001/*-
002 * #%L
003 * HAPI FHIR - Converter
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.hapi.converters.canonical;
021
022import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
023import ca.uhn.fhir.context.FhirContext;
024import ca.uhn.fhir.context.FhirVersionEnum;
025import ca.uhn.fhir.i18n.Msg;
026import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
027import ca.uhn.fhir.model.dstu2.composite.CodingDt;
028import ca.uhn.fhir.util.HapiExtensions;
029import jakarta.annotation.Nonnull;
030import org.apache.commons.lang3.StringUtils;
031import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
032import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
033import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40;
034import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_50;
035import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
036import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
037import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
038import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_50;
039import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
040import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
041import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_40;
042import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
043import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
044import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
045import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
046import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
047import org.hl7.fhir.dstu2.model.Resource;
048import org.hl7.fhir.instance.model.api.IBase;
049import org.hl7.fhir.instance.model.api.IBaseCoding;
050import org.hl7.fhir.instance.model.api.IBaseConformance;
051import org.hl7.fhir.instance.model.api.IBaseDatatype;
052import org.hl7.fhir.instance.model.api.IBaseParameters;
053import org.hl7.fhir.instance.model.api.IBaseResource;
054import org.hl7.fhir.instance.model.api.IPrimitiveType;
055import org.hl7.fhir.r4.model.AuditEvent;
056import org.hl7.fhir.r4.model.CodeSystem;
057import org.hl7.fhir.r4.model.CodeableConcept;
058import org.hl7.fhir.r4.model.Coding;
059import org.hl7.fhir.r4.model.ConceptMap;
060import org.hl7.fhir.r4.model.Parameters;
061import org.hl7.fhir.r4.model.ValueSet;
062import org.hl7.fhir.r5.model.CapabilityStatement;
063import org.hl7.fhir.r5.model.CodeType;
064import org.hl7.fhir.r5.model.Enumerations;
065import org.hl7.fhir.r5.model.PackageInformation;
066import org.hl7.fhir.r5.model.SearchParameter;
067import org.hl7.fhir.r5.model.StructureDefinition;
068
069import java.util.Date;
070import java.util.List;
071import java.util.Objects;
072import java.util.stream.Collectors;
073
074import static org.apache.commons.lang3.StringUtils.isBlank;
075
076/**
077 * This class converts versions of various resources to/from a canonical version
078 * of the resource. The specific version that is considered canonical is arbitrary
079 * for historical reasons, generally it will be R4 or R5 but this varies by resource
080 * type.
081 * <p>
082 * This class is an internal HAPI FHIR API and can change without notice at any time.
083 * Use with caution!
084 * </p>
085 */
086public class VersionCanonicalizer {
087
088        private static final BaseAdvisor_30_50 ADVISOR_30_50 = new BaseAdvisor_30_50(false);
089        private static final BaseAdvisor_30_40 ADVISOR_30_40 = new BaseAdvisor_30_40(false);
090        private static final BaseAdvisor_10_40 ADVISOR_10_40 = new BaseAdvisor_10_40(false);
091        private static final BaseAdvisor_10_50 ADVISOR_10_50 = new BaseAdvisor_10_50(false);
092        private static final BaseAdvisor_40_50 ADVISOR_40_50 = new BaseAdvisor_40_50(false);
093        private static final BaseAdvisor_43_50 ADVISOR_43_50 = new BaseAdvisor_43_50(false);
094        private static final BaseAdvisor_14_40 ADVISOR_14_40 = new BaseAdvisor_14_40(false);
095        private static final BaseAdvisor_14_50 ADVISOR_14_50 = new BaseAdvisor_14_50(false);
096
097        private final IStrategy myStrategy;
098        private final FhirContext myContext;
099
100        public VersionCanonicalizer(FhirVersionEnum theTargetVersion) {
101                this(FhirContext.forCached(theTargetVersion));
102        }
103
104        public VersionCanonicalizer(FhirContext theTargetContext) {
105                myContext = theTargetContext;
106                FhirVersionEnum targetVersion = theTargetContext.getVersion().getVersion();
107                switch (targetVersion) {
108                        case DSTU2:
109                                myStrategy = new Dstu2Strategy(false);
110                                break;
111                        case DSTU2_HL7ORG:
112                                myStrategy = new Dstu2Strategy(true);
113                                break;
114                        case DSTU2_1:
115                                myStrategy = new Dstu21Strategy();
116                                break;
117                        case DSTU3:
118                                myStrategy = new Dstu3Strategy();
119                                break;
120                        case R4:
121                                myStrategy = new R4Strategy();
122                                break;
123                        case R4B:
124                                myStrategy = new R4BStrategy();
125                                break;
126                        case R5:
127                                myStrategy = new R5Strategy();
128                                break;
129                        default:
130                                throw new IllegalStateException(Msg.code(193) + "Can't handle version: " + targetVersion);
131                }
132        }
133
134        @SuppressWarnings({"EnhancedSwitchMigration"})
135
136        /**
137         * Canonical version: R5
138         */
139        public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
140                return myStrategy.capabilityStatementToCanonical(theCapabilityStatement);
141        }
142
143        /**
144         * Canonical version: R5
145         */
146        public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theCapabilityStatement) {
147                return myStrategy.capabilityStatementFromCanonical(theCapabilityStatement);
148        }
149
150        /**
151         * Canonical version: R4
152         */
153        public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
154                if (theCodeableConcept == null) {
155                        return null;
156                }
157                return myStrategy.codeableConceptToCanonical(theCodeableConcept);
158        }
159
160        /**
161         * Canonical version: R4
162         */
163        public Coding codingToCanonical(IBaseCoding theCodingToValidate) {
164                if (theCodingToValidate == null) {
165                        return null;
166                }
167                return myStrategy.codingToCanonical(theCodingToValidate);
168        }
169
170        /**
171         * Canonical version: R4
172         */
173        public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
174                if (theValueSet == null) {
175                        return null;
176                }
177                return myStrategy.valueSetToCanonical(theValueSet);
178        }
179
180        /**
181         * Canonical version: R4
182         */
183        public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
184                return myStrategy.codeSystemToCanonical(theCodeSystem);
185        }
186
187        /**
188         * Canonical version: R4
189         */
190        public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
191                return myStrategy.valueSetFromCanonical(theValueSet);
192        }
193
194        /**
195         * Canonical version: R4
196         */
197        public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
198                return myStrategy.conceptMapToCanonical(theConceptMap);
199        }
200
201        /**
202         * Canonical version: R5
203         * <p>
204         * Note that this method will look for any nonstandard resource types specified in
205         * {@literal SearchParameter.base} or {@literal SearchParameter.target} and move them into
206         * extensions with the URLs {@link HapiExtensions#EXTENSION_SEARCHPARAM_CUSTOM_BASE_RESOURCE}
207         * and {@link HapiExtensions#EXTENSION_SEARCHPARAM_CUSTOM_TARGET_RESOURCE} respectively. If any
208         * nonstandard resource types are found, all resource types in the respective list are moved into
209         * the extension (including standard types) and the source list is cleared.
210         */
211        public <T extends IBaseResource> SearchParameter searchParameterToCanonical(T theSearchParameter) {
212
213                /*
214                 * The R4 model allows custom types to be put into SearchParameter.base and
215                 * SearchParameter.target because those fields use a simple CodeType. But
216                 * in R5 it uses an Enumeration, so it's not actually possible to put custom
217                 * resource types into those fields. This means that the version converter fails
218                 * with an exception unless we remove those values from those fields before
219                 * conversion. However, we don't want to affect the state of the originally
220                 * passed in resource since that may affect other things. So, we clone
221                 * it first. This is a pain in the butt, but there doesn't seem to be any
222                 * better option.
223                 */
224                T input = myContext.newTerser().clone(theSearchParameter);
225
226                List<String> baseExtensionValues =
227                                extractNonStandardSearchParameterListAndClearSourceIfAnyArePresent(input, "base");
228                List<String> targetExtensionValues =
229                                extractNonStandardSearchParameterListAndClearSourceIfAnyArePresent(input, "target");
230
231                SearchParameter retVal = myStrategy.searchParameterToCanonical(input);
232
233                baseExtensionValues.forEach(
234                                t -> retVal.addExtension(HapiExtensions.EXTENSION_SEARCHPARAM_CUSTOM_BASE_RESOURCE, new CodeType(t)));
235                targetExtensionValues.forEach(
236                                t -> retVal.addExtension(HapiExtensions.EXTENSION_SEARCHPARAM_CUSTOM_TARGET_RESOURCE, new CodeType(t)));
237                return retVal;
238        }
239
240        public IBaseResource searchParameterFromCanonical(SearchParameter theSearchParameter) {
241                return myStrategy.searchParameterFromCanonical(theSearchParameter);
242        }
243
244        public IBaseParameters parametersFromCanonical(Parameters theParameters) {
245                return myStrategy.parametersFromCanonical(theParameters);
246        }
247
248        public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
249                StructureDefinition retVal = myStrategy.structureDefinitionToCanonical(theResource);
250                String packageUserData = (String) theResource.getUserData("package");
251                if (packageUserData != null) {
252                        retVal.setUserData("package", packageUserData);
253                        retVal.setSourcePackage(new PackageInformation(
254                                        packageUserData, theResource.getStructureFhirVersionEnum().getFhirVersionString(), new Date()));
255                }
256                return retVal;
257        }
258
259        public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
260                return myStrategy.structureDefinitionFromCanonical(theResource);
261        }
262
263        public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
264                return myStrategy.valueSetFromValidatorCanonical(theResource);
265        }
266
267        public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
268                return myStrategy.resourceToValidatorCanonical(theResource);
269        }
270
271        public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
272                return myStrategy.valueSetToValidatorCanonical(theResource);
273        }
274
275        public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
276                return myStrategy.codeSystemToValidatorCanonical(theResource);
277        }
278
279        public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
280                return myStrategy.auditEventFromCanonical(theResource);
281        }
282
283        @Nonnull
284        private List<String> extractNonStandardSearchParameterListAndClearSourceIfAnyArePresent(
285                        IBaseResource theSearchParameter, String theChildName) {
286
287                BaseRuntimeChildDefinition child =
288                                myContext.getResourceDefinition(theSearchParameter).getChildByName(theChildName);
289                List<IBase> baseList = child.getAccessor().getValues(theSearchParameter);
290
291                List<String> baseExtensionValues = baseList.stream()
292                                .filter(Objects::nonNull)
293                                .filter(t -> t instanceof IPrimitiveType)
294                                .map(t -> (IPrimitiveType<?>) t)
295                                .map(IPrimitiveType::getValueAsString)
296                                .filter(StringUtils::isNotBlank)
297                                .collect(Collectors.toList());
298                if (baseExtensionValues.stream().allMatch(Enumerations.VersionIndependentResourceTypesAll::isValidCode)) {
299                        baseExtensionValues.clear();
300                } else {
301                        baseList.clear();
302                }
303                return baseExtensionValues;
304        }
305
306        private interface IStrategy {
307
308                CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement);
309
310                Coding codingToCanonical(IBaseCoding theCoding);
311
312                CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept);
313
314                ValueSet valueSetToCanonical(IBaseResource theValueSet);
315
316                CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem);
317
318                IBaseResource valueSetFromCanonical(ValueSet theValueSet);
319
320                ConceptMap conceptMapToCanonical(IBaseResource theConceptMap);
321
322                SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter);
323
324                IBaseParameters parametersFromCanonical(Parameters theParameters);
325
326                StructureDefinition structureDefinitionToCanonical(IBaseResource theResource);
327
328                IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource);
329
330                IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource);
331
332                org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource);
333
334                org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource);
335
336                org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource);
337
338                IBaseResource searchParameterFromCanonical(SearchParameter theResource);
339
340                IBaseResource auditEventFromCanonical(AuditEvent theResource);
341
342                IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource);
343        }
344
345        private static class Dstu2Strategy implements IStrategy {
346
347                private final FhirContext myDstu2Hl7OrgContext = FhirContext.forDstu2Hl7OrgCached();
348
349                private final FhirContext myDstu2Context = FhirContext.forDstu2Cached();
350                private final boolean myHl7OrgStructures;
351
352                public Dstu2Strategy(boolean theHl7OrgStructures) {
353                        myHl7OrgStructures = theHl7OrgStructures;
354                }
355
356                @Override
357                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
358                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theCapabilityStatement);
359                        return (CapabilityStatement) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
360                }
361
362                @Override
363                public Coding codingToCanonical(IBaseCoding theCoding) {
364                        CodingDt coding = (CodingDt) theCoding;
365                        Coding retVal = new Coding();
366                        retVal.setCode(coding.getCode());
367                        retVal.setSystem(coding.getSystem());
368                        retVal.setDisplay(coding.getDisplay());
369                        retVal.setVersion(coding.getVersion());
370                        if (!coding.getUserSelectedElement().isEmpty()) {
371                                retVal.setUserSelected(coding.getUserSelected());
372                        }
373
374                        return retVal;
375                }
376
377                @Override
378                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
379                        CodeableConceptDt codeableConcept = (CodeableConceptDt) theCodeableConcept;
380
381                        CodeableConcept retVal = new CodeableConcept();
382                        retVal.setText(codeableConcept.getText());
383                        for (CodingDt next : codeableConcept.getCoding()) {
384                                retVal.addCoding(codingToCanonical(next));
385                        }
386
387                        return retVal;
388                }
389
390                @Override
391                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
392                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theValueSet);
393                        return (ValueSet) VersionConvertorFactory_10_40.convertResource(reencoded, ADVISOR_10_40);
394                }
395
396                @Override
397                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
398                        CodeSystem retVal = new CodeSystem();
399
400                        ca.uhn.fhir.model.dstu2.resource.ValueSet input = (ca.uhn.fhir.model.dstu2.resource.ValueSet) theCodeSystem;
401                        retVal.setUrl(input.getUrl());
402
403                        for (ca.uhn.fhir.model.dstu2.resource.ValueSet.CodeSystemConcept next :
404                                        input.getCodeSystem().getConcept()) {
405                                translateAndAddConcept(next, retVal.getConcept());
406                        }
407
408                        return retVal;
409                }
410
411                private void translateAndAddConcept(
412                                ca.uhn.fhir.model.dstu2.resource.ValueSet.CodeSystemConcept theSource,
413                                List<CodeSystem.ConceptDefinitionComponent> theTarget) {
414                        CodeSystem.ConceptDefinitionComponent targetConcept = new CodeSystem.ConceptDefinitionComponent();
415                        targetConcept.setCode(theSource.getCode());
416                        targetConcept.setDisplay(theSource.getDisplay());
417
418                        for (ca.uhn.fhir.model.dstu2.resource.ValueSet.CodeSystemConceptDesignation next :
419                                        theSource.getDesignation()) {
420                                CodeSystem.ConceptDefinitionDesignationComponent targetDesignation = targetConcept.addDesignation();
421                                targetDesignation.setLanguage(next.getLanguage());
422                                targetDesignation.setValue(next.getValue());
423                                if (next.getUse() != null) {
424                                        targetDesignation.setUse(codingToCanonical(next.getUse()));
425                                }
426                        }
427
428                        for (ca.uhn.fhir.model.dstu2.resource.ValueSet.CodeSystemConcept nextChild : theSource.getConcept()) {
429                                translateAndAddConcept(nextChild, targetConcept.getConcept());
430                        }
431
432                        theTarget.add(targetConcept);
433                }
434
435                @Override
436                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
437                        Resource valueSetDstu2Hl7Org = VersionConvertorFactory_10_40.convertResource(theValueSet, ADVISOR_10_40);
438                        return reencodeFromHl7Org(valueSetDstu2Hl7Org);
439                }
440
441                @Override
442                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
443                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theConceptMap);
444                        return (ConceptMap) VersionConvertorFactory_10_40.convertResource(reencoded, ADVISOR_10_40);
445                }
446
447                @Override
448                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
449                        org.hl7.fhir.dstu2.model.SearchParameter reencoded =
450                                        (org.hl7.fhir.dstu2.model.SearchParameter) reencodeToHl7Org(theSearchParameter);
451                        SearchParameter retVal =
452                                        (SearchParameter) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
453                        if (isBlank(retVal.getExpression())) {
454                                retVal.setExpression(reencoded.getXpath());
455                        }
456                        return retVal;
457                }
458
459                @Override
460                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
461                        Resource converted = VersionConvertorFactory_10_40.convertResource(theParameters, ADVISOR_10_40);
462                        return (IBaseParameters) reencodeFromHl7Org(converted);
463                }
464
465                @Override
466                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
467                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
468                        return (StructureDefinition) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
469                }
470
471                @Override
472                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
473                        Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
474                        return reencodeFromHl7Org(converted);
475                }
476
477                @Override
478                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
479                        Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
480                        return reencodeFromHl7Org(converted);
481                }
482
483                @Override
484                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
485                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
486                        return VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
487                }
488
489                @Override
490                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
491                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
492                        return (org.hl7.fhir.r5.model.ValueSet)
493                                        VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
494                }
495
496                @Override
497                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
498                        org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
499                        return (org.hl7.fhir.r5.model.CodeSystem)
500                                        VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
501                }
502
503                @Override
504                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
505                        Resource hl7Org = VersionConvertorFactory_10_40.convertResource(theResource, ADVISOR_10_40);
506                        return reencodeFromHl7Org(hl7Org);
507                }
508
509                @Override
510                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
511                        Resource resource = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
512                        return reencodeFromHl7Org(resource);
513                }
514
515                @Override
516                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
517                        Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
518                        return (IBaseConformance) reencodeFromHl7Org(converted);
519                }
520
521                private Resource reencodeToHl7Org(IBaseResource theInput) {
522                        if (myHl7OrgStructures) {
523                                return (Resource) theInput;
524                        }
525                        return (Resource) myDstu2Hl7OrgContext
526                                        .newJsonParser()
527                                        .parseResource(myDstu2Context.newJsonParser().encodeResourceToString(theInput));
528                }
529
530                private IBaseResource reencodeFromHl7Org(Resource theInput) {
531                        if (myHl7OrgStructures) {
532                                return theInput;
533                        }
534                        return myDstu2Context
535                                        .newJsonParser()
536                                        .parseResource(myDstu2Hl7OrgContext.newJsonParser().encodeResourceToString(theInput));
537                }
538        }
539
540        private static class Dstu21Strategy implements IStrategy {
541
542                @Override
543                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
544                        return (CapabilityStatement) VersionConvertorFactory_14_50.convertResource(
545                                        (org.hl7.fhir.dstu2016may.model.Resource) theCapabilityStatement, ADVISOR_14_50);
546                }
547
548                @Override
549                public Coding codingToCanonical(IBaseCoding theCoding) {
550                        return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_14_40.convertType(
551                                        (org.hl7.fhir.dstu2016may.model.Coding) theCoding, ADVISOR_14_40);
552                }
553
554                @Override
555                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
556                        return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_14_40.convertType(
557                                        (org.hl7.fhir.dstu2016may.model.CodeableConcept) theCodeableConcept, ADVISOR_14_40);
558                }
559
560                @Override
561                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
562                        return (ValueSet) VersionConvertorFactory_14_40.convertResource(
563                                        (org.hl7.fhir.dstu2016may.model.Resource) theValueSet, ADVISOR_14_40);
564                }
565
566                @Override
567                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
568                        return (CodeSystem) VersionConvertorFactory_14_40.convertResource(
569                                        (org.hl7.fhir.dstu2016may.model.Resource) theCodeSystem, ADVISOR_14_40);
570                }
571
572                @Override
573                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
574                        return VersionConvertorFactory_14_40.convertResource(theValueSet, ADVISOR_14_40);
575                }
576
577                @Override
578                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
579                        return (ConceptMap) VersionConvertorFactory_14_40.convertResource(
580                                        (org.hl7.fhir.dstu2016may.model.Resource) theConceptMap, ADVISOR_14_40);
581                }
582
583                @Override
584                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
585                        return (SearchParameter) VersionConvertorFactory_14_50.convertResource(
586                                        (org.hl7.fhir.dstu2016may.model.Resource) theSearchParameter, ADVISOR_14_50);
587                }
588
589                @Override
590                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
591                        return (IBaseParameters) VersionConvertorFactory_14_40.convertResource(theParameters, ADVISOR_14_40);
592                }
593
594                @Override
595                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
596                        return (StructureDefinition) VersionConvertorFactory_14_50.convertResource(
597                                        (org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
598                }
599
600                @Override
601                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
602                        return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
603                }
604
605                @Override
606                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
607                        return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
608                }
609
610                @Override
611                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
612                        return VersionConvertorFactory_14_50.convertResource(
613                                        (org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
614                }
615
616                @Override
617                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
618                        return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_14_50.convertResource(
619                                        (org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
620                }
621
622                @Override
623                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
624                        return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_14_50.convertResource(
625                                        (org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
626                }
627
628                @Override
629                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
630                        return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
631                }
632
633                @Override
634                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
635                        return VersionConvertorFactory_14_40.convertResource(theResource, ADVISOR_14_40);
636                }
637
638                @Override
639                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
640                        return (IBaseConformance) VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
641                }
642        }
643
644        private static class Dstu3Strategy implements IStrategy {
645
646                @Override
647                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
648                        return (CapabilityStatement) VersionConvertorFactory_30_50.convertResource(
649                                        (org.hl7.fhir.dstu3.model.Resource) theCapabilityStatement, ADVISOR_30_50);
650                }
651
652                @Override
653                public Coding codingToCanonical(IBaseCoding theCoding) {
654                        return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_30_40.convertType(
655                                        (org.hl7.fhir.dstu3.model.Coding) theCoding, ADVISOR_30_40);
656                }
657
658                @Override
659                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
660                        return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_30_40.convertType(
661                                        (org.hl7.fhir.dstu3.model.CodeableConcept) theCodeableConcept, ADVISOR_30_40);
662                }
663
664                @Override
665                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
666                        return (ValueSet) VersionConvertorFactory_30_40.convertResource(
667                                        (org.hl7.fhir.dstu3.model.Resource) theValueSet, ADVISOR_30_40);
668                }
669
670                @Override
671                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
672                        return (CodeSystem) VersionConvertorFactory_30_40.convertResource(
673                                        (org.hl7.fhir.dstu3.model.Resource) theCodeSystem, ADVISOR_30_40);
674                }
675
676                @Override
677                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
678                        return VersionConvertorFactory_30_40.convertResource(theValueSet, ADVISOR_30_40);
679                }
680
681                @Override
682                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
683                        return (ConceptMap) VersionConvertorFactory_30_40.convertResource(
684                                        (org.hl7.fhir.dstu3.model.Resource) theConceptMap, ADVISOR_30_40);
685                }
686
687                @Override
688                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
689                        return (SearchParameter) VersionConvertorFactory_30_50.convertResource(
690                                        (org.hl7.fhir.dstu3.model.Resource) theSearchParameter, ADVISOR_30_50);
691                }
692
693                @Override
694                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
695                        return (IBaseParameters) VersionConvertorFactory_30_40.convertResource(theParameters, ADVISOR_30_40);
696                }
697
698                @Override
699                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
700                        return (StructureDefinition) VersionConvertorFactory_30_50.convertResource(
701                                        (org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
702                }
703
704                @Override
705                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
706                        return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
707                }
708
709                @Override
710                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
711                        return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
712                }
713
714                @Override
715                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
716                        return VersionConvertorFactory_30_50.convertResource(
717                                        (org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
718                }
719
720                @Override
721                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
722                        return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_30_50.convertResource(
723                                        (org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
724                }
725
726                @Override
727                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
728                        return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_30_50.convertResource(
729                                        (org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
730                }
731
732                @Override
733                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
734                        return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
735                }
736
737                @Override
738                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
739                        return VersionConvertorFactory_30_40.convertResource(theResource, ADVISOR_30_40);
740                }
741
742                @Override
743                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
744                        return (IBaseConformance) VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
745                }
746        }
747
748        private static class R4Strategy implements IStrategy {
749                @Override
750                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
751                        return (CapabilityStatement) VersionConvertorFactory_40_50.convertResource(
752                                        (org.hl7.fhir.r4.model.Resource) theCapabilityStatement, ADVISOR_40_50);
753                }
754
755                @Override
756                public Coding codingToCanonical(IBaseCoding theCoding) {
757                        return (Coding) theCoding;
758                }
759
760                @Override
761                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
762                        return (CodeableConcept) theCodeableConcept;
763                }
764
765                @Override
766                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
767                        return (ValueSet) theValueSet;
768                }
769
770                @Override
771                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
772                        return (CodeSystem) theCodeSystem;
773                }
774
775                @Override
776                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
777                        return theValueSet;
778                }
779
780                @Override
781                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
782                        return (ConceptMap) theConceptMap;
783                }
784
785                @Override
786                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
787                        return (SearchParameter) VersionConvertorFactory_40_50.convertResource(
788                                        (org.hl7.fhir.r4.model.Resource) theSearchParameter, ADVISOR_40_50);
789                }
790
791                @Override
792                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
793                        return theParameters;
794                }
795
796                @Override
797                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
798                        return (StructureDefinition) VersionConvertorFactory_40_50.convertResource(
799                                        (org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
800                }
801
802                @Override
803                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
804                        return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
805                }
806
807                @Override
808                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
809                        return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
810                }
811
812                @Override
813                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
814                        return VersionConvertorFactory_40_50.convertResource(
815                                        (org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
816                }
817
818                @Override
819                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
820                        return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_40_50.convertResource(
821                                        (org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
822                }
823
824                @Override
825                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
826                        return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_40_50.convertResource(
827                                        (org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
828                }
829
830                @Override
831                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
832                        return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
833                }
834
835                @Override
836                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
837                        return theResource;
838                }
839
840                @Override
841                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
842                        return (IBaseConformance) VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
843                }
844        }
845
846        private static class R4BStrategy implements IStrategy {
847
848                @Override
849                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
850                        return (CapabilityStatement) VersionConvertorFactory_43_50.convertResource(
851                                        (org.hl7.fhir.r4b.model.Resource) theCapabilityStatement, ADVISOR_43_50);
852                }
853
854                @Override
855                public Coding codingToCanonical(IBaseCoding theCoding) {
856                        org.hl7.fhir.r5.model.Coding r5coding = (org.hl7.fhir.r5.model.Coding)
857                                        VersionConvertorFactory_43_50.convertType((org.hl7.fhir.r4b.model.Coding) theCoding, ADVISOR_43_50);
858                        return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_40_50.convertType(r5coding, ADVISOR_40_50);
859                }
860
861                @Override
862                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
863                        org.hl7.fhir.r5.model.CodeableConcept r5coding =
864                                        (org.hl7.fhir.r5.model.CodeableConcept) VersionConvertorFactory_43_50.convertType(
865                                                        (org.hl7.fhir.r4b.model.CodeableConcept) theCodeableConcept, ADVISOR_43_50);
866                        return (org.hl7.fhir.r4.model.CodeableConcept)
867                                        VersionConvertorFactory_40_50.convertType(r5coding, ADVISOR_40_50);
868                }
869
870                @Override
871                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
872                        org.hl7.fhir.r5.model.ValueSet valueSetR5 =
873                                        (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_43_50.convertResource(
874                                                        (org.hl7.fhir.r4b.model.Resource) theValueSet, ADVISOR_43_50);
875                        return (org.hl7.fhir.r4.model.ValueSet)
876                                        VersionConvertorFactory_40_50.convertResource(valueSetR5, ADVISOR_40_50);
877                }
878
879                @Override
880                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
881                        org.hl7.fhir.r5.model.CodeSystem codeSystemR5 =
882                                        (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_43_50.convertResource(
883                                                        (org.hl7.fhir.r4b.model.Resource) theCodeSystem, ADVISOR_43_50);
884                        return (org.hl7.fhir.r4.model.CodeSystem)
885                                        VersionConvertorFactory_40_50.convertResource(codeSystemR5, ADVISOR_40_50);
886                }
887
888                @Override
889                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
890                        org.hl7.fhir.r5.model.ValueSet valueSetR5 = (org.hl7.fhir.r5.model.ValueSet)
891                                        VersionConvertorFactory_40_50.convertResource(theValueSet, ADVISOR_40_50);
892                        return VersionConvertorFactory_43_50.convertResource(valueSetR5, ADVISOR_43_50);
893                }
894
895                @Override
896                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
897                        org.hl7.fhir.r5.model.ConceptMap conceptMapR5 =
898                                        (org.hl7.fhir.r5.model.ConceptMap) VersionConvertorFactory_43_50.convertResource(
899                                                        (org.hl7.fhir.r4b.model.Resource) theConceptMap, ADVISOR_43_50);
900                        return (ConceptMap) VersionConvertorFactory_40_50.convertResource(conceptMapR5, ADVISOR_40_50);
901                }
902
903                @Override
904                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
905                        return (SearchParameter) VersionConvertorFactory_43_50.convertResource(
906                                        (org.hl7.fhir.r4b.model.Resource) theSearchParameter, ADVISOR_43_50);
907                }
908
909                @Override
910                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
911                        org.hl7.fhir.r5.model.Parameters parametersR5 = (org.hl7.fhir.r5.model.Parameters)
912                                        VersionConvertorFactory_40_50.convertResource(theParameters, ADVISOR_40_50);
913                        return (IBaseParameters) VersionConvertorFactory_43_50.convertResource(parametersR5, ADVISOR_43_50);
914                }
915
916                @Override
917                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
918                        return (StructureDefinition) VersionConvertorFactory_43_50.convertResource(
919                                        (org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
920                }
921
922                @Override
923                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
924                        return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
925                }
926
927                @Override
928                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
929                        return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
930                }
931
932                @Override
933                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
934                        return VersionConvertorFactory_43_50.convertResource(
935                                        (org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
936                }
937
938                @Override
939                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
940                        return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_43_50.convertResource(
941                                        (org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
942                }
943
944                @Override
945                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
946                        return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_43_50.convertResource(
947                                        (org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
948                }
949
950                @Override
951                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
952                        return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
953                }
954
955                @Override
956                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
957                        org.hl7.fhir.r5.model.AuditEvent r5 = (org.hl7.fhir.r5.model.AuditEvent)
958                                        VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
959                        return VersionConvertorFactory_43_50.convertResource(r5, ADVISOR_43_50);
960                }
961
962                @Override
963                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
964                        return (IBaseConformance) VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
965                }
966        }
967
968        private static class R5Strategy implements IStrategy {
969
970                @Override
971                public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
972                        return (CapabilityStatement) theCapabilityStatement;
973                }
974
975                @Override
976                public Coding codingToCanonical(IBaseCoding theCoding) {
977                        return (org.hl7.fhir.r4.model.Coding)
978                                        VersionConvertorFactory_40_50.convertType((org.hl7.fhir.r5.model.Coding) theCoding, ADVISOR_40_50);
979                }
980
981                @Override
982                public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
983                        return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_40_50.convertType(
984                                        (org.hl7.fhir.r5.model.CodeableConcept) theCodeableConcept, ADVISOR_40_50);
985                }
986
987                @Override
988                public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
989                        return (ValueSet) VersionConvertorFactory_40_50.convertResource(
990                                        (org.hl7.fhir.r5.model.ValueSet) theValueSet, ADVISOR_40_50);
991                }
992
993                @Override
994                public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
995                        return (CodeSystem) VersionConvertorFactory_40_50.convertResource(
996                                        (org.hl7.fhir.r5.model.CodeSystem) theCodeSystem, ADVISOR_40_50);
997                }
998
999                @Override
1000                public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
1001                        return VersionConvertorFactory_40_50.convertResource(theValueSet, ADVISOR_40_50);
1002                }
1003
1004                @Override
1005                public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
1006                        return (ConceptMap) VersionConvertorFactory_40_50.convertResource(
1007                                        (org.hl7.fhir.r5.model.ConceptMap) theConceptMap, ADVISOR_40_50);
1008                }
1009
1010                @Override
1011                public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
1012                        return (SearchParameter) theSearchParameter;
1013                }
1014
1015                @Override
1016                public IBaseParameters parametersFromCanonical(Parameters theParameters) {
1017                        return (IBaseParameters) VersionConvertorFactory_40_50.convertResource(theParameters, ADVISOR_40_50);
1018                }
1019
1020                @Override
1021                public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
1022                        return (StructureDefinition) theResource;
1023                }
1024
1025                @Override
1026                public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
1027                        return theResource;
1028                }
1029
1030                @Override
1031                public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
1032                        return theResource;
1033                }
1034
1035                @Override
1036                public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
1037                        return (org.hl7.fhir.r5.model.Resource) theResource;
1038                }
1039
1040                @Override
1041                public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
1042                        return (org.hl7.fhir.r5.model.ValueSet) theResource;
1043                }
1044
1045                @Override
1046                public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
1047                        return (org.hl7.fhir.r5.model.CodeSystem) theResource;
1048                }
1049
1050                @Override
1051                public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
1052                        return theResource;
1053                }
1054
1055                @Override
1056                public IBaseResource auditEventFromCanonical(AuditEvent theResource) {
1057                        return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
1058                }
1059
1060                @Override
1061                public IBaseConformance capabilityStatementFromCanonical(CapabilityStatement theResource) {
1062                        return theResource;
1063                }
1064        }
1065}