From 9ca85b4cf3142c6088b01887be4dda03b5e01a39 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sun, 15 Oct 2017 11:27:30 -0400 Subject: [PATCH] Re-enable errorprone on standard hapi fhir build. woohoo! --- .travis.yml | 2 +- hapi-deployable-pom/pom.xml | 54 + .../uhn/fhir/context/RuntimeSearchParam.java | 3 +- .../convertors/VersionConvertor_10_40.java | 15020 ++++++++-------- .../convertors/VersionConvertor_14_40.java | 2 +- .../java/org/hl7/fhir/utilities/OIDUtils.java | 83 - .../hl7/fhir/utilities/ucum/UcumService.java | 193 - hapi-fhir-jacoco/pom.xml | 56 +- hapi-fhir-jpaserver-base/pom.xml | 5 +- .../dao/dstu3/SearchParamRegistryDstu3.java | 3 + .../jpa/dao/r4/SearchParamRegistryR4.java | 3 + .../fhir/jpa/graphql/JpaStorageServices.java | 2 + .../SubscriptionActivatingSubscriber.java | 2 + .../src/main/resources/.keep | 0 .../src/main/resources/.keep | 0 .../src/main/resources/.keep | 0 hapi-fhir-structures-dstu3/pom.xml | 29 - .../fhir/r4/conformance/ProfileUtilities.java | 25 +- .../hl7/fhir/r4/model/BaseDateTimeType.java | 228 +- .../fhir/r4/utils/client/ResourceAddress.java | 834 +- .../src/main/resources/.keep | 0 .../src/main/java/.keep | 0 .../dstu3/validation/InstanceValidator.java | 12 +- .../validation/InstanceValidator.java | 5585 +++--- .../fhir/r4/validation/InstanceValidator.java | 17 +- pom.xml | 8 + 26 files changed, 11002 insertions(+), 11164 deletions(-) delete mode 100644 hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/OIDUtils.java delete mode 100644 hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/ucum/UcumService.java delete mode 100644 hapi-fhir-jpaserver-base/src/main/resources/.keep delete mode 100644 hapi-fhir-structures-dstu2.1/src/main/resources/.keep delete mode 100644 hapi-fhir-structures-dstu2/src/main/resources/.keep delete mode 100644 hapi-fhir-testpage-overlay/src/main/resources/.keep delete mode 100644 hapi-fhir-validation-resources-dstu3/src/main/java/.keep diff --git a/.travis.yml b/.travis.yml index 4b5b599e73a..e856f74456d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,4 +22,4 @@ before_script: script: # - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report # - mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report - - mvn -Dci=true -e -B -P ALLMODULES,MINPARALLEL clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report + - mvn -Dci=true -e -B -P ALLMODULES,MINPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index f13b998e86a..3c169c7edc8 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -63,6 +63,60 @@ + + org.basepom.maven + duplicate-finder-maven-plugin + + + default + verify + + check + + true + + + + false + true + true + true + true + false + false + false + false + true + true + 2 + ${project.build.directory}/duplicate-finder-result.xml + + + javax.el + javax.el-api + + + javax.mail + javax.mail-api + + + com.phloc + phloc-commons + + + commons-logging + commons-logging + + + org.jscience + jscience + + + + changelog.txt + + + diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java index d3df0dd67e2..af1a5498a84 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java @@ -152,7 +152,8 @@ public class RuntimeSearchParam { public enum RuntimeSearchParamStatusEnum { ACTIVE, DRAFT, - RETIRED + RETIRED, + UNKNOWN } } diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index 742c9aac7a7..b3df974c78a 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -1,25 +1,5 @@ package org.hl7.fhir.convertors; -/*- - * #%L - * HAPI FHIR - Converter - * %% - * Copyright (C) 2014 - 2017 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - import java.util.ArrayList; import java.util.List; @@ -87,6 +67,1973 @@ public class VersionConvertor_10_40 { this.advisor = advisor; } + public void copyElement(org.hl7.fhir.instance.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.instance.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.instance.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public void copyElement(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.instance.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public void copyBackboneElement(org.hl7.fhir.instance.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.instance.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.instance.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.instance.model.Base64BinaryType tgt = new org.hl7.fhir.instance.model.Base64BinaryType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.instance.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { + org.hl7.fhir.instance.model.BooleanType tgt = new org.hl7.fhir.instance.model.BooleanType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.instance.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { + org.hl7.fhir.instance.model.CodeType tgt = new org.hl7.fhir.instance.model.CodeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.UriType convertCodeToUri(org.hl7.fhir.instance.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.CodeType convertUriToCode(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.instance.model.CodeType tgt = new org.hl7.fhir.instance.model.CodeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.instance.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.instance.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { + org.hl7.fhir.instance.model.DateType tgt = new org.hl7.fhir.instance.model.DateType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.DateType convertDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.instance.model.DateType tgt = new org.hl7.fhir.instance.model.DateType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.instance.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.instance.model.DateTimeType tgt = new org.hl7.fhir.instance.model.DateTimeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.instance.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { + org.hl7.fhir.instance.model.DecimalType tgt = new org.hl7.fhir.instance.model.DecimalType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.instance.model.IdType src) throws FHIRException { + org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { + org.hl7.fhir.instance.model.IdType tgt = new org.hl7.fhir.instance.model.IdType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.instance.model.InstantType src) throws FHIRException { + org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { + org.hl7.fhir.instance.model.InstantType tgt = new org.hl7.fhir.instance.model.InstantType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.instance.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { + org.hl7.fhir.instance.model.IntegerType tgt = new org.hl7.fhir.instance.model.IntegerType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.instance.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.instance.model.MarkdownType tgt = new org.hl7.fhir.instance.model.MarkdownType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.instance.model.OidType src) throws FHIRException { + org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { + org.hl7.fhir.instance.model.OidType tgt = new org.hl7.fhir.instance.model.OidType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.instance.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.instance.model.PositiveIntType tgt = new org.hl7.fhir.instance.model.PositiveIntType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.instance.model.StringType src) throws FHIRException { + org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.instance.model.StringType tgt = new org.hl7.fhir.instance.model.StringType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.instance.model.TimeType src) throws FHIRException { + org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { + org.hl7.fhir.instance.model.TimeType tgt = new org.hl7.fhir.instance.model.TimeType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.instance.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.instance.model.UnsignedIntType tgt = new org.hl7.fhir.instance.model.UnsignedIntType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.instance.model.UriType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.instance.model.UriType tgt = new org.hl7.fhir.instance.model.UriType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.instance.model.UuidType src) throws FHIRException { + org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.instance.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { + org.hl7.fhir.instance.model.UuidType tgt = new org.hl7.fhir.instance.model.UuidType(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.instance.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); + copyElement(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public org.hl7.fhir.instance.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Extension tgt = new org.hl7.fhir.instance.model.Extension(); + copyElement(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.instance.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); + copyElement(src, tgt); + tgt.setStatus(convertNarrativeStatus(src.getStatus())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public org.hl7.fhir.instance.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Narrative tgt = new org.hl7.fhir.instance.model.Narrative(); + copyElement(src, tgt); + tgt.setStatus(convertNarrativeStatus(src.getStatus())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public org.hl7.fhir.r4.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.instance.model.Narrative.NarrativeStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case GENERATED: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED; + case EXTENSIONS: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS; + case ADDITIONAL: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL; + case EMPTY: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY; + default: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.r4.model.Narrative.NarrativeStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case GENERATED: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.GENERATED; + case EXTENSIONS: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.EXTENSIONS; + case ADDITIONAL: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.ADDITIONAL; + case EMPTY: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.EMPTY; + default: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.instance.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); + copyElement(src, tgt); + tgt.setAuthor(convertType(src.getAuthor())); + tgt.setTime(src.getTime()); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.instance.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Annotation tgt = new org.hl7.fhir.instance.model.Annotation(); + copyElement(src, tgt); + tgt.setAuthor(convertType(src.getAuthor())); + tgt.setTime(src.getTime()); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.instance.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + copyElement(src, tgt); + tgt.setContentType(src.getContentType()); + tgt.setLanguage(src.getLanguage()); + tgt.setData(src.getData()); + tgt.setUrl(src.getUrl()); + tgt.setSize(src.getSize()); + tgt.setHash(src.getHash()); + tgt.setTitle(src.getTitle()); + tgt.setCreation(src.getCreation()); + return tgt; + } + + public org.hl7.fhir.instance.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Attachment tgt = new org.hl7.fhir.instance.model.Attachment(); + copyElement(src, tgt); + tgt.setContentType(src.getContentType()); + tgt.setLanguage(src.getLanguage()); + tgt.setData(src.getData()); + tgt.setUrl(src.getUrl()); + tgt.setSize(src.getSize()); + tgt.setHash(src.getHash()); + tgt.setTitle(src.getTitle()); + tgt.setCreation(src.getCreation()); + return tgt; + } + + public org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.instance.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.Coding t : src.getCoding()) + tgt.addCoding(convertCoding(t)); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.instance.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.CodeableConcept tgt = new org.hl7.fhir.instance.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) + tgt.addCoding(convertCoding(t)); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.instance.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setVersion(src.getVersion()); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + tgt.setUserSelected(src.getUserSelected()); + return tgt; + } + + public org.hl7.fhir.instance.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Coding tgt = new org.hl7.fhir.instance.model.Coding(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setVersion(src.getVersion()); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + tgt.setUserSelected(src.getUserSelected()); + return tgt; + } + + + + public org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.instance.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); + copyElement(src, tgt); + tgt.setUse(convertIdentifierUse(src.getUse())); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setSystem(src.getSystem()); + tgt.setValue(src.getValue()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public org.hl7.fhir.instance.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Identifier tgt = new org.hl7.fhir.instance.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUse(convertIdentifierUse(src.getUse())); + if (src.hasType()) + tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) + tgt.setSystem(src.getSystem()); + if (src.hasValue()) + tgt.setValue(src.getValue()); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) + tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public org.hl7.fhir.r4.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.instance.model.Identifier.IdentifierUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case USUAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL; + case OFFICIAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL; + case TEMP: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP; + case SECONDARY: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY; + default: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL; + } + } + + public org.hl7.fhir.instance.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.r4.model.Identifier.IdentifierUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case USUAL: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.USUAL; + case OFFICIAL: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.OFFICIAL; + case TEMP: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.TEMP; + case SECONDARY: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.SECONDARY; + default: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.NULL; + } + } + + public org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.instance.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); + copyElement(src, tgt); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + return tgt; + } + + public org.hl7.fhir.instance.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Period tgt = new org.hl7.fhir.instance.model.Period(); + copyElement(src, tgt); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + return tgt; + } + + public org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.instance.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Quantity tgt = new org.hl7.fhir.instance.model.Quantity(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.instance.model.Quantity.QuantityComparator src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case LESS_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN; + case LESS_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL; + case GREATER_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; + case GREATER_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN; + default: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL; + } + } + + public org.hl7.fhir.instance.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.r4.model.Quantity.QuantityComparator src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case LESS_THAN: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.LESS_THAN; + case LESS_OR_EQUAL: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.LESS_OR_EQUAL; + case GREATER_OR_EQUAL: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; + case GREATER_THAN: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.GREATER_THAN; + default: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.NULL; + } + } + + public org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.instance.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); + copyElement(src, tgt); + tgt.setLow(convertSimpleQuantity(src.getLow())); + tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public org.hl7.fhir.instance.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Range tgt = new org.hl7.fhir.instance.model.Range(); + copyElement(src, tgt); + tgt.setLow(convertSimpleQuantity(src.getLow())); + tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.instance.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); + copyElement(src, tgt); + tgt.setNumerator(convertQuantity(src.getNumerator())); + tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public org.hl7.fhir.instance.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Ratio tgt = new org.hl7.fhir.instance.model.Ratio(); + copyElement(src, tgt); + tgt.setNumerator(convertQuantity(src.getNumerator())); + tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.instance.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + tgt.setDisplay(src.getDisplay()); + return tgt; + } + + public org.hl7.fhir.instance.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Reference tgt = new org.hl7.fhir.instance.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + tgt.setDisplay(src.getDisplay()); + return tgt; + } + + public org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.instance.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); + copyElement(src, tgt); + tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + tgt.setPeriod(src.getPeriod()); + tgt.setFactor(src.getFactor()); + tgt.setLowerLimit(src.getLowerLimit()); + tgt.setUpperLimit(src.getUpperLimit()); + tgt.setDimensions(src.getDimensions()); + tgt.setData(src.getData()); + return tgt; + } + + public org.hl7.fhir.instance.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SampledData tgt = new org.hl7.fhir.instance.model.SampledData(); + copyElement(src, tgt); + tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + tgt.setPeriod(src.getPeriod()); + tgt.setFactor(src.getFactor()); + tgt.setLowerLimit(src.getLowerLimit()); + tgt.setUpperLimit(src.getUpperLimit()); + tgt.setDimensions(src.getDimensions()); + tgt.setData(src.getData()); + return tgt; + } + + public org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.instance.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.Coding t : src.getType()) + tgt.addType(convertCoding(t)); + tgt.setWhen(src.getWhen()); + tgt.setWho(convertType(src.getWho())); + tgt.setContentType(src.getContentType()); + tgt.setBlob(src.getBlob()); + return tgt; + } + + public org.hl7.fhir.instance.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Signature tgt = new org.hl7.fhir.instance.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getType()) + tgt.addType(convertCoding(t)); + tgt.setWhen(src.getWhen()); + tgt.setWho(convertType(src.getWho())); + tgt.setContentType(src.getContentType()); + tgt.setBlob(src.getBlob()); + return tgt; + } + + public org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.instance.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); + copyElement(src, tgt); + tgt.setUse(convertAddressUse(src.getUse())); + tgt.setType(convertAddressType(src.getType())); + tgt.setText(src.getText()); + for (org.hl7.fhir.instance.model.StringType t : src.getLine()) + tgt.addLine(t.getValue()); + tgt.setCity(src.getCity()); + tgt.setDistrict(src.getDistrict()); + tgt.setState(src.getState()); + tgt.setPostalCode(src.getPostalCode()); + tgt.setCountry(src.getCountry()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Address tgt = new org.hl7.fhir.instance.model.Address(); + copyElement(src, tgt); + tgt.setUse(convertAddressUse(src.getUse())); + tgt.setType(convertAddressType(src.getType())); + tgt.setText(src.getText()); + for (org.hl7.fhir.r4.model.StringType t : src.getLine()) + tgt.addLine(t.getValue()); + tgt.setCity(src.getCity()); + tgt.setDistrict(src.getDistrict()); + tgt.setState(src.getState()); + tgt.setPostalCode(src.getPostalCode()); + tgt.setCountry(src.getCountry()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.Address.AddressUse convertAddressUse(org.hl7.fhir.instance.model.Address.AddressUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HOME: return org.hl7.fhir.r4.model.Address.AddressUse.HOME; + case WORK: return org.hl7.fhir.r4.model.Address.AddressUse.WORK; + case TEMP: return org.hl7.fhir.r4.model.Address.AddressUse.TEMP; + case OLD: return org.hl7.fhir.r4.model.Address.AddressUse.OLD; + default: return org.hl7.fhir.r4.model.Address.AddressUse.NULL; + } + } + + public org.hl7.fhir.instance.model.Address.AddressUse convertAddressUse(org.hl7.fhir.r4.model.Address.AddressUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HOME: return org.hl7.fhir.instance.model.Address.AddressUse.HOME; + case WORK: return org.hl7.fhir.instance.model.Address.AddressUse.WORK; + case TEMP: return org.hl7.fhir.instance.model.Address.AddressUse.TEMP; + case OLD: return org.hl7.fhir.instance.model.Address.AddressUse.OLD; + default: return org.hl7.fhir.instance.model.Address.AddressUse.NULL; + } + } + + public org.hl7.fhir.r4.model.Address.AddressType convertAddressType(org.hl7.fhir.instance.model.Address.AddressType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case POSTAL: return org.hl7.fhir.r4.model.Address.AddressType.POSTAL; + case PHYSICAL: return org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL; + case BOTH: return org.hl7.fhir.r4.model.Address.AddressType.BOTH; + default: return org.hl7.fhir.r4.model.Address.AddressType.NULL; + } + } + + public org.hl7.fhir.instance.model.Address.AddressType convertAddressType(org.hl7.fhir.r4.model.Address.AddressType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case POSTAL: return org.hl7.fhir.instance.model.Address.AddressType.POSTAL; + case PHYSICAL: return org.hl7.fhir.instance.model.Address.AddressType.PHYSICAL; + case BOTH: return org.hl7.fhir.instance.model.Address.AddressType.BOTH; + default: return org.hl7.fhir.instance.model.Address.AddressType.NULL; + } + } + + public org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.instance.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); + copyElement(src, tgt); + tgt.setSystem(convertContactPointSystem(src.getSystem())); + tgt.setValue(src.getValue()); + tgt.setUse(convertContactPointUse(src.getUse())); + if (src.hasRank()) + tgt.setRank(src.getRank()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ContactPoint tgt = new org.hl7.fhir.instance.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) + tgt.setSystem(convertContactPointSystem(src.getSystem())); + tgt.setValue(src.getValue()); + tgt.setUse(convertContactPointUse(src.getUse())); + tgt.setRank(src.getRank()); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PHONE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE; + case FAX: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX; + case EMAIL: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL; + case PAGER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER; + case OTHER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER; + default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL; + } + } + + public org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PHONE: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.PHONE; + case FAX: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.FAX; + case EMAIL: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.EMAIL; + case PAGER: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.PAGER; + case OTHER: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.OTHER; + case URL: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.OTHER; + default: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.NULL; + } + } + + public org.hl7.fhir.r4.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.instance.model.ContactPoint.ContactPointUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HOME: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME; + case WORK: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK; + case TEMP: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP; + case OLD: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD; + case MOBILE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE; + default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL; + } + } + + public org.hl7.fhir.instance.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HOME: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.HOME; + case WORK: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.WORK; + case TEMP: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.TEMP; + case OLD: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.OLD; + case MOBILE: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.MOBILE; + default: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.instance.model.ElementDefinition src, List slicePaths, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); + copyElement(src, tgt); + tgt.setPath(src.getPath()); + for (org.hl7.fhir.instance.model.Enumeration t : src.getRepresentation()) + tgt.addRepresentation(convertPropertyRepresentation(t.getValue())); + if (src.hasName()) { + if (slicePaths.contains(src.getPath())) + tgt.setSliceName(src.getName()); + tgt.setId(src.getName()); + } + if (src.hasLabel()) + tgt.setLabel(src.getLabel()); + for (org.hl7.fhir.instance.model.Coding t : src.getCode()) + tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) + tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); + if (src.hasShort()) + tgt.setShort(src.getShort()); + if (src.hasDefinition()) + tgt.setDefinition(src.getDefinition()); + if (src.hasComments()) + tgt.setComment(src.getComments()); + if (src.hasRequirements()) + tgt.setRequirements(src.getRequirements()); + for (org.hl7.fhir.instance.model.StringType t : src.getAlias()) + tgt.addAlias(t.getValue()); + if (src.hasMin()) + tgt.setMin(src.getMin()); + if (src.hasMax()) + tgt.setMax(src.getMax()); + if (src.hasBase()) + tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasNameReference()) + tgt.setContentReference("#"+src.getNameReference()); + for (org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertElementDefinitionTypeComponent(t)); + if (src.hasDefaultValue()) + tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissing(src.getMeaningWhenMissing()); + if (src.hasFixed()) + tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) + tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) + tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) + tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) + tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) + tgt.setMaxLength(src.getMaxLength()); + for (org.hl7.fhir.instance.model.IdType t : src.getCondition()) + tgt.addCondition(t.getValue()); + for (org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) + tgt.setMustSupport(src.getMustSupport()); + if (src.hasIsModifier()) + tgt.setIsModifier(src.getIsModifier()); + if (src.hasIsSummary()) + tgt.setIsSummary(src.getIsSummary()); + if (src.hasBinding()) + tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition tgt = new org.hl7.fhir.instance.model.ElementDefinition(); + copyElement(src, tgt); + tgt.setPath(src.getPath()); + for (org.hl7.fhir.r4.model.Enumeration t : src.getRepresentation()) + tgt.addRepresentation(convertPropertyRepresentation(t.getValue())); + if (src.hasSliceName()) + tgt.setName(src.getSliceName()); + else + tgt.setName(src.getId()); + tgt.setLabel(src.getLabel()); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) + tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) + tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + tgt.setShort(src.getShort()); + tgt.setDefinition(src.getDefinition()); + tgt.setComments(src.getComment()); + tgt.setRequirements(src.getRequirements()); + for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) + tgt.addAlias(t.getValue()); + tgt.setMin(src.getMin()); + tgt.setMax(src.getMax()); + if (src.hasBase()) + tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) + tgt.setNameReference(src.getContentReference().substring(1)); + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertElementDefinitionTypeComponent(t)); + tgt.setDefaultValue(convertType(src.getDefaultValue())); + tgt.setMeaningWhenMissing(src.getMeaningWhenMissing()); + tgt.setFixed(convertType(src.getFixed())); + tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) + tgt.setExample(convertType(src.getExampleFirstRep().getValue())); + tgt.setMinValue(convertType(src.getMinValue())); + tgt.setMaxValue(convertType(src.getMaxValue())); + tgt.setMaxLength(src.getMaxLength()); + for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) + tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + tgt.setMustSupport(src.getMustSupport()); + tgt.setIsModifier(src.getIsModifier()); + tgt.setIsSummary(src.getIsSummary()); + if (src.hasBinding()) + tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case XMLATTR: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR; + default: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL; + } + } + + public org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case XMLATTR: return org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation.XMLATTR; + default: return org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + org.hl7.fhir.instance.model.ElementDefinition slicingElement = context.get(pos); + for (org.hl7.fhir.instance.model.StringType t : src.getDiscriminator()) { + boolean isExists = false; + if (!t.asStringValue().contains("@")) { + int slices = 0; + boolean existsSlicePresent = false; + boolean notExistsSlicePresent = false; + String existsPath = slicingElement.getPath() + "." + t.asStringValue(); + for (int i = pos + 1; i < context.size(); i++) { + org.hl7.fhir.instance.model.ElementDefinition e = context.get(i); + if (e.getPath().equals(slicingElement.getPath())) + slices++; + else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) + break; + else if (e.getPath().equals(existsPath)) { + if (e.hasMin() && e.getMin() > 0) + existsSlicePresent = true; + else if (e.hasMax() && e.getMax().equals("0")) + notExistsSlicePresent = true; + } + } + isExists = slices==2 && existsSlicePresent && notExistsSlicePresent; + } + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); + } + tgt.setDescription(src.getDescription()); + tgt.setOrdered(src.getOrdered()); + tgt.setRules(convertSlicingRules(src.getRules())); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + tgt.setDescription(src.getDescription()); + tgt.setOrdered(src.getOrdered()); + tgt.setRules(convertSlicingRules(src.getRules())); + return tgt; + } + + public org.hl7.fhir.r4.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.instance.model.ElementDefinition.SlicingRules src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CLOSED: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED; + case OPEN: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN; + case OPENATEND: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND; + default: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL; + } + } + + public org.hl7.fhir.instance.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CLOSED: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.CLOSED; + case OPEN: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.OPEN; + case OPENATEND: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.OPENATEND; + default: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + tgt.setPath(src.getPath()); + tgt.setMin(src.getMin()); + tgt.setMax(src.getMax()); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + tgt.setPath(src.getPath()); + tgt.setMin(src.getMin()); + tgt.setMax(src.getMax()); + return tgt; + } + + public org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); + for (org.hl7.fhir.instance.model.UriType t : src.getProfile()) + if (src.hasCode() && "Reference".equals(src.getCode())) + tgt.setTargetProfile(t.getValueAsString()); + else + tgt.setProfile(t.getValue()); + for (org.hl7.fhir.instance.model.Enumeration t : src.getAggregation()) + tgt.addAggregation(convertAggregationMode(t.getValue())); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCodeElement(convertUriToCode(src.getCodeElement())); + if (src.hasCode() && "Reference".equals(src.getCode())) { + if (src.hasTargetProfile()) + tgt.addProfile(src.getTargetProfile()); + } else if (src.hasProfile()) + tgt.addProfile(src.getProfile()); + for (org.hl7.fhir.r4.model.Enumeration t : src.getAggregation()) + tgt.addAggregation(convertAggregationMode(t.getValue())); + return tgt; + } + + public org.hl7.fhir.r4.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.instance.model.ElementDefinition.AggregationMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CONTAINED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED; + case REFERENCED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED; + case BUNDLED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED; + default: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL; + } + } + + public org.hl7.fhir.instance.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CONTAINED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.CONTAINED; + case REFERENCED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.REFERENCED; + case BUNDLED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.BUNDLED; + default: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + tgt.setKey(src.getKey()); + tgt.setRequirements(src.getRequirements()); + tgt.setSeverity(convertConstraintSeverity(src.getSeverity())); + tgt.setHuman(src.getHuman()); + tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); + tgt.setXpath(src.getXpath()); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + tgt.setKey(src.getKey()); + tgt.setRequirements(src.getRequirements()); + tgt.setSeverity(convertConstraintSeverity(src.getSeverity())); + tgt.setHuman(src.getHuman()); + if (src.hasExpression()) + ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); + tgt.setXpath(src.getXpath()); + return tgt; + } + + public org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ERROR: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR; + case WARNING: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING; + default: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL; + } + } + + public org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ERROR: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.ERROR; + case WARNING: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.WARNING; + default: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + tgt.setStrength(convertBindingStrength(src.getStrength())); + tgt.setDescription(src.getDescription()); + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + tgt.setStrength(convertBindingStrength(src.getStrength())); + tgt.setDescription(src.getDescription()); + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public org.hl7.fhir.r4.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.instance.model.Enumerations.BindingStrength src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUIRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED; + case EXTENSIBLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE; + case PREFERRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED; + case EXAMPLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE; + default: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL; + } + } + + public org.hl7.fhir.instance.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.r4.model.Enumerations.BindingStrength src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUIRED: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.REQUIRED; + case EXTENSIBLE: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.EXTENSIBLE; + case PREFERRED: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.PREFERRED; + case EXAMPLE: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.EXAMPLE; + default: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.NULL; + } + } + + public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + tgt.setIdentity(src.getIdentity()); + tgt.setLanguage(src.getLanguage()); + tgt.setMap(src.getMap()); + return tgt; + } + + public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + tgt.setIdentity(src.getIdentity()); + tgt.setLanguage(src.getLanguage()); + tgt.setMap(src.getMap()); + return tgt; + } + + public org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.instance.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); + copyElement(src, tgt); + tgt.setUse(convertNameUse(src.getUse())); + tgt.setText(src.getText()); + for (org.hl7.fhir.instance.model.StringType t : src.getFamily()) + tgt.setFamily(t.getValue()); + for (org.hl7.fhir.instance.model.StringType t : src.getGiven()) + tgt.addGiven(t.getValue()); + for (org.hl7.fhir.instance.model.StringType t : src.getPrefix()) + tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.instance.model.StringType t : src.getSuffix()) + tgt.addSuffix(t.getValue()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.HumanName tgt = new org.hl7.fhir.instance.model.HumanName(); + copyElement(src, tgt); + tgt.setUse(convertNameUse(src.getUse())); + tgt.setText(src.getText()); + if (src.hasFamily()) + tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) + tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) + tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) + tgt.addSuffix(t.getValue()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.HumanName.NameUse convertNameUse(org.hl7.fhir.instance.model.HumanName.NameUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case USUAL: return org.hl7.fhir.r4.model.HumanName.NameUse.USUAL; + case OFFICIAL: return org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL; + case TEMP: return org.hl7.fhir.r4.model.HumanName.NameUse.TEMP; + case NICKNAME: return org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME; + case ANONYMOUS: return org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS; + case OLD: return org.hl7.fhir.r4.model.HumanName.NameUse.OLD; + case MAIDEN: return org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN; + default: return org.hl7.fhir.r4.model.HumanName.NameUse.NULL; + } + } + + public org.hl7.fhir.instance.model.HumanName.NameUse convertNameUse(org.hl7.fhir.r4.model.HumanName.NameUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case USUAL: return org.hl7.fhir.instance.model.HumanName.NameUse.USUAL; + case OFFICIAL: return org.hl7.fhir.instance.model.HumanName.NameUse.OFFICIAL; + case TEMP: return org.hl7.fhir.instance.model.HumanName.NameUse.TEMP; + case NICKNAME: return org.hl7.fhir.instance.model.HumanName.NameUse.NICKNAME; + case ANONYMOUS: return org.hl7.fhir.instance.model.HumanName.NameUse.ANONYMOUS; + case OLD: return org.hl7.fhir.instance.model.HumanName.NameUse.OLD; + case MAIDEN: return org.hl7.fhir.instance.model.HumanName.NameUse.MAIDEN; + default: return org.hl7.fhir.instance.model.HumanName.NameUse.NULL; + } + } + + public org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.instance.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); + copyElement(src, tgt); + tgt.setVersionId(src.getVersionId()); + tgt.setLastUpdated(src.getLastUpdated()); + for (org.hl7.fhir.instance.model.UriType t : src.getProfile()) + tgt.addProfile(t.getValue()); + for (org.hl7.fhir.instance.model.Coding t : src.getSecurity()) + tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.instance.model.Coding t : src.getTag()) + tgt.addTag(convertCoding(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Meta tgt = new org.hl7.fhir.instance.model.Meta(); + copyElement(src, tgt); + tgt.setVersionId(src.getVersionId()); + tgt.setLastUpdated(src.getLastUpdated()); + for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) + tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) + tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) + tgt.addTag(convertCoding(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.instance.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.DateTimeType t : src.getEvent()) + tgt.addEvent(t.getValue()); + tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public org.hl7.fhir.instance.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Timing tgt = new org.hl7.fhir.instance.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) + tgt.addEvent(t.getValue()); + tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.instance.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + tgt.setBounds(convertType(src.getBounds())); + tgt.setCount(src.getCount()); + tgt.setDuration(src.getDuration()); + tgt.setDurationMax(src.getDurationMax()); + tgt.setDurationUnit(convertUnitsOfTime(src.getDurationUnits())); + tgt.setFrequency(src.getFrequency()); + tgt.setFrequencyMax(src.getFrequencyMax()); + tgt.setPeriod(src.getPeriod()); + tgt.setPeriodMax(src.getPeriodMax()); + tgt.setPeriodUnit(convertUnitsOfTime(src.getPeriodUnits())); + tgt.addWhen(convertEventTiming(src.getWhen())); + return tgt; + } + + public org.hl7.fhir.instance.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.instance.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + tgt.setBounds(convertType(src.getBounds())); + tgt.setCount(src.getCount()); + tgt.setDuration(src.getDuration()); + tgt.setDurationMax(src.getDurationMax()); + tgt.setDurationUnits(convertUnitsOfTime(src.getDurationUnit())); + tgt.setFrequency(src.getFrequency()); + tgt.setFrequencyMax(src.getFrequencyMax()); + tgt.setPeriod(src.getPeriod()); + tgt.setPeriodMax(src.getPeriodMax()); + tgt.setPeriodUnits(convertUnitsOfTime(src.getPeriodUnit())); + for (Enumeration t : src.getWhen()) + tgt.setWhen(convertEventTiming(t.getValue())); + return tgt; + } + + public org.hl7.fhir.r4.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.instance.model.Timing.UnitsOfTime src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case S: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.S; + case MIN: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN; + case H: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.H; + case D: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.D; + case WK: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK; + case MO: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO; + case A: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.A; + default: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL; + } + } + + public org.hl7.fhir.instance.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.r4.model.Timing.UnitsOfTime src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case S: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.S; + case MIN: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.MIN; + case H: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.H; + case D: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.D; + case WK: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.WK; + case MO: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.MO; + case A: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.A; + default: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.NULL; + } + } + + public org.hl7.fhir.r4.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.instance.model.Timing.EventTiming src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HS: return org.hl7.fhir.r4.model.Timing.EventTiming.HS; + case WAKE: return org.hl7.fhir.r4.model.Timing.EventTiming.WAKE; + case C: return org.hl7.fhir.r4.model.Timing.EventTiming.C; + case CM: return org.hl7.fhir.r4.model.Timing.EventTiming.CM; + case CD: return org.hl7.fhir.r4.model.Timing.EventTiming.CD; + case CV: return org.hl7.fhir.r4.model.Timing.EventTiming.CV; + case AC: return org.hl7.fhir.r4.model.Timing.EventTiming.AC; + case ACM: return org.hl7.fhir.r4.model.Timing.EventTiming.ACM; + case ACD: return org.hl7.fhir.r4.model.Timing.EventTiming.ACD; + case ACV: return org.hl7.fhir.r4.model.Timing.EventTiming.ACV; + case PC: return org.hl7.fhir.r4.model.Timing.EventTiming.PC; + case PCM: return org.hl7.fhir.r4.model.Timing.EventTiming.PCM; + case PCD: return org.hl7.fhir.r4.model.Timing.EventTiming.PCD; + case PCV: return org.hl7.fhir.r4.model.Timing.EventTiming.PCV; + default: return org.hl7.fhir.r4.model.Timing.EventTiming.NULL; + } + } + + public org.hl7.fhir.instance.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.r4.model.Timing.EventTiming src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HS: return org.hl7.fhir.instance.model.Timing.EventTiming.HS; + case WAKE: return org.hl7.fhir.instance.model.Timing.EventTiming.WAKE; + case C: return org.hl7.fhir.instance.model.Timing.EventTiming.C; + case CM: return org.hl7.fhir.instance.model.Timing.EventTiming.CM; + case CD: return org.hl7.fhir.instance.model.Timing.EventTiming.CD; + case CV: return org.hl7.fhir.instance.model.Timing.EventTiming.CV; + case AC: return org.hl7.fhir.instance.model.Timing.EventTiming.AC; + case ACM: return org.hl7.fhir.instance.model.Timing.EventTiming.ACM; + case ACD: return org.hl7.fhir.instance.model.Timing.EventTiming.ACD; + case ACV: return org.hl7.fhir.instance.model.Timing.EventTiming.ACV; + case PC: return org.hl7.fhir.instance.model.Timing.EventTiming.PC; + case PCM: return org.hl7.fhir.instance.model.Timing.EventTiming.PCM; + case PCD: return org.hl7.fhir.instance.model.Timing.EventTiming.PCD; + case PCV: return org.hl7.fhir.instance.model.Timing.EventTiming.PCV; + default: return org.hl7.fhir.instance.model.Timing.EventTiming.NULL; + } + } + + public org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.instance.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Age tgt = new org.hl7.fhir.instance.model.Age(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.instance.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Count tgt = new org.hl7.fhir.instance.model.Count(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.instance.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Distance tgt = new org.hl7.fhir.instance.model.Distance(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.instance.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Duration tgt = new org.hl7.fhir.instance.model.Duration(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.instance.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Money tgt = new org.hl7.fhir.instance.model.Money(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.instance.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.instance.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SimpleQuantity tgt = new org.hl7.fhir.instance.model.SimpleQuantity(); + copyElement(src, tgt); + tgt.setValue(src.getValue()); + tgt.setComparator(convertQuantityComparator(src.getComparator())); + tgt.setUnit(src.getUnit()); + tgt.setSystem(src.getSystem()); + tgt.setCode(src.getCode()); + return tgt; + } + + public org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.instance.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.instance.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.instance.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.instance.model.BooleanType) + return convertBoolean((org.hl7.fhir.instance.model.BooleanType) src); + if (src instanceof org.hl7.fhir.instance.model.CodeType) + return convertCode((org.hl7.fhir.instance.model.CodeType) src); + if (src instanceof org.hl7.fhir.instance.model.DateType) + return convertDate((org.hl7.fhir.instance.model.DateType) src); + if (src instanceof org.hl7.fhir.instance.model.DateTimeType) + return convertDateTime((org.hl7.fhir.instance.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.instance.model.DecimalType) + return convertDecimal((org.hl7.fhir.instance.model.DecimalType) src); + if (src instanceof org.hl7.fhir.instance.model.IdType) + return convertId((org.hl7.fhir.instance.model.IdType) src); + if (src instanceof org.hl7.fhir.instance.model.InstantType) + return convertInstant((org.hl7.fhir.instance.model.InstantType) src); + if (src instanceof org.hl7.fhir.instance.model.IntegerType) + return convertInteger((org.hl7.fhir.instance.model.IntegerType) src); + if (src instanceof org.hl7.fhir.instance.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.instance.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.instance.model.OidType) + return convertOid((org.hl7.fhir.instance.model.OidType) src); + if (src instanceof org.hl7.fhir.instance.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.instance.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.instance.model.StringType) + return convertString((org.hl7.fhir.instance.model.StringType) src); + if (src instanceof org.hl7.fhir.instance.model.TimeType) + return convertTime((org.hl7.fhir.instance.model.TimeType) src); + if (src instanceof org.hl7.fhir.instance.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.instance.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.instance.model.UriType) + return convertUri((org.hl7.fhir.instance.model.UriType) src); + if (src instanceof org.hl7.fhir.instance.model.UuidType) + return convertUuid((org.hl7.fhir.instance.model.UuidType) src); + if (src instanceof org.hl7.fhir.instance.model.Extension) + return convertExtension((org.hl7.fhir.instance.model.Extension) src); + if (src instanceof org.hl7.fhir.instance.model.Narrative) + return convertNarrative((org.hl7.fhir.instance.model.Narrative) src); + if (src instanceof org.hl7.fhir.instance.model.Annotation) + return convertAnnotation((org.hl7.fhir.instance.model.Annotation) src); + if (src instanceof org.hl7.fhir.instance.model.Attachment) + return convertAttachment((org.hl7.fhir.instance.model.Attachment) src); + if (src instanceof org.hl7.fhir.instance.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.instance.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.instance.model.Coding) + return convertCoding((org.hl7.fhir.instance.model.Coding) src); + if (src instanceof org.hl7.fhir.instance.model.Identifier) + return convertIdentifier((org.hl7.fhir.instance.model.Identifier) src); + if (src instanceof org.hl7.fhir.instance.model.Period) + return convertPeriod((org.hl7.fhir.instance.model.Period) src); + if (src instanceof org.hl7.fhir.instance.model.Quantity) + return convertQuantity((org.hl7.fhir.instance.model.Quantity) src); + if (src instanceof org.hl7.fhir.instance.model.Range) + return convertRange((org.hl7.fhir.instance.model.Range) src); + if (src instanceof org.hl7.fhir.instance.model.Ratio) + return convertRatio((org.hl7.fhir.instance.model.Ratio) src); + if (src instanceof org.hl7.fhir.instance.model.Reference) + return convertReference((org.hl7.fhir.instance.model.Reference) src); + if (src instanceof org.hl7.fhir.instance.model.SampledData) + return convertSampledData((org.hl7.fhir.instance.model.SampledData) src); + if (src instanceof org.hl7.fhir.instance.model.Signature) + return convertSignature((org.hl7.fhir.instance.model.Signature) src); + if (src instanceof org.hl7.fhir.instance.model.Address) + return convertAddress((org.hl7.fhir.instance.model.Address) src); + if (src instanceof org.hl7.fhir.instance.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.instance.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.instance.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.instance.model.ElementDefinition) src, new ArrayList(), new ArrayList(), 0); + if (src instanceof org.hl7.fhir.instance.model.HumanName) + return convertHumanName((org.hl7.fhir.instance.model.HumanName) src); + if (src instanceof org.hl7.fhir.instance.model.Meta) + return convertMeta((org.hl7.fhir.instance.model.Meta) src); + if (src instanceof org.hl7.fhir.instance.model.Timing) + return convertTiming((org.hl7.fhir.instance.model.Timing) src); + if (src instanceof org.hl7.fhir.instance.model.Age) + return convertAge((org.hl7.fhir.instance.model.Age) src); + if (src instanceof org.hl7.fhir.instance.model.Count) + return convertCount((org.hl7.fhir.instance.model.Count) src); + if (src instanceof org.hl7.fhir.instance.model.Distance) + return convertDistance((org.hl7.fhir.instance.model.Distance) src); + if (src instanceof org.hl7.fhir.instance.model.Duration) + return convertDuration((org.hl7.fhir.instance.model.Duration) src); + if (src instanceof org.hl7.fhir.instance.model.Money) + return convertMoney((org.hl7.fhir.instance.model.Money) src); + if (src instanceof org.hl7.fhir.instance.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.instance.model.SimpleQuantity) src); + throw new Error("Unknown type "+src.fhirType()); + } + + public org.hl7.fhir.instance.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r4.model.BooleanType) + return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r4.model.CodeType) + return convertCode((org.hl7.fhir.r4.model.CodeType) src); + if (src instanceof org.hl7.fhir.r4.model.DateType) + return convertDate((org.hl7.fhir.r4.model.DateType) src); + if (src instanceof org.hl7.fhir.r4.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r4.model.DecimalType) + return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r4.model.IdType) + return convertId((org.hl7.fhir.r4.model.IdType) src); + if (src instanceof org.hl7.fhir.r4.model.InstantType) + return convertInstant((org.hl7.fhir.r4.model.InstantType) src); + if (src instanceof org.hl7.fhir.r4.model.IntegerType) + return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r4.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r4.model.OidType) + return convertOid((org.hl7.fhir.r4.model.OidType) src); + if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r4.model.StringType) + return convertString((org.hl7.fhir.r4.model.StringType) src); + if (src instanceof org.hl7.fhir.r4.model.TimeType) + return convertTime((org.hl7.fhir.r4.model.TimeType) src); + if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) + return convertUri((org.hl7.fhir.r4.model.UriType) src); + if (src instanceof org.hl7.fhir.r4.model.UuidType) + return convertUuid((org.hl7.fhir.r4.model.UuidType) src); + if (src instanceof org.hl7.fhir.r4.model.Extension) + return convertExtension((org.hl7.fhir.r4.model.Extension) src); + if (src instanceof org.hl7.fhir.r4.model.Narrative) + return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); + if (src instanceof org.hl7.fhir.r4.model.Annotation) + return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); + if (src instanceof org.hl7.fhir.r4.model.Attachment) + return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); + if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r4.model.Coding) + return convertCoding((org.hl7.fhir.r4.model.Coding) src); + if (src instanceof org.hl7.fhir.r4.model.Identifier) + return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); + if (src instanceof org.hl7.fhir.r4.model.Period) + return convertPeriod((org.hl7.fhir.r4.model.Period) src); + if (src instanceof org.hl7.fhir.r4.model.Quantity) + return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); + if (src instanceof org.hl7.fhir.r4.model.Range) + return convertRange((org.hl7.fhir.r4.model.Range) src); + if (src instanceof org.hl7.fhir.r4.model.Ratio) + return convertRatio((org.hl7.fhir.r4.model.Ratio) src); + if (src instanceof org.hl7.fhir.r4.model.Reference) + return convertReference((org.hl7.fhir.r4.model.Reference) src); + if (src instanceof org.hl7.fhir.r4.model.SampledData) + return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); + if (src instanceof org.hl7.fhir.r4.model.Signature) + return convertSignature((org.hl7.fhir.r4.model.Signature) src); + if (src instanceof org.hl7.fhir.r4.model.Address) + return convertAddress((org.hl7.fhir.r4.model.Address) src); + if (src instanceof org.hl7.fhir.r4.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.HumanName) + return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); + if (src instanceof org.hl7.fhir.r4.model.Meta) + return convertMeta((org.hl7.fhir.r4.model.Meta) src); + if (src instanceof org.hl7.fhir.r4.model.Timing) + return convertTiming((org.hl7.fhir.r4.model.Timing) src); + if (src instanceof org.hl7.fhir.r4.model.Age) + return convertAge((org.hl7.fhir.r4.model.Age) src); + if (src instanceof org.hl7.fhir.r4.model.Count) + return convertCount((org.hl7.fhir.r4.model.Count) src); + if (src instanceof org.hl7.fhir.r4.model.Distance) + return convertDistance((org.hl7.fhir.r4.model.Distance) src); + if (src instanceof org.hl7.fhir.r4.model.Duration) + return convertDuration((org.hl7.fhir.r4.model.Duration) src); + if (src instanceof org.hl7.fhir.r4.model.Money) + return convertMoney((org.hl7.fhir.r4.model.Money) src); + if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); + throw new Error("Unknown type "+src.fhirType()); + } + + public void copyDomainResource(org.hl7.fhir.instance.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.instance.model.Resource t : src.getContained()) + tgt.addContained(convertResource(t)); + for (org.hl7.fhir.instance.model.Extension t : src.getExtension()) + tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.instance.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.instance.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r4.model.Resource t : src.getContained()) + tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) + tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + + public org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.instance.model.Parameters src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Parameters tgt = new org.hl7.fhir.r4.model.Parameters(); + copyResource(src, tgt); + for (org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent t : src.getParameter()) + tgt.addParameter(convertParametersParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Parameters convertParameters(org.hl7.fhir.r4.model.Parameters src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Parameters tgt = new org.hl7.fhir.instance.model.Parameters(); + copyResource(src, tgt); + for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getParameter()) + tgt.addParameter(convertParametersParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setValue(convertType(src.getValue())); + tgt.setResource(convertResource(src.getResource())); + for (org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent t : src.getPart()) + tgt.addPart(convertParametersParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setValue(convertType(src.getValue())); + tgt.setResource(convertResource(src.getResource())); + for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getPart()) + tgt.addPart(convertParametersParameterComponent(t)); + return tgt; + } + + public void copyResource(org.hl7.fhir.instance.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + tgt.setMeta(convertMeta(src.getMeta())); + tgt.setImplicitRules(src.getImplicitRules()); + tgt.setLanguage(src.getLanguage()); + } + public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.instance.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + if (src.hasMeta()) + tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) + tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) + tgt.setLanguage(src.getLanguage()); + } + + public org.hl7.fhir.r4.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.instance.model.Enumerations.AdministrativeGender src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE; + case FEMALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE; + case OTHER: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER; + case UNKNOWN: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN; + default: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL; + } + } + + public org.hl7.fhir.instance.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MALE: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.MALE; + case FEMALE: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.FEMALE; + case OTHER: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.OTHER; + case UNKNOWN: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.UNKNOWN; + default: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.NULL; + } + } + + public org.hl7.fhir.r4.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.instance.model.Enumerations.SearchParamType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NUMBER: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER; + case DATE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE; + case STRING: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING; + case TOKEN: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN; + case REFERENCE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE; + case COMPOSITE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE; + case QUANTITY: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY; + case URI: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI; + default: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL; + } + } + + public org.hl7.fhir.instance.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.r4.model.Enumerations.SearchParamType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NUMBER: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.NUMBER; + case DATE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.DATE; + case STRING: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.STRING; + case TOKEN: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.TOKEN; + case REFERENCE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.REFERENCE; + case COMPOSITE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.COMPOSITE; + case QUANTITY: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.QUANTITY; + case URI: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.URI; + default: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.NULL; + } + } + public org.hl7.fhir.r4.model.Account convertAccount(org.hl7.fhir.instance.model.Account src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -147,251 +2094,6 @@ public class VersionConvertor_10_40 { } } - public org.hl7.fhir.r4.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.instance.model.ProcessRequest.ActionList src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CANCEL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.CANCEL; - case POLL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.POLL; - case REPROCESS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.REPROCESS; - case STATUS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.STATUS; - default: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.NULL; - } - } - - public org.hl7.fhir.instance.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.r4.model.ProcessRequest.ActionList src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CANCEL: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.CANCEL; - case POLL: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.POLL; - case REPROCESS: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.REPROCESS; - case STATUS: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.STATUS; - default: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.NULL; - } - } - - public org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.instance.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); - copyElement(src, tgt); - tgt.setUse(convertAddressUse(src.getUse())); - tgt.setType(convertAddressType(src.getType())); - tgt.setText(src.getText()); - for (org.hl7.fhir.instance.model.StringType t : src.getLine()) - tgt.addLine(t.getValue()); - tgt.setCity(src.getCity()); - tgt.setDistrict(src.getDistrict()); - tgt.setState(src.getState()); - tgt.setPostalCode(src.getPostalCode()); - tgt.setCountry(src.getCountry()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Address tgt = new org.hl7.fhir.instance.model.Address(); - copyElement(src, tgt); - tgt.setUse(convertAddressUse(src.getUse())); - tgt.setType(convertAddressType(src.getType())); - tgt.setText(src.getText()); - for (org.hl7.fhir.r4.model.StringType t : src.getLine()) - tgt.addLine(t.getValue()); - tgt.setCity(src.getCity()); - tgt.setDistrict(src.getDistrict()); - tgt.setState(src.getState()); - tgt.setPostalCode(src.getPostalCode()); - tgt.setCountry(src.getCountry()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.Address.AddressType convertAddressType(org.hl7.fhir.instance.model.Address.AddressType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case POSTAL: return org.hl7.fhir.r4.model.Address.AddressType.POSTAL; - case PHYSICAL: return org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL; - case BOTH: return org.hl7.fhir.r4.model.Address.AddressType.BOTH; - default: return org.hl7.fhir.r4.model.Address.AddressType.NULL; - } - } - - public org.hl7.fhir.instance.model.Address.AddressType convertAddressType(org.hl7.fhir.r4.model.Address.AddressType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case POSTAL: return org.hl7.fhir.instance.model.Address.AddressType.POSTAL; - case PHYSICAL: return org.hl7.fhir.instance.model.Address.AddressType.PHYSICAL; - case BOTH: return org.hl7.fhir.instance.model.Address.AddressType.BOTH; - default: return org.hl7.fhir.instance.model.Address.AddressType.NULL; - } - } - - public org.hl7.fhir.r4.model.Address.AddressUse convertAddressUse(org.hl7.fhir.instance.model.Address.AddressUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HOME: return org.hl7.fhir.r4.model.Address.AddressUse.HOME; - case WORK: return org.hl7.fhir.r4.model.Address.AddressUse.WORK; - case TEMP: return org.hl7.fhir.r4.model.Address.AddressUse.TEMP; - case OLD: return org.hl7.fhir.r4.model.Address.AddressUse.OLD; - default: return org.hl7.fhir.r4.model.Address.AddressUse.NULL; - } - } - - public org.hl7.fhir.instance.model.Address.AddressUse convertAddressUse(org.hl7.fhir.r4.model.Address.AddressUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HOME: return org.hl7.fhir.instance.model.Address.AddressUse.HOME; - case WORK: return org.hl7.fhir.instance.model.Address.AddressUse.WORK; - case TEMP: return org.hl7.fhir.instance.model.Address.AddressUse.TEMP; - case OLD: return org.hl7.fhir.instance.model.Address.AddressUse.OLD; - default: return org.hl7.fhir.instance.model.Address.AddressUse.NULL; - } - } - - public org.hl7.fhir.r4.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.instance.model.Enumerations.AdministrativeGender src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE; - case FEMALE: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE; - case OTHER: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER; - case UNKNOWN: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN; - default: return org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL; - } - } - - public org.hl7.fhir.instance.model.Enumerations.AdministrativeGender convertAdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MALE: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.MALE; - case FEMALE: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.FEMALE; - case OTHER: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.OTHER; - case UNKNOWN: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.UNKNOWN; - default: return org.hl7.fhir.instance.model.Enumerations.AdministrativeGender.NULL; - } - } - - public org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.instance.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.instance.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Age tgt = new org.hl7.fhir.instance.model.Age(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.AgentComponent convertAgentComponent(org.hl7.fhir.instance.model.Contract.ActorComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent(); - copyElement(src, tgt); - tgt.setActor(convertReference(src.getEntity())); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRole()) - tgt.addRole(convertCodeableConcept(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.ActorComponent convertAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.ActorComponent tgt = new org.hl7.fhir.instance.model.Contract.ActorComponent(); - copyElement(src, tgt); - tgt.setEntity(convertReference(src.getActor())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) - tgt.addRole(convertCodeableConcept(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.instance.model.ElementDefinition.AggregationMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CONTAINED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED; - case REFERENCED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED; - case BUNDLED: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED; - default: return org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL; - } - } - - public org.hl7.fhir.instance.model.ElementDefinition.AggregationMode convertAggregationMode(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CONTAINED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.CONTAINED; - case REFERENCED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.REFERENCED; - case BUNDLED: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.BUNDLED; - default: return org.hl7.fhir.instance.model.ElementDefinition.AggregationMode.NULL; - } - } - - public org.hl7.fhir.r4.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.instance.model.Patient.AnimalComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Patient.AnimalComponent tgt = new org.hl7.fhir.r4.model.Patient.AnimalComponent(); - copyElement(src, tgt); - tgt.setSpecies(convertCodeableConcept(src.getSpecies())); - tgt.setBreed(convertCodeableConcept(src.getBreed())); - tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus())); - return tgt; - } - - public org.hl7.fhir.instance.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.r4.model.Patient.AnimalComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Patient.AnimalComponent tgt = new org.hl7.fhir.instance.model.Patient.AnimalComponent(); - copyElement(src, tgt); - tgt.setSpecies(convertCodeableConcept(src.getSpecies())); - tgt.setBreed(convertCodeableConcept(src.getBreed())); - tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus())); - return tgt; - } - - public org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.instance.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); - copyElement(src, tgt); - tgt.setAuthor(convertType(src.getAuthor())); - tgt.setTime(src.getTime()); - tgt.setText(src.getText()); - return tgt; - } - - public org.hl7.fhir.instance.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Annotation tgt = new org.hl7.fhir.instance.model.Annotation(); - copyElement(src, tgt); - tgt.setAuthor(convertType(src.getAuthor())); - tgt.setTime(src.getTime()); - tgt.setText(src.getText()); - return tgt; - } public org.hl7.fhir.r4.model.Appointment convertAppointment(org.hl7.fhir.instance.model.Appointment src) throws FHIRException { if (src == null || src.isEmpty()) @@ -441,68 +2143,6 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) - tgt.addType(convertCodeableConcept(t)); - tgt.setActor(convertReference(src.getActor())); - tgt.setRequired(convertParticipantRequired(src.getRequired())); - tgt.setStatus(convertParticipationStatus(src.getStatus())); - return tgt; - } - - public org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) - tgt.addType(convertCodeableConcept(t)); - tgt.setActor(convertReference(src.getActor())); - tgt.setRequired(convertParticipantRequired(src.getRequired())); - tgt.setStatus(convertParticipationStatus(src.getStatus())); - return tgt; - } - - public org.hl7.fhir.r4.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.instance.model.AppointmentResponse src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.AppointmentResponse tgt = new org.hl7.fhir.r4.model.AppointmentResponse(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setAppointment(convertReference(src.getAppointment())); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getParticipantType()) - tgt.addParticipantType(convertCodeableConcept(t)); - tgt.setActor(convertReference(src.getActor())); - tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus())); - tgt.setComment(src.getComment()); - return tgt; - } - - public org.hl7.fhir.instance.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r4.model.AppointmentResponse src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.AppointmentResponse tgt = new org.hl7.fhir.instance.model.AppointmentResponse(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setAppointment(convertReference(src.getAppointment())); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getParticipantType()) - tgt.addParticipantType(convertCodeableConcept(t)); - tgt.setActor(convertReference(src.getActor())); - tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus())); - tgt.setComment(src.getComment()); - return tgt; - } - public org.hl7.fhir.r4.model.Appointment.AppointmentStatus convertAppointmentStatus(org.hl7.fhir.instance.model.Appointment.AppointmentStatus src) throws FHIRException { if (src == null) return null; @@ -533,131 +2173,137 @@ public class VersionConvertor_10_40 { } } - public org.hl7.fhir.r4.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.instance.model.TestScript.AssertionDirectionType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESPONSE: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.RESPONSE; - case REQUEST: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.REQUEST; - default: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL; - } - } - - public org.hl7.fhir.instance.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESPONSE: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.RESPONSE; - case REQUEST: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.REQUEST; - default: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.NULL; - } - } - - public org.hl7.fhir.r4.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.instance.model.TestScript.AssertionOperatorType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case EQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EQUALS; - case NOTEQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEQUALS; - case IN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.IN; - case NOTIN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTIN; - case GREATERTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.GREATERTHAN; - case LESSTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.LESSTHAN; - case EMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EMPTY; - case NOTEMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEMPTY; - case CONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.CONTAINS; - case NOTCONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTCONTAINS; - default: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL; - } - } - - public org.hl7.fhir.instance.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case EQUALS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.EQUALS; - case NOTEQUALS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTEQUALS; - case IN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.IN; - case NOTIN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTIN; - case GREATERTHAN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.GREATERTHAN; - case LESSTHAN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.LESSTHAN; - case EMPTY: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.EMPTY; - case NOTEMPTY: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTEMPTY; - case CONTAINS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.CONTAINS; - case NOTCONTAINS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTCONTAINS; - default: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NULL; - } - } - - public org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OKAY: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.OKAY; - case CREATED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CREATED; - case NOCONTENT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOCONTENT; - case NOTMODIFIED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTMODIFIED; - case BAD: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.BAD; - case FORBIDDEN: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.FORBIDDEN; - case NOTFOUND: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTFOUND; - case METHODNOTALLOWED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED; - case CONFLICT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CONFLICT; - case GONE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.GONE; - case PRECONDITIONFAILED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED; - case UNPROCESSABLE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.UNPROCESSABLE; - default: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL; - } - } - - public org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OKAY: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.OKAY; - case CREATED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.CREATED; - case NOCONTENT: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOCONTENT; - case NOTMODIFIED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOTMODIFIED; - case BAD: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.BAD; - case FORBIDDEN: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.FORBIDDEN; - case NOTFOUND: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOTFOUND; - case METHODNOTALLOWED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED; - case CONFLICT: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.CONFLICT; - case GONE: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.GONE; - case PRECONDITIONFAILED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED; - case UNPROCESSABLE: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.UNPROCESSABLE; - default: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NULL; - } - } - - public org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.instance.model.Attachment src) throws FHIRException { + public org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent(); copyElement(src, tgt); - tgt.setContentType(src.getContentType()); - tgt.setLanguage(src.getLanguage()); - tgt.setData(src.getData()); - tgt.setUrl(src.getUrl()); - tgt.setSize(src.getSize()); - tgt.setHash(src.getHash()); - tgt.setTitle(src.getTitle()); - tgt.setCreation(src.getCreation()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) + tgt.addType(convertCodeableConcept(t)); + tgt.setActor(convertReference(src.getActor())); + tgt.setRequired(convertParticipantRequired(src.getRequired())); + tgt.setStatus(convertParticipationStatus(src.getStatus())); return tgt; } - public org.hl7.fhir.instance.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + public org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Attachment tgt = new org.hl7.fhir.instance.model.Attachment(); + org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.instance.model.Appointment.AppointmentParticipantComponent(); copyElement(src, tgt); - tgt.setContentType(src.getContentType()); - tgt.setLanguage(src.getLanguage()); - tgt.setData(src.getData()); - tgt.setUrl(src.getUrl()); - tgt.setSize(src.getSize()); - tgt.setHash(src.getHash()); - tgt.setTitle(src.getTitle()); - tgt.setCreation(src.getCreation()); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) + tgt.addType(convertCodeableConcept(t)); + tgt.setActor(convertReference(src.getActor())); + tgt.setRequired(convertParticipantRequired(src.getRequired())); + tgt.setStatus(convertParticipationStatus(src.getStatus())); + return tgt; + } + + public org.hl7.fhir.r4.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.instance.model.Appointment.ParticipantRequired src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUIRED: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.REQUIRED; + case OPTIONAL: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.OPTIONAL; + case INFORMATIONONLY: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.INFORMATIONONLY; + default: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.NULL; + } + } + + public org.hl7.fhir.instance.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.r4.model.Appointment.ParticipantRequired src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUIRED: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.REQUIRED; + case OPTIONAL: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.OPTIONAL; + case INFORMATIONONLY: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.INFORMATIONONLY; + default: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.NULL; + } + } + + public org.hl7.fhir.r4.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.instance.model.Appointment.ParticipationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACCEPTED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.ACCEPTED; + case DECLINED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.DECLINED; + case TENTATIVE: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.TENTATIVE; + case NEEDSACTION: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NEEDSACTION; + default: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.r4.model.Appointment.ParticipationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACCEPTED: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.ACCEPTED; + case DECLINED: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.DECLINED; + case TENTATIVE: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.TENTATIVE; + case NEEDSACTION: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.NEEDSACTION; + default: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.instance.model.AppointmentResponse src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.AppointmentResponse tgt = new org.hl7.fhir.r4.model.AppointmentResponse(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setAppointment(convertReference(src.getAppointment())); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getParticipantType()) + tgt.addParticipantType(convertCodeableConcept(t)); + tgt.setActor(convertReference(src.getActor())); + tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus())); + tgt.setComment(src.getComment()); + return tgt; + } + + private org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus src) { + if (src == null) + return null; + switch (src) { + case ACCEPTED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; + case DECLINED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.DECLINED; + case TENTATIVE: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.TENTATIVE; + case INPROCESS: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; + case COMPLETED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; + case NEEDSACTION: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NEEDSACTION; + default: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NULL; + } + } + + private org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus src) { + if (src == null) + return null; + switch (src) { + case ACCEPTED: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.ACCEPTED; + case DECLINED: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.DECLINED; + case TENTATIVE: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.TENTATIVE; + case NEEDSACTION: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.NEEDSACTION; + default: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r4.model.AppointmentResponse src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.AppointmentResponse tgt = new org.hl7.fhir.instance.model.AppointmentResponse(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setAppointment(convertReference(src.getAppointment())); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getParticipantType()) + tgt.addParticipantType(convertCodeableConcept(t)); + tgt.setActor(convertReference(src.getActor())); + tgt.setParticipantStatus(convertParticipantStatus(src.getParticipantStatus())); + tgt.setComment(src.getComment()); return tgt; } @@ -734,6 +2380,30 @@ public class VersionConvertor_10_40 { } } + public org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case _0: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._0; + case _4: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._4; + case _8: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._8; + case _12: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._12; + default: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome.NULL; + } + } + + public org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case _0: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._0; + case _4: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._4; + case _8: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._8; + case _12: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._12; + default: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome.NULL; + } + } + public org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.instance.model.AuditEvent.AuditEventParticipantComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -799,90 +2469,6 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setReference(convertReference(src.getReference())); - tgt.setType(convertCoding(src.getType())); - tgt.setRole(convertCoding(src.getRole())); - tgt.setLifecycle(convertCoding(src.getLifecycle())); - for (org.hl7.fhir.instance.model.Coding t : src.getSecurityLabel()) - tgt.addSecurityLabel(convertCoding(t)); - tgt.setName(src.getName()); - tgt.setDescription(src.getDescription()); - tgt.setQuery(src.getQuery()); - for (org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent t : src.getDetail()) - tgt.addDetail(convertAuditEventEntityDetailComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent convertAuditEventEntityComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent tgt = new org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setReference(convertReference(src.getReference())); - tgt.setType(convertCoding(src.getType())); - tgt.setRole(convertCoding(src.getRole())); - tgt.setLifecycle(convertCoding(src.getLifecycle())); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel()) - tgt.addSecurityLabel(convertCoding(t)); - tgt.setName(src.getName()); - tgt.setDescription(src.getDescription()); - tgt.setQuery(src.getQuery()); - for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) - tgt.addDetail(convertAuditEventEntityDetailComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setValue(new Base64BinaryType(src.getValue())); - return tgt; - } - - public org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent tgt = new org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setValue((src.getValueBase64BinaryType().getValue())); - return tgt; - } - - public org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case _0: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._0; - case _4: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._4; - case _8: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._8; - case _12: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._12; - default: return org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome.NULL; - } - } - - public org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome convertAuditEventOutcome(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case _0: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._0; - case _4: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._4; - case _8: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._8; - case _12: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome._12; - default: return org.hl7.fhir.instance.model.AuditEvent.AuditEventOutcome.NULL; - } - } - public org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType convertAuditEventParticipantNetworkType(org.hl7.fhir.instance.model.AuditEvent.AuditEventParticipantNetworkType src) throws FHIRException { if (src == null) return null; @@ -933,15 +2519,63 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.instance.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()); + public org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent(); copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setReference(convertReference(src.getReference())); + tgt.setType(convertCoding(src.getType())); + tgt.setRole(convertCoding(src.getRole())); + tgt.setLifecycle(convertCoding(src.getLifecycle())); + for (org.hl7.fhir.instance.model.Coding t : src.getSecurityLabel()) + tgt.addSecurityLabel(convertCoding(t)); + tgt.setName(src.getName()); + tgt.setDescription(src.getDescription()); + tgt.setQuery(src.getQuery()); + for (org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent t : src.getDetail()) + tgt.addDetail(convertAuditEventEntityDetailComponent(t)); return tgt; } - public org.hl7.fhir.instance.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.instance.model.Base64BinaryType tgt = new org.hl7.fhir.instance.model.Base64BinaryType(src.getValue()); + public org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent convertAuditEventEntityComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent tgt = new org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectComponent(); copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setReference(convertReference(src.getReference())); + tgt.setType(convertCoding(src.getType())); + tgt.setRole(convertCoding(src.getRole())); + tgt.setLifecycle(convertCoding(src.getLifecycle())); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel()) + tgt.addSecurityLabel(convertCoding(t)); + tgt.setName(src.getName()); + tgt.setDescription(src.getDescription()); + tgt.setQuery(src.getQuery()); + for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) + tgt.addDetail(convertAuditEventEntityDetailComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setValue(new Base64BinaryType(src.getValueElement().getValue())); + return tgt; + } + + public org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent tgt = new org.hl7.fhir.instance.model.AuditEvent.AuditEventObjectDetailComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setValue(src.getValueBase64BinaryType().getValue()); return tgt; } @@ -993,42 +2627,6 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.instance.model.Enumerations.BindingStrength src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REQUIRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED; - case EXTENSIBLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE; - case PREFERRED: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED; - case EXAMPLE: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE; - default: return org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL; - } - } - - public org.hl7.fhir.instance.model.Enumerations.BindingStrength convertBindingStrength(org.hl7.fhir.r4.model.Enumerations.BindingStrength src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REQUIRED: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.REQUIRED; - case EXTENSIBLE: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.EXTENSIBLE; - case PREFERRED: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.PREFERRED; - case EXAMPLE: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.EXAMPLE; - default: return org.hl7.fhir.instance.model.Enumerations.BindingStrength.NULL; - } - } - - public org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.instance.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.instance.model.BooleanType tgt = new org.hl7.fhir.instance.model.BooleanType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - public org.hl7.fhir.r4.model.Bundle convertBundle(org.hl7.fhir.instance.model.Bundle src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1062,6 +2660,60 @@ public class VersionConvertor_10_40 { return tgt; } + public org.hl7.fhir.r4.model.Bundle.BundleType convertBundleType(org.hl7.fhir.instance.model.Bundle.BundleType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DOCUMENT: return org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT; + case MESSAGE: return org.hl7.fhir.r4.model.Bundle.BundleType.MESSAGE; + case TRANSACTION: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION; + case TRANSACTIONRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTIONRESPONSE; + case BATCH: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCH; + case BATCHRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCHRESPONSE; + case HISTORY: return org.hl7.fhir.r4.model.Bundle.BundleType.HISTORY; + case SEARCHSET: return org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET; + case COLLECTION: return org.hl7.fhir.r4.model.Bundle.BundleType.COLLECTION; + default: return org.hl7.fhir.r4.model.Bundle.BundleType.NULL; + } + } + + public org.hl7.fhir.instance.model.Bundle.BundleType convertBundleType(org.hl7.fhir.r4.model.Bundle.BundleType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DOCUMENT: return org.hl7.fhir.instance.model.Bundle.BundleType.DOCUMENT; + case MESSAGE: return org.hl7.fhir.instance.model.Bundle.BundleType.MESSAGE; + case TRANSACTION: return org.hl7.fhir.instance.model.Bundle.BundleType.TRANSACTION; + case TRANSACTIONRESPONSE: return org.hl7.fhir.instance.model.Bundle.BundleType.TRANSACTIONRESPONSE; + case BATCH: return org.hl7.fhir.instance.model.Bundle.BundleType.BATCH; + case BATCHRESPONSE: return org.hl7.fhir.instance.model.Bundle.BundleType.BATCHRESPONSE; + case HISTORY: return org.hl7.fhir.instance.model.Bundle.BundleType.HISTORY; + case SEARCHSET: return org.hl7.fhir.instance.model.Bundle.BundleType.SEARCHSET; + case COLLECTION: return org.hl7.fhir.instance.model.Bundle.BundleType.COLLECTION; + default: return org.hl7.fhir.instance.model.Bundle.BundleType.NULL; + } + } + + public org.hl7.fhir.r4.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.instance.model.Bundle.BundleLinkComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleLinkComponent(); + copyElement(src, tgt); + tgt.setRelation(src.getRelation()); + tgt.setUrl(src.getUrl()); + return tgt; + } + + public org.hl7.fhir.instance.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.instance.model.Bundle.BundleLinkComponent(); + copyElement(src, tgt); + tgt.setRelation(src.getRelation()); + tgt.setUrl(src.getUrl()); + return tgt; + } + public org.hl7.fhir.r4.model.Bundle.BundleEntryComponent convertBundleEntryComponent(org.hl7.fhir.instance.model.Bundle.BundleEntryComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1101,6 +2753,48 @@ public class VersionConvertor_10_40 { return tgt; } + public org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent(); + copyElement(src, tgt); + tgt.setMode(convertSearchEntryMode(src.getMode())); + tgt.setScore(src.getScore()); + return tgt; + } + + public org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent(); + copyElement(src, tgt); + tgt.setMode(convertSearchEntryMode(src.getMode())); + tgt.setScore(src.getScore()); + return tgt; + } + + public org.hl7.fhir.r4.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.instance.model.Bundle.SearchEntryMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MATCH: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.MATCH; + case INCLUDE: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.INCLUDE; + case OUTCOME: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.OUTCOME; + default: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.NULL; + } + } + + public org.hl7.fhir.instance.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.r4.model.Bundle.SearchEntryMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MATCH: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.MATCH; + case INCLUDE: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.INCLUDE; + case OUTCOME: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.OUTCOME; + default: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.NULL; + } + } + public org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent convertBundleEntryRequestComponent(org.hl7.fhir.instance.model.Bundle.BundleEntryRequestComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1129,6 +2823,30 @@ public class VersionConvertor_10_40 { return tgt; } + public org.hl7.fhir.r4.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.instance.model.Bundle.HTTPVerb src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case GET: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET; + case POST: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST; + case PUT: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT; + case DELETE: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE; + default: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.NULL; + } + } + + public org.hl7.fhir.instance.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case GET: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.GET; + case POST: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.POST; + case PUT: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.PUT; + case DELETE: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.DELETE; + default: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.NULL; + } + } + public org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent convertBundleEntryResponseComponent(org.hl7.fhir.instance.model.Bundle.BundleEntryResponseComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1153,80 +2871,6 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent(); - copyElement(src, tgt); - tgt.setMode(convertSearchEntryMode(src.getMode())); - tgt.setScore(src.getScore()); - return tgt; - } - - public org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent convertBundleEntrySearchComponent(org.hl7.fhir.r4.model.Bundle.BundleEntrySearchComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent tgt = new org.hl7.fhir.instance.model.Bundle.BundleEntrySearchComponent(); - copyElement(src, tgt); - tgt.setMode(convertSearchEntryMode(src.getMode())); - tgt.setScore(src.getScore()); - return tgt; - } - - public org.hl7.fhir.r4.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.instance.model.Bundle.BundleLinkComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.r4.model.Bundle.BundleLinkComponent(); - copyElement(src, tgt); - tgt.setRelation(src.getRelation()); - tgt.setUrl(src.getUrl()); - return tgt; - } - - public org.hl7.fhir.instance.model.Bundle.BundleLinkComponent convertBundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Bundle.BundleLinkComponent tgt = new org.hl7.fhir.instance.model.Bundle.BundleLinkComponent(); - copyElement(src, tgt); - tgt.setRelation(src.getRelation()); - tgt.setUrl(src.getUrl()); - return tgt; - } - - public org.hl7.fhir.r4.model.Bundle.BundleType convertBundleType(org.hl7.fhir.instance.model.Bundle.BundleType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case DOCUMENT: return org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT; - case MESSAGE: return org.hl7.fhir.r4.model.Bundle.BundleType.MESSAGE; - case TRANSACTION: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION; - case TRANSACTIONRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTIONRESPONSE; - case BATCH: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCH; - case BATCHRESPONSE: return org.hl7.fhir.r4.model.Bundle.BundleType.BATCHRESPONSE; - case HISTORY: return org.hl7.fhir.r4.model.Bundle.BundleType.HISTORY; - case SEARCHSET: return org.hl7.fhir.r4.model.Bundle.BundleType.SEARCHSET; - case COLLECTION: return org.hl7.fhir.r4.model.Bundle.BundleType.COLLECTION; - default: return org.hl7.fhir.r4.model.Bundle.BundleType.NULL; - } - } - - public org.hl7.fhir.instance.model.Bundle.BundleType convertBundleType(org.hl7.fhir.r4.model.Bundle.BundleType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case DOCUMENT: return org.hl7.fhir.instance.model.Bundle.BundleType.DOCUMENT; - case MESSAGE: return org.hl7.fhir.instance.model.Bundle.BundleType.MESSAGE; - case TRANSACTION: return org.hl7.fhir.instance.model.Bundle.BundleType.TRANSACTION; - case TRANSACTIONRESPONSE: return org.hl7.fhir.instance.model.Bundle.BundleType.TRANSACTIONRESPONSE; - case BATCH: return org.hl7.fhir.instance.model.Bundle.BundleType.BATCH; - case BATCHRESPONSE: return org.hl7.fhir.instance.model.Bundle.BundleType.BATCHRESPONSE; - case HISTORY: return org.hl7.fhir.instance.model.Bundle.BundleType.HISTORY; - case SEARCHSET: return org.hl7.fhir.instance.model.Bundle.BundleType.SEARCHSET; - case COLLECTION: return org.hl7.fhir.instance.model.Bundle.BundleType.COLLECTION; - default: return org.hl7.fhir.instance.model.Bundle.BundleType.NULL; - } - } - public org.hl7.fhir.r4.model.CarePlan convertCarePlan(org.hl7.fhir.instance.model.CarePlan src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1293,6 +2937,74 @@ public class VersionConvertor_10_40 { return tgt; } + public org.hl7.fhir.r4.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.instance.model.CarePlan.CarePlanStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PROPOSED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT; + case DRAFT: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT; + case ACTIVE: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ACTIVE; + case COMPLETED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.COMPLETED; + case CANCELLED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.CANCELLED; + default: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { +// case PROPOSED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.PROPOSED; + case DRAFT: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.DRAFT; + case ACTIVE: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.ACTIVE; + case COMPLETED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.COMPLETED; + case CANCELLED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.CANCELLED; + default: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.NULL; + } + } + +// public org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent convertCarePlanRelatedPlanComponent(org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent(); +// copyElement(src, tgt); +// tgt.setCode(convertCarePlanRelationship(src.getCode())); +// tgt.setPlan(convertReference(src.getPlan())); +// return tgt; +// } + +// public org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent convertCarePlanRelatedPlanComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent tgt = new org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent(); +// copyElement(src, tgt); +// tgt.setCode(convertCarePlanRelationship(src.getCode())); +// tgt.setPlan(convertReference(src.getPlan())); +// return tgt; +// } + +// public org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship convertCarePlanRelationship(org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship src) throws FHIRException { +// if (src == null) +// return null; +// switch (src) { +// case INCLUDES: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.INCLUDES; +// case REPLACES: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.REPLACES; +// case FULFILLS: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.FULFILLS; +// default: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.NULL; +// } +// } + +// public org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship convertCarePlanRelationship(org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship src) throws FHIRException { +// if (src == null) +// return null; +// switch (src) { +// case INCLUDES: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.INCLUDES; +// case REPLACES: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.REPLACES; +// case FULFILLS: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.FULFILLS; +// default: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.NULL; +// } +// } + // public org.hl7.fhir.r4.model.CarePlan.CarePlanParticipantComponent convertCarePlanParticipantComponent(org.hl7.fhir.instance.model.CarePlan.CarePlanParticipantComponent src) throws FHIRException { // if (src == null || src.isEmpty()) // return null; @@ -1423,32 +3135,6 @@ public class VersionConvertor_10_40 { } } - public org.hl7.fhir.r4.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.instance.model.CarePlan.CarePlanStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PROPOSED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT; - case DRAFT: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT; - case ACTIVE: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ACTIVE; - case COMPLETED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.COMPLETED; - case CANCELLED: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.CANCELLED; - default: return org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.CarePlan.CarePlanStatus convertCarePlanStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { -// case PROPOSED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.PROPOSED; - case DRAFT: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.DRAFT; - case ACTIVE: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.ACTIVE; - case COMPLETED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.COMPLETED; - case CANCELLED: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.CANCELLED; - default: return org.hl7.fhir.instance.model.CarePlan.CarePlanStatus.NULL; - } - } - public org.hl7.fhir.r4.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.instance.model.ClinicalImpression src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1507,30 +3193,6 @@ public class VersionConvertor_10_40 { return tgt; } - public org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent(); - copyElement(src, tgt); - tgt.setItem(convertCodeableConcept(src.getItem())); -// tgt.setCause(src.getCause()); - return tgt; - } - - public org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent(); - copyElement(src, tgt); - if (src.hasItemCodeableConcept()) - try { - tgt.setItem(convertCodeableConcept(src.getItemCodeableConcept())); - } catch (org.hl7.fhir.exceptions.FHIRException e) { - } -// tgt.setCause(src.getCause()); - return tgt; - } - public org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionStatus convertClinicalImpressionStatus(org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionStatus src) throws FHIRException { if (src == null) return null; @@ -1553,119 +3215,49 @@ public class VersionConvertor_10_40 { } } - public org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.instance.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } +// public org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent convertClinicalImpressionInvestigationsComponent(org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent(); +// copyElement(src, tgt); +// tgt.setCode(convertCodeableConcept(src.getCode())); +// for (org.hl7.fhir.instance.model.Reference t : src.getItem()) +// tgt.addItem(convertReference(t)); +// return tgt; +// } +// +// public org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent convertClinicalImpressionInvestigationsComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent tgt = new org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent(); +// copyElement(src, tgt); +// tgt.setCode(convertCodeableConcept(src.getCode())); +// for (org.hl7.fhir.r4.model.Reference t : src.getItem()) +// tgt.addItem(convertReference(t)); +// return tgt; +// } - public org.hl7.fhir.instance.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.instance.model.CodeType tgt = new org.hl7.fhir.instance.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { + public org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent(); + org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent(); copyElement(src, tgt); - tgt.setSystem(src.getUrl()); - tgt.setVersion(src.getVersion()); - tgt.setCaseSensitive(src.getCaseSensitive()); - - for (ConceptDefinitionComponent cc : src.getConcept()) - tgt.addConcept(convertCodeSystemConcept(src, cc)); + tgt.setItem(convertCodeableConcept(src.getItem())); +// tgt.setCause(src.getCause()); return tgt; } -public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); + org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionFindingComponent(); copyElement(src, tgt); - tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); - tgt.setCode(src.getCode()); - tgt.setDefinition(src.getDefinition()); - tgt.setDisplay(src.getDisplay()); - - for (ConceptDefinitionComponent cc : src.getConcept()) - tgt.addConcept(convertCodeSystemConcept(cs, cc)); - for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) - tgt.addDesignation(convertCodeSystemDesignation(cc)); - return tgt; - } - -public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); - copyElement(src, tgt); - tgt.setUse(convertCoding(src.getUse())); - tgt.setLanguage(src.getLanguage()); - tgt.setValue(src.getValue()); - - return tgt; - } - - public org.hl7.fhir.r4.model.UriType convertCodeToUri(org.hl7.fhir.instance.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.instance.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.Coding t : src.getCoding()) - tgt.addCoding(convertCoding(t)); - tgt.setText(src.getText()); - return tgt; - } - - public org.hl7.fhir.instance.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.CodeableConcept tgt = new org.hl7.fhir.instance.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) - tgt.addCoding(convertCoding(t)); - tgt.setText(src.getText()); - return tgt; - } - - public org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.instance.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); - // todo: set type.. - result.setValue(convertCodeableConcept(t)); - return result; - } - - public org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.instance.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setVersion(src.getVersion()); - tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - tgt.setUserSelected(src.getUserSelected()); - return tgt; - } - - public org.hl7.fhir.instance.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Coding tgt = new org.hl7.fhir.instance.model.Coding(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setVersion(src.getVersion()); - tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - tgt.setUserSelected(src.getUserSelected()); + if (src.hasItemCodeableConcept()) + try { + tgt.setItem(convertCodeableConcept(src.getItemCodeableConcept())); + } catch (org.hl7.fhir.exceptions.FHIRException e) { + } +// tgt.setCause(src.getCause()); return tgt; } @@ -1719,6 +3311,32 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.instance.model.Communication.CommunicationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.COMPLETED; + case SUSPENDED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.SUSPENDED; + case REJECTED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ENTEREDINERROR; + case FAILED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ABORTED; + default: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.r4.model.Communication.CommunicationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.COMPLETED; + case SUSPENDED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.SUSPENDED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.REJECTED; + case ABORTED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.FAILED; + default: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.NULL; + } + } + public org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent convertCommunicationPayloadComponent(org.hl7.fhir.instance.model.Communication.CommunicationPayloadComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1764,6 +3382,20 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + private org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority convertPriorityCode(org.hl7.fhir.instance.model.CodeableConcept priority) { + for (org.hl7.fhir.instance.model.Coding c : priority.getCoding()) { + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "routine".equals(c.getCode())) + return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ROUTINE; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "urgent".equals(c.getCode())) + return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.URGENT; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "stat".equals(c.getCode())) + return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.STAT; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "asap".equals(c.getCode())) + return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ASAP; + } + return null; + } + public org.hl7.fhir.instance.model.CommunicationRequest convertCommunicationRequest(org.hl7.fhir.r4.model.CommunicationRequest src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -1791,22 +3423,16 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; - } - - public org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; + private org.hl7.fhir.instance.model.CodeableConcept convertPriorityCode(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority priority) { + org.hl7.fhir.instance.model.CodeableConcept cc = new org.hl7.fhir.instance.model.CodeableConcept(); + switch (priority) { + case ROUTINE: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("routine"); break; + case URGENT: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("urgent"); break; + case STAT: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("stat"); break; + case ASAP: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("asap"); break; + default: return null; + } + return cc; } public org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestStatus convertCommunicationRequestStatus(org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestStatus src) throws FHIRException { @@ -1845,30 +3471,22 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.instance.model.Communication.CommunicationStatus src) throws FHIRException { - if (src == null) + public org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.COMPLETED; - case SUSPENDED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.SUSPENDED; - case REJECTED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ENTEREDINERROR; - case FAILED: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.ABORTED; - default: return org.hl7.fhir.r4.model.Communication.CommunicationStatus.NULL; - } + org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; } - public org.hl7.fhir.instance.model.Communication.CommunicationStatus convertCommunicationStatus(org.hl7.fhir.r4.model.Communication.CommunicationStatus src) throws FHIRException { - if (src == null) + public org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.COMPLETED; - case SUSPENDED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.SUSPENDED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.REJECTED; - case ABORTED: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.FAILED; - default: return org.hl7.fhir.instance.model.Communication.CommunicationStatus.NULL; - } + org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.instance.model.CommunicationRequest.CommunicationRequestPayloadComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; } public org.hl7.fhir.r4.model.Composition convertComposition(org.hl7.fhir.instance.model.Composition src) throws FHIRException { @@ -1929,27 +3547,27 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.instance.model.Composition.CompositionAttestationMode src) throws FHIRException { + public org.hl7.fhir.r4.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.instance.model.Composition.CompositionStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case PERSONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PERSONAL; - case PROFESSIONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PROFESSIONAL; - case LEGAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.LEGAL; - case OFFICIAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.OFFICIAL; - default: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.NULL; + case PRELIMINARY: return org.hl7.fhir.r4.model.Composition.CompositionStatus.PRELIMINARY; + case FINAL: return org.hl7.fhir.r4.model.Composition.CompositionStatus.FINAL; + case AMENDED: return org.hl7.fhir.r4.model.Composition.CompositionStatus.AMENDED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.Composition.CompositionStatus.ENTEREDINERROR; + default: return org.hl7.fhir.r4.model.Composition.CompositionStatus.NULL; } } - public org.hl7.fhir.instance.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.r4.model.Composition.CompositionAttestationMode src) throws FHIRException { + public org.hl7.fhir.instance.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.r4.model.Composition.CompositionStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case PERSONAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.PERSONAL; - case PROFESSIONAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.PROFESSIONAL; - case LEGAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.LEGAL; - case OFFICIAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.OFFICIAL; - default: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.NULL; + case PRELIMINARY: return org.hl7.fhir.instance.model.Composition.CompositionStatus.PRELIMINARY; + case FINAL: return org.hl7.fhir.instance.model.Composition.CompositionStatus.FINAL; + case AMENDED: return org.hl7.fhir.instance.model.Composition.CompositionStatus.AMENDED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Composition.CompositionStatus.ENTEREDINERROR; + default: return org.hl7.fhir.instance.model.Composition.CompositionStatus.NULL; } } @@ -1977,6 +3595,30 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.instance.model.Composition.CompositionAttestationMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PERSONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PERSONAL; + case PROFESSIONAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.PROFESSIONAL; + case LEGAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.LEGAL; + case OFFICIAL: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.OFFICIAL; + default: return org.hl7.fhir.r4.model.Composition.CompositionAttestationMode.NULL; + } + } + + public org.hl7.fhir.instance.model.Composition.CompositionAttestationMode convertCompositionAttestationMode(org.hl7.fhir.r4.model.Composition.CompositionAttestationMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PERSONAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.PERSONAL; + case PROFESSIONAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.PROFESSIONAL; + case LEGAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.LEGAL; + case OFFICIAL: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.OFFICIAL; + default: return org.hl7.fhir.instance.model.Composition.CompositionAttestationMode.NULL; + } + } + public org.hl7.fhir.r4.model.Composition.CompositionEventComponent convertCompositionEventComponent(org.hl7.fhir.instance.model.Composition.CompositionEventComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2003,48 +3645,59 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.instance.model.Composition.CompositionStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PRELIMINARY: return org.hl7.fhir.r4.model.Composition.CompositionStatus.PRELIMINARY; - case FINAL: return org.hl7.fhir.r4.model.Composition.CompositionStatus.FINAL; - case AMENDED: return org.hl7.fhir.r4.model.Composition.CompositionStatus.AMENDED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.Composition.CompositionStatus.ENTEREDINERROR; - default: return org.hl7.fhir.r4.model.Composition.CompositionStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Composition.CompositionStatus convertCompositionStatus(org.hl7.fhir.r4.model.Composition.CompositionStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PRELIMINARY: return org.hl7.fhir.instance.model.Composition.CompositionStatus.PRELIMINARY; - case FINAL: return org.hl7.fhir.instance.model.Composition.CompositionStatus.FINAL; - case AMENDED: return org.hl7.fhir.instance.model.Composition.CompositionStatus.AMENDED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Composition.CompositionStatus.ENTEREDINERROR; - default: return org.hl7.fhir.instance.model.Composition.CompositionStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.instance.model.Composition.SectionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent(); + org.hl7.fhir.r4.model.Composition.SectionComponent tgt = new org.hl7.fhir.r4.model.Composition.SectionComponent(); copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); + tgt.setTitle(src.getTitle()); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setText(convertNarrative(src.getText())); + try { + tgt.setMode(org.hl7.fhir.r4.model.Composition.SectionMode.fromCode(src.getMode())); + } catch (org.hl7.fhir.exceptions.FHIRException e) { + throw new FHIRException(e); + } + tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); + for (org.hl7.fhir.instance.model.Reference t : src.getEntry()) + tgt.addEntry(convertReference(t)); + tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason())); + for (org.hl7.fhir.instance.model.Composition.SectionComponent t : src.getSection()) + tgt.addSection(convertSectionComponent(t)); return tgt; } - public org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent(); + org.hl7.fhir.instance.model.Composition.SectionComponent tgt = new org.hl7.fhir.instance.model.Composition.SectionComponent(); copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); + tgt.setTitle(src.getTitle()); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setText(convertNarrative(src.getText())); + tgt.setMode(src.getMode().toCode()); + tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); + for (org.hl7.fhir.r4.model.Reference t : src.getEntry()) + tgt.addEntry(convertReference(t)); + tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason())); + for (org.hl7.fhir.r4.model.Composition.SectionComponent t : src.getSection()) + tgt.addSection(convertSectionComponent(t)); return tgt; } + private class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + private String source; + private String target; + private org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; + + } + public org.hl7.fhir.r4.model.ConceptMap convertConceptMap(org.hl7.fhir.instance.model.ConceptMap src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2080,6 +3733,26 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.instance.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); + // todo: set type.. + result.setValue(convertCodeableConcept(t)); + return result; + } + + + private ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) { + for (ConceptMapGroupComponent grp : map.getGroup()) { + if (grp.getSource().equals(srcs) && grp.getTarget().equals(tgts)) + return grp; + } + ConceptMapGroupComponent grp = map.addGroup(); + grp.setSource(srcs); + grp.setTarget(tgts); + return grp; + } + + public org.hl7.fhir.instance.model.ConceptMap convertConceptMap(org.hl7.fhir.r4.model.ConceptMap src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2113,6 +3786,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Enumerations.PublicationStatus convertConformanceResourceStatus(org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DRAFT: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT; + case ACTIVE: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE; + case RETIRED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED; + default: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DRAFT: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.DRAFT; + case ACTIVE: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.ACTIVE; + case RETIRED: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.RETIRED; + default: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.NULL; + } + } + public org.hl7.fhir.r4.model.ContactDetail convertConceptMapContactComponent(org.hl7.fhir.instance.model.ConceptMap.ConceptMapContactComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2135,6 +3830,63 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public List convertSourceElementComponent(org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent src) throws FHIRException { + List res = new ArrayList(); + if (src == null || src.isEmpty()) + return res; + for (org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent t : src.getTarget()) { + org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + tgt.addTarget(convertTargetElementComponent(t)); + res.add(new SourceElementComponentWrapper(tgt, src.getCodeSystem(), t.getCodeSystem())); + } + return res; + } + + public org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent src, org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent(); + copyElement(src, tgt); + tgt.setCodeSystem(g.getSource()); + tgt.setCode(src.getCode()); + for (org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent t : src.getTarget()) + tgt.addTarget(convertTargetElementComponent(t, g)); + return tgt; + } + + public org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence())); + tgt.setComment(src.getComments()); + for (org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) + tgt.addDependsOn(convertOtherElementComponent(t)); + for (org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent t : src.getProduct()) + tgt.addProduct(convertOtherElementComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent src, org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent(); + copyElement(src, tgt); + tgt.setCodeSystem(g.getTarget()); + tgt.setCode(src.getCode()); + tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence())); + tgt.setComments(src.getComment()); + for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) + tgt.addDependsOn(convertOtherElementComponent(t)); + for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getProduct()) + tgt.addProduct(convertOtherElementComponent(t)); + return tgt; + } + public org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence convertConceptMapEquivalence(org.hl7.fhir.instance.model.Enumerations.ConceptMapEquivalence src) throws FHIRException { if (src == null) return null; @@ -2169,99 +3921,25 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent(); + org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent(); copyElement(src, tgt); + tgt.setProperty(src.getElement()); + tgt.setSystem(src.getCodeSystem()); tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent t : src.getDesignation()) - tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); return tgt; } - public org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent(); + org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent(); copyElement(src, tgt); + tgt.setElement(src.getProperty()); + tgt.setCodeSystem(src.getSystem()); tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation()) - tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent(); - copyElement(src, tgt); - tgt.setLanguage(src.getLanguage()); - tgt.setUse(convertCoding(src.getUse())); - tgt.setValue(src.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); - copyElement(src, tgt); - tgt.setLanguage(src.getLanguage()); - tgt.setUse(convertCoding(src.getUse())); - tgt.setValue(src.getValue()); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setVersion(src.getVersion()); - for (org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) - tgt.addConcept(convertConceptReferenceComponent(t)); - for (org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) - tgt.addFilter(convertConceptSetFilterComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setVersion(src.getVersion()); - for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) - tgt.addConcept(convertConceptReferenceComponent(t)); - for (org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) - tgt.addFilter(convertConceptSetFilterComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent(); - copyElement(src, tgt); - tgt.setProperty(src.getProperty()); - tgt.setOp(convertFilterOperator(src.getOp())); - tgt.setValue(src.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent(); - copyElement(src, tgt); - tgt.setProperty(src.getProperty()); - tgt.setOp(convertFilterOperator(src.getOp())); - tgt.setValue(src.getValue()); return tgt; } @@ -2326,51 +4004,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent(); - copyElement(src, tgt); - tgt.addCode(convertCodeableConcept(src.getCode())); - for (org.hl7.fhir.instance.model.Reference t : src.getDetail()) - tgt.addDetail(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.CodeableConcept cc : src.getCode()) - tgt.setCode(convertCodeableConcept(cc)); - for (org.hl7.fhir.r4.model.Reference t : src.getDetail()) - tgt.addDetail(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.instance.model.Condition.ConditionStageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionStageComponent(); - copyElement(src, tgt); - tgt.setSummary(convertCodeableConcept(src.getSummary())); - for (org.hl7.fhir.instance.model.Reference t : src.getAssessment()) - tgt.addAssessment(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.instance.model.Condition.ConditionStageComponent(); - copyElement(src, tgt); - tgt.setSummary(convertCodeableConcept(src.getSummary())); - for (org.hl7.fhir.r4.model.Reference t : src.getAssessment()) - tgt.addAssessment(convertReference(t)); - return tgt; - } - public org.hl7.fhir.r4.model.Condition.ConditionVerificationStatus convertConditionVerificationStatus(org.hl7.fhir.instance.model.Condition.ConditionVerificationStatus src) throws FHIRException { if (src == null) return null; @@ -2399,26 +4032,49 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus src) throws FHIRException { - if (src == null) + public org.hl7.fhir.r4.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.instance.model.Condition.ConditionStageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; - switch (src) { - case NOTSUPPORTED: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NOTSUPPORTED; - case SINGLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.SINGLE; - case MULTIPLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.MULTIPLE; - default: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NULL; - } + org.hl7.fhir.r4.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionStageComponent(); + copyElement(src, tgt); + tgt.setSummary(convertCodeableConcept(src.getSummary())); + for (org.hl7.fhir.instance.model.Reference t : src.getAssessment()) + tgt.addAssessment(convertReference(t)); + return tgt; } - public org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus src) throws FHIRException { - if (src == null) + public org.hl7.fhir.instance.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; - switch (src) { - case NOTSUPPORTED: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.NOTSUPPORTED; - case SINGLE: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.SINGLE; - case MULTIPLE: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.MULTIPLE; - default: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.NULL; - } + org.hl7.fhir.instance.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.instance.model.Condition.ConditionStageComponent(); + copyElement(src, tgt); + tgt.setSummary(convertCodeableConcept(src.getSummary())); + for (org.hl7.fhir.r4.model.Reference t : src.getAssessment()) + tgt.addAssessment(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent(); + copyElement(src, tgt); + tgt.addCode(convertCodeableConcept(src.getCode())); + for (org.hl7.fhir.instance.model.Reference t : src.getDetail()) + tgt.addDetail(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.instance.model.Condition.ConditionEvidenceComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.CodeableConcept cc : src.getCode()) + tgt.setCode(convertCodeableConcept(cc)); + for (org.hl7.fhir.r4.model.Reference t : src.getDetail()) + tgt.addDetail(convertReference(t)); + return tgt; } public org.hl7.fhir.r4.model.CapabilityStatement convertConformance(org.hl7.fhir.instance.model.Conformance src) throws FHIRException { @@ -2496,6 +4152,52 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind convertConformanceStatementKind(org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.INSTANCE; + case CAPABILITY: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.CAPABILITY; + case REQUIREMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.REQUIREMENTS; + default: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind convertConformanceStatementKind(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INSTANCE: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.INSTANCE; + case CAPABILITY: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.CAPABILITY; + case REQUIREMENTS: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.REQUIREMENTS; + default: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.NULL; + } + } + + public org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.instance.model.Conformance.UnknownContentCode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NO: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NO; + case EXTENSIONS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.EXTENSIONS; + case ELEMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.ELEMENTS; + case BOTH: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.BOTH; + default: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NO: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.NO; + case EXTENSIONS: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.EXTENSIONS; + case ELEMENTS: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.ELEMENTS; + case BOTH: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.BOTH; + default: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.NULL; + } + } + public org.hl7.fhir.r4.model.ContactDetail convertConformanceContactComponent(org.hl7.fhir.instance.model.Conformance.ConformanceContactComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2518,48 +4220,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent(); + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent(); copyElement(src, tgt); - tgt.setMode(convertDocumentMode(src.getMode())); - tgt.setDocumentation(src.getDocumentation()); - tgt.setProfile(convertReference(src.getProfile())); + tgt.setName(src.getName()); + tgt.setVersion(src.getVersion()); + tgt.setReleaseDate(src.getReleaseDate()); return tgt; } - public org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent(); + org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent(); copyElement(src, tgt); - tgt.setMode(convertDocumentMode(src.getMode())); - tgt.setDocumentation(src.getDocumentation()); - tgt.setProfile(convertReference(src.getProfile())); + tgt.setName(src.getName()); + tgt.setVersion(src.getVersion()); + tgt.setReleaseDate(src.getReleaseDate()); return tgt; } - public org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode convertConformanceEventMode(org.hl7.fhir.instance.model.Conformance.ConformanceEventMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case SENDER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER; - case RECEIVER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER; - default: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.ConformanceEventMode convertConformanceEventMode(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case SENDER: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.SENDER; - case RECEIVER: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.RECEIVER; - default: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.NULL; - } - } - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent convertConformanceImplementationComponent(org.hl7.fhir.instance.model.Conformance.ConformanceImplementationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2580,6 +4262,362 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent convertConformanceRestComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent(); + copyElement(src, tgt); + tgt.setMode(convertRestfulConformanceMode(src.getMode())); + tgt.setDocumentation(src.getDocumentation()); + tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity())); + for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent t : src.getResource()) + tgt.addResource(convertConformanceRestResourceComponent(t)); + for (org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent t : src.getInteraction()) + tgt.addInteraction(convertSystemInteractionComponent(t)); + if (src.getTransactionMode() == org.hl7.fhir.instance.model.Conformance.TransactionMode.BATCH || src.getTransactionMode() == org.hl7.fhir.instance.model.Conformance.TransactionMode.BOTH) + tgt.addInteraction().setCode(SystemRestfulInteraction.BATCH); + for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam()) + tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); + for (org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent t : src.getOperation()) + tgt.addOperation(convertConformanceRestOperationComponent(t)); + for (org.hl7.fhir.instance.model.UriType t : src.getCompartment()) + tgt.addCompartment(t.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent convertConformanceRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent(); + copyElement(src, tgt); + tgt.setMode(convertRestfulConformanceMode(src.getMode())); + tgt.setDocumentation(src.getDocumentation()); + tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity())); + for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent t : src.getResource()) + tgt.addResource(convertConformanceRestResourceComponent(t)); + boolean batch = false; + boolean transaction = false; + for (org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent t : src.getInteraction()) { + if (t.getCode().equals(SystemRestfulInteraction.BATCH)) + batch = true; + else + tgt.addInteraction(convertSystemInteractionComponent(t)); + if (t.getCode().equals(SystemRestfulInteraction.TRANSACTION)) + transaction = true; + } + if (batch) + tgt.setTransactionMode(transaction ? org.hl7.fhir.instance.model.Conformance.TransactionMode.BOTH : org.hl7.fhir.instance.model.Conformance.TransactionMode.BATCH); + else + tgt.setTransactionMode(transaction ? org.hl7.fhir.instance.model.Conformance.TransactionMode.TRANSACTION : org.hl7.fhir.instance.model.Conformance.TransactionMode.NOTSUPPORTED); + for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam()) + tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); + for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent t : src.getOperation()) + tgt.addOperation(convertConformanceRestOperationComponent(t)); + for (org.hl7.fhir.r4.model.UriType t : src.getCompartment()) + tgt.addCompartment(t.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode convertRestfulConformanceMode(org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CLIENT: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.CLIENT; + case SERVER: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.SERVER; + default: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode convertRestfulConformanceMode(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CLIENT: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.CLIENT; + case SERVER: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.SERVER; + default: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.NULL; + } + } + + + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent(); + copyElement(src, tgt); + tgt.setCors(src.getCors()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getService()) + tgt.addService(convertCodeableConcept(t)); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent t : src.getCertificate()) + tgt.addCertificate(convertConformanceRestSecurityCertificateComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent(); + copyElement(src, tgt); + tgt.setCors(src.getCors()); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getService()) + tgt.addService(convertCodeableConcept(t)); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent t : src.getCertificate()) + tgt.addCertificate(convertConformanceRestSecurityCertificateComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent convertConformanceRestSecurityCertificateComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setBlob(src.getBlob()); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent convertConformanceRestSecurityCertificateComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setBlob(src.getBlob()); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setProfile(convertReference(src.getProfile())); + for (org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent t : src.getInteraction()) + tgt.addInteraction(convertResourceInteractionComponent(t)); + tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning())); + tgt.setReadHistory(src.getReadHistory()); + tgt.setUpdateCreate(src.getUpdateCreate()); + tgt.setConditionalCreate(src.getConditionalCreate()); + tgt.setConditionalUpdate(src.getConditionalUpdate()); + tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete())); + for (org.hl7.fhir.instance.model.StringType t : src.getSearchInclude()) + tgt.addSearchInclude(t.getValue()); + for (org.hl7.fhir.instance.model.StringType t : src.getSearchRevInclude()) + tgt.addSearchRevInclude(t.getValue()); + for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam()) + tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + if (src.hasProfile()) + tgt.setProfile(convertReference(src.getProfile())); + for (org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction()) + tgt.addInteraction(convertResourceInteractionComponent(t)); + tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning())); + tgt.setReadHistory(src.getReadHistory()); + tgt.setUpdateCreate(src.getUpdateCreate()); + tgt.setConditionalCreate(src.getConditionalCreate()); + tgt.setConditionalUpdate(src.getConditionalUpdate()); + tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete())); + for (org.hl7.fhir.r4.model.StringType t : src.getSearchInclude()) + tgt.addSearchInclude(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getSearchRevInclude()) + tgt.addSearchRevInclude(t.getValue()); + for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam()) + tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOVERSION: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NOVERSION; + case VERSIONED: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONED; + case VERSIONEDUPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONEDUPDATE; + default: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOVERSION: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.NOVERSION; + case VERSIONED: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.VERSIONED; + case VERSIONEDUPDATE: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.VERSIONEDUPDATE; + default: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.NULL; + } + } + + public org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOTSUPPORTED: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NOTSUPPORTED; + case SINGLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.SINGLE; + case MULTIPLE: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.MULTIPLE; + default: return org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus convertConditionalDeleteStatus(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOTSUPPORTED: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.NOTSUPPORTED; + case SINGLE: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.SINGLE; + case MULTIPLE: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.MULTIPLE; + default: return org.hl7.fhir.instance.model.Conformance.ConditionalDeleteStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent(); + copyElement(src, tgt); + tgt.setCode(convertTypeRestfulInteraction(src.getCode())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent tgt = new org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent(); + copyElement(src, tgt); + tgt.setCode(convertTypeRestfulInteraction(src.getCode())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case READ: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.READ; + case VREAD: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.VREAD; + case UPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.UPDATE; + case DELETE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.DELETE; + case HISTORYINSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYINSTANCE; + case HISTORYTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYTYPE; + case CREATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.CREATE; + case SEARCHTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.SEARCHTYPE; + default: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case READ: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.READ; + case VREAD: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.VREAD; + case UPDATE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.UPDATE; + case DELETE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.DELETE; + case HISTORYINSTANCE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.HISTORYINSTANCE; + case HISTORYTYPE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.HISTORYTYPE; + case CREATE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.CREATE; + case SEARCHTYPE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.SEARCHTYPE; + default: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.NULL; + } + } + + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDefinition(src.getDefinition()); + tgt.setType(convertSearchParamType(src.getType())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDefinition(src.getDefinition()); + tgt.setType(convertSearchParamType(src.getType())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent(); + copyElement(src, tgt); + tgt.setCode(convertSystemRestfulInteraction(src.getCode())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent tgt = new org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent(); + copyElement(src, tgt); + tgt.setCode(convertSystemRestfulInteraction(src.getCode())); + tgt.setDocumentation(src.getDocumentation()); + return tgt; + } + + public org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case TRANSACTION: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.TRANSACTION; + case SEARCHSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.SEARCHSYSTEM; + case HISTORYSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.HISTORYSYSTEM; + default: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.NULL; + } + } + + public org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case TRANSACTION: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.TRANSACTION; + case SEARCHSYSTEM: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.SEARCHSYSTEM; + case HISTORYSYSTEM: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.HISTORYSYSTEM; + default: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.NULL; + } + } + + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDefinition(convertReference(src.getDefinition())); + return tgt; + } + + public org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDefinition(convertReference(src.getDefinition())); + return tgt; + } + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent convertConformanceMessagingComponent(org.hl7.fhir.instance.model.Conformance.ConformanceMessagingComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -2658,422 +4696,87 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Enumerations.PublicationStatus convertConformanceResourceStatus(org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus src) throws FHIRException { + public org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory src) throws FHIRException { if (src == null) return null; switch (src) { - case DRAFT: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT; - case ACTIVE: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE; - case RETIRED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED; - default: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL; + case CONSEQUENCE: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CONSEQUENCE; + case CURRENCY: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CURRENCY; + case NOTIFICATION: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NOTIFICATION; + default: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NULL; } } - public org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus src) throws FHIRException { + public org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory src) throws FHIRException { if (src == null) return null; switch (src) { - case DRAFT: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.DRAFT; - case ACTIVE: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.ACTIVE; - case RETIRED: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.RETIRED; - default: return org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus.NULL; + case CONSEQUENCE: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.CONSEQUENCE; + case CURRENCY: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.CURRENCY; + case NOTIFICATION: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.NOTIFICATION; + default: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.NULL; } } - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent convertConformanceRestComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode convertConformanceEventMode(org.hl7.fhir.instance.model.Conformance.ConformanceEventMode src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent(); - copyElement(src, tgt); - tgt.setMode(convertRestfulConformanceMode(src.getMode())); - tgt.setDocumentation(src.getDocumentation()); - tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity())); - for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent t : src.getResource()) - tgt.addResource(convertConformanceRestResourceComponent(t)); - for (org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent t : src.getInteraction()) - tgt.addInteraction(convertSystemInteractionComponent(t)); - if (src.getTransactionMode() == org.hl7.fhir.instance.model.Conformance.TransactionMode.BATCH || src.getTransactionMode() == org.hl7.fhir.instance.model.Conformance.TransactionMode.BOTH) - tgt.addInteraction().setCode(SystemRestfulInteraction.BATCH); - for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam()) - tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); - for (org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent t : src.getOperation()) - tgt.addOperation(convertConformanceRestOperationComponent(t)); - for (org.hl7.fhir.instance.model.UriType t : src.getCompartment()) - tgt.addCompartment(t.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent convertConformanceRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent(); - copyElement(src, tgt); - tgt.setMode(convertRestfulConformanceMode(src.getMode())); - tgt.setDocumentation(src.getDocumentation()); - tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity())); - for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent t : src.getResource()) - tgt.addResource(convertConformanceRestResourceComponent(t)); - boolean batch = false; - boolean transaction = false; - for (org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent t : src.getInteraction()) { - if (t.getCode().equals(SystemRestfulInteraction.BATCH)) - batch = true; - else - tgt.addInteraction(convertSystemInteractionComponent(t)); - if (t.getCode().equals(SystemRestfulInteraction.TRANSACTION)) - transaction = true; + switch (src) { + case SENDER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER; + case RECEIVER: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER; + default: return org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL; } - if (batch) - tgt.setTransactionMode(transaction ? org.hl7.fhir.instance.model.Conformance.TransactionMode.BOTH : org.hl7.fhir.instance.model.Conformance.TransactionMode.BATCH); - else - tgt.setTransactionMode(transaction ? org.hl7.fhir.instance.model.Conformance.TransactionMode.TRANSACTION : org.hl7.fhir.instance.model.Conformance.TransactionMode.NOTSUPPORTED); - for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam()) - tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); - for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent t : src.getOperation()) - tgt.addOperation(convertConformanceRestOperationComponent(t)); - for (org.hl7.fhir.r4.model.UriType t : src.getCompartment()) - tgt.addCompartment(t.getValue()); - return tgt; } - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.instance.model.Conformance.ConformanceEventMode convertConformanceEventMode(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDefinition(convertReference(src.getDefinition())); - return tgt; + switch (src) { + case SENDER: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.SENDER; + case RECEIVER: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.RECEIVER; + default: return org.hl7.fhir.instance.model.Conformance.ConformanceEventMode.NULL; + } } - public org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestOperationComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestOperationComponent(); + org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent(); copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDefinition(convertReference(src.getDefinition())); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); + tgt.setMode(convertDocumentMode(src.getMode())); + tgt.setDocumentation(src.getDocumentation()); tgt.setProfile(convertReference(src.getProfile())); - for (org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent t : src.getInteraction()) - tgt.addInteraction(convertResourceInteractionComponent(t)); - tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning())); - tgt.setReadHistory(src.getReadHistory()); - tgt.setUpdateCreate(src.getUpdateCreate()); - tgt.setConditionalCreate(src.getConditionalCreate()); - tgt.setConditionalUpdate(src.getConditionalUpdate()); - tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete())); - for (org.hl7.fhir.instance.model.StringType t : src.getSearchInclude()) - tgt.addSearchInclude(t.getValue()); - for (org.hl7.fhir.instance.model.StringType t : src.getSearchRevInclude()) - tgt.addSearchRevInclude(t.getValue()); - for (org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam()) - tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); return tgt; } - public org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent(); + org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceDocumentComponent(); copyElement(src, tgt); - tgt.setType(src.getType()); - if (src.hasProfile()) - tgt.setProfile(convertReference(src.getProfile())); - for (org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction()) - tgt.addInteraction(convertResourceInteractionComponent(t)); - tgt.setVersioning(convertResourceVersionPolicy(src.getVersioning())); - tgt.setReadHistory(src.getReadHistory()); - tgt.setUpdateCreate(src.getUpdateCreate()); - tgt.setConditionalCreate(src.getConditionalCreate()); - tgt.setConditionalUpdate(src.getConditionalUpdate()); - tgt.setConditionalDelete(convertConditionalDeleteStatus(src.getConditionalDelete())); - for (org.hl7.fhir.r4.model.StringType t : src.getSearchInclude()) - tgt.addSearchInclude(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getSearchRevInclude()) - tgt.addSearchRevInclude(t.getValue()); - for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam()) - tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDefinition(src.getDefinition()); - tgt.setType(convertSearchParamType(src.getType())); + tgt.setMode(convertDocumentMode(src.getMode())); tgt.setDocumentation(src.getDocumentation()); + tgt.setProfile(convertReference(src.getProfile())); return tgt; } - public org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDefinition(src.getDefinition()); - tgt.setType(convertSearchParamType(src.getType())); - tgt.setDocumentation(src.getDocumentation()); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent convertConformanceRestSecurityCertificateComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setBlob(src.getBlob()); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent convertConformanceRestSecurityCertificateComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setBlob(src.getBlob()); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent(); - copyElement(src, tgt); - tgt.setCors(src.getCors()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getService()) - tgt.addService(convertCodeableConcept(t)); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityCertificateComponent t : src.getCertificate()) - tgt.addCertificate(convertConformanceRestSecurityCertificateComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceRestSecurityComponent(); - copyElement(src, tgt); - tgt.setCors(src.getCors()); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getService()) - tgt.addService(convertCodeableConcept(t)); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityCertificateComponent t : src.getCertificate()) - tgt.addCertificate(convertConformanceRestSecurityCertificateComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setVersion(src.getVersion()); - tgt.setReleaseDate(src.getReleaseDate()); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent tgt = new org.hl7.fhir.instance.model.Conformance.ConformanceSoftwareComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setVersion(src.getVersion()); - tgt.setReleaseDate(src.getReleaseDate()); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind convertConformanceStatementKind(org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind src) throws FHIRException { + public org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode convertDocumentMode(org.hl7.fhir.instance.model.Conformance.DocumentMode src) throws FHIRException { if (src == null) return null; switch (src) { - case INSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.INSTANCE; - case CAPABILITY: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.CAPABILITY; - case REQUIREMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.REQUIREMENTS; - default: return org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.NULL; + case PRODUCER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.PRODUCER; + case CONSUMER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.CONSUMER; + default: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.NULL; } } - public org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind convertConformanceStatementKind(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind src) throws FHIRException { + public org.hl7.fhir.instance.model.Conformance.DocumentMode convertDocumentMode(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode src) throws FHIRException { if (src == null) return null; switch (src) { - case INSTANCE: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.INSTANCE; - case CAPABILITY: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.CAPABILITY; - case REQUIREMENTS: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.REQUIREMENTS; - default: return org.hl7.fhir.instance.model.Conformance.ConformanceStatementKind.NULL; - } - } - - public org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ERROR: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR; - case WARNING: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING; - default: return org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL; - } - } - - public org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity convertConstraintSeverity(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ERROR: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.ERROR; - case WARNING: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.WARNING; - default: return org.hl7.fhir.instance.model.ElementDefinition.ConstraintSeverity.NULL; - } - } - - public org.hl7.fhir.r4.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.instance.model.Patient.ContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Patient.ContactComponent tgt = new org.hl7.fhir.r4.model.Patient.ContactComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRelationship()) - tgt.addRelationship(convertCodeableConcept(t)); - tgt.setName(convertHumanName(src.getName())); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - tgt.setAddress(convertAddress(src.getAddress())); - tgt.setGender(convertAdministrativeGender(src.getGender())); - tgt.setOrganization(convertReference(src.getOrganization())); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r4.model.Patient.ContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Patient.ContactComponent tgt = new org.hl7.fhir.instance.model.Patient.ContactComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRelationship()) - tgt.addRelationship(convertCodeableConcept(t)); - tgt.setName(convertHumanName(src.getName())); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - tgt.setAddress(convertAddress(src.getAddress())); - tgt.setGender(convertAdministrativeGender(src.getGender())); - tgt.setOrganization(convertReference(src.getOrganization())); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.instance.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); - copyElement(src, tgt); - tgt.setSystem(convertContactPointSystem(src.getSystem())); - tgt.setValue(src.getValue()); - tgt.setUse(convertContactPointUse(src.getUse())); - if (src.hasRank()) - tgt.setRank(src.getRank()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ContactPoint tgt = new org.hl7.fhir.instance.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystem(convertContactPointSystem(src.getSystem())); - tgt.setValue(src.getValue()); - tgt.setUse(convertContactPointUse(src.getUse())); - tgt.setRank(src.getRank()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PHONE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE; - case FAX: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX; - case EMAIL: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL; - case PAGER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER; - case OTHER: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER; - default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL; - } - } - - public org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem convertContactPointSystem(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PHONE: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.PHONE; - case FAX: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.FAX; - case EMAIL: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.EMAIL; - case PAGER: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.PAGER; - case OTHER: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.OTHER; - case URL: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.OTHER; - default: return org.hl7.fhir.instance.model.ContactPoint.ContactPointSystem.NULL; - } - } - - public org.hl7.fhir.r4.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.instance.model.ContactPoint.ContactPointUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HOME: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME; - case WORK: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK; - case TEMP: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP; - case OLD: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD; - case MOBILE: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE; - default: return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL; - } - } - - public org.hl7.fhir.instance.model.ContactPoint.ContactPointUse convertContactPointUse(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HOME: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.HOME; - case WORK: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.WORK; - case TEMP: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.TEMP; - case OLD: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.OLD; - case MOBILE: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.MOBILE; - default: return org.hl7.fhir.instance.model.ContactPoint.ContactPointUse.NULL; - } - } - - public org.hl7.fhir.r4.model.TestScript.ContentType convertContentType(org.hl7.fhir.instance.model.TestScript.ContentType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case XML: return org.hl7.fhir.r4.model.TestScript.ContentType.XML; - case JSON: return org.hl7.fhir.r4.model.TestScript.ContentType.JSON; - default: return org.hl7.fhir.r4.model.TestScript.ContentType.NULL; - } - } - - public org.hl7.fhir.instance.model.TestScript.ContentType convertContentType(org.hl7.fhir.r4.model.TestScript.ContentType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case XML: return org.hl7.fhir.instance.model.TestScript.ContentType.XML; - case JSON: return org.hl7.fhir.instance.model.TestScript.ContentType.JSON; - default: return org.hl7.fhir.instance.model.TestScript.ContentType.NULL; + case PRODUCER: return org.hl7.fhir.instance.model.Conformance.DocumentMode.PRODUCER; + case CONSUMER: return org.hl7.fhir.instance.model.Conformance.DocumentMode.CONSUMER; + default: return org.hl7.fhir.instance.model.Conformance.DocumentMode.NULL; } } @@ -3137,32 +4840,235 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.instance.model.Count src) throws FHIRException { + public org.hl7.fhir.r4.model.Contract.AgentComponent convertAgentComponent(org.hl7.fhir.instance.model.Contract.ActorComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent(); copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); + tgt.setActor(convertReference(src.getEntity())); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRole()) + tgt.addRole(convertCodeableConcept(t)); return tgt; } - public org.hl7.fhir.instance.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + public org.hl7.fhir.instance.model.Contract.ActorComponent convertAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Count tgt = new org.hl7.fhir.instance.model.Count(); + org.hl7.fhir.instance.model.Contract.ActorComponent tgt = new org.hl7.fhir.instance.model.Contract.ActorComponent(); copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); + tgt.setEntity(convertReference(src.getActor())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) + tgt.addRole(convertCodeableConcept(t)); return tgt; } + public org.hl7.fhir.r4.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.instance.model.Contract.SignatoryComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.r4.model.Contract.SignatoryComponent(); + copyElement(src, tgt); + tgt.setType(convertCoding(src.getType())); + tgt.setParty(convertReference(src.getParty())); + if (src.hasSignature()) + tgt.addSignature(new org.hl7.fhir.r4.model.Signature().setBlob(src.getSignature().getBytes())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.r4.model.Contract.SignatoryComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.instance.model.Contract.SignatoryComponent(); + copyElement(src, tgt); + tgt.setType(convertCoding(src.getType())); + tgt.setParty(convertReference(src.getParty())); + for (org.hl7.fhir.r4.model.Signature t : src.getSignature()) + tgt.setSignature(Base64.encodeBase64String(t.getBlob())); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.instance.model.Contract.ValuedItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent(); + copyElement(src, tgt); + tgt.setEntity(convertType(src.getEntity())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setEffectiveTime(src.getEffectiveTime()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setUnitPrice(convertMoney(src.getUnitPrice())); + tgt.setFactor(src.getFactor()); + tgt.setPoints(src.getPoints()); + tgt.setNet(convertMoney(src.getNet())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.instance.model.Contract.ValuedItemComponent(); + copyElement(src, tgt); + tgt.setEntity(convertType(src.getEntity())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setEffectiveTime(src.getEffectiveTime()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setUnitPrice(convertMoney(src.getUnitPrice())); + tgt.setFactor(src.getFactor()); + tgt.setPoints(src.getPoints()); + tgt.setNet(convertMoney(src.getNet())); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.instance.model.Contract.TermComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.TermComponent tgt = new org.hl7.fhir.r4.model.Contract.TermComponent(); + copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setIssued(src.getIssued()); + tgt.setApplies(convertPeriod(src.getApplies())); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setSubType(convertCodeableConcept(src.getSubType())); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getAction()) + tgt.addAction(convertCodeableConcept(t)); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getActionReason()) + tgt.addActionReason(convertCodeableConcept(t)); + for (org.hl7.fhir.instance.model.Contract.TermActorComponent t : src.getActor()) + tgt.addAgent(convertTermAgentComponent(t)); + for (org.hl7.fhir.instance.model.Contract.TermComponent t : src.getGroup()) + tgt.addGroup(convertTermComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.r4.model.Contract.TermComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.TermComponent tgt = new org.hl7.fhir.instance.model.Contract.TermComponent(); + copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setIssued(src.getIssued()); + tgt.setApplies(convertPeriod(src.getApplies())); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setSubType(convertCodeableConcept(src.getSubType())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction()) + tgt.addAction(convertCodeableConcept(t)); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getActionReason()) + tgt.addActionReason(convertCodeableConcept(t)); + for (org.hl7.fhir.r4.model.Contract.AgentComponent t : src.getAgent()) + tgt.addActor(convertTermAgentComponent(t)); + for (org.hl7.fhir.r4.model.Contract.TermComponent t : src.getGroup()) + tgt.addGroup(convertTermComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.AgentComponent convertTermAgentComponent(org.hl7.fhir.instance.model.Contract.TermActorComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent(); + copyElement(src, tgt); + tgt.setActor(convertReference(src.getEntity())); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRole()) + tgt.addRole(convertCodeableConcept(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.TermActorComponent convertTermAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.TermActorComponent tgt = new org.hl7.fhir.instance.model.Contract.TermActorComponent(); + copyElement(src, tgt); + tgt.setEntity(convertReference(src.getActor())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) + tgt.addRole(convertCodeableConcept(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.instance.model.Contract.TermValuedItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent(); + copyElement(src, tgt); + tgt.setEntity(convertType(src.getEntity())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setEffectiveTime(src.getEffectiveTime()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setUnitPrice(convertMoney(src.getUnitPrice())); + tgt.setFactor(src.getFactor()); + tgt.setPoints(src.getPoints()); + tgt.setNet(convertMoney(src.getNet())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.TermValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.TermValuedItemComponent tgt = new org.hl7.fhir.instance.model.Contract.TermValuedItemComponent(); + copyElement(src, tgt); + tgt.setEntity(convertType(src.getEntity())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setEffectiveTime(src.getEffectiveTime()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setUnitPrice(convertMoney(src.getUnitPrice())); + tgt.setFactor(src.getFactor()); + tgt.setPoints(src.getPoints()); + tgt.setNet(convertMoney(src.getNet())); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.instance.model.Contract.LegalLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.LegalLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.r4.model.Contract.LegalLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.LegalLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent convertComputableLanguageComponent(org.hl7.fhir.r4.model.Contract.ComputableLanguageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.ComputableLanguageComponent(); + copyElement(src, tgt); + tgt.setContent(convertType(src.getContent())); + return tgt; + } + + public org.hl7.fhir.r4.model.StructureDefinition convertDataElement(org.hl7.fhir.instance.model.DataElement src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3195,7 +5101,7 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen for (org.hl7.fhir.instance.model.ElementDefinition t : src.getElement()) { if (t.hasSlicing()) slicePaths.add(t.getPath()); - tgt.getSnapshot().addElement(convertElementDefinition(t, slicePaths)); + tgt.getSnapshot().addElement(convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t))); } tgt.setKind(StructureDefinitionKind.LOGICAL); tgt.setAbstract(false); @@ -3205,6 +5111,66 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } +// public org.hl7.fhir.instance.model.DataElement convertDataElement(org.hl7.fhir.r4.model.DataElement src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.instance.model.DataElement tgt = new org.hl7.fhir.instance.model.DataElement(); +// copyDomainResource(src, tgt); +// tgt.setUrl(src.getUrl()); +// for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) +// tgt.addIdentifier(convertIdentifier(t)); +// tgt.setVersion(src.getVersion()); +// tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); +// if (src.hasExperimental()) +// tgt.setExperimental(src.getExperimental()); +// tgt.setPublisher(src.getPublisher()); +// if (src.hasDate()) +// tgt.setDate(src.getDate()); +// tgt.setName(src.getName()); +// for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) +// tgt.addContact(convertDataElementContactComponent(t)); +// for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) +// if (t.hasValueCodeableConcept()) +// tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); +// for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) +// tgt.addUseContext(convertCodeableConcept(t)); +// tgt.setCopyright(src.getCopyright()); +// tgt.setStringency(convertDataElementStringency(src.getStringency())); +// for (org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent t : src.getMapping()) +// tgt.addMapping(convertDataElementMappingComponent(t)); +// for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) +// tgt.addElement(convertElementDefinition(t)); +// return tgt; +// } + +// public org.hl7.fhir.r4.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.instance.model.DataElement.DataElementStringency src) throws FHIRException { +// if (src == null) +// return null; +// switch (src) { +// case COMPARABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.COMPARABLE; +// case FULLYSPECIFIED: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FULLYSPECIFIED; +// case EQUIVALENT: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.EQUIVALENT; +// case CONVERTABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.CONVERTABLE; +// case SCALEABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.SCALEABLE; +// case FLEXIBLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FLEXIBLE; +// default: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.NULL; +// } +// } +// +// public org.hl7.fhir.instance.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.r4.model.DataElement.DataElementStringency src) throws FHIRException { +// if (src == null) +// return null; +// switch (src) { +// case COMPARABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.COMPARABLE; +// case FULLYSPECIFIED: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.FULLYSPECIFIED; +// case EQUIVALENT: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.EQUIVALENT; +// case CONVERTABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.CONVERTABLE; +// case SCALEABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.SCALEABLE; +// case FLEXIBLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.FLEXIBLE; +// default: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.NULL; +// } +// } + public org.hl7.fhir.r4.model.ContactDetail convertDataElementContactComponent(org.hl7.fhir.instance.model.DataElement.DataElementContactComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3239,126 +5205,18 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.instance.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.instance.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.instance.model.DateType tgt = new org.hl7.fhir.instance.model.DateType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.DateType convertDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.instance.model.DateType tgt = new org.hl7.fhir.instance.model.DateType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - -// public org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent convertCarePlanRelatedPlanComponent(org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent src) throws FHIRException { +// public org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent src) throws FHIRException { // if (src == null || src.isEmpty()) // return null; -// org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent(); +// org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent(); // copyElement(src, tgt); -// tgt.setCode(convertCarePlanRelationship(src.getCode())); -// tgt.setPlan(convertReference(src.getPlan())); +// tgt.setIdentity(src.getIdentity()); +// tgt.setUri(src.getUri()); +// tgt.setName(src.getName()); +// tgt.setComments(src.getComment()); // return tgt; // } -// public org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent convertCarePlanRelatedPlanComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanRelatedPlanComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent tgt = new org.hl7.fhir.instance.model.CarePlan.CarePlanRelatedPlanComponent(); -// copyElement(src, tgt); -// tgt.setCode(convertCarePlanRelationship(src.getCode())); -// tgt.setPlan(convertReference(src.getPlan())); -// return tgt; -// } - -// public org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship convertCarePlanRelationship(org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship src) throws FHIRException { -// if (src == null) -// return null; -// switch (src) { -// case INCLUDES: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.INCLUDES; -// case REPLACES: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.REPLACES; -// case FULFILLS: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.FULFILLS; -// default: return org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship.NULL; -// } -// } - -// public org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship convertCarePlanRelationship(org.hl7.fhir.r4.model.CarePlan.CarePlanRelationship src) throws FHIRException { -// if (src == null) -// return null; -// switch (src) { -// case INCLUDES: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.INCLUDES; -// case REPLACES: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.REPLACES; -// case FULFILLS: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.FULFILLS; -// default: return org.hl7.fhir.instance.model.CarePlan.CarePlanRelationship.NULL; -// } -// } - - public org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.instance.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.instance.model.DateTimeType tgt = new org.hl7.fhir.instance.model.DateTimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MON: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON; - case TUE: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE; - case WED: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED; - case THU: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU; - case FRI: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI; - case SAT: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT; - case SUN: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN; - default: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL; - } - } - - public org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MON: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.MON; - case TUE: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.TUE; - case WED: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.WED; - case THU: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.THU; - case FRI: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.FRI; - case SAT: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.SAT; - case SUN: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.SUN; - default: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.NULL; - } - } - - public org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.instance.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.instance.model.DecimalType tgt = new org.hl7.fhir.instance.model.DecimalType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - public org.hl7.fhir.r4.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.instance.model.DetectedIssue src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3401,6 +5259,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HIGH: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.HIGH; + case MODERATE: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.MODERATE; + case LOW: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.LOW; + default: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.NULL; + } + } + + public org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HIGH: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.HIGH; + case MODERATE: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.MODERATE; + case LOW: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.LOW; + default: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.NULL; + } + } + public org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3425,50 +5305,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } -// public org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent convertClinicalImpressionInvestigationsComponent(org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent tgt = new org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent(); -// copyElement(src, tgt); -// tgt.setCode(convertCodeableConcept(src.getCode())); -// for (org.hl7.fhir.instance.model.Reference t : src.getItem()) -// tgt.addItem(convertReference(t)); -// return tgt; -// } -// -// public org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent convertClinicalImpressionInvestigationsComponent(org.hl7.fhir.r4.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent tgt = new org.hl7.fhir.instance.model.ClinicalImpression.ClinicalImpressionInvestigationsComponent(); -// copyElement(src, tgt); -// tgt.setCode(convertCodeableConcept(src.getCode())); -// for (org.hl7.fhir.r4.model.Reference t : src.getItem()) -// tgt.addItem(convertReference(t)); -// return tgt; -// } - - public org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HIGH: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.HIGH; - case MODERATE: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.MODERATE; - case LOW: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.LOW; - default: return org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity.NULL; - } - } - - public org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity convertDetectedIssueSeverity(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HIGH: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.HIGH; - case MODERATE: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.MODERATE; - case LOW: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.LOW; - default: return org.hl7.fhir.instance.model.DetectedIssue.DetectedIssueSeverity.NULL; - } - } - public org.hl7.fhir.r4.model.Device convertDevice(org.hl7.fhir.instance.model.Device src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3524,6 +5360,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Device.FHIRDeviceStatus convertDeviceStatus(org.hl7.fhir.instance.model.Device.DeviceStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case AVAILABLE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ACTIVE; + case NOTAVAILABLE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.INACTIVE; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ENTEREDINERROR; + default: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Device.DeviceStatus convertDeviceStatus(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.instance.model.Device.DeviceStatus.AVAILABLE; + case INACTIVE: return org.hl7.fhir.instance.model.Device.DeviceStatus.NOTAVAILABLE; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Device.DeviceStatus.ENTEREDINERROR; + default: return org.hl7.fhir.instance.model.Device.DeviceStatus.NULL; + } + } + public org.hl7.fhir.r4.model.DeviceComponent convertDeviceComponent(org.hl7.fhir.instance.model.DeviceComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3564,6 +5422,44 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OTHER: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OTHER; + case CHEMICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.CHEMICAL; + case ELECTRICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL; + case IMPEDANCE: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE; + case NUCLEAR: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NUCLEAR; + case OPTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OPTICAL; + case THERMAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.THERMAL; + case BIOLOGICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL; + case MECHANICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MECHANICAL; + case ACOUSTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL; + case MANUAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MANUAL; + default: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NULL; + } + } + + public org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OTHER: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.OTHER; + case CHEMICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.CHEMICAL; + case ELECTRICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL; + case IMPEDANCE: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE; + case NUCLEAR: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.NUCLEAR; + case OPTICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.OPTICAL; + case THERMAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.THERMAL; + case BIOLOGICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL; + case MECHANICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.MECHANICAL; + case ACOUSTICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL; + case MANUAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.MANUAL; + default: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.NULL; + } + } + public org.hl7.fhir.r4.model.DeviceComponent.DeviceComponentProductionSpecificationComponent convertDeviceComponentProductionSpecificationComponent(org.hl7.fhir.instance.model.DeviceComponent.DeviceComponentProductionSpecificationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3624,97 +5520,25 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent(); - copyElement(src, tgt); - tgt.setType(convertDeviceMetricCalibrationType(src.getType())); - tgt.setState(convertDeviceMetricCalibrationState(src.getState())); - tgt.setTime(src.getTime()); - return tgt; - } - - public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent(); - copyElement(src, tgt); - tgt.setType(convertDeviceMetricCalibrationType(src.getType())); - tgt.setState(convertDeviceMetricCalibrationState(src.getState())); - tgt.setTime(src.getTime()); - return tgt; - } - - public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException { + public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case NOTCALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED; - case CALIBRATIONREQUIRED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED; - case CALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED; - case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED; - default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NULL; + case ON: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.ON; + case OFF: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.OFF; + case STANDBY: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY; + default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.NULL; } } - public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException { + public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case NOTCALIBRATED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED; - case CALIBRATIONREQUIRED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED; - case CALIBRATED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED; - case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED; - default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.NULL; - } - } - - public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED; - case OFFSET: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET; - case GAIN: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.GAIN; - case TWOPOINT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT; - default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.NULL; - } - } - - public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED; - case OFFSET: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET; - case GAIN: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.GAIN; - case TWOPOINT: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT; - default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.NULL; - } - } - - public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MEASUREMENT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT; - case SETTING: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.SETTING; - case CALCULATION: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.CALCULATION; - case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED; - default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.NULL; - } - } - - public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MEASUREMENT: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT; - case SETTING: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.SETTING; - case CALCULATION: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.CALCULATION; - case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED; - default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.NULL; + case ON: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.ON; + case OFF: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.OFF; + case STANDBY: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY; + default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.NULL; } } @@ -3750,47 +5574,97 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException { + public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException { if (src == null) return null; switch (src) { - case ON: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.ON; - case OFF: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.OFF; - case STANDBY: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY; - default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus.NULL; + case MEASUREMENT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT; + case SETTING: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.SETTING; + case CALCULATION: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.CALCULATION; + case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED; + default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory.NULL; } } - public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus convertDeviceMetricOperationalStatus(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricOperationalStatus src) throws FHIRException { + public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory convertDeviceMetricCategory(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCategory src) throws FHIRException { if (src == null) return null; switch (src) { - case ON: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.ON; - case OFF: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.OFF; - case STANDBY: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.STANDBY; - default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricOperationalStatus.NULL; + case MEASUREMENT: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.MEASUREMENT; + case SETTING: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.SETTING; + case CALCULATION: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.CALCULATION; + case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.UNSPECIFIED; + default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCategory.NULL; } } - public org.hl7.fhir.r4.model.Device.FHIRDeviceStatus convertDeviceStatus(org.hl7.fhir.instance.model.Device.DeviceStatus src) throws FHIRException { + public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent(); + copyElement(src, tgt); + tgt.setType(convertDeviceMetricCalibrationType(src.getType())); + tgt.setState(convertDeviceMetricCalibrationState(src.getState())); + tgt.setTime(src.getTime()); + return tgt; + } + + public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent convertDeviceMetricCalibrationComponent(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent tgt = new org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationComponent(); + copyElement(src, tgt); + tgt.setType(convertDeviceMetricCalibrationType(src.getType())); + tgt.setState(convertDeviceMetricCalibrationState(src.getState())); + tgt.setTime(src.getTime()); + return tgt; + } + + public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException { if (src == null) return null; switch (src) { - case AVAILABLE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ACTIVE; - case NOTAVAILABLE: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.INACTIVE; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.ENTEREDINERROR; - default: return org.hl7.fhir.r4.model.Device.FHIRDeviceStatus.NULL; + case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED; + case OFFSET: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET; + case GAIN: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.GAIN; + case TWOPOINT: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT; + default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType.NULL; } } - public org.hl7.fhir.instance.model.Device.DeviceStatus convertDeviceStatus(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus src) throws FHIRException { + public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType convertDeviceMetricCalibrationType(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationType src) throws FHIRException { if (src == null) return null; switch (src) { - case ACTIVE: return org.hl7.fhir.instance.model.Device.DeviceStatus.AVAILABLE; - case INACTIVE: return org.hl7.fhir.instance.model.Device.DeviceStatus.NOTAVAILABLE; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Device.DeviceStatus.ENTEREDINERROR; - default: return org.hl7.fhir.instance.model.Device.DeviceStatus.NULL; + case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.UNSPECIFIED; + case OFFSET: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.OFFSET; + case GAIN: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.GAIN; + case TWOPOINT: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.TWOPOINT; + default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationType.NULL; + } + } + + public org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOTCALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED; + case CALIBRATIONREQUIRED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED; + case CALIBRATED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED; + case UNSPECIFIED: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED; + default: return org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState.NULL; + } + } + + public org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState convertDeviceMetricCalibrationState(org.hl7.fhir.r4.model.DeviceMetric.DeviceMetricCalibrationState src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NOTCALIBRATED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.NOTCALIBRATED; + case CALIBRATIONREQUIRED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATIONREQUIRED; + case CALIBRATED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.CALIBRATED; + case UNSPECIFIED: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.UNSPECIFIED; + default: return org.hl7.fhir.instance.model.DeviceMetric.DeviceMetricCalibrationState.NULL; } } @@ -3835,6 +5709,49 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } +// public org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus convertDiagnosticOrderStatus(org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus src) throws FHIRException { +// if (src ==/* null || src.isEmpty()*/) +// return null; +// switch (src) { +// case PROPOSED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.PROPOSED; +// case DRAFT: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.DRAFT; +// case PLANNED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.PLANNED; +// case REQUESTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REQUESTED; +// case RECEIVED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.RECEIVED; +// case ACCEPTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.ACCEPTED; +// case INPROGRESS: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.INPROGRESS; +// case REVIEW: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REVIEW; +// case COMPLETED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.COMPLETED; +// case CANCELLED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.CANCELLED; +// case SUSPENDED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.SUSPENDED; +// case REJECTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REJECTED; +// case FAILED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.FAILED; +// default: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.NULL; +// } +// } +// +// public org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus convertDiagnosticOrderStatus(org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus src) throws FHIRException { +// if (src ==/* null || src.isEmpty()*/) +// return null; +// switch (src) { +// case PROPOSED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.PROPOSED; +// case DRAFT: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.DRAFT; +// case PLANNED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.PLANNED; +// case REQUESTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REQUESTED; +// case RECEIVED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.RECEIVED; +// case ACCEPTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.ACCEPTED; +// case INPROGRESS: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.INPROGRESS; +// case REVIEW: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REVIEW; +// case COMPLETED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.COMPLETED; +// case CANCELLED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.CANCELLED; +// case SUSPENDED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.SUSPENDED; +// case REJECTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REJECTED; +// case FAILED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.FAILED; +// default: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.NULL; +// } +// } + + public org.hl7.fhir.r4.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.instance.model.DiagnosticReport src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -3901,26 +5818,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent(); - copyElement(src, tgt); - tgt.setComment(src.getComment()); - tgt.setLink(convertReference(src.getLink())); - return tgt; - } - - public org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent(); - copyElement(src, tgt); - tgt.setComment(src.getComment()); - tgt.setLink(convertReference(src.getLink())); - return tgt; - } - public org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus convertDiagnosticReportStatus(org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportStatus src) throws FHIRException { if (src == null) return null; @@ -3951,79 +5848,26 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.instance.model.Media.DigitalMediaType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PHOTO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.PHOTO; - case VIDEO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.VIDEO; - case AUDIO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.AUDIO; - default: return org.hl7.fhir.r4.model.Media.DigitalMediaType.NULL; - } - } - - public org.hl7.fhir.instance.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.r4.model.Media.DigitalMediaType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PHOTO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.PHOTO; - case VIDEO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.VIDEO; - case AUDIO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.AUDIO; - default: return org.hl7.fhir.instance.model.Media.DigitalMediaType.NULL; - } - } - - public org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.instance.model.Distance src) throws FHIRException { + public org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent(); copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); + tgt.setComment(src.getComment()); + tgt.setLink(convertReference(src.getLink())); return tgt; } - public org.hl7.fhir.instance.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + public org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Distance tgt = new org.hl7.fhir.instance.model.Distance(); + org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.instance.model.DiagnosticReport.DiagnosticReportImageComponent(); copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); + tgt.setComment(src.getComment()); + tgt.setLink(convertReference(src.getLink())); return tgt; } - private ReferredDocumentStatus convertDocStatus(CodeableConcept cc) { - if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "preliminary")) - return ReferredDocumentStatus.PRELIMINARY; - if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "final")) - return ReferredDocumentStatus.FINAL; - if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "amended")) - return ReferredDocumentStatus.AMENDED; - if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "entered-in-error")) - return ReferredDocumentStatus.ENTEREDINERROR; - - return null; - } - - private CodeableConcept convertDocStatus(ReferredDocumentStatus docStatus) { - CodeableConcept cc = new CodeableConcept (); - switch (docStatus) { - case AMENDED: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("amended"); break; - case ENTEREDINERROR: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("entered-in-error"); break; - case FINAL: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("final"); break; - case PRELIMINARY: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("preliminary"); break; - default: return null; - } - return cc; - } - public org.hl7.fhir.r4.model.DocumentManifest convertDocumentManifest(org.hl7.fhir.instance.model.DocumentManifest src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -4066,6 +5910,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CURRENT: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT; + case SUPERSEDED: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.SUPERSEDED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR; + default: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CURRENT: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.CURRENT; + case SUPERSEDED: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.SUPERSEDED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR; + default: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.NULL; + } + } + public org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.instance.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { @@ -4088,26 +5954,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode convertDocumentMode(org.hl7.fhir.instance.model.Conformance.DocumentMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PRODUCER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.PRODUCER; - case CONSUMER: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.CONSUMER; - default: return org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.DocumentMode convertDocumentMode(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PRODUCER: return org.hl7.fhir.instance.model.Conformance.DocumentMode.PRODUCER; - case CONSUMER: return org.hl7.fhir.instance.model.Conformance.DocumentMode.CONSUMER; - default: return org.hl7.fhir.instance.model.Conformance.DocumentMode.NULL; - } - } - public org.hl7.fhir.r4.model.DocumentReference convertDocumentReference(org.hl7.fhir.instance.model.DocumentReference src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -4135,6 +5981,31 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + private ReferredDocumentStatus convertDocStatus(CodeableConcept cc) { + if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "preliminary")) + return ReferredDocumentStatus.PRELIMINARY; + if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "final")) + return ReferredDocumentStatus.FINAL; + if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "amended")) + return ReferredDocumentStatus.AMENDED; + if (hasConcept(cc, "http://hl7.org/fhir/composition-status", "entered-in-error")) + return ReferredDocumentStatus.ENTEREDINERROR; + + return null; + } + + private CodeableConcept convertDocStatus(ReferredDocumentStatus docStatus) { + CodeableConcept cc = new CodeableConcept (); + switch (docStatus) { + case AMENDED: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("amended"); break; + case ENTEREDINERROR: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("entered-in-error"); break; + case FINAL: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("final"); break; + case PRELIMINARY: cc.addCoding(). setSystem("http://hl7.org/fhir/composition-status").setCode("preliminary"); break; + default: return null; + } + return cc; + } + public org.hl7.fhir.instance.model.DocumentReference convertDocumentReference(org.hl7.fhir.r4.model.DocumentReference src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -4162,6 +6033,51 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + + public org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent(); + copyElement(src, tgt); + tgt.setCode(convertDocumentRelationshipType(src.getCode())); + tgt.setTarget(convertReference(src.getTarget())); + return tgt; + } + + public org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent(); + copyElement(src, tgt); + tgt.setCode(convertDocumentRelationshipType(src.getCode())); + tgt.setTarget(convertReference(src.getTarget())); + return tgt; + } + + public org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REPLACES: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.REPLACES; + case TRANSFORMS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.TRANSFORMS; + case SIGNS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.SIGNS; + case APPENDS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.APPENDS; + default: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL; + } + } + + public org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REPLACES: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.REPLACES; + case TRANSFORMS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.TRANSFORMS; + case SIGNS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.SIGNS; + case APPENDS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.APPENDS; + default: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.NULL; + } + } + public org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContentComponent convertDocumentReferenceContentComponent(org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceContentComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -4237,376 +6153,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent(); - copyElement(src, tgt); - tgt.setCode(convertDocumentRelationshipType(src.getCode())); - tgt.setTarget(convertReference(src.getTarget())); - return tgt; - } - - public org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.instance.model.DocumentReference.DocumentReferenceRelatesToComponent(); - copyElement(src, tgt); - tgt.setCode(convertDocumentRelationshipType(src.getCode())); - tgt.setTarget(convertReference(src.getTarget())); - return tgt; - } - - public org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CURRENT: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT; - case SUPERSEDED: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.SUPERSEDED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR; - default: return org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus convertDocumentReferenceStatus(org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CURRENT: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.CURRENT; - case SUPERSEDED: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.SUPERSEDED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR; - default: return org.hl7.fhir.instance.model.Enumerations.DocumentReferenceStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REPLACES: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.REPLACES; - case TRANSFORMS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.TRANSFORMS; - case SIGNS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.SIGNS; - case APPENDS: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.APPENDS; - default: return org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL; - } - } - - public org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType convertDocumentRelationshipType(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REPLACES: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.REPLACES; - case TRANSFORMS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.TRANSFORMS; - case SIGNS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.SIGNS; - case APPENDS: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.APPENDS; - default: return org.hl7.fhir.instance.model.DocumentReference.DocumentRelationshipType.NULL; - } - } - - public org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.instance.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.instance.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Duration tgt = new org.hl7.fhir.instance.model.Duration(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.instance.model.ElementDefinition src, List slicePaths) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); - copyElement(src, tgt); - tgt.setPath(src.getPath()); - for (org.hl7.fhir.instance.model.Enumeration t : src.getRepresentation()) - tgt.addRepresentation(convertPropertyRepresentation(t.getValue())); - if (src.hasName()) { - if (slicePaths.contains(src.getPath())) - tgt.setSliceName(src.getName()); - tgt.setId(src.getName()); - } - if (src.hasLabel()) - tgt.setLabel(src.getLabel()); - for (org.hl7.fhir.instance.model.Coding t : src.getCode()) - tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShort(src.getShort()); - if (src.hasDefinition()) - tgt.setDefinition(src.getDefinition()); - if (src.hasComments()) - tgt.setComment(src.getComments()); - if (src.hasRequirements()) - tgt.setRequirements(src.getRequirements()); - for (org.hl7.fhir.instance.model.StringType t : src.getAlias()) - tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMax(src.getMax()); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasNameReference()) - tgt.setContentReference("#"+src.getNameReference()); - for (org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent t : src.getType()) - tgt.addType(convertElementDefinitionTypeComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissing(src.getMeaningWhenMissing()); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLength(src.getMaxLength()); - for (org.hl7.fhir.instance.model.IdType t : src.getCondition()) - tgt.addCondition(t.getValue()); - for (org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) - tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupport(src.getMustSupport()); - if (src.hasIsModifier()) - tgt.setIsModifier(src.getIsModifier()); - if (src.hasIsSummary()) - tgt.setIsSummary(src.getIsSummary()); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition tgt = new org.hl7.fhir.instance.model.ElementDefinition(); - copyElement(src, tgt); - tgt.setPath(src.getPath()); - for (org.hl7.fhir.r4.model.Enumeration t : src.getRepresentation()) - tgt.addRepresentation(convertPropertyRepresentation(t.getValue())); - if (src.hasSliceName()) - tgt.setName(src.getSliceName()); - else - tgt.setName(src.getId()); - tgt.setLabel(src.getLabel()); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) - tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - tgt.setShort(src.getShort()); - tgt.setDefinition(src.getDefinition()); - tgt.setComments(src.getComment()); - tgt.setRequirements(src.getRequirements()); - for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) - tgt.addAlias(t.getValue()); - tgt.setMin(src.getMin()); - tgt.setMax(src.getMax()); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setNameReference(src.getContentReference().substring(1)); - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) - tgt.addType(convertElementDefinitionTypeComponent(t)); - tgt.setDefaultValue(convertType(src.getDefaultValue())); - tgt.setMeaningWhenMissing(src.getMeaningWhenMissing()); - tgt.setFixed(convertType(src.getFixed())); - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExampleFirstRep().getValue())); - tgt.setMinValue(convertType(src.getMinValue())); - tgt.setMaxValue(convertType(src.getMaxValue())); - tgt.setMaxLength(src.getMaxLength()); - for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) - tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) - tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - tgt.setMustSupport(src.getMustSupport()); - tgt.setIsModifier(src.getIsModifier()); - tgt.setIsSummary(src.getIsSummary()); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - tgt.setPath(src.getPath()); - tgt.setMin(src.getMin()); - tgt.setMax(src.getMax()); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - tgt.setPath(src.getPath()); - tgt.setMin(src.getMin()); - tgt.setMax(src.getMax()); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - tgt.setStrength(convertBindingStrength(src.getStrength())); - tgt.setDescription(src.getDescription()); - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - tgt.setStrength(convertBindingStrength(src.getStrength())); - tgt.setDescription(src.getDescription()); - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - tgt.setKey(src.getKey()); - tgt.setRequirements(src.getRequirements()); - tgt.setSeverity(convertConstraintSeverity(src.getSeverity())); - tgt.setHuman(src.getHuman()); - tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - tgt.setXpath(src.getXpath()); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - tgt.setKey(src.getKey()); - tgt.setRequirements(src.getRequirements()); - tgt.setSeverity(convertConstraintSeverity(src.getSeverity())); - tgt.setHuman(src.getHuman()); - if (src.hasExpression()) - ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - tgt.setXpath(src.getXpath()); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - tgt.setIdentity(src.getIdentity()); - tgt.setLanguage(src.getLanguage()); - tgt.setMap(src.getMap()); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - tgt.setIdentity(src.getIdentity()); - tgt.setLanguage(src.getLanguage()); - tgt.setMap(src.getMap()); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.StringType t : src.getDiscriminator()) - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); - tgt.setDescription(src.getDescription()); - tgt.setOrdered(src.getOrdered()); - tgt.setRules(convertSlicingRules(src.getRules())); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) - tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - tgt.setDescription(src.getDescription()); - tgt.setOrdered(src.getOrdered()); - tgt.setRules(convertSlicingRules(src.getRules())); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); - for (org.hl7.fhir.instance.model.UriType t : src.getProfile()) - if (src.hasCode() && "Reference".equals(src.getCode())) - tgt.setTargetProfile(t.getValueAsString()); - else - tgt.setProfile(t.getValue()); - for (org.hl7.fhir.instance.model.Enumeration t : src.getAggregation()) - tgt.addAggregation(convertAggregationMode(t.getValue())); - return tgt; - } - - public org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.instance.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCodeElement(convertUriToCode(src.getCodeElement())); - if (src.hasCode() && "Reference".equals(src.getCode())) { - if (src.hasTargetProfile()) - tgt.addProfile(src.getTargetProfile()); - } else if (src.hasProfile()) - tgt.addProfile(src.getProfile()); - for (org.hl7.fhir.r4.model.Enumeration t : src.getAggregation()) - tgt.addAggregation(convertAggregationMode(t.getValue())); - return tgt; - } public org.hl7.fhir.r4.model.Encounter convertEncounter(org.hl7.fhir.instance.model.Encounter src) throws FHIRException { if (src == null || src.isEmpty()) @@ -4676,6 +6222,34 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Encounter.EncounterStatus convertEncounterState(org.hl7.fhir.instance.model.Encounter.EncounterState src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PLANNED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.PLANNED; + case ARRIVED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ARRIVED; + case INPROGRESS: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.INPROGRESS; + case ONLEAVE: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ONLEAVE; + case FINISHED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED; + case CANCELLED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.CANCELLED; + default: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Encounter.EncounterState convertEncounterState(org.hl7.fhir.r4.model.Encounter.EncounterStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PLANNED: return org.hl7.fhir.instance.model.Encounter.EncounterState.PLANNED; + case ARRIVED: return org.hl7.fhir.instance.model.Encounter.EncounterState.ARRIVED; + case INPROGRESS: return org.hl7.fhir.instance.model.Encounter.EncounterState.INPROGRESS; + case ONLEAVE: return org.hl7.fhir.instance.model.Encounter.EncounterState.ONLEAVE; + case FINISHED: return org.hl7.fhir.instance.model.Encounter.EncounterState.FINISHED; + case CANCELLED: return org.hl7.fhir.instance.model.Encounter.EncounterState.CANCELLED; + default: return org.hl7.fhir.instance.model.Encounter.EncounterState.NULL; + } + } + public org.hl7.fhir.r4.model.Coding convertEncounterClass(org.hl7.fhir.instance.model.Encounter.EncounterClass src) throws FHIRException { if (src == null) return null; @@ -4707,6 +6281,50 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return org.hl7.fhir.instance.model.Encounter.EncounterClass.NULL; } +// public org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent convertEncounterStatusHistoryComponent(org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent(); +// copyElement(src, tgt); +// tgt.setStatus(convertEncounterState(src.getStatus())); +// tgt.setPeriod(convertPeriod(src.getPeriod())); +// return tgt; +// } + +// public org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent convertEncounterStatusHistoryComponent(org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent tgt = new org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent(); +// copyElement(src, tgt); +// tgt.setStatus(convertEncounterState(src.getStatus())); +// tgt.setPeriod(convertPeriod(src.getPeriod())); +// return tgt; +// } + + public org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) + tgt.addType(convertCodeableConcept(t)); + tgt.setPeriod(convertPeriod(src.getPeriod())); + tgt.setIndividual(convertReference(src.getIndividual())); + return tgt; + } + + public org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) + tgt.addType(convertCodeableConcept(t)); + tgt.setPeriod(convertPeriod(src.getPeriod())); + tgt.setIndividual(convertReference(src.getIndividual())); + return tgt; + } + public org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent convertEncounterHospitalizationComponent(org.hl7.fhir.instance.model.Encounter.EncounterHospitalizationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -4793,58 +6411,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) - tgt.addType(convertCodeableConcept(t)); - tgt.setPeriod(convertPeriod(src.getPeriod())); - tgt.setIndividual(convertReference(src.getIndividual())); - return tgt; - } - - public org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.instance.model.Encounter.EncounterParticipantComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) - tgt.addType(convertCodeableConcept(t)); - tgt.setPeriod(convertPeriod(src.getPeriod())); - tgt.setIndividual(convertReference(src.getIndividual())); - return tgt; - } - - public org.hl7.fhir.r4.model.Encounter.EncounterStatus convertEncounterState(org.hl7.fhir.instance.model.Encounter.EncounterState src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PLANNED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.PLANNED; - case ARRIVED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ARRIVED; - case INPROGRESS: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.INPROGRESS; - case ONLEAVE: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.ONLEAVE; - case FINISHED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED; - case CANCELLED: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.CANCELLED; - default: return org.hl7.fhir.r4.model.Encounter.EncounterStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Encounter.EncounterState convertEncounterState(org.hl7.fhir.r4.model.Encounter.EncounterStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PLANNED: return org.hl7.fhir.instance.model.Encounter.EncounterState.PLANNED; - case ARRIVED: return org.hl7.fhir.instance.model.Encounter.EncounterState.ARRIVED; - case INPROGRESS: return org.hl7.fhir.instance.model.Encounter.EncounterState.INPROGRESS; - case ONLEAVE: return org.hl7.fhir.instance.model.Encounter.EncounterState.ONLEAVE; - case FINISHED: return org.hl7.fhir.instance.model.Encounter.EncounterState.FINISHED; - case CANCELLED: return org.hl7.fhir.instance.model.Encounter.EncounterState.CANCELLED; - default: return org.hl7.fhir.instance.model.Encounter.EncounterState.NULL; - } - } - public org.hl7.fhir.r4.model.EnrollmentRequest convertEnrollmentRequest(org.hl7.fhir.instance.model.EnrollmentRequest src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5003,115 +6569,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.instance.model.Timing.EventTiming src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HS: return org.hl7.fhir.r4.model.Timing.EventTiming.HS; - case WAKE: return org.hl7.fhir.r4.model.Timing.EventTiming.WAKE; - case C: return org.hl7.fhir.r4.model.Timing.EventTiming.C; - case CM: return org.hl7.fhir.r4.model.Timing.EventTiming.CM; - case CD: return org.hl7.fhir.r4.model.Timing.EventTiming.CD; - case CV: return org.hl7.fhir.r4.model.Timing.EventTiming.CV; - case AC: return org.hl7.fhir.r4.model.Timing.EventTiming.AC; - case ACM: return org.hl7.fhir.r4.model.Timing.EventTiming.ACM; - case ACD: return org.hl7.fhir.r4.model.Timing.EventTiming.ACD; - case ACV: return org.hl7.fhir.r4.model.Timing.EventTiming.ACV; - case PC: return org.hl7.fhir.r4.model.Timing.EventTiming.PC; - case PCM: return org.hl7.fhir.r4.model.Timing.EventTiming.PCM; - case PCD: return org.hl7.fhir.r4.model.Timing.EventTiming.PCD; - case PCV: return org.hl7.fhir.r4.model.Timing.EventTiming.PCV; - default: return org.hl7.fhir.r4.model.Timing.EventTiming.NULL; - } - } - - public org.hl7.fhir.instance.model.Timing.EventTiming convertEventTiming(org.hl7.fhir.r4.model.Timing.EventTiming src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HS: return org.hl7.fhir.instance.model.Timing.EventTiming.HS; - case WAKE: return org.hl7.fhir.instance.model.Timing.EventTiming.WAKE; - case C: return org.hl7.fhir.instance.model.Timing.EventTiming.C; - case CM: return org.hl7.fhir.instance.model.Timing.EventTiming.CM; - case CD: return org.hl7.fhir.instance.model.Timing.EventTiming.CD; - case CV: return org.hl7.fhir.instance.model.Timing.EventTiming.CV; - case AC: return org.hl7.fhir.instance.model.Timing.EventTiming.AC; - case ACM: return org.hl7.fhir.instance.model.Timing.EventTiming.ACM; - case ACD: return org.hl7.fhir.instance.model.Timing.EventTiming.ACD; - case ACV: return org.hl7.fhir.instance.model.Timing.EventTiming.ACV; - case PC: return org.hl7.fhir.instance.model.Timing.EventTiming.PC; - case PCM: return org.hl7.fhir.instance.model.Timing.EventTiming.PCM; - case PCD: return org.hl7.fhir.instance.model.Timing.EventTiming.PCD; - case PCV: return org.hl7.fhir.instance.model.Timing.EventTiming.PCV; - default: return org.hl7.fhir.instance.model.Timing.EventTiming.NULL; - } - } - - public org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.instance.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); - copyElement(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public org.hl7.fhir.instance.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Extension tgt = new org.hl7.fhir.instance.model.Extension(); - copyElement(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.RESOURCE; - case DATATYPE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.DATATYPE; - case EXTENSION: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.EXTENSION; - default: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.NULL; - } - } - - public org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESOURCE: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.RESOURCE; - case DATATYPE: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.DATATYPE; - case EXTENSION: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.EXTENSION; - default: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.NULL; - } - } - - public org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PARTIAL: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL; - case COMPLETED: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR; - case HEALTHUNKNOWN: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN; - default: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PARTIAL: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL; - case COMPLETED: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR; - case HEALTHUNKNOWN: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN; - default: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.NULL; - } - } public org.hl7.fhir.r4.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.instance.model.FamilyMemberHistory src) throws FHIRException { if (src == null || src.isEmpty()) @@ -5159,6 +6616,30 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PARTIAL: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL; + case COMPLETED: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR; + case HEALTHUNKNOWN: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN; + default: return org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus convertFamilyHistoryStatus(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PARTIAL: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL; + case COMPLETED: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR; + case HEALTHUNKNOWN: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN; + default: return org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyHistoryStatus.NULL; + } + } + public org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.instance.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5183,34 +6664,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.instance.model.ValueSet.FilterOperator src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case EQUAL: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL; - case ISA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA; - case ISNOTA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA; - case REGEX: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX; - case IN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN; - case NOTIN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN; - default: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL; - } - } - - public org.hl7.fhir.instance.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.r4.model.ValueSet.FilterOperator src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case EQUAL: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.EQUAL; - case ISA: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.ISA; - case ISNOTA: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.ISNOTA; - case REGEX: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.REGEX; - case IN: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.IN; - case NOTIN: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.NOTIN; - default: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.NULL; - } - } - public org.hl7.fhir.r4.model.Flag convertFlag(org.hl7.fhir.instance.model.Flag src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5267,24 +6720,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent convertFriendlyLanguageComponent(org.hl7.fhir.r4.model.Contract.FriendlyLanguageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.FriendlyLanguageComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; - } - public org.hl7.fhir.r4.model.Group convertGroup(org.hl7.fhir.instance.model.Group src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5323,6 +6758,34 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Group.GroupType convertGroupType(org.hl7.fhir.instance.model.Group.GroupType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PERSON: return org.hl7.fhir.r4.model.Group.GroupType.PERSON; + case ANIMAL: return org.hl7.fhir.r4.model.Group.GroupType.ANIMAL; + case PRACTITIONER: return org.hl7.fhir.r4.model.Group.GroupType.PRACTITIONER; + case DEVICE: return org.hl7.fhir.r4.model.Group.GroupType.DEVICE; + case MEDICATION: return org.hl7.fhir.r4.model.Group.GroupType.MEDICATION; + case SUBSTANCE: return org.hl7.fhir.r4.model.Group.GroupType.SUBSTANCE; + default: return org.hl7.fhir.r4.model.Group.GroupType.NULL; + } + } + + public org.hl7.fhir.instance.model.Group.GroupType convertGroupType(org.hl7.fhir.r4.model.Group.GroupType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PERSON: return org.hl7.fhir.instance.model.Group.GroupType.PERSON; + case ANIMAL: return org.hl7.fhir.instance.model.Group.GroupType.ANIMAL; + case PRACTITIONER: return org.hl7.fhir.instance.model.Group.GroupType.PRACTITIONER; + case DEVICE: return org.hl7.fhir.instance.model.Group.GroupType.DEVICE; + case MEDICATION: return org.hl7.fhir.instance.model.Group.GroupType.MEDICATION; + case SUBSTANCE: return org.hl7.fhir.instance.model.Group.GroupType.SUBSTANCE; + default: return org.hl7.fhir.instance.model.Group.GroupType.NULL; + } + } + public org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.instance.model.Group.GroupCharacteristicComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5369,182 +6832,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } -// public org.hl7.fhir.instance.model.DataElement convertDataElement(org.hl7.fhir.r4.model.DataElement src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.DataElement tgt = new org.hl7.fhir.instance.model.DataElement(); -// copyDomainResource(src, tgt); -// tgt.setUrl(src.getUrl()); -// for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) -// tgt.addIdentifier(convertIdentifier(t)); -// tgt.setVersion(src.getVersion()); -// tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); -// if (src.hasExperimental()) -// tgt.setExperimental(src.getExperimental()); -// tgt.setPublisher(src.getPublisher()); -// if (src.hasDate()) -// tgt.setDate(src.getDate()); -// tgt.setName(src.getName()); -// for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) -// tgt.addContact(convertDataElementContactComponent(t)); -// for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) -// if (t.hasValueCodeableConcept()) -// tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); -// for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) -// tgt.addUseContext(convertCodeableConcept(t)); -// tgt.setCopyright(src.getCopyright()); -// tgt.setStringency(convertDataElementStringency(src.getStringency())); -// for (org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent t : src.getMapping()) -// tgt.addMapping(convertDataElementMappingComponent(t)); -// for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) -// tgt.addElement(convertElementDefinition(t)); -// return tgt; -// } - -// public org.hl7.fhir.r4.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.instance.model.DataElement.DataElementStringency src) throws FHIRException { -// if (src == null) -// return null; -// switch (src) { -// case COMPARABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.COMPARABLE; -// case FULLYSPECIFIED: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FULLYSPECIFIED; -// case EQUIVALENT: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.EQUIVALENT; -// case CONVERTABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.CONVERTABLE; -// case SCALEABLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.SCALEABLE; -// case FLEXIBLE: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.FLEXIBLE; -// default: return org.hl7.fhir.r4.model.DataElement.DataElementStringency.NULL; -// } -// } -// -// public org.hl7.fhir.instance.model.DataElement.DataElementStringency convertDataElementStringency(org.hl7.fhir.r4.model.DataElement.DataElementStringency src) throws FHIRException { -// if (src == null) -// return null; -// switch (src) { -// case COMPARABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.COMPARABLE; -// case FULLYSPECIFIED: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.FULLYSPECIFIED; -// case EQUIVALENT: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.EQUIVALENT; -// case CONVERTABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.CONVERTABLE; -// case SCALEABLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.SCALEABLE; -// case FLEXIBLE: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.FLEXIBLE; -// default: return org.hl7.fhir.instance.model.DataElement.DataElementStringency.NULL; -// } -// } - - public org.hl7.fhir.r4.model.Group.GroupType convertGroupType(org.hl7.fhir.instance.model.Group.GroupType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PERSON: return org.hl7.fhir.r4.model.Group.GroupType.PERSON; - case ANIMAL: return org.hl7.fhir.r4.model.Group.GroupType.ANIMAL; - case PRACTITIONER: return org.hl7.fhir.r4.model.Group.GroupType.PRACTITIONER; - case DEVICE: return org.hl7.fhir.r4.model.Group.GroupType.DEVICE; - case MEDICATION: return org.hl7.fhir.r4.model.Group.GroupType.MEDICATION; - case SUBSTANCE: return org.hl7.fhir.r4.model.Group.GroupType.SUBSTANCE; - default: return org.hl7.fhir.r4.model.Group.GroupType.NULL; - } - } - - public org.hl7.fhir.instance.model.Group.GroupType convertGroupType(org.hl7.fhir.r4.model.Group.GroupType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PERSON: return org.hl7.fhir.instance.model.Group.GroupType.PERSON; - case ANIMAL: return org.hl7.fhir.instance.model.Group.GroupType.ANIMAL; - case PRACTITIONER: return org.hl7.fhir.instance.model.Group.GroupType.PRACTITIONER; - case DEVICE: return org.hl7.fhir.instance.model.Group.GroupType.DEVICE; - case MEDICATION: return org.hl7.fhir.instance.model.Group.GroupType.MEDICATION; - case SUBSTANCE: return org.hl7.fhir.instance.model.Group.GroupType.SUBSTANCE; - default: return org.hl7.fhir.instance.model.Group.GroupType.NULL; - } - } - - public org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REFERENCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.REFERENCE; - case INCLUSION: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.INCLUSION; - default: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.NULL; - } - } - -// public org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.r4.model.DataElement.DataElementMappingComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.instance.model.DataElement.DataElementMappingComponent(); -// copyElement(src, tgt); -// tgt.setIdentity(src.getIdentity()); -// tgt.setUri(src.getUri()); -// tgt.setName(src.getName()); -// tgt.setComments(src.getComment()); -// return tgt; -// } - - public org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REFERENCE: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.REFERENCE; - case INCLUSION: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.INCLUSION; - default: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.NULL; - } - } - - public org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PAGE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.PAGE; - case EXAMPLE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.EXAMPLE; - case LIST: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.LIST; - case INCLUDE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.INCLUDE; - case DIRECTORY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DIRECTORY; - case DICTIONARY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DICTIONARY; - case TOC: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.TOC; - case RESOURCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.RESOURCE; - default: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.NULL; - } - } - - public org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PAGE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.PAGE; - case EXAMPLE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.EXAMPLE; - case LIST: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.LIST; - case INCLUDE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.INCLUDE; - case DIRECTORY: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.DIRECTORY; - case DICTIONARY: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.DICTIONARY; - case TOC: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.TOC; - case RESOURCE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.RESOURCE; - default: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.NULL; - } - } - - public org.hl7.fhir.r4.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.instance.model.Bundle.HTTPVerb src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case GET: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET; - case POST: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST; - case PUT: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT; - case DELETE: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE; - default: return org.hl7.fhir.r4.model.Bundle.HTTPVerb.NULL; - } - } - - public org.hl7.fhir.instance.model.Bundle.HTTPVerb convertHTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case GET: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.GET; - case POST: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.POST; - case PUT: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.PUT; - case DELETE: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.DELETE; - default: return org.hl7.fhir.instance.model.Bundle.HTTPVerb.NULL; - } - } - public org.hl7.fhir.r4.model.HealthcareService convertHealthcareService(org.hl7.fhir.instance.model.HealthcareService src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5661,6 +6948,36 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MON: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON; + case TUE: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE; + case WED: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED; + case THU: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU; + case FRI: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI; + case SAT: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT; + case SUN: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN; + default: return org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL; + } + } + + public org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek convertDaysOfWeek(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case MON: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.MON; + case TUE: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.TUE; + case WED: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.WED; + case THU: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.THU; + case FRI: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.FRI; + case SAT: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.SAT; + case SUN: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.SUN; + default: return org.hl7.fhir.instance.model.HealthcareService.DaysOfWeek.NULL; + } + } + public org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.instance.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -5681,138 +6998,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.instance.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); - copyElement(src, tgt); - tgt.setUse(convertNameUse(src.getUse())); - tgt.setText(src.getText()); - for (org.hl7.fhir.instance.model.StringType t : src.getFamily()) - tgt.setFamily(t.getValue()); - for (org.hl7.fhir.instance.model.StringType t : src.getGiven()) - tgt.addGiven(t.getValue()); - for (org.hl7.fhir.instance.model.StringType t : src.getPrefix()) - tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.instance.model.StringType t : src.getSuffix()) - tgt.addSuffix(t.getValue()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.HumanName tgt = new org.hl7.fhir.instance.model.HumanName(); - copyElement(src, tgt); - tgt.setUse(convertNameUse(src.getUse())); - tgt.setText(src.getText()); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) - tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) - tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) - tgt.addSuffix(t.getValue()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.instance.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.instance.model.IdType tgt = new org.hl7.fhir.instance.model.IdType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.instance.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); - copyElement(src, tgt); - tgt.setUse(convertIdentifierUse(src.getUse())); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setSystem(src.getSystem()); - tgt.setValue(src.getValue()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public org.hl7.fhir.instance.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Identifier tgt = new org.hl7.fhir.instance.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUse(convertIdentifierUse(src.getUse())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystem(src.getSystem()); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public org.hl7.fhir.r4.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.instance.model.Identifier.IdentifierUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case USUAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL; - case OFFICIAL: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL; - case TEMP: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP; - case SECONDARY: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY; - default: return org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL; - } - } - - public org.hl7.fhir.instance.model.Identifier.IdentifierUse convertIdentifierUse(org.hl7.fhir.r4.model.Identifier.IdentifierUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case USUAL: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.USUAL; - case OFFICIAL: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.OFFICIAL; - case TEMP: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.TEMP; - case SECONDARY: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.SECONDARY; - default: return org.hl7.fhir.instance.model.Identifier.IdentifierUse.NULL; - } - } - - public org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case LEVEL1: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL1; - case LEVEL2: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL2; - case LEVEL3: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL3; - case LEVEL4: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL4; - default: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.NULL; - } - } - - public org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case LEVEL1: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL1; - case LEVEL2: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL2; - case LEVEL3: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL3; - case LEVEL4: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL4; - default: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.NULL; - } - } - // public org.hl7.fhir.r4.model.ImagingObjectSelection convertImagingObjectSelection(org.hl7.fhir.instance.model.ImagingObjectSelection src) throws FHIRException { // if (src == null || src.isEmpty()) // return null; @@ -5996,6 +7181,30 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ONLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.ONLINE; + case OFFLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.OFFLINE; + case NEARLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NEARLINE; + case UNAVAILABLE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.UNAVAILABLE; + default: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NULL; + } + } + + public org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ONLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.ONLINE; + case OFFLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.OFFLINE; + case NEARLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.NEARLINE; + case UNAVAILABLE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.UNAVAILABLE; + default: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.NULL; + } + } + public org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent convertImagingStudySeriesComponent(org.hl7.fhir.instance.model.ImagingStudy.ImagingStudySeriesComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6132,6 +7341,38 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + private org.hl7.fhir.r4.model.Reference getPerformer(List practitioner) { + for (ImmunizationPractitionerComponent p : practitioner) { + if (hasConcept(p.getRole(), "http://hl7.org/fhir/v2/0443", "AP")) + return p.getActor(); + } + return null; + } + + private org.hl7.fhir.r4.model.Reference getRequester(List practitioner) { + for (ImmunizationPractitionerComponent p : practitioner) { + if (hasConcept(p.getRole(), "http://hl7.org/fhir/v2/0443", "OP")) + return p.getActor(); + } + return null; + } + + private boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) + return true; + } + return false; + } + + private boolean hasConcept(org.hl7.fhir.instance.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.instance.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) + return true; + } + return false; + } + public org.hl7.fhir.r4.model.Immunization.ImmunizationExplanationComponent convertImmunizationExplanationComponent(org.hl7.fhir.instance.model.Immunization.ImmunizationExplanationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6168,48 +7409,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } -// public org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus convertDiagnosticOrderStatus(org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus src) throws FHIRException { -// if (src ==/* null || src.isEmpty()*/) -// return null; -// switch (src) { -// case PROPOSED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.PROPOSED; -// case DRAFT: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.DRAFT; -// case PLANNED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.PLANNED; -// case REQUESTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REQUESTED; -// case RECEIVED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.RECEIVED; -// case ACCEPTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.ACCEPTED; -// case INPROGRESS: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.INPROGRESS; -// case REVIEW: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REVIEW; -// case COMPLETED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.COMPLETED; -// case CANCELLED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.CANCELLED; -// case SUSPENDED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.SUSPENDED; -// case REJECTED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.REJECTED; -// case FAILED: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.FAILED; -// default: return org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus.NULL; -// } -// } -// -// public org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus convertDiagnosticOrderStatus(org.hl7.fhir.r4.model.DiagnosticRequest.DiagnosticRequestStatus src) throws FHIRException { -// if (src ==/* null || src.isEmpty()*/) -// return null; -// switch (src) { -// case PROPOSED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.PROPOSED; -// case DRAFT: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.DRAFT; -// case PLANNED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.PLANNED; -// case REQUESTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REQUESTED; -// case RECEIVED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.RECEIVED; -// case ACCEPTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.ACCEPTED; -// case INPROGRESS: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.INPROGRESS; -// case REVIEW: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REVIEW; -// case COMPLETED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.COMPLETED; -// case CANCELLED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.CANCELLED; -// case SUSPENDED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.SUSPENDED; -// case REJECTED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.REJECTED; -// case FAILED: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.FAILED; -// default: return org.hl7.fhir.instance.model.DiagnosticOrder.DiagnosticOrderStatus.NULL; -// } -// } - public org.hl7.fhir.instance.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6222,6 +7421,40 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent(); + copyElement(src, tgt); + tgt.setDoseSequence(src.getDoseSequence()); + tgt.setDescription(src.getDescription()); + tgt.setAuthority(convertReference(src.getAuthority())); + tgt.setSeries(src.getSeries()); + tgt.setSeriesDoses(src.getSeriesDoses()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getTargetDisease()) + tgt.addTargetDisease(convertCodeableConcept(t)); + tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus())); + tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason())); + return tgt; + } + + public org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent(); + copyElement(src, tgt); + tgt.setDoseSequence(src.getDoseSequence()); + tgt.setDescription(src.getDescription()); + tgt.setAuthority(convertReference(src.getAuthority())); + tgt.setSeries(src.getSeries()); + tgt.setSeriesDoses(src.getSeriesDoses()); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTargetDisease()) + tgt.addTargetDisease(convertCodeableConcept(t)); + tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus())); + tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason())); + return tgt; + } + public org.hl7.fhir.r4.model.ImmunizationRecommendation convertImmunizationRecommendation(org.hl7.fhir.instance.model.ImmunizationRecommendation src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6332,40 +7565,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent(); - copyElement(src, tgt); - tgt.setDoseSequence(src.getDoseSequence()); - tgt.setDescription(src.getDescription()); - tgt.setAuthority(convertReference(src.getAuthority())); - tgt.setSeries(src.getSeries()); - tgt.setSeriesDoses(src.getSeriesDoses()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getTargetDisease()) - tgt.addTargetDisease(convertCodeableConcept(t)); - tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus())); - tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason())); - return tgt; - } - - public org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent convertImmunizationVaccinationProtocolComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationVaccinationProtocolComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent tgt = new org.hl7.fhir.instance.model.Immunization.ImmunizationVaccinationProtocolComponent(); - copyElement(src, tgt); - tgt.setDoseSequence(src.getDoseSequence()); - tgt.setDescription(src.getDescription()); - tgt.setAuthority(convertReference(src.getAuthority())); - tgt.setSeries(src.getSeries()); - tgt.setSeriesDoses(src.getSeriesDoses()); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTargetDisease()) - tgt.addTargetDisease(convertCodeableConcept(t)); - tgt.setDoseStatus(convertCodeableConcept(src.getDoseStatus())); - tgt.setDoseStatusReason(convertCodeableConcept(src.getDoseStatusReason())); - return tgt; - } - public org.hl7.fhir.r4.model.ImplementationGuide convertImplementationGuide(org.hl7.fhir.instance.model.ImplementationGuide src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6480,24 +7679,24 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setProfile(convertReference(src.getProfile())); - return tgt; + switch (src) { + case REFERENCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.REFERENCE; + case INCLUSION: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.INCLUSION; + default: return org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType.NULL; + } } - public org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType convertGuideDependencyType(org.hl7.fhir.r4.model.ImplementationGuide.GuideDependencyType src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent(); - copyElement(src, tgt); - tgt.setType(src.getType()); - tgt.setProfile(convertReference(src.getProfile())); - return tgt; + switch (src) { + case REFERENCE: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.REFERENCE; + case INCLUSION: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.INCLUSION; + default: return org.hl7.fhir.instance.model.ImplementationGuide.GuideDependencyType.NULL; + } } public org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePackageComponent convertImplementationGuidePackageComponent(org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuidePackageComponent src) throws FHIRException { @@ -6555,6 +7754,26 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setProfile(convertReference(src.getProfile())); + return tgt; + } + + public org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent convertImplementationGuideGlobalComponent(org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideGlobalComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent tgt = new org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuideGlobalComponent(); + copyElement(src, tgt); + tgt.setType(src.getType()); + tgt.setProfile(convertReference(src.getProfile())); + return tgt; + } + public org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuidePageComponent convertImplementationGuidePageComponent(org.hl7.fhir.instance.model.ImplementationGuide.ImplementationGuidePageComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -6591,348 +7810,38 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability src) throws FHIRException { + public org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind src) throws FHIRException { if (src == null) return null; switch (src) { - case ONLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.ONLINE; - case OFFLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.OFFLINE; - case NEARLINE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NEARLINE; - case UNAVAILABLE: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.UNAVAILABLE; - default: return org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability.NULL; + case PAGE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.PAGE; + case EXAMPLE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.EXAMPLE; + case LIST: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.LIST; + case INCLUDE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.INCLUDE; + case DIRECTORY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DIRECTORY; + case DICTIONARY: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.DICTIONARY; + case TOC: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.TOC; + case RESOURCE: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.RESOURCE; + default: return org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind.NULL; } } - public org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability convertInstanceAvailability(org.hl7.fhir.r4.model.ImagingStudy.InstanceAvailability src) throws FHIRException { + public org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind convertGuidePageKind(org.hl7.fhir.r4.model.ImplementationGuide.GuidePageKind src) throws FHIRException { if (src == null) return null; switch (src) { - case ONLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.ONLINE; - case OFFLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.OFFLINE; - case NEARLINE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.NEARLINE; - case UNAVAILABLE: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.UNAVAILABLE; - default: return org.hl7.fhir.instance.model.ImagingStudy.InstanceAvailability.NULL; + case PAGE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.PAGE; + case EXAMPLE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.EXAMPLE; + case LIST: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.LIST; + case INCLUDE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.INCLUDE; + case DIRECTORY: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.DIRECTORY; + case DICTIONARY: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.DICTIONARY; + case TOC: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.TOC; + case RESOURCE: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.RESOURCE; + default: return org.hl7.fhir.instance.model.ImplementationGuide.GuidePageKind.NULL; } } - public org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.instance.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.instance.model.InstantType tgt = new org.hl7.fhir.instance.model.InstantType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.instance.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.instance.model.IntegerType tgt = new org.hl7.fhir.instance.model.IntegerType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case FATAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.FATAL; - case ERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.ERROR; - case WARNING: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.WARNING; - case INFORMATION: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.INFORMATION; - default: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.NULL; - } - } - - public org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case FATAL: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.FATAL; - case ERROR: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR; - case WARNING: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING; - case INFORMATION: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION; - default: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.NULL; - } - } - - public org.hl7.fhir.r4.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.instance.model.OperationOutcome.IssueType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVALID; - case STRUCTURE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.STRUCTURE; - case REQUIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.REQUIRED; - case VALUE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.VALUE; - case INVARIANT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVARIANT; - case SECURITY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SECURITY; - case LOGIN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOGIN; - case UNKNOWN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.UNKNOWN; - case EXPIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXPIRED; - case FORBIDDEN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.FORBIDDEN; - case SUPPRESSED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SUPPRESSED; - case PROCESSING: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.PROCESSING; - case NOTSUPPORTED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTSUPPORTED; - case DUPLICATE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.DUPLICATE; - case NOTFOUND: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTFOUND; - case TOOLONG: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOLONG; - case CODEINVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CODEINVALID; - case EXTENSION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXTENSION; - case TOOCOSTLY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOCOSTLY; - case BUSINESSRULE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.BUSINESSRULE; - case CONFLICT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CONFLICT; - case INCOMPLETE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INCOMPLETE; - case TRANSIENT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TRANSIENT; - case LOCKERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOCKERROR; - case NOSTORE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOSTORE; - case EXCEPTION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXCEPTION; - case TIMEOUT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TIMEOUT; - case THROTTLED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.THROTTLED; - case INFORMATIONAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INFORMATIONAL; - default: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NULL; - } - } - -// public org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent convertEncounterStatusHistoryComponent(org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent(); -// copyElement(src, tgt); -// tgt.setStatus(convertEncounterState(src.getStatus())); -// tgt.setPeriod(convertPeriod(src.getPeriod())); -// return tgt; -// } - -// public org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent convertEncounterStatusHistoryComponent(org.hl7.fhir.r4.model.Encounter.EncounterStatusHistoryComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent tgt = new org.hl7.fhir.instance.model.Encounter.EncounterStatusHistoryComponent(); -// copyElement(src, tgt); -// tgt.setStatus(convertEncounterState(src.getStatus())); -// tgt.setPeriod(convertPeriod(src.getPeriod())); -// return tgt; -// } - - public org.hl7.fhir.instance.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.r4.model.OperationOutcome.IssueType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INVALID: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INVALID; - case STRUCTURE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.STRUCTURE; - case REQUIRED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.REQUIRED; - case VALUE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.VALUE; - case INVARIANT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INVARIANT; - case SECURITY: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.SECURITY; - case LOGIN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.LOGIN; - case UNKNOWN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.UNKNOWN; - case EXPIRED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXPIRED; - case FORBIDDEN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.FORBIDDEN; - case SUPPRESSED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.SUPPRESSED; - case PROCESSING: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.PROCESSING; - case NOTSUPPORTED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOTSUPPORTED; - case DUPLICATE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.DUPLICATE; - case NOTFOUND: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOTFOUND; - case TOOLONG: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TOOLONG; - case CODEINVALID: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.CODEINVALID; - case EXTENSION: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXTENSION; - case TOOCOSTLY: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TOOCOSTLY; - case BUSINESSRULE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.BUSINESSRULE; - case CONFLICT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.CONFLICT; - case INCOMPLETE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INCOMPLETE; - case TRANSIENT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TRANSIENT; - case LOCKERROR: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.LOCKERROR; - case NOSTORE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOSTORE; - case EXCEPTION: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXCEPTION; - case TIMEOUT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TIMEOUT; - case THROTTLED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.THROTTLED; - case INFORMATIONAL: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INFORMATIONAL; - default: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NULL; - } - } - - public org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent(); - copyElement(src, tgt); - tgt.setSequenceLinkId(src.getSequenceLinkId()); - return tgt; - } - - public org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent(); - copyElement(src, tgt); - tgt.setSequenceLinkId(src.getSequenceLinkId()); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.instance.model.Contract.LegalLanguageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.r4.model.Contract.LegalLanguageComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.LegalLanguageComponent convertLegalLanguageComponent(org.hl7.fhir.r4.model.Contract.LegalLanguageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.LegalLanguageComponent tgt = new org.hl7.fhir.instance.model.Contract.LegalLanguageComponent(); - copyElement(src, tgt); - tgt.setContent(convertType(src.getContent())); - return tgt; - } - - public org.hl7.fhir.r4.model.Patient.LinkType convertLinkType(org.hl7.fhir.instance.model.Patient.LinkType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REPLACE: return org.hl7.fhir.r4.model.Patient.LinkType.REPLACEDBY; - case REFER: return org.hl7.fhir.r4.model.Patient.LinkType.REFER; - case SEEALSO: return org.hl7.fhir.r4.model.Patient.LinkType.SEEALSO; - default: return org.hl7.fhir.r4.model.Patient.LinkType.NULL; - } - } - - public org.hl7.fhir.instance.model.Patient.LinkType convertLinkType(org.hl7.fhir.r4.model.Patient.LinkType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REPLACEDBY: return org.hl7.fhir.instance.model.Patient.LinkType.REPLACE; - case REPLACES: return org.hl7.fhir.instance.model.Patient.LinkType.REPLACE; - case REFER: return org.hl7.fhir.instance.model.Patient.LinkType.REFER; - case SEEALSO: return org.hl7.fhir.instance.model.Patient.LinkType.SEEALSO; - default: return org.hl7.fhir.instance.model.Patient.LinkType.NULL; - } - } - - public org.hl7.fhir.r4.model.ListResource convertList(org.hl7.fhir.instance.model.List_ src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ListResource tgt = new org.hl7.fhir.r4.model.ListResource(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setTitle(src.getTitle()); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setSubject(convertReference(src.getSubject())); - tgt.setSource(convertReference(src.getSource())); - tgt.setEncounter(convertReference(src.getEncounter())); - tgt.setStatus(convertListStatus(src.getStatus())); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); - tgt.setMode(convertListMode(src.getMode())); - if (src.hasNote()) - tgt.addNote(new org.hl7.fhir.r4.model.Annotation().setText(src.getNote())); - for (org.hl7.fhir.instance.model.List_.ListEntryComponent t : src.getEntry()) - tgt.addEntry(convertListEntry(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.List_ convertList(org.hl7.fhir.r4.model.ListResource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.List_ tgt = new org.hl7.fhir.instance.model.List_(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setTitle(src.getTitle()); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setSubject(convertReference(src.getSubject())); - tgt.setSource(convertReference(src.getSource())); - tgt.setEncounter(convertReference(src.getEncounter())); - tgt.setStatus(convertListStatus(src.getStatus())); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); - tgt.setMode(convertListMode(src.getMode())); - for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) - tgt.setNote(t.getText()); - for (org.hl7.fhir.r4.model.ListResource.ListEntryComponent t : src.getEntry()) - tgt.addEntry(convertListEntry(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ListResource.ListEntryComponent convertListEntry(org.hl7.fhir.instance.model.List_.ListEntryComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.r4.model.ListResource.ListEntryComponent(); - copyBackboneElement(src, tgt); - tgt.setFlag(convertCodeableConcept(src.getFlag())); - tgt.setDeleted(src.getDeleted()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setItem(convertReference(src.getItem())); - return tgt; - } - - public org.hl7.fhir.instance.model.List_.ListEntryComponent convertListEntry(org.hl7.fhir.r4.model.ListResource.ListEntryComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.List_.ListEntryComponent tgt = new org.hl7.fhir.instance.model.List_.ListEntryComponent(); - copyBackboneElement(src, tgt); - tgt.setFlag(convertCodeableConcept(src.getFlag())); - tgt.setDeleted(src.getDeleted()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setItem(convertReference(src.getItem())); - return tgt; - } - - public org.hl7.fhir.r4.model.ListResource.ListMode convertListMode(org.hl7.fhir.instance.model.List_.ListMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case WORKING: return org.hl7.fhir.r4.model.ListResource.ListMode.WORKING; - case SNAPSHOT: return org.hl7.fhir.r4.model.ListResource.ListMode.SNAPSHOT; - case CHANGES: return org.hl7.fhir.r4.model.ListResource.ListMode.CHANGES; - default: return org.hl7.fhir.r4.model.ListResource.ListMode.NULL; - } - } - - public org.hl7.fhir.instance.model.List_.ListMode convertListMode(org.hl7.fhir.r4.model.ListResource.ListMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case WORKING: return org.hl7.fhir.instance.model.List_.ListMode.WORKING; - case SNAPSHOT: return org.hl7.fhir.instance.model.List_.ListMode.SNAPSHOT; - case CHANGES: return org.hl7.fhir.instance.model.List_.ListMode.CHANGES; - default: return org.hl7.fhir.instance.model.List_.ListMode.NULL; - } - } - - public org.hl7.fhir.r4.model.ListResource.ListStatus convertListStatus(org.hl7.fhir.instance.model.List_.ListStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CURRENT: return org.hl7.fhir.r4.model.ListResource.ListStatus.CURRENT; - case RETIRED: return org.hl7.fhir.r4.model.ListResource.ListStatus.RETIRED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.ListResource.ListStatus.ENTEREDINERROR; - default: return org.hl7.fhir.r4.model.ListResource.ListStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.List_.ListStatus convertListStatus(org.hl7.fhir.r4.model.ListResource.ListStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CURRENT: return org.hl7.fhir.instance.model.List_.ListStatus.CURRENT; - case RETIRED: return org.hl7.fhir.instance.model.List_.ListStatus.RETIRED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.List_.ListStatus.ENTEREDINERROR; - default: return org.hl7.fhir.instance.model.List_.ListStatus.NULL; - } - } public org.hl7.fhir.r4.model.Location convertLocation(org.hl7.fhir.instance.model.Location src) throws FHIRException { if (src == null || src.isEmpty()) @@ -6978,6 +7887,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.instance.model.Location.LocationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.ACTIVE; + case SUSPENDED: return org.hl7.fhir.r4.model.Location.LocationStatus.SUSPENDED; + case INACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.INACTIVE; + default: return org.hl7.fhir.r4.model.Location.LocationStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.r4.model.Location.LocationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.instance.model.Location.LocationStatus.ACTIVE; + case SUSPENDED: return org.hl7.fhir.instance.model.Location.LocationStatus.SUSPENDED; + case INACTIVE: return org.hl7.fhir.instance.model.Location.LocationStatus.INACTIVE; + default: return org.hl7.fhir.instance.model.Location.LocationStatus.NULL; + } + } + public org.hl7.fhir.r4.model.Location.LocationMode convertLocationMode(org.hl7.fhir.instance.model.Location.LocationMode src) throws FHIRException { if (src == null) return null; @@ -7020,78 +7951,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.instance.model.Location.LocationStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.ACTIVE; - case SUSPENDED: return org.hl7.fhir.r4.model.Location.LocationStatus.SUSPENDED; - case INACTIVE: return org.hl7.fhir.r4.model.Location.LocationStatus.INACTIVE; - default: return org.hl7.fhir.r4.model.Location.LocationStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Location.LocationStatus convertLocationStatus(org.hl7.fhir.r4.model.Location.LocationStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ACTIVE: return org.hl7.fhir.instance.model.Location.LocationStatus.ACTIVE; - case SUSPENDED: return org.hl7.fhir.instance.model.Location.LocationStatus.SUSPENDED; - case INACTIVE: return org.hl7.fhir.instance.model.Location.LocationStatus.INACTIVE; - default: return org.hl7.fhir.instance.model.Location.LocationStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.instance.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.instance.model.MarkdownType tgt = new org.hl7.fhir.instance.model.MarkdownType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OTHER: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OTHER; - case CHEMICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.CHEMICAL; - case ELECTRICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL; - case IMPEDANCE: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE; - case NUCLEAR: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NUCLEAR; - case OPTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.OPTICAL; - case THERMAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.THERMAL; - case BIOLOGICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL; - case MECHANICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MECHANICAL; - case ACOUSTICAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL; - case MANUAL: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.MANUAL; - default: return org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple.NULL; - } - } - - public org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple convertMeasmntPrinciple(org.hl7.fhir.r4.model.DeviceComponent.MeasmntPrinciple src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OTHER: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.OTHER; - case CHEMICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.CHEMICAL; - case ELECTRICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.ELECTRICAL; - case IMPEDANCE: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.IMPEDANCE; - case NUCLEAR: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.NUCLEAR; - case OPTICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.OPTICAL; - case THERMAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.THERMAL; - case BIOLOGICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.BIOLOGICAL; - case MECHANICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.MECHANICAL; - case ACOUSTICAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.ACOUSTICAL; - case MANUAL: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.MANUAL; - default: return org.hl7.fhir.instance.model.DeviceComponent.MeasmntPrinciple.NULL; - } - } - public org.hl7.fhir.r4.model.Media convertMedia(org.hl7.fhir.instance.model.Media src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -7134,6 +7993,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.instance.model.Media.DigitalMediaType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PHOTO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.PHOTO; + case VIDEO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.VIDEO; + case AUDIO: return org.hl7.fhir.r4.model.Media.DigitalMediaType.AUDIO; + default: return org.hl7.fhir.r4.model.Media.DigitalMediaType.NULL; + } + } + + public org.hl7.fhir.instance.model.Media.DigitalMediaType convertDigitalMediaType(org.hl7.fhir.r4.model.Media.DigitalMediaType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PHOTO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.PHOTO; + case VIDEO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.VIDEO; + case AUDIO: return org.hl7.fhir.instance.model.Media.DigitalMediaType.AUDIO; + default: return org.hl7.fhir.instance.model.Media.DigitalMediaType.NULL; + } + } + public org.hl7.fhir.r4.model.Medication convertMedication(org.hl7.fhir.instance.model.Medication src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -7160,1128 +8041,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.instance.model.MedicationDispense src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MedicationDispense tgt = new org.hl7.fhir.r4.model.MedicationDispense(); - copyDomainResource(src, tgt); - tgt.addIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setStatus(convertMedicationDispenseStatus(src.getStatus())); - tgt.setMedication(convertType(src.getMedication())); - tgt.setSubject(convertReference(src.getPatient())); -// tgt.setDispenser(convertReference(src.getDispenser())); - for (org.hl7.fhir.instance.model.Reference t : src.getAuthorizingPrescription()) - tgt.addAuthorizingPrescription(convertReference(t)); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply())); - tgt.setWhenPrepared(src.getWhenPrepared()); - tgt.setWhenHandedOver(src.getWhenHandedOver()); - tgt.setDestination(convertReference(src.getDestination())); - for (org.hl7.fhir.instance.model.Reference t : src.getReceiver()) - tgt.addReceiver(convertReference(t)); - if (src.hasNote()) - tgt.addNote().setText(src.getNote()); - for (org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent t : src.getDosageInstruction()) - tgt.addDosageInstruction(convertMedicationDispenseDosageInstructionComponent(t)); - tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution())); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.r4.model.MedicationDispense src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationDispense tgt = new org.hl7.fhir.instance.model.MedicationDispense(); - copyDomainResource(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifierFirstRep())); - tgt.setStatus(convertMedicationDispenseStatus(src.getStatus())); - tgt.setMedication(convertType(src.getMedication())); - tgt.setPatient(convertReference(src.getSubject())); -// tgt.setDispenser(convertReference(src.getDispenser())); - for (org.hl7.fhir.r4.model.Reference t : src.getAuthorizingPrescription()) - tgt.addAuthorizingPrescription(convertReference(t)); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply())); - tgt.setWhenPrepared(src.getWhenPrepared()); - tgt.setWhenHandedOver(src.getWhenHandedOver()); - tgt.setDestination(convertReference(src.getDestination())); - for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) - tgt.addReceiver(convertReference(t)); - for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) - tgt.setNote(t.getText()); - for (org.hl7.fhir.r4.model.Dosage t : src.getDosageInstruction()) - tgt.addDosageInstruction(convertMedicationDispenseDosageInstructionComponent(t)); - tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution())); - return tgt; - } - - public org.hl7.fhir.r4.model.Dosage convertMedicationDispenseDosageInstructionComponent(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyElement(src, tgt); - tgt.setText(src.getText()); -// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setDose(convertType(src.getDose())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent convertMedicationDispenseDosageInstructionComponent(Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent tgt = new org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent(); - copyElement(src, tgt); - tgt.setText(src.getText()); -// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - tgt.setSite(convertType(src.getSite())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setDose(convertType(src.getDose())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS; - case ONHOLD: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ONHOLD; - case COMPLETED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR; - case STOPPED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.STOPPED; - default: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS; - case ONHOLD: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.ONHOLD; - case COMPLETED: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR; - case STOPPED: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.STOPPED; - default: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent(); - copyElement(src, tgt); - tgt.setType(convertCodeableConcept(src.getType())); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getReason()) - tgt.addReason(convertCodeableConcept(t)); - for (org.hl7.fhir.instance.model.Reference t : src.getResponsibleParty()) - tgt.addResponsibleParty(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent(); - copyElement(src, tgt); - tgt.setType(convertCodeableConcept(src.getType())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason()) - tgt.addReason(convertCodeableConcept(t)); - for (org.hl7.fhir.r4.model.Reference t : src.getResponsibleParty()) - tgt.addResponsibleParty(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyElement(src, tgt); - tgt.setText(src.getText()); -// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setDose(convertType(src.getDose())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); - copyElement(src, tgt); - tgt.setText(src.getText()); -// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - tgt.setSite(convertType(src.getSite())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setDose(convertType(src.getDose())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.instance.model.Medication.MedicationPackageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageComponent(); - copyElement(src, tgt); - tgt.setContainer(convertCodeableConcept(src.getContainer())); - for (org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent t : src.getContent()) - tgt.addContent(convertMedicationPackageContentComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.instance.model.Medication.MedicationPackageComponent(); - copyElement(src, tgt); - tgt.setContainer(convertCodeableConcept(src.getContainer())); - for (org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent t : src.getContent()) - tgt.addContent(convertMedicationPackageContentComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent(); - copyElement(src, tgt); - tgt.setItem(convertType(src.getItem())); - tgt.setAmount(convertSimpleQuantity(src.getAmount())); - return tgt; - } - - public org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent(); - copyElement(src, tgt); - if (src.hasItemReference()) - tgt.setItem((org.hl7.fhir.instance.model.Reference) convertType(src.getItem())); - tgt.setAmount(convertSimpleQuantity(src.getAmount())); - return tgt; - } - - public org.hl7.fhir.r4.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.instance.model.MedicationStatement src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MedicationStatement tgt = new org.hl7.fhir.r4.model.MedicationStatement(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setStatus(convertMedicationStatementStatus(src.getStatus())); - tgt.setMedication(convertType(src.getMedication())); - tgt.setSubject(convertReference(src.getPatient())); - tgt.setEffective(convertType(src.getEffective())); - tgt.setInformationSource(convertReference(src.getInformationSource())); - for (org.hl7.fhir.instance.model.Reference t : src.getSupportingInformation()) - tgt.addDerivedFrom(convertReference(t)); - if (src.hasDateAsserted()) - tgt.setDateAsserted(src.getDateAsserted()); -// tgt.getNotTakenElement().setValueAsString(src.getWasNotTaken() ? "Y" : "N"); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getReasonNotTaken()) - tgt.addReasonNotTaken(convertCodeableConcept(t)); -// tgt.setReasonForUse(convertType(src.getReasonForUse())); - if (src.hasNote()) - tgt.addNote().setText(src.getNote()); - for (org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent t : src.getDosage()) - tgt.addDosage(convertMedicationStatementDosageComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.r4.model.MedicationStatement src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationStatement tgt = new org.hl7.fhir.instance.model.MedicationStatement(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setStatus(convertMedicationStatementStatus(src.getStatus())); - tgt.setMedication(convertType(src.getMedication())); - tgt.setPatient(convertReference(src.getSubject())); - tgt.setEffective(convertType(src.getEffective())); - tgt.setInformationSource(convertReference(src.getInformationSource())); - for (org.hl7.fhir.r4.model.Reference t : src.getDerivedFrom()) - tgt.addSupportingInformation(convertReference(t)); - if (src.hasDateAsserted()) - tgt.setDateAsserted(src.getDateAsserted()); -// tgt.setWasNotTaken("Y".equals(src.getNotTakenElement().getValueAsString())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonNotTaken()) - tgt.addReasonNotTaken(convertCodeableConcept(t)); -// tgt.setReasonForUse(convertType(src.getReasonForUse())); - for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) - tgt.setNote(t.getText()); - for (org.hl7.fhir.r4.model.Dosage t : src.getDosage()) - tgt.addDosage(convertMedicationStatementDosageComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Dosage convertMedicationStatementDosageComponent(org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyElement(src, tgt); - tgt.setText(src.getText()); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); -// tgt.setQuantity(convertType(src.getQuantity())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent convertMedicationStatementDosageComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent tgt = new org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent(); - copyElement(src, tgt); - tgt.setText(src.getText()); - tgt.setTiming(convertTiming(src.getTiming())); - tgt.setAsNeeded(convertType(src.getAsNeeded())); - tgt.setSite(convertType(src.getSite())); - tgt.setRoute(convertCodeableConcept(src.getRoute())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); -// tgt.setQuantity(convertType(src.getQuantity())); - tgt.setRate(convertType(src.getRate())); - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ACTIVE: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ACTIVE; - case COMPLETED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR; - case INTENDED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.INTENDED; - default: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ACTIVE: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.ACTIVE; - case COMPLETED: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR; - case INTENDED: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.INTENDED; - default: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setTarget(convertReference(src.getTarget())); - tgt.setEndpoint(src.getEndpoint()); - return tgt; - } - - public org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setTarget(convertReference(src.getTarget())); - tgt.setEndpoint(src.getEndpoint()); - return tgt; - } - - public org.hl7.fhir.r4.model.MessageHeader convertMessageHeader(org.hl7.fhir.instance.model.MessageHeader src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MessageHeader tgt = new org.hl7.fhir.r4.model.MessageHeader(); - copyDomainResource(src, tgt); - tgt.setTimestamp(src.getTimestamp()); - tgt.setEvent(convertCoding(src.getEvent())); - tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); - tgt.setSource(convertMessageSourceComponent(src.getSource())); - for (org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) - tgt.addDestination(convertMessageDestinationComponent(t)); - tgt.setEnterer(convertReference(src.getEnterer())); - tgt.setAuthor(convertReference(src.getAuthor())); - tgt.setResponsible(convertReference(src.getResponsible())); - tgt.setReason(convertCodeableConcept(src.getReason())); - for (org.hl7.fhir.instance.model.Reference t : src.getData()) - tgt.addFocus(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.MessageHeader convertMessageHeader(org.hl7.fhir.r4.model.MessageHeader src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MessageHeader tgt = new org.hl7.fhir.instance.model.MessageHeader(); - copyDomainResource(src, tgt); - tgt.setTimestamp(src.getTimestamp()); - tgt.setEvent(convertCoding(src.getEvent())); - tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); - tgt.setSource(convertMessageSourceComponent(src.getSource())); - for (org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) - tgt.addDestination(convertMessageDestinationComponent(t)); - tgt.setEnterer(convertReference(src.getEnterer())); - tgt.setAuthor(convertReference(src.getAuthor())); - tgt.setResponsible(convertReference(src.getResponsible())); - tgt.setReason(convertCodeableConcept(src.getReason())); - for (org.hl7.fhir.r4.model.Reference t : src.getFocus()) - tgt.addData(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent(); - copyElement(src, tgt); - tgt.setIdentifier(src.getIdentifier()); - tgt.setCode(convertResponseType(src.getCode())); - tgt.setDetails(convertReference(src.getDetails())); - return tgt; - } - - public org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent(); - copyElement(src, tgt); - tgt.setIdentifier(src.getIdentifier()); - tgt.setCode(convertResponseType(src.getCode())); - tgt.setDetails(convertReference(src.getDetails())); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CONSEQUENCE: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CONSEQUENCE; - case CURRENCY: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.CURRENCY; - case NOTIFICATION: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NOTIFICATION; - default: return org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory convertMessageSignificanceCategory(org.hl7.fhir.r4.model.CapabilityStatement.MessageSignificanceCategory src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CONSEQUENCE: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.CONSEQUENCE; - case CURRENCY: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.CURRENCY; - case NOTIFICATION: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.NOTIFICATION; - default: return org.hl7.fhir.instance.model.Conformance.MessageSignificanceCategory.NULL; - } - } - - public org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setSoftware(src.getSoftware()); - tgt.setVersion(src.getVersion()); - tgt.setContact(convertContactPoint(src.getContact())); - tgt.setEndpoint(src.getEndpoint()); - return tgt; - } - - public org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setSoftware(src.getSoftware()); - tgt.setVersion(src.getVersion()); - tgt.setContact(convertContactPoint(src.getContact())); - tgt.setEndpoint(src.getEndpoint()); - return tgt; - } - - public org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.instance.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); - copyElement(src, tgt); - tgt.setVersionId(src.getVersionId()); - tgt.setLastUpdated(src.getLastUpdated()); - for (org.hl7.fhir.instance.model.UriType t : src.getProfile()) - tgt.addProfile(t.getValue()); - for (org.hl7.fhir.instance.model.Coding t : src.getSecurity()) - tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.instance.model.Coding t : src.getTag()) - tgt.addTag(convertCoding(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Meta tgt = new org.hl7.fhir.instance.model.Meta(); - copyElement(src, tgt); - tgt.setVersionId(src.getVersionId()); - tgt.setLastUpdated(src.getLastUpdated()); - for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) - tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) - tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) - tgt.addTag(convertCoding(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.instance.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.instance.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Money tgt = new org.hl7.fhir.instance.model.Money(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.r4.model.HumanName.NameUse convertNameUse(org.hl7.fhir.instance.model.HumanName.NameUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case USUAL: return org.hl7.fhir.r4.model.HumanName.NameUse.USUAL; - case OFFICIAL: return org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL; - case TEMP: return org.hl7.fhir.r4.model.HumanName.NameUse.TEMP; - case NICKNAME: return org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME; - case ANONYMOUS: return org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS; - case OLD: return org.hl7.fhir.r4.model.HumanName.NameUse.OLD; - case MAIDEN: return org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN; - default: return org.hl7.fhir.r4.model.HumanName.NameUse.NULL; - } - } - - public org.hl7.fhir.instance.model.HumanName.NameUse convertNameUse(org.hl7.fhir.r4.model.HumanName.NameUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case USUAL: return org.hl7.fhir.instance.model.HumanName.NameUse.USUAL; - case OFFICIAL: return org.hl7.fhir.instance.model.HumanName.NameUse.OFFICIAL; - case TEMP: return org.hl7.fhir.instance.model.HumanName.NameUse.TEMP; - case NICKNAME: return org.hl7.fhir.instance.model.HumanName.NameUse.NICKNAME; - case ANONYMOUS: return org.hl7.fhir.instance.model.HumanName.NameUse.ANONYMOUS; - case OLD: return org.hl7.fhir.instance.model.HumanName.NameUse.OLD; - case MAIDEN: return org.hl7.fhir.instance.model.HumanName.NameUse.MAIDEN; - default: return org.hl7.fhir.instance.model.HumanName.NameUse.NULL; - } - } - - public org.hl7.fhir.r4.model.NamingSystem convertNamingSystem(org.hl7.fhir.instance.model.NamingSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.NamingSystem tgt = new org.hl7.fhir.r4.model.NamingSystem(); - copyDomainResource(src, tgt); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setKind(convertNamingSystemType(src.getKind())); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent t : src.getContact()) - tgt.addContact(convertNamingSystemContactComponent(t)); - tgt.setResponsible(src.getResponsible()); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) - if (isJurisdiction(t)) - tgt.addJurisdiction(convertCodeableConcept(t)); - else - tgt.addUseContext(convertCodeableConceptToUsageContext(t)); - tgt.setUsage(src.getUsage()); - for (org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) - tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); - tgt.setReplacedBy(convertReference(src.getReplacedBy())); - return tgt; - } - - public org.hl7.fhir.instance.model.NamingSystem convertNamingSystem(org.hl7.fhir.r4.model.NamingSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.NamingSystem tgt = new org.hl7.fhir.instance.model.NamingSystem(); - copyDomainResource(src, tgt); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setKind(convertNamingSystemType(src.getKind())); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertNamingSystemContactComponent(t)); - tgt.setResponsible(src.getResponsible()); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) - if (t.hasValueCodeableConcept()) - tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) - tgt.addUseContext(convertCodeableConcept(t)); - tgt.setUsage(src.getUsage()); - for (org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) - tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); - tgt.setReplacedBy(convertReference(src.getReplacedBy())); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertNamingSystemContactComponent(org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent convertNamingSystemContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent tgt = new org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OID; - case UUID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.UUID; - case URI: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.URI; - case OTHER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OTHER; - default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.NULL; - } - } - - public org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OID: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.OID; - case UUID: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.UUID; - case URI: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.URI; - case OTHER: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.OTHER; - default: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.NULL; - } - } - - public org.hl7.fhir.r4.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.instance.model.NamingSystem.NamingSystemType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CODESYSTEM: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.CODESYSTEM; - case IDENTIFIER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.IDENTIFIER; - case ROOT: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.ROOT; - default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.NULL; - } - } - - public org.hl7.fhir.instance.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CODESYSTEM: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.CODESYSTEM; - case IDENTIFIER: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.IDENTIFIER; - case ROOT: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.ROOT; - default: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.NULL; - } - } - - public org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent(); - copyElement(src, tgt); - tgt.setType(convertNamingSystemIdentifierType(src.getType())); - tgt.setValue(src.getValue()); - tgt.setPreferred(src.getPreferred()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent(); - copyElement(src, tgt); - tgt.setType(convertNamingSystemIdentifierType(src.getType())); - tgt.setValue(src.getValue()); - tgt.setPreferred(src.getPreferred()); - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.instance.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); - copyElement(src, tgt); - tgt.setStatus(convertNarrativeStatus(src.getStatus())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - public org.hl7.fhir.instance.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Narrative tgt = new org.hl7.fhir.instance.model.Narrative(); - copyElement(src, tgt); - tgt.setStatus(convertNarrativeStatus(src.getStatus())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - public org.hl7.fhir.r4.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.instance.model.Narrative.NarrativeStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case GENERATED: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED; - case EXTENSIONS: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS; - case ADDITIONAL: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL; - case EMPTY: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY; - default: return org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Narrative.NarrativeStatus convertNarrativeStatus(org.hl7.fhir.r4.model.Narrative.NarrativeStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case GENERATED: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.GENERATED; - case EXTENSIONS: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.EXTENSIONS; - case ADDITIONAL: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.ADDITIONAL; - case EMPTY: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.EMPTY; - default: return org.hl7.fhir.instance.model.Narrative.NarrativeStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.Observation convertObservation(org.hl7.fhir.instance.model.Observation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Observation tgt = new org.hl7.fhir.r4.model.Observation(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setStatus(convertObservationStatus(src.getStatus())); - tgt.addCategory(convertCodeableConcept(src.getCategory())); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setSubject(convertReference(src.getSubject())); - tgt.setContext(convertReference(src.getEncounter())); - tgt.setEffective(convertType(src.getEffective())); - tgt.setIssued(src.getIssued()); - for (org.hl7.fhir.instance.model.Reference t : src.getPerformer()) - tgt.addPerformer(convertReference(t)); - tgt.setValue(convertType(src.getValue())); - tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); - tgt.setInterpretation(convertCodeableConcept(src.getInterpretation())); - tgt.setComment(src.getComments()); - tgt.setBodySite(convertCodeableConcept(src.getBodySite())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setSpecimen(convertReference(src.getSpecimen())); - tgt.setDevice(convertReference(src.getDevice())); - for (org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) - tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); - for (org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent t : src.getRelated()) - tgt.addRelated(convertObservationRelatedComponent(t)); - for (org.hl7.fhir.instance.model.Observation.ObservationComponentComponent t : src.getComponent()) - tgt.addComponent(convertObservationComponentComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Observation convertObservation(org.hl7.fhir.r4.model.Observation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Observation tgt = new org.hl7.fhir.instance.model.Observation(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setStatus(convertObservationStatus(src.getStatus())); - for (org.hl7.fhir.r4.model.CodeableConcept c : src.getCategory()) - tgt.setCategory(convertCodeableConcept(c)); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setSubject(convertReference(src.getSubject())); - tgt.setEncounter(convertReference(src.getContext())); - tgt.setEffective(convertType(src.getEffective())); - tgt.setIssued(src.getIssued()); - for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) - tgt.addPerformer(convertReference(t)); - tgt.setValue(convertType(src.getValue())); - tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); - tgt.setInterpretation(convertCodeableConcept(src.getInterpretation())); - tgt.setComments(src.getComment()); - tgt.setBodySite(convertCodeableConcept(src.getBodySite())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - tgt.setSpecimen(convertReference(src.getSpecimen())); - tgt.setDevice(convertReference(src.getDevice())); - for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) - tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); - for (org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent t : src.getRelated()) - tgt.addRelated(convertObservationRelatedComponent(t)); - for (org.hl7.fhir.r4.model.Observation.ObservationComponentComponent t : src.getComponent()) - tgt.addComponent(convertObservationComponentComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.instance.model.Observation.ObservationComponentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationComponentComponent(); - copyElement(src, tgt); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setValue(convertType(src.getValue())); - tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); - for (org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) - tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationComponentComponent(); - copyElement(src, tgt); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setValue(convertType(src.getValue())); - tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); - for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) - tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent(); - copyElement(src, tgt); - tgt.setLow(convertSimpleQuantity(src.getLow())); - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - tgt.setType(convertCodeableConcept(src.getMeaning())); - tgt.setAge(convertRange(src.getAge())); - tgt.setText(src.getText()); - return tgt; - } - - public org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent(); - copyElement(src, tgt); - tgt.setLow(convertSimpleQuantity(src.getLow())); - tgt.setHigh(convertSimpleQuantity(src.getHigh())); -// for (org.hl7.fhir.r4.model.CodeableConcept c : src.getMeaning()) - tgt.setMeaning(convertCodeableConcept(src.getType())); - tgt.setAge(convertRange(src.getAge())); - tgt.setText(src.getText()); - return tgt; - } - - public org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent(); - copyElement(src, tgt); - tgt.setType(convertObservationRelationshipType(src.getType())); - tgt.setTarget(convertReference(src.getTarget())); - return tgt; - } - - public org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent(); - copyElement(src, tgt); - tgt.setType(convertObservationRelationshipType(src.getType())); - tgt.setTarget(convertReference(src.getTarget())); - return tgt; - } - - public org.hl7.fhir.r4.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.instance.model.Observation.ObservationRelationshipType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HASMEMBER: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.HASMEMBER; - case DERIVEDFROM: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.DERIVEDFROM; - case SEQUELTO: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.SEQUELTO; - case REPLACES: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.REPLACES; - case QUALIFIEDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.QUALIFIEDBY; - case INTERFEREDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.INTERFEREDBY; - default: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.NULL; - } - } - - public org.hl7.fhir.instance.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.r4.model.Observation.ObservationRelationshipType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case HASMEMBER: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.HASMEMBER; - case DERIVEDFROM: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.DERIVEDFROM; - case SEQUELTO: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.SEQUELTO; - case REPLACES: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.REPLACES; - case QUALIFIEDBY: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.QUALIFIEDBY; - case INTERFEREDBY: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.INTERFEREDBY; - default: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.NULL; - } - } - - public org.hl7.fhir.r4.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.instance.model.Observation.ObservationStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REGISTERED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.REGISTERED; - case PRELIMINARY: return org.hl7.fhir.r4.model.Observation.ObservationStatus.PRELIMINARY; - case FINAL: return org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL; - case AMENDED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.AMENDED; - case CANCELLED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.CANCELLED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR; - case UNKNOWN: return org.hl7.fhir.r4.model.Observation.ObservationStatus.UNKNOWN; - default: return org.hl7.fhir.r4.model.Observation.ObservationStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.r4.model.Observation.ObservationStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REGISTERED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.REGISTERED; - case PRELIMINARY: return org.hl7.fhir.instance.model.Observation.ObservationStatus.PRELIMINARY; - case FINAL: return org.hl7.fhir.instance.model.Observation.ObservationStatus.FINAL; - case AMENDED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.AMENDED; - case CANCELLED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.CANCELLED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Observation.ObservationStatus.ENTEREDINERROR; - case UNKNOWN: return org.hl7.fhir.instance.model.Observation.ObservationStatus.UNKNOWN; - default: return org.hl7.fhir.instance.model.Observation.ObservationStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.instance.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.instance.model.OidType tgt = new org.hl7.fhir.instance.model.OidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.instance.model.OperationDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.OperationDefinition tgt = new org.hl7.fhir.r4.model.OperationDefinition(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setKind(convertOperationKind(src.getKind())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent t : src.getContact()) - tgt.addContact(convertOperationDefinitionContactComponent(t)); - tgt.setDescription(src.getDescription()); - tgt.setPurpose(src.getRequirements()); - if (src.hasIdempotent()) - tgt.setIdempotent(src.getIdempotent()); - tgt.setCode(src.getCode()); - tgt.setComment(src.getNotes()); - tgt.setBase(convertReference(src.getBase())); - tgt.setSystem(src.getSystem()); - for (org.hl7.fhir.instance.model.CodeType t : src.getType()) - tgt.addResource(t.getValue()); - tgt.setType(tgt.hasResource()); - tgt.setInstance(src.getInstance()); - for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) - tgt.addParameter(convertOperationDefinitionParameterComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.r4.model.OperationDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationDefinition tgt = new org.hl7.fhir.instance.model.OperationDefinition(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setKind(convertOperationKind(src.getKind())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertOperationDefinitionContactComponent(t)); - tgt.setDescription(src.getDescription()); - tgt.setRequirements(src.getPurpose()); - tgt.setIdempotent(src.getIdempotent()); - tgt.setCode(src.getCode()); - tgt.setNotes(src.getComment()); - if (src.hasBase()) - tgt.setBase(convertReference(src.getBase())); - tgt.setSystem(src.getSystem()); - if (src.getType()) - for (org.hl7.fhir.r4.model.CodeType t : src.getResource()) - tgt.addType(t.getValue()); - tgt.setInstance(src.getInstance()); - for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) - tgt.addParameter(convertOperationDefinitionParameterComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertOperationDefinitionContactComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent convertOperationDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); - copyElement(src, tgt); - tgt.setStrength(convertBindingStrength(src.getStrength())); - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); - copyElement(src, tgt); - tgt.setStrength(convertBindingStrength(src.getStrength())); - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setUse(convertOperationParameterUse(src.getUse())); - tgt.setMin(src.getMin()); - tgt.setMax(src.getMax()); - tgt.setDocumentation(src.getDocumentation()); - tgt.setType(src.getType()); - tgt.setProfile(convertReference(src.getProfile())); - tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); - for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) - tgt.addPart(convertOperationDefinitionParameterComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setUse(convertOperationParameterUse(src.getUse())); - tgt.setMin(src.getMin()); - tgt.setMax(src.getMax()); - tgt.setDocumentation(src.getDocumentation()); - if (src.hasSearchType()) { - tgt.setType(src.getSearchType().toCode()); - tgt.setType("string"); - } else - tgt.setType(src.getType()); - if (src.hasProfile()) - tgt.setProfile(convertReference(src.getProfile())); - if (src.hasBinding()) - tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) - tgt.addPart(convertOperationDefinitionParameterComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.instance.model.OperationDefinition.OperationKind src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OPERATION: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.OPERATION; - case QUERY: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.QUERY; - default: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.NULL; - } - } - // public org.hl7.fhir.r4.model.Medication.MedicationProductComponent convertMedicationProductComponent(org.hl7.fhir.instance.model.Medication.MedicationProductComponent src) throws FHIRException { // if (src == null || src.isEmpty()) // return null; @@ -8349,158 +8108,191 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen // return tgt; // } - public org.hl7.fhir.instance.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.r4.model.OperationDefinition.OperationKind src) throws FHIRException { + public org.hl7.fhir.r4.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.instance.model.Medication.MedicationPackageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageComponent(); + copyElement(src, tgt); + tgt.setContainer(convertCodeableConcept(src.getContainer())); + for (org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent t : src.getContent()) + tgt.addContent(convertMedicationPackageContentComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.instance.model.Medication.MedicationPackageComponent(); + copyElement(src, tgt); + tgt.setContainer(convertCodeableConcept(src.getContainer())); + for (org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent t : src.getContent()) + tgt.addContent(convertMedicationPackageContentComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent(); + copyElement(src, tgt); + tgt.setItem(convertType(src.getItem())); + tgt.setAmount(convertSimpleQuantity(src.getAmount())); + return tgt; + } + + public org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.r4.model.Medication.MedicationPackageContentComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.instance.model.Medication.MedicationPackageContentComponent(); + copyElement(src, tgt); + if (src.hasItemReference()) + tgt.setItem((org.hl7.fhir.instance.model.Reference) convertType(src.getItem())); + tgt.setAmount(convertSimpleQuantity(src.getAmount())); + return tgt; + } + + public org.hl7.fhir.r4.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.instance.model.MedicationDispense src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.MedicationDispense tgt = new org.hl7.fhir.r4.model.MedicationDispense(); + copyDomainResource(src, tgt); + tgt.addIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setStatus(convertMedicationDispenseStatus(src.getStatus())); + tgt.setMedication(convertType(src.getMedication())); + tgt.setSubject(convertReference(src.getPatient())); +// tgt.setDispenser(convertReference(src.getDispenser())); + for (org.hl7.fhir.instance.model.Reference t : src.getAuthorizingPrescription()) + tgt.addAuthorizingPrescription(convertReference(t)); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply())); + tgt.setWhenPrepared(src.getWhenPrepared()); + tgt.setWhenHandedOver(src.getWhenHandedOver()); + tgt.setDestination(convertReference(src.getDestination())); + for (org.hl7.fhir.instance.model.Reference t : src.getReceiver()) + tgt.addReceiver(convertReference(t)); + if (src.hasNote()) + tgt.addNote().setText(src.getNote()); + for (org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent t : src.getDosageInstruction()) + tgt.addDosageInstruction(convertMedicationDispenseDosageInstructionComponent(t)); + tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution())); + return tgt; + } + + public org.hl7.fhir.instance.model.MedicationDispense convertMedicationDispense(org.hl7.fhir.r4.model.MedicationDispense src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MedicationDispense tgt = new org.hl7.fhir.instance.model.MedicationDispense(); + copyDomainResource(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifierFirstRep())); + tgt.setStatus(convertMedicationDispenseStatus(src.getStatus())); + tgt.setMedication(convertType(src.getMedication())); + tgt.setPatient(convertReference(src.getSubject())); +// tgt.setDispenser(convertReference(src.getDispenser())); + for (org.hl7.fhir.r4.model.Reference t : src.getAuthorizingPrescription()) + tgt.addAuthorizingPrescription(convertReference(t)); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + tgt.setDaysSupply(convertSimpleQuantity(src.getDaysSupply())); + tgt.setWhenPrepared(src.getWhenPrepared()); + tgt.setWhenHandedOver(src.getWhenHandedOver()); + tgt.setDestination(convertReference(src.getDestination())); + for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) + tgt.addReceiver(convertReference(t)); + for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) + tgt.setNote(t.getText()); + for (org.hl7.fhir.r4.model.Dosage t : src.getDosageInstruction()) + tgt.addDosageInstruction(convertMedicationDispenseDosageInstructionComponent(t)); + tgt.setSubstitution(convertMedicationDispenseSubstitutionComponent(src.getSubstitution())); + return tgt; + } + + public org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case OPERATION: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.OPERATION; - case QUERY: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.QUERY; - default: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.NULL; + case INPROGRESS: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS; + case ONHOLD: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ONHOLD; + case COMPLETED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR; + case STOPPED: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.STOPPED; + default: return org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus.NULL; } } - public org.hl7.fhir.r4.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.instance.model.OperationOutcome src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.OperationOutcome tgt = new org.hl7.fhir.r4.model.OperationOutcome(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue()) - tgt.addIssue(convertOperationOutcomeIssueComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r4.model.OperationOutcome src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationOutcome tgt = new org.hl7.fhir.instance.model.OperationOutcome(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue()) - tgt.addIssue(convertOperationOutcomeIssueComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent(); - copyElement(src, tgt); - tgt.setSeverity(convertIssueSeverity(src.getSeverity())); - tgt.setCode(convertIssueType(src.getCode())); - tgt.setDetails(convertCodeableConcept(src.getDetails())); - tgt.setDiagnostics(src.getDiagnostics()); - for (org.hl7.fhir.instance.model.StringType t : src.getLocation()) - tgt.addLocation(t.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent(); - copyElement(src, tgt); - tgt.setSeverity(convertIssueSeverity(src.getSeverity())); - tgt.setCode(convertIssueType(src.getCode())); - tgt.setDetails(convertCodeableConcept(src.getDetails())); - tgt.setDiagnostics(src.getDiagnostics()); - for (org.hl7.fhir.r4.model.StringType t : src.getLocation()) - tgt.addLocation(t.getValue()); - return tgt; - } - - public org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse src) throws FHIRException { + public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus convertMedicationDispenseStatus(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case IN: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.IN; - case OUT: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.OUT; - default: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.NULL; + case INPROGRESS: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.INPROGRESS; + case ONHOLD: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.ONHOLD; + case COMPLETED: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.ENTEREDINERROR; + case STOPPED: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.STOPPED; + default: return org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseStatus.NULL; } } - public org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case IN: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.IN; - case OUT: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.OUT; - default: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.NULL; - } - } - - public org.hl7.fhir.r4.model.Organization convertOrganization(org.hl7.fhir.instance.model.Organization src) throws FHIRException { + public org.hl7.fhir.r4.model.Dosage convertMedicationDispenseDosageInstructionComponent(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Organization tgt = new org.hl7.fhir.r4.model.Organization(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setActive(src.getActive()); - tgt.addType(convertCodeableConcept(src.getType())); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - for (org.hl7.fhir.instance.model.Address t : src.getAddress()) - tgt.addAddress(convertAddress(t)); - tgt.setPartOf(convertReference(src.getPartOf())); - for (org.hl7.fhir.instance.model.Organization.OrganizationContactComponent t : src.getContact()) - tgt.addContact(convertOrganizationContactComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Organization convertOrganization(org.hl7.fhir.r4.model.Organization src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Organization tgt = new org.hl7.fhir.instance.model.Organization(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setActive(src.getActive()); - tgt.setType(convertCodeableConcept(src.getTypeFirstRep())); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - for (org.hl7.fhir.r4.model.Address t : src.getAddress()) - tgt.addAddress(convertAddress(t)); - tgt.setPartOf(convertReference(src.getPartOf())); - for (org.hl7.fhir.r4.model.Organization.OrganizationContactComponent t : src.getContact()) - tgt.addContact(convertOrganizationContactComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.instance.model.Organization.OrganizationContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.r4.model.Organization.OrganizationContactComponent(); + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); copyElement(src, tgt); - tgt.setPurpose(convertCodeableConcept(src.getPurpose())); - tgt.setName(convertHumanName(src.getName())); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - tgt.setAddress(convertAddress(src.getAddress())); + tgt.setText(src.getText()); +// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) + tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setDose(convertType(src.getDose())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } - public org.hl7.fhir.instance.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent convertMedicationDispenseDosageInstructionComponent(Dosage src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.instance.model.Organization.OrganizationContactComponent(); + org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent tgt = new org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseDosageInstructionComponent(); copyElement(src, tgt); - tgt.setPurpose(convertCodeableConcept(src.getPurpose())); - tgt.setName(convertHumanName(src.getName())); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - tgt.setAddress(convertAddress(src.getAddress())); + tgt.setText(src.getText()); +// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + tgt.setSite(convertType(src.getSite())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setDose(convertType(src.getDose())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } - public org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent(); + org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent(); copyElement(src, tgt); - tgt.setProperty(src.getElement()); - tgt.setSystem(src.getCodeSystem()); - tgt.setCode(src.getCode()); + tgt.setType(convertCodeableConcept(src.getType())); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getReason()) + tgt.addReason(convertCodeableConcept(t)); + for (org.hl7.fhir.instance.model.Reference t : src.getResponsibleParty()) + tgt.addResponsibleParty(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent convertMedicationDispenseSubstitutionComponent(org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseSubstitutionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent tgt = new org.hl7.fhir.instance.model.MedicationDispense.MedicationDispenseSubstitutionComponent(); + copyElement(src, tgt); + tgt.setType(convertCodeableConcept(src.getType())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason()) + tgt.addReason(convertCodeableConcept(t)); + for (org.hl7.fhir.r4.model.Reference t : src.getResponsibleParty()) + tgt.addResponsibleParty(convertReference(t)); return tgt; } @@ -8592,24 +8384,40 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen // } // } - public org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent src) throws FHIRException { + public org.hl7.fhir.r4.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent(); + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); copyElement(src, tgt); - tgt.setElement(src.getProperty()); - tgt.setCodeSystem(src.getSystem()); - tgt.setCode(src.getCode()); + tgt.setText(src.getText()); +// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) + tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setDose(convertType(src.getDose())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } - public org.hl7.fhir.r4.model.Parameters convertParameters(org.hl7.fhir.instance.model.Parameters src) throws FHIRException { + public org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Parameters tgt = new org.hl7.fhir.r4.model.Parameters(); - copyResource(src, tgt); - for (org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent t : src.getParameter()) - tgt.addParameter(convertParametersParameterComponent(t)); + org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.instance.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); + copyElement(src, tgt); + tgt.setText(src.getText()); +// tgt.setAdditionalInstructions(convertCodeableConcept(src.getAdditionalInstructions())); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + tgt.setSite(convertType(src.getSite())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setDose(convertType(src.getDose())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } @@ -8659,114 +8467,1003 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen // return tgt; // } - public org.hl7.fhir.instance.model.Parameters convertParameters(org.hl7.fhir.r4.model.Parameters src) throws FHIRException { + public org.hl7.fhir.r4.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.instance.model.MedicationStatement src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Parameters tgt = new org.hl7.fhir.instance.model.Parameters(); - copyResource(src, tgt); - for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getParameter()) - tgt.addParameter(convertParametersParameterComponent(t)); + org.hl7.fhir.r4.model.MedicationStatement tgt = new org.hl7.fhir.r4.model.MedicationStatement(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setStatus(convertMedicationStatementStatus(src.getStatus())); + tgt.setMedication(convertType(src.getMedication())); + tgt.setSubject(convertReference(src.getPatient())); + tgt.setEffective(convertType(src.getEffective())); + tgt.setInformationSource(convertReference(src.getInformationSource())); + for (org.hl7.fhir.instance.model.Reference t : src.getSupportingInformation()) + tgt.addDerivedFrom(convertReference(t)); + if (src.hasDateAsserted()) + tgt.setDateAsserted(src.getDateAsserted()); +// tgt.getNotTakenElement().setValueAsString(src.getWasNotTaken() ? "Y" : "N"); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getReasonNotTaken()) + tgt.addReasonNotTaken(convertCodeableConcept(t)); +// tgt.setReasonForUse(convertType(src.getReasonForUse())); + if (src.hasNote()) + tgt.addNote().setText(src.getNote()); + for (org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent t : src.getDosage()) + tgt.addDosage(convertMedicationStatementDosageComponent(t)); return tgt; } - public org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.r4.model.MedicationStatement src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent(); + org.hl7.fhir.instance.model.MedicationStatement tgt = new org.hl7.fhir.instance.model.MedicationStatement(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setStatus(convertMedicationStatementStatus(src.getStatus())); + tgt.setMedication(convertType(src.getMedication())); + tgt.setPatient(convertReference(src.getSubject())); + tgt.setEffective(convertType(src.getEffective())); + tgt.setInformationSource(convertReference(src.getInformationSource())); + for (org.hl7.fhir.r4.model.Reference t : src.getDerivedFrom()) + tgt.addSupportingInformation(convertReference(t)); + if (src.hasDateAsserted()) + tgt.setDateAsserted(src.getDateAsserted()); +// tgt.setWasNotTaken("Y".equals(src.getNotTakenElement().getValueAsString())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonNotTaken()) + tgt.addReasonNotTaken(convertCodeableConcept(t)); +// tgt.setReasonForUse(convertType(src.getReasonForUse())); + for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) + tgt.setNote(t.getText()); + for (org.hl7.fhir.r4.model.Dosage t : src.getDosage()) + tgt.addDosage(convertMedicationStatementDosageComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ACTIVE; + case COMPLETED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR; + case INTENDED: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.INTENDED; + default: return org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus convertMedicationStatementStatus(org.hl7.fhir.r4.model.MedicationStatement.MedicationStatementStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.ACTIVE; + case COMPLETED: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR; + case INTENDED: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.INTENDED; + default: return org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.Dosage convertMedicationStatementDosageComponent(org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); + copyElement(src, tgt); + tgt.setText(src.getText()); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) + tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); +// tgt.setQuantity(convertType(src.getQuantity())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent convertMedicationStatementDosageComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent tgt = new org.hl7.fhir.instance.model.MedicationStatement.MedicationStatementDosageComponent(); + copyElement(src, tgt); + tgt.setText(src.getText()); + tgt.setTiming(convertTiming(src.getTiming())); + tgt.setAsNeeded(convertType(src.getAsNeeded())); + tgt.setSite(convertType(src.getSite())); + tgt.setRoute(convertCodeableConcept(src.getRoute())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); +// tgt.setQuantity(convertType(src.getQuantity())); + tgt.setRate(convertType(src.getRate())); + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.MessageHeader convertMessageHeader(org.hl7.fhir.instance.model.MessageHeader src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.MessageHeader tgt = new org.hl7.fhir.r4.model.MessageHeader(); + copyDomainResource(src, tgt); + tgt.setTimestamp(src.getTimestamp()); + tgt.setEvent(convertCoding(src.getEvent())); + tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); + tgt.setSource(convertMessageSourceComponent(src.getSource())); + for (org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) + tgt.addDestination(convertMessageDestinationComponent(t)); + tgt.setEnterer(convertReference(src.getEnterer())); + tgt.setAuthor(convertReference(src.getAuthor())); + tgt.setResponsible(convertReference(src.getResponsible())); + tgt.setReason(convertCodeableConcept(src.getReason())); + for (org.hl7.fhir.instance.model.Reference t : src.getData()) + tgt.addFocus(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.MessageHeader convertMessageHeader(org.hl7.fhir.r4.model.MessageHeader src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MessageHeader tgt = new org.hl7.fhir.instance.model.MessageHeader(); + copyDomainResource(src, tgt); + tgt.setTimestamp(src.getTimestamp()); + tgt.setEvent(convertCoding(src.getEvent())); + tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); + tgt.setSource(convertMessageSourceComponent(src.getSource())); + for (org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) + tgt.addDestination(convertMessageDestinationComponent(t)); + tgt.setEnterer(convertReference(src.getEnterer())); + tgt.setAuthor(convertReference(src.getAuthor())); + tgt.setResponsible(convertReference(src.getResponsible())); + tgt.setReason(convertCodeableConcept(src.getReason())); + for (org.hl7.fhir.r4.model.Reference t : src.getFocus()) + tgt.addData(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent(); + copyElement(src, tgt); + tgt.setIdentifier(src.getIdentifier()); + tgt.setCode(convertResponseType(src.getCode())); + tgt.setDetails(convertReference(src.getDetails())); + return tgt; + } + + public org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageHeaderResponseComponent(); + copyElement(src, tgt); + tgt.setIdentifier(src.getIdentifier()); + tgt.setCode(convertResponseType(src.getCode())); + tgt.setDetails(convertReference(src.getDetails())); + return tgt; + } + + public org.hl7.fhir.r4.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.instance.model.MessageHeader.ResponseType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OK: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.OK; + case TRANSIENTERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.TRANSIENTERROR; + case FATALERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.FATALERROR; + default: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.NULL; + } + } + + public org.hl7.fhir.instance.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.r4.model.MessageHeader.ResponseType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OK: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.OK; + case TRANSIENTERROR: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.TRANSIENTERROR; + case FATALERROR: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.FATALERROR; + default: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.NULL; + } + } + + public org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent(); copyElement(src, tgt); tgt.setName(src.getName()); - tgt.setValue(convertType(src.getValue())); - tgt.setResource(convertResource(src.getResource())); - for (org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent t : src.getPart()) - tgt.addPart(convertParametersParameterComponent(t)); + tgt.setSoftware(src.getSoftware()); + tgt.setVersion(src.getVersion()); + tgt.setContact(convertContactPoint(src.getContact())); + tgt.setEndpoint(src.getEndpoint()); return tgt; } - public org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent convertParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent src) throws FHIRException { + public org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; - org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent tgt = new org.hl7.fhir.instance.model.Parameters.ParametersParameterComponent(); + org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageSourceComponent(); copyElement(src, tgt); tgt.setName(src.getName()); - tgt.setValue(convertType(src.getValue())); - tgt.setResource(convertResource(src.getResource())); - for (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent t : src.getPart()) - tgt.addPart(convertParametersParameterComponent(t)); + tgt.setSoftware(src.getSoftware()); + tgt.setVersion(src.getVersion()); + tgt.setContact(convertContactPoint(src.getContact())); + tgt.setEndpoint(src.getEndpoint()); return tgt; } - public org.hl7.fhir.r4.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.instance.model.Appointment.ParticipantRequired src) throws FHIRException { + public org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setTarget(convertReference(src.getTarget())); + tgt.setEndpoint(src.getEndpoint()); + return tgt; + } + + public org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.instance.model.MessageHeader.MessageDestinationComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setTarget(convertReference(src.getTarget())); + tgt.setEndpoint(src.getEndpoint()); + return tgt; + } + + public org.hl7.fhir.r4.model.NamingSystem convertNamingSystem(org.hl7.fhir.instance.model.NamingSystem src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.NamingSystem tgt = new org.hl7.fhir.r4.model.NamingSystem(); + copyDomainResource(src, tgt); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setKind(convertNamingSystemType(src.getKind())); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent t : src.getContact()) + tgt.addContact(convertNamingSystemContactComponent(t)); + tgt.setResponsible(src.getResponsible()); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) + if (isJurisdiction(t)) + tgt.addJurisdiction(convertCodeableConcept(t)); + else + tgt.addUseContext(convertCodeableConceptToUsageContext(t)); + tgt.setUsage(src.getUsage()); + for (org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) + tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); + tgt.setReplacedBy(convertReference(src.getReplacedBy())); + return tgt; + } + + public org.hl7.fhir.instance.model.NamingSystem convertNamingSystem(org.hl7.fhir.r4.model.NamingSystem src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.NamingSystem tgt = new org.hl7.fhir.instance.model.NamingSystem(); + copyDomainResource(src, tgt); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setKind(convertNamingSystemType(src.getKind())); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertNamingSystemContactComponent(t)); + tgt.setResponsible(src.getResponsible()); + tgt.setType(convertCodeableConcept(src.getType())); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) + if (t.hasValueCodeableConcept()) + tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) + tgt.addUseContext(convertCodeableConcept(t)); + tgt.setUsage(src.getUsage()); + for (org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) + tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); + tgt.setReplacedBy(convertReference(src.getReplacedBy())); + return tgt; + } + + public org.hl7.fhir.r4.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.instance.model.NamingSystem.NamingSystemType src) throws FHIRException { if (src == null) return null; switch (src) { - case REQUIRED: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.REQUIRED; - case OPTIONAL: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.OPTIONAL; - case INFORMATIONONLY: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.INFORMATIONONLY; - default: return org.hl7.fhir.r4.model.Appointment.ParticipantRequired.NULL; + case CODESYSTEM: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.CODESYSTEM; + case IDENTIFIER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.IDENTIFIER; + case ROOT: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.ROOT; + default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.NULL; } } - public org.hl7.fhir.instance.model.Appointment.ParticipantRequired convertParticipantRequired(org.hl7.fhir.r4.model.Appointment.ParticipantRequired src) throws FHIRException { + public org.hl7.fhir.instance.model.NamingSystem.NamingSystemType convertNamingSystemType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType src) throws FHIRException { if (src == null) return null; switch (src) { - case REQUIRED: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.REQUIRED; - case OPTIONAL: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.OPTIONAL; - case INFORMATIONONLY: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.INFORMATIONONLY; - default: return org.hl7.fhir.instance.model.Appointment.ParticipantRequired.NULL; + case CODESYSTEM: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.CODESYSTEM; + case IDENTIFIER: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.IDENTIFIER; + case ROOT: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.ROOT; + default: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemType.NULL; } } - private org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus src) { + public org.hl7.fhir.r4.model.ContactDetail convertNamingSystemContactComponent(org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent convertNamingSystemContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent tgt = new org.hl7.fhir.instance.model.NamingSystem.NamingSystemContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent(); + copyElement(src, tgt); + tgt.setType(convertNamingSystemIdentifierType(src.getType())); + tgt.setValue(src.getValue()); + tgt.setPreferred(src.getPreferred()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.instance.model.NamingSystem.NamingSystemUniqueIdComponent(); + copyElement(src, tgt); + tgt.setType(convertNamingSystemIdentifierType(src.getType())); + tgt.setValue(src.getValue()); + tgt.setPreferred(src.getPreferred()); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException { if (src == null) return null; switch (src) { - case ACCEPTED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; - case DECLINED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.DECLINED; - case TENTATIVE: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.TENTATIVE; - case INPROCESS: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; - case COMPLETED: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.ACCEPTED; - case NEEDSACTION: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NEEDSACTION; - default: return org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus.NULL; + case OID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OID; + case UUID: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.UUID; + case URI: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.URI; + case OTHER: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OTHER; + default: return org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.NULL; } } - private org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus convertParticipantStatus(org.hl7.fhir.r4.model.AppointmentResponse.ParticipantStatus src) { + public org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType convertNamingSystemIdentifierType(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType src) throws FHIRException { if (src == null) return null; switch (src) { - case ACCEPTED: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.ACCEPTED; - case DECLINED: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.DECLINED; - case TENTATIVE: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.TENTATIVE; - case NEEDSACTION: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.NEEDSACTION; - default: return org.hl7.fhir.instance.model.AppointmentResponse.ParticipantStatus.NULL; + case OID: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.OID; + case UUID: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.UUID; + case URI: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.URI; + case OTHER: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.OTHER; + default: return org.hl7.fhir.instance.model.NamingSystem.NamingSystemIdentifierType.NULL; } } - public org.hl7.fhir.r4.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.instance.model.Appointment.ParticipationStatus src) throws FHIRException { + public org.hl7.fhir.r4.model.Observation convertObservation(org.hl7.fhir.instance.model.Observation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Observation tgt = new org.hl7.fhir.r4.model.Observation(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setStatus(convertObservationStatus(src.getStatus())); + tgt.addCategory(convertCodeableConcept(src.getCategory())); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setSubject(convertReference(src.getSubject())); + tgt.setContext(convertReference(src.getEncounter())); + tgt.setEffective(convertType(src.getEffective())); + tgt.setIssued(src.getIssued()); + for (org.hl7.fhir.instance.model.Reference t : src.getPerformer()) + tgt.addPerformer(convertReference(t)); + tgt.setValue(convertType(src.getValue())); + tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); + tgt.setInterpretation(convertCodeableConcept(src.getInterpretation())); + tgt.setComment(src.getComments()); + tgt.setBodySite(convertCodeableConcept(src.getBodySite())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setSpecimen(convertReference(src.getSpecimen())); + tgt.setDevice(convertReference(src.getDevice())); + for (org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) + tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); + for (org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent t : src.getRelated()) + tgt.addRelated(convertObservationRelatedComponent(t)); + for (org.hl7.fhir.instance.model.Observation.ObservationComponentComponent t : src.getComponent()) + tgt.addComponent(convertObservationComponentComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Observation convertObservation(org.hl7.fhir.r4.model.Observation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Observation tgt = new org.hl7.fhir.instance.model.Observation(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setStatus(convertObservationStatus(src.getStatus())); + for (org.hl7.fhir.r4.model.CodeableConcept c : src.getCategory()) + tgt.setCategory(convertCodeableConcept(c)); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setSubject(convertReference(src.getSubject())); + tgt.setEncounter(convertReference(src.getContext())); + tgt.setEffective(convertType(src.getEffective())); + tgt.setIssued(src.getIssued()); + for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) + tgt.addPerformer(convertReference(t)); + tgt.setValue(convertType(src.getValue())); + tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); + tgt.setInterpretation(convertCodeableConcept(src.getInterpretation())); + tgt.setComments(src.getComment()); + tgt.setBodySite(convertCodeableConcept(src.getBodySite())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + tgt.setSpecimen(convertReference(src.getSpecimen())); + tgt.setDevice(convertReference(src.getDevice())); + for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) + tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); + for (org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent t : src.getRelated()) + tgt.addRelated(convertObservationRelatedComponent(t)); + for (org.hl7.fhir.r4.model.Observation.ObservationComponentComponent t : src.getComponent()) + tgt.addComponent(convertObservationComponentComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.instance.model.Observation.ObservationStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case ACCEPTED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.ACCEPTED; - case DECLINED: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.DECLINED; - case TENTATIVE: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.TENTATIVE; - case NEEDSACTION: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NEEDSACTION; - default: return org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NULL; + case REGISTERED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.REGISTERED; + case PRELIMINARY: return org.hl7.fhir.r4.model.Observation.ObservationStatus.PRELIMINARY; + case FINAL: return org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL; + case AMENDED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.AMENDED; + case CANCELLED: return org.hl7.fhir.r4.model.Observation.ObservationStatus.CANCELLED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR; + case UNKNOWN: return org.hl7.fhir.r4.model.Observation.ObservationStatus.UNKNOWN; + default: return org.hl7.fhir.r4.model.Observation.ObservationStatus.NULL; } } - public org.hl7.fhir.instance.model.Appointment.ParticipationStatus convertParticipationStatus(org.hl7.fhir.r4.model.Appointment.ParticipationStatus src) throws FHIRException { + public org.hl7.fhir.instance.model.Observation.ObservationStatus convertObservationStatus(org.hl7.fhir.r4.model.Observation.ObservationStatus src) throws FHIRException { if (src == null) return null; switch (src) { - case ACCEPTED: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.ACCEPTED; - case DECLINED: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.DECLINED; - case TENTATIVE: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.TENTATIVE; - case NEEDSACTION: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.NEEDSACTION; - default: return org.hl7.fhir.instance.model.Appointment.ParticipationStatus.NULL; + case REGISTERED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.REGISTERED; + case PRELIMINARY: return org.hl7.fhir.instance.model.Observation.ObservationStatus.PRELIMINARY; + case FINAL: return org.hl7.fhir.instance.model.Observation.ObservationStatus.FINAL; + case AMENDED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.AMENDED; + case CANCELLED: return org.hl7.fhir.instance.model.Observation.ObservationStatus.CANCELLED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Observation.ObservationStatus.ENTEREDINERROR; + case UNKNOWN: return org.hl7.fhir.instance.model.Observation.ObservationStatus.UNKNOWN; + default: return org.hl7.fhir.instance.model.Observation.ObservationStatus.NULL; } } + public org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent(); + copyElement(src, tgt); + tgt.setLow(convertSimpleQuantity(src.getLow())); + tgt.setHigh(convertSimpleQuantity(src.getHigh())); + tgt.setType(convertCodeableConcept(src.getMeaning())); + tgt.setAge(convertRange(src.getAge())); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent convertObservationReferenceRangeComponent(org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent(); + copyElement(src, tgt); + tgt.setLow(convertSimpleQuantity(src.getLow())); + tgt.setHigh(convertSimpleQuantity(src.getHigh())); +// for (org.hl7.fhir.r4.model.CodeableConcept c : src.getMeaning()) + tgt.setMeaning(convertCodeableConcept(src.getType())); + tgt.setAge(convertRange(src.getAge())); + tgt.setText(src.getText()); + return tgt; + } + + public org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent(); + copyElement(src, tgt); + tgt.setType(convertObservationRelationshipType(src.getType())); + tgt.setTarget(convertReference(src.getTarget())); + return tgt; + } + + public org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent convertObservationRelatedComponent(org.hl7.fhir.r4.model.Observation.ObservationRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationRelatedComponent(); + copyElement(src, tgt); + tgt.setType(convertObservationRelationshipType(src.getType())); + tgt.setTarget(convertReference(src.getTarget())); + return tgt; + } + + public org.hl7.fhir.r4.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.instance.model.Observation.ObservationRelationshipType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HASMEMBER: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.HASMEMBER; + case DERIVEDFROM: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.DERIVEDFROM; + case SEQUELTO: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.SEQUELTO; + case REPLACES: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.REPLACES; + case QUALIFIEDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.QUALIFIEDBY; + case INTERFEREDBY: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.INTERFEREDBY; + default: return org.hl7.fhir.r4.model.Observation.ObservationRelationshipType.NULL; + } + } + + public org.hl7.fhir.instance.model.Observation.ObservationRelationshipType convertObservationRelationshipType(org.hl7.fhir.r4.model.Observation.ObservationRelationshipType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case HASMEMBER: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.HASMEMBER; + case DERIVEDFROM: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.DERIVEDFROM; + case SEQUELTO: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.SEQUELTO; + case REPLACES: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.REPLACES; + case QUALIFIEDBY: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.QUALIFIEDBY; + case INTERFEREDBY: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.INTERFEREDBY; + default: return org.hl7.fhir.instance.model.Observation.ObservationRelationshipType.NULL; + } + } + + public org.hl7.fhir.r4.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.instance.model.Observation.ObservationComponentComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.r4.model.Observation.ObservationComponentComponent(); + copyElement(src, tgt); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setValue(convertType(src.getValue())); + tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); + for (org.hl7.fhir.instance.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) + tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Observation.ObservationComponentComponent convertObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Observation.ObservationComponentComponent tgt = new org.hl7.fhir.instance.model.Observation.ObservationComponentComponent(); + copyElement(src, tgt); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setValue(convertType(src.getValue())); + tgt.setDataAbsentReason(convertCodeableConcept(src.getDataAbsentReason())); + for (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent t : src.getReferenceRange()) + tgt.addReferenceRange(convertObservationReferenceRangeComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.instance.model.OperationDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.OperationDefinition tgt = new org.hl7.fhir.r4.model.OperationDefinition(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setKind(convertOperationKind(src.getKind())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent t : src.getContact()) + tgt.addContact(convertOperationDefinitionContactComponent(t)); + tgt.setDescription(src.getDescription()); + tgt.setPurpose(src.getRequirements()); + if (src.hasIdempotent()) + tgt.setIdempotent(src.getIdempotent()); + tgt.setCode(src.getCode()); + tgt.setComment(src.getNotes()); + tgt.setBase(convertReference(src.getBase())); + tgt.setSystem(src.getSystem()); + for (org.hl7.fhir.instance.model.CodeType t : src.getType()) + tgt.addResource(t.getValue()); + tgt.setType(tgt.hasResource()); + tgt.setInstance(src.getInstance()); + for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) + tgt.addParameter(convertOperationDefinitionParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.r4.model.OperationDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationDefinition tgt = new org.hl7.fhir.instance.model.OperationDefinition(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setKind(convertOperationKind(src.getKind())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertOperationDefinitionContactComponent(t)); + tgt.setDescription(src.getDescription()); + tgt.setRequirements(src.getPurpose()); + tgt.setIdempotent(src.getIdempotent()); + tgt.setCode(src.getCode()); + tgt.setNotes(src.getComment()); + if (src.hasBase()) + tgt.setBase(convertReference(src.getBase())); + tgt.setSystem(src.getSystem()); + if (src.getType()) + for (org.hl7.fhir.r4.model.CodeType t : src.getResource()) + tgt.addType(t.getValue()); + tgt.setInstance(src.getInstance()); + for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) + tgt.addParameter(convertOperationDefinitionParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.instance.model.OperationDefinition.OperationKind src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OPERATION: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.OPERATION; + case QUERY: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.QUERY; + default: return org.hl7.fhir.r4.model.OperationDefinition.OperationKind.NULL; + } + } + + public org.hl7.fhir.instance.model.OperationDefinition.OperationKind convertOperationKind(org.hl7.fhir.r4.model.OperationDefinition.OperationKind src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OPERATION: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.OPERATION; + case QUERY: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.QUERY; + default: return org.hl7.fhir.instance.model.OperationDefinition.OperationKind.NULL; + } + } + + public org.hl7.fhir.r4.model.ContactDetail convertOperationDefinitionContactComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent convertOperationDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setUse(convertOperationParameterUse(src.getUse())); + tgt.setMin(src.getMin()); + tgt.setMax(src.getMax()); + tgt.setDocumentation(src.getDocumentation()); + tgt.setType(src.getType()); + tgt.setProfile(convertReference(src.getProfile())); + tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); + for (org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) + tgt.addPart(convertOperationDefinitionParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setUse(convertOperationParameterUse(src.getUse())); + tgt.setMin(src.getMin()); + tgt.setMax(src.getMax()); + tgt.setDocumentation(src.getDocumentation()); + if (src.hasSearchType()) { + tgt.setType(src.getSearchType().toCode()); + tgt.setType("string"); + } else + tgt.setType(src.getType()); + if (src.hasProfile()) + tgt.setProfile(convertReference(src.getProfile())); + if (src.hasBinding()) + tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) + tgt.addPart(convertOperationDefinitionParameterComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case IN: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.IN; + case OUT: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.OUT; + default: return org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.NULL; + } + } + + public org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse convertOperationParameterUse(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case IN: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.IN; + case OUT: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.OUT; + default: return org.hl7.fhir.instance.model.OperationDefinition.OperationParameterUse.NULL; + } + } + + public org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); + copyElement(src, tgt); + tgt.setStrength(convertBindingStrength(src.getStrength())); + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.instance.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); + copyElement(src, tgt); + tgt.setStrength(convertBindingStrength(src.getStrength())); + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.instance.model.OperationOutcome src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.OperationOutcome tgt = new org.hl7.fhir.r4.model.OperationOutcome(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue()) + tgt.addIssue(convertOperationOutcomeIssueComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationOutcome convertOperationOutcome(org.hl7.fhir.r4.model.OperationOutcome src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationOutcome tgt = new org.hl7.fhir.instance.model.OperationOutcome(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent t : src.getIssue()) + tgt.addIssue(convertOperationOutcomeIssueComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent(); + copyElement(src, tgt); + tgt.setSeverity(convertIssueSeverity(src.getSeverity())); + tgt.setCode(convertIssueType(src.getCode())); + tgt.setDetails(convertCodeableConcept(src.getDetails())); + tgt.setDiagnostics(src.getDiagnostics()); + for (org.hl7.fhir.instance.model.StringType t : src.getLocation()) + tgt.addLocation(t.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent convertOperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent tgt = new org.hl7.fhir.instance.model.OperationOutcome.OperationOutcomeIssueComponent(); + copyElement(src, tgt); + tgt.setSeverity(convertIssueSeverity(src.getSeverity())); + tgt.setCode(convertIssueType(src.getCode())); + tgt.setDetails(convertCodeableConcept(src.getDetails())); + tgt.setDiagnostics(src.getDiagnostics()); + for (org.hl7.fhir.r4.model.StringType t : src.getLocation()) + tgt.addLocation(t.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case FATAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.FATAL; + case ERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.ERROR; + case WARNING: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.WARNING; + case INFORMATION: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.INFORMATION; + default: return org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity.NULL; + } + } + + public org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity convertIssueSeverity(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case FATAL: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.FATAL; + case ERROR: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR; + case WARNING: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING; + case INFORMATION: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION; + default: return org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.NULL; + } + } + + public org.hl7.fhir.r4.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.instance.model.OperationOutcome.IssueType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVALID; + case STRUCTURE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.STRUCTURE; + case REQUIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.REQUIRED; + case VALUE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.VALUE; + case INVARIANT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INVARIANT; + case SECURITY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SECURITY; + case LOGIN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOGIN; + case UNKNOWN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.UNKNOWN; + case EXPIRED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXPIRED; + case FORBIDDEN: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.FORBIDDEN; + case SUPPRESSED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.SUPPRESSED; + case PROCESSING: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.PROCESSING; + case NOTSUPPORTED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTSUPPORTED; + case DUPLICATE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.DUPLICATE; + case NOTFOUND: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOTFOUND; + case TOOLONG: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOLONG; + case CODEINVALID: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CODEINVALID; + case EXTENSION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXTENSION; + case TOOCOSTLY: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TOOCOSTLY; + case BUSINESSRULE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.BUSINESSRULE; + case CONFLICT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.CONFLICT; + case INCOMPLETE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INCOMPLETE; + case TRANSIENT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TRANSIENT; + case LOCKERROR: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.LOCKERROR; + case NOSTORE: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NOSTORE; + case EXCEPTION: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.EXCEPTION; + case TIMEOUT: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.TIMEOUT; + case THROTTLED: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.THROTTLED; + case INFORMATIONAL: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.INFORMATIONAL; + default: return org.hl7.fhir.r4.model.OperationOutcome.IssueType.NULL; + } + } + + public org.hl7.fhir.instance.model.OperationOutcome.IssueType convertIssueType(org.hl7.fhir.r4.model.OperationOutcome.IssueType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INVALID: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INVALID; + case STRUCTURE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.STRUCTURE; + case REQUIRED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.REQUIRED; + case VALUE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.VALUE; + case INVARIANT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INVARIANT; + case SECURITY: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.SECURITY; + case LOGIN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.LOGIN; + case UNKNOWN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.UNKNOWN; + case EXPIRED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXPIRED; + case FORBIDDEN: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.FORBIDDEN; + case SUPPRESSED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.SUPPRESSED; + case PROCESSING: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.PROCESSING; + case NOTSUPPORTED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOTSUPPORTED; + case DUPLICATE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.DUPLICATE; + case NOTFOUND: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOTFOUND; + case TOOLONG: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TOOLONG; + case CODEINVALID: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.CODEINVALID; + case EXTENSION: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXTENSION; + case TOOCOSTLY: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TOOCOSTLY; + case BUSINESSRULE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.BUSINESSRULE; + case CONFLICT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.CONFLICT; + case INCOMPLETE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INCOMPLETE; + case TRANSIENT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TRANSIENT; + case LOCKERROR: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.LOCKERROR; + case NOSTORE: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NOSTORE; + case EXCEPTION: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.EXCEPTION; + case TIMEOUT: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.TIMEOUT; + case THROTTLED: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.THROTTLED; + case INFORMATIONAL: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.INFORMATIONAL; + default: return org.hl7.fhir.instance.model.OperationOutcome.IssueType.NULL; + } + } + + + public org.hl7.fhir.r4.model.Organization convertOrganization(org.hl7.fhir.instance.model.Organization src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Organization tgt = new org.hl7.fhir.r4.model.Organization(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setActive(src.getActive()); + tgt.addType(convertCodeableConcept(src.getType())); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + for (org.hl7.fhir.instance.model.Address t : src.getAddress()) + tgt.addAddress(convertAddress(t)); + tgt.setPartOf(convertReference(src.getPartOf())); + for (org.hl7.fhir.instance.model.Organization.OrganizationContactComponent t : src.getContact()) + tgt.addContact(convertOrganizationContactComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Organization convertOrganization(org.hl7.fhir.r4.model.Organization src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Organization tgt = new org.hl7.fhir.instance.model.Organization(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setActive(src.getActive()); + tgt.setType(convertCodeableConcept(src.getTypeFirstRep())); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + for (org.hl7.fhir.r4.model.Address t : src.getAddress()) + tgt.addAddress(convertAddress(t)); + tgt.setPartOf(convertReference(src.getPartOf())); + for (org.hl7.fhir.r4.model.Organization.OrganizationContactComponent t : src.getContact()) + tgt.addContact(convertOrganizationContactComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.instance.model.Organization.OrganizationContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.r4.model.Organization.OrganizationContactComponent(); + copyElement(src, tgt); + tgt.setPurpose(convertCodeableConcept(src.getPurpose())); + tgt.setName(convertHumanName(src.getName())); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + tgt.setAddress(convertAddress(src.getAddress())); + return tgt; + } + + public org.hl7.fhir.instance.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.instance.model.Organization.OrganizationContactComponent(); + copyElement(src, tgt); + tgt.setPurpose(convertCodeableConcept(src.getPurpose())); + tgt.setName(convertHumanName(src.getName())); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + tgt.setAddress(convertAddress(src.getAddress())); + return tgt; + } + + public org.hl7.fhir.r4.model.Patient convertPatient(org.hl7.fhir.instance.model.Patient src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -8835,6 +9532,62 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.instance.model.Patient.ContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Patient.ContactComponent tgt = new org.hl7.fhir.r4.model.Patient.ContactComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRelationship()) + tgt.addRelationship(convertCodeableConcept(t)); + tgt.setName(convertHumanName(src.getName())); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + tgt.setAddress(convertAddress(src.getAddress())); + tgt.setGender(convertAdministrativeGender(src.getGender())); + tgt.setOrganization(convertReference(src.getOrganization())); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.instance.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r4.model.Patient.ContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Patient.ContactComponent tgt = new org.hl7.fhir.instance.model.Patient.ContactComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRelationship()) + tgt.addRelationship(convertCodeableConcept(t)); + tgt.setName(convertHumanName(src.getName())); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + tgt.setAddress(convertAddress(src.getAddress())); + tgt.setGender(convertAdministrativeGender(src.getGender())); + tgt.setOrganization(convertReference(src.getOrganization())); + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public org.hl7.fhir.r4.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.instance.model.Patient.AnimalComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Patient.AnimalComponent tgt = new org.hl7.fhir.r4.model.Patient.AnimalComponent(); + copyElement(src, tgt); + tgt.setSpecies(convertCodeableConcept(src.getSpecies())); + tgt.setBreed(convertCodeableConcept(src.getBreed())); + tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus())); + return tgt; + } + + public org.hl7.fhir.instance.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.r4.model.Patient.AnimalComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Patient.AnimalComponent tgt = new org.hl7.fhir.instance.model.Patient.AnimalComponent(); + copyElement(src, tgt); + tgt.setSpecies(convertCodeableConcept(src.getSpecies())); + tgt.setBreed(convertCodeableConcept(src.getBreed())); + tgt.setGenderStatus(convertCodeableConcept(src.getGenderStatus())); + return tgt; + } + public org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.instance.model.Patient.PatientCommunicationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -8875,26 +9628,30 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.instance.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.r4.model.Patient.LinkType convertLinkType(org.hl7.fhir.instance.model.Patient.LinkType src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); - copyElement(src, tgt); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - return tgt; + switch (src) { + case REPLACE: return org.hl7.fhir.r4.model.Patient.LinkType.REPLACEDBY; + case REFER: return org.hl7.fhir.r4.model.Patient.LinkType.REFER; + case SEEALSO: return org.hl7.fhir.r4.model.Patient.LinkType.SEEALSO; + default: return org.hl7.fhir.r4.model.Patient.LinkType.NULL; + } } - public org.hl7.fhir.instance.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.instance.model.Patient.LinkType convertLinkType(org.hl7.fhir.r4.model.Patient.LinkType src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.instance.model.Period tgt = new org.hl7.fhir.instance.model.Period(); - copyElement(src, tgt); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - return tgt; + switch (src) { + case REPLACEDBY: return org.hl7.fhir.instance.model.Patient.LinkType.REPLACE; + case REPLACES: return org.hl7.fhir.instance.model.Patient.LinkType.REPLACE; + case REFER: return org.hl7.fhir.instance.model.Patient.LinkType.REFER; + case SEEALSO: return org.hl7.fhir.instance.model.Patient.LinkType.SEEALSO; + default: return org.hl7.fhir.instance.model.Patient.LinkType.NULL; + } } + public org.hl7.fhir.r4.model.Person convertPerson(org.hl7.fhir.instance.model.Person src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -8961,16 +9718,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.instance.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()); - copyElement(src, tgt); - return tgt; + public org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case LEVEL1: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL1; + case LEVEL2: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL2; + case LEVEL3: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL3; + case LEVEL4: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.LEVEL4; + default: return org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel.NULL; + } } - public org.hl7.fhir.instance.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.instance.model.PositiveIntType tgt = new org.hl7.fhir.instance.model.PositiveIntType(src.getValue()); - copyElement(src, tgt); - return tgt; + public org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel convertIdentityAssuranceLevel(org.hl7.fhir.r4.model.Person.IdentityAssuranceLevel src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case LEVEL1: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL1; + case LEVEL2: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL2; + case LEVEL3: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL3; + case LEVEL4: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.LEVEL4; + default: return org.hl7.fhir.instance.model.Person.IdentityAssuranceLevel.NULL; + } } public org.hl7.fhir.r4.model.Practitioner convertPractitioner(org.hl7.fhir.instance.model.Practitioner src) throws FHIRException { @@ -9027,6 +9796,40 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } +// public org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent convertPractitionerPractitionerRoleComponent(org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent tgt = new org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent(); +// copyElement(src, tgt); +// tgt.setOrganization(convertReference(src.getManagingOrganization())); +// tgt.setCode(convertCodeableConcept(src.getRole())); +// for (org.hl7.fhir.instance.model.CodeableConcept t : src.getSpecialty()) +// tgt.addSpecialty(convertCodeableConcept(t)); +// tgt.setPeriod(convertPeriod(src.getPeriod())); +// for (org.hl7.fhir.instance.model.Reference t : src.getLocation()) +// tgt.addLocation(convertReference(t)); +// for (org.hl7.fhir.instance.model.Reference t : src.getHealthcareService()) +// tgt.addHealthcareService(convertReference(t)); +// return tgt; +// } + +// public org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent convertPractitionerPractitionerRoleComponent(org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent src) throws FHIRException { +// if (src == null || src.isEmpty()) +// return null; +// org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent tgt = new org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent(); +// copyElement(src, tgt); +// tgt.setManagingOrganization(convertReference(src.getOrganization())); +// tgt.setRole(convertCodeableConcept(src.getCode())); +// for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty()) +// tgt.addSpecialty(convertCodeableConcept(t)); +// tgt.setPeriod(convertPeriod(src.getPeriod())); +// for (org.hl7.fhir.r4.model.Reference t : src.getLocation()) +// tgt.addLocation(convertReference(t)); +// for (org.hl7.fhir.r4.model.Reference t : src.getHealthcareService()) +// tgt.addHealthcareService(convertReference(t)); +// return tgt; +// } + public org.hl7.fhir.r4.model.Practitioner.PractitionerQualificationComponent convertPractitionerQualificationComponent(org.hl7.fhir.instance.model.Practitioner.PractitionerQualificationComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9053,32 +9856,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - private org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority convertPriorityCode(org.hl7.fhir.instance.model.CodeableConcept priority) { - for (org.hl7.fhir.instance.model.Coding c : priority.getCoding()) { - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "routine".equals(c.getCode())) - return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ROUTINE; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "urgent".equals(c.getCode())) - return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.URGENT; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "stat".equals(c.getCode())) - return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.STAT; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "asap".equals(c.getCode())) - return org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority.ASAP; - } - return null; - } - - private org.hl7.fhir.instance.model.CodeableConcept convertPriorityCode(org.hl7.fhir.r4.model.CommunicationRequest.CommunicationPriority priority) { - org.hl7.fhir.instance.model.CodeableConcept cc = new org.hl7.fhir.instance.model.CodeableConcept(); - switch (priority) { - case ROUTINE: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("routine"); break; - case URGENT: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("urgent"); break; - case STAT: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("stat"); break; - case ASAP: cc.addCoding().setSystem("http://hl7.org/fhir/diagnostic-order-priority").setCode("asap"); break; - default: return null; - } - return cc; - } - public org.hl7.fhir.r4.model.Procedure convertProcedure(org.hl7.fhir.instance.model.Procedure src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9155,24 +9932,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.r4.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.instance.model.Procedure.ProcedureStatus src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent(); - copyElement(src, tgt); - tgt.setAction(convertCodeableConcept(src.getAction())); - tgt.setManipulated(convertReference(src.getManipulated())); - return tgt; + switch (src) { + case INPROGRESS: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.INPROGRESS; + case ABORTED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ABORTED; + case COMPLETED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ENTEREDINERROR; + default: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.NULL; + } } - public org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) + public org.hl7.fhir.instance.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.r4.model.Procedure.ProcedureStatus src) throws FHIRException { + if (src == null) return null; - org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent(); - copyElement(src, tgt); - tgt.setAction(convertCodeableConcept(src.getAction())); - tgt.setManipulated(convertReference(src.getManipulated())); - return tgt; + switch (src) { + case INPROGRESS: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.INPROGRESS; + case ABORTED: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.ABORTED; + case COMPLETED: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.COMPLETED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.ENTEREDINERROR; + default: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.NULL; + } } public org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.instance.model.Procedure.ProcedurePerformerComponent src) throws FHIRException { @@ -9195,6 +9976,26 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent(); + copyElement(src, tgt); + tgt.setAction(convertCodeableConcept(src.getAction())); + tgt.setManipulated(convertReference(src.getManipulated())); + return tgt; + } + + public org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.instance.model.Procedure.ProcedureFocalDeviceComponent(); + copyElement(src, tgt); + tgt.setAction(convertCodeableConcept(src.getAction())); + tgt.setManipulated(convertReference(src.getManipulated())); + return tgt; + } + public org.hl7.fhir.r4.model.ProcedureRequest convertProcedureRequest(org.hl7.fhir.instance.model.ProcedureRequest src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9246,30 +10047,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ROUTINE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; - case URGENT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT; - case STAT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT; - case ASAP: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP; - default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.NULL; - } - } - - public org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ROUTINE: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; - case URGENT: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.URGENT; - case STAT: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.STAT; - case ASAP: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.ASAP; - default: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.NULL; - } - } - public org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus convertProcedureRequestStatus(org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestStatus src) throws FHIRException { if (src == null) return null; @@ -9306,48 +10083,73 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.instance.model.Procedure.ProcedureStatus src) throws FHIRException { + public org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException { if (src == null) return null; switch (src) { - case INPROGRESS: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.INPROGRESS; - case ABORTED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ABORTED; - case COMPLETED: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ENTEREDINERROR; - default: return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.NULL; + case ROUTINE: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; + case URGENT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT; + case STAT: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT; + case ASAP: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP; + default: return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.NULL; } } - public org.hl7.fhir.instance.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.r4.model.Procedure.ProcedureStatus src) throws FHIRException { + public org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority convertProcedureRequestPriority(org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority src) throws FHIRException { if (src == null) return null; switch (src) { - case INPROGRESS: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.INPROGRESS; - case ABORTED: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.ABORTED; - case COMPLETED: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.COMPLETED; - case ENTEREDINERROR: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.ENTEREDINERROR; - default: return org.hl7.fhir.instance.model.Procedure.ProcedureStatus.NULL; + case ROUTINE: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; + case URGENT: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.URGENT; + case STAT: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.STAT; + case ASAP: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.ASAP; + default: return org.hl7.fhir.instance.model.ProcedureRequest.ProcedureRequestPriority.NULL; } } - public org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation src) throws FHIRException { + + public org.hl7.fhir.r4.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.instance.model.ProcessRequest.ActionList src) throws FHIRException { if (src == null) return null; switch (src) { - case XMLATTR: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR; - default: return org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL; + case CANCEL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.CANCEL; + case POLL: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.POLL; + case REPROCESS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.REPROCESS; + case STATUS: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.STATUS; + default: return org.hl7.fhir.r4.model.ProcessRequest.ActionList.NULL; } } - public org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation convertPropertyRepresentation(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation src) throws FHIRException { + public org.hl7.fhir.instance.model.ProcessRequest.ActionList convertActionList(org.hl7.fhir.r4.model.ProcessRequest.ActionList src) throws FHIRException { if (src == null) return null; switch (src) { - case XMLATTR: return org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation.XMLATTR; - default: return org.hl7.fhir.instance.model.ElementDefinition.PropertyRepresentation.NULL; + case CANCEL: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.CANCEL; + case POLL: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.POLL; + case REPROCESS: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.REPROCESS; + case STATUS: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.STATUS; + default: return org.hl7.fhir.instance.model.ProcessRequest.ActionList.NULL; } } + public org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent(); + copyElement(src, tgt); + tgt.setSequenceLinkId(src.getSequenceLinkId()); + return tgt; + } + + public org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.r4.model.ProcessRequest.ItemsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.instance.model.ProcessRequest.ItemsComponent(); + copyElement(src, tgt); + tgt.setSequenceLinkId(src.getSequenceLinkId()); + return tgt; + } + public org.hl7.fhir.r4.model.Provenance convertProvenance(org.hl7.fhir.instance.model.Provenance src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9356,6 +10158,7 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen for (org.hl7.fhir.instance.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t)); tgt.setRecorded(src.getRecorded()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getReason()) tgt.setLocation(convertReference(src.getLocation())); for (org.hl7.fhir.instance.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue()); @@ -9458,56 +10261,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } - public org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.instance.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.instance.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Quantity tgt = new org.hl7.fhir.instance.model.Quantity(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.r4.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.instance.model.Quantity.QuantityComparator src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case LESS_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN; - case LESS_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL; - case GREATER_OR_EQUAL: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; - case GREATER_THAN: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN; - default: return org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL; - } - } - - public org.hl7.fhir.instance.model.Quantity.QuantityComparator convertQuantityComparator(org.hl7.fhir.r4.model.Quantity.QuantityComparator src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case LESS_THAN: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.LESS_THAN; - case LESS_OR_EQUAL: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.LESS_OR_EQUAL; - case GREATER_OR_EQUAL: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; - case GREATER_THAN: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.GREATER_THAN; - default: return org.hl7.fhir.instance.model.Quantity.QuantityComparator.NULL; - } - } - public org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.instance.model.Questionnaire src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9570,6 +10323,48 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen tgt.addTelecom(convertContactPoint(src)); return tgt; } + + private static org.hl7.fhir.r4.model.Enumerations.PublicationStatus convertQuestionnaireStatus(org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DRAFT: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT; + case PUBLISHED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE; + case RETIRED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED; + default: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL; + } + } + + private static org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus convertQuestionnaireStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DRAFT: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.DRAFT; + case ACTIVE: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.PUBLISHED; + case RETIRED: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.RETIRED; + default: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.instance.model.Questionnaire.QuestionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent(); + copyElement(src, tgt); + tgt.setLinkId(src.getLinkId()); + for (org.hl7.fhir.instance.model.Coding t : src.getConcept()) + tgt.addCode(convertCoding(t)); + tgt.setText(src.getText()); + tgt.setType(convertQuestionnaireQuestionType(src.getType())); + tgt.setRequired(src.getRequired()); + tgt.setRepeats(src.getRepeats()); + tgt.setOptions(convertReference(src.getOptions())); + for (org.hl7.fhir.instance.model.Coding t : src.getOption()) + tgt.addOption().setValue(convertCoding(t)); + for (org.hl7.fhir.instance.model.Questionnaire.GroupComponent t : src.getGroup()) + tgt.addItem(convertQuestionnaireGroupComponent(t)); + return tgt; + } public org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireGroupComponent(org.hl7.fhir.instance.model.Questionnaire.GroupComponent src) throws FHIRException { if (src == null || src.isEmpty()) @@ -9609,76 +10404,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent convertQuestionnaireItemToGroup(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent tgt = new org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent(); - copyElement(src, tgt); - tgt.setLinkId(src.getLinkId()); - tgt.setText(src.getText()); - tgt.setSubject(convertReference(src.getSubject())); - for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem()) - if (t.hasAnswer()) - tgt.addQuestion(convertQuestionnaireItemToQuestion(t)); - else - tgt.addGroup(convertQuestionnaireItemToGroup(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent convertQuestionnaireItemToQuestion(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent tgt = new org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent(); - copyElement(src, tgt); - tgt.setLinkId(src.getLinkId()); - tgt.setText(src.getText()); - for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer()) - tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Questionnaire.AnswerFormat convertQuestionnaireItemType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case BOOLEAN: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.BOOLEAN; - case DECIMAL: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DECIMAL; - case INTEGER: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.INTEGER; - case DATE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DATE; - case DATETIME: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DATETIME; - case TIME: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.TIME; - case STRING: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.STRING; - case TEXT: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.TEXT; - case URL: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.URL; - case CHOICE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.CHOICE; - case OPENCHOICE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.OPENCHOICE; - case ATTACHMENT: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.ATTACHMENT; - case REFERENCE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.REFERENCE; - case QUANTITY: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.QUANTITY; - default: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.NULL; - } - } - - public org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.instance.model.Questionnaire.QuestionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent(); - copyElement(src, tgt); - tgt.setLinkId(src.getLinkId()); - for (org.hl7.fhir.instance.model.Coding t : src.getConcept()) - tgt.addCode(convertCoding(t)); - tgt.setText(src.getText()); - tgt.setType(convertQuestionnaireQuestionType(src.getType())); - tgt.setRequired(src.getRequired()); - tgt.setRepeats(src.getRepeats()); - tgt.setOptions(convertReference(src.getOptions())); - for (org.hl7.fhir.instance.model.Coding t : src.getOption()) - tgt.addOption().setValue(convertCoding(t)); - for (org.hl7.fhir.instance.model.Questionnaire.GroupComponent t : src.getGroup()) - tgt.addItem(convertQuestionnaireGroupComponent(t)); - return tgt; - } - public org.hl7.fhir.instance.model.Questionnaire.QuestionComponent convertQuestionnaireQuestionComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9727,6 +10452,28 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen } } + public org.hl7.fhir.instance.model.Questionnaire.AnswerFormat convertQuestionnaireItemType(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case BOOLEAN: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.BOOLEAN; + case DECIMAL: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DECIMAL; + case INTEGER: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.INTEGER; + case DATE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DATE; + case DATETIME: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.DATETIME; + case TIME: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.TIME; + case STRING: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.STRING; + case TEXT: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.TEXT; + case URL: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.URL; + case CHOICE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.CHOICE; + case OPENCHOICE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.OPENCHOICE; + case ATTACHMENT: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.ATTACHMENT; + case REFERENCE: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.REFERENCE; + case QUANTITY: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.QUANTITY; + default: return org.hl7.fhir.instance.model.Questionnaire.AnswerFormat.NULL; + } + } + public org.hl7.fhir.r4.model.QuestionnaireResponse convertQuestionnaireResponse(org.hl7.fhir.instance.model.QuestionnaireResponse src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9766,6 +10513,29 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + + public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED; + case AMENDED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED; + default: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED; + case AMENDED: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED; + default: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL; + } + } + public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseGroupComponent(org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9781,6 +10551,46 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseQuestionComponent(org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent(); + copyElement(src, tgt); + tgt.setLinkId(src.getLinkId()); + tgt.setText(src.getText()); + for (org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionAnswerComponent t : src.getAnswer()) + tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent convertQuestionnaireItemToGroup(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent tgt = new org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent(); + copyElement(src, tgt); + tgt.setLinkId(src.getLinkId()); + tgt.setText(src.getText()); + tgt.setSubject(convertReference(src.getSubject())); + for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem()) + if (t.hasAnswer()) + tgt.addQuestion(convertQuestionnaireItemToQuestion(t)); + else + tgt.addGroup(convertQuestionnaireItemToGroup(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent convertQuestionnaireItemToQuestion(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent tgt = new org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent(); + copyElement(src, tgt); + tgt.setLinkId(src.getLinkId()); + tgt.setText(src.getText()); + for (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer()) + tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t)); + return tgt; + } + public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent convertQuestionnaireResponseItemAnswerComponent(org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionAnswerComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9803,148 +10613,6 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } - public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseQuestionComponent(org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent(); - copyElement(src, tgt); - tgt.setLinkId(src.getLinkId()); - tgt.setText(src.getText()); - for (org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionAnswerComponent t : src.getAnswer()) - tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED; - case AMENDED: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED; - default: return org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus convertQuestionnaireResponseStatus(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED; - case AMENDED: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED; - default: return org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.instance.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); - copyElement(src, tgt); - tgt.setLow(convertSimpleQuantity(src.getLow())); - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public org.hl7.fhir.instance.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Range tgt = new org.hl7.fhir.instance.model.Range(); - copyElement(src, tgt); - tgt.setLow(convertSimpleQuantity(src.getLow())); - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.instance.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); - copyElement(src, tgt); - tgt.setNumerator(convertQuantity(src.getNumerator())); - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public org.hl7.fhir.instance.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Ratio tgt = new org.hl7.fhir.instance.model.Ratio(); - copyElement(src, tgt); - tgt.setNumerator(convertQuantity(src.getNumerator())); - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.instance.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - tgt.setDisplay(src.getDisplay()); - return tgt; - } - - public org.hl7.fhir.instance.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Reference tgt = new org.hl7.fhir.instance.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - tgt.setDisplay(src.getDisplay()); - return tgt; - } - -// public org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent convertPractitionerPractitionerRoleComponent(org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent tgt = new org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent(); -// copyElement(src, tgt); -// tgt.setOrganization(convertReference(src.getManagingOrganization())); -// tgt.setCode(convertCodeableConcept(src.getRole())); -// for (org.hl7.fhir.instance.model.CodeableConcept t : src.getSpecialty()) -// tgt.addSpecialty(convertCodeableConcept(t)); -// tgt.setPeriod(convertPeriod(src.getPeriod())); -// for (org.hl7.fhir.instance.model.Reference t : src.getLocation()) -// tgt.addLocation(convertReference(t)); -// for (org.hl7.fhir.instance.model.Reference t : src.getHealthcareService()) -// tgt.addHealthcareService(convertReference(t)); -// return tgt; -// } - -// public org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent convertPractitionerPractitionerRoleComponent(org.hl7.fhir.r4.model.Practitioner.PractitionerRoleComponent src) throws FHIRException { -// if (src == null || src.isEmpty()) -// return null; -// org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent tgt = new org.hl7.fhir.instance.model.Practitioner.PractitionerPractitionerRoleComponent(); -// copyElement(src, tgt); -// tgt.setManagingOrganization(convertReference(src.getOrganization())); -// tgt.setRole(convertCodeableConcept(src.getCode())); -// for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty()) -// tgt.addSpecialty(convertCodeableConcept(t)); -// tgt.setPeriod(convertPeriod(src.getPeriod())); -// for (org.hl7.fhir.r4.model.Reference t : src.getLocation()) -// tgt.addLocation(convertReference(t)); -// for (org.hl7.fhir.r4.model.Reference t : src.getHealthcareService()) -// tgt.addHealthcareService(convertReference(t)); -// return tgt; -// } - - private org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertReferralPriorityCode(CodeableConcept priority) { - for (org.hl7.fhir.instance.model.Coding c : priority.getCoding()) { - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "routine".equals(c.getCode())) - return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "urgent".equals(c.getCode())) - return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "stat".equals(c.getCode())) - return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT; - if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "asap".equals(c.getCode())) - return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP; - } - return null; - } - public org.hl7.fhir.r4.model.ProcedureRequest convertReferralRequest(org.hl7.fhir.instance.model.ReferralRequest src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -9965,6 +10633,21 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + private org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority convertReferralPriorityCode(CodeableConcept priority) { + for (org.hl7.fhir.instance.model.Coding c : priority.getCoding()) { + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "routine".equals(c.getCode())) + return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "urgent".equals(c.getCode())) + return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.URGENT; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "stat".equals(c.getCode())) + return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.STAT; + if ("http://hl7.org/fhir/diagnostic-order-priority".equals(c.getSystem()) && "asap".equals(c.getCode())) + return org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestPriority.ASAP; + } + return null; + } + + public org.hl7.fhir.r4.model.ProcedureRequest.ProcedureRequestStatus convertReferralStatus(org.hl7.fhir.instance.model.ReferralRequest.ReferralStatus src) throws FHIRException { if (src == null) return null; @@ -10025,6 +10708,1998 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen return tgt; } + public org.hl7.fhir.r4.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.instance.model.RiskAssessment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.RiskAssessment tgt = new org.hl7.fhir.r4.model.RiskAssessment(); + copyDomainResource(src, tgt); + tgt.setSubject(convertReference(src.getSubject())); +// tgt.setDate(src.getDate()); + tgt.setCondition(convertReference(src.getCondition())); + tgt.setContext(convertReference(src.getEncounter())); + tgt.setPerformer(convertReference(src.getPerformer())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + for (org.hl7.fhir.instance.model.Reference t : src.getBasis()) + tgt.addBasis(convertReference(t)); + for (org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction()) + tgt.addPrediction(convertRiskAssessmentPredictionComponent(t)); + tgt.setMitigation(src.getMitigation()); + return tgt; + } + + public org.hl7.fhir.instance.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.r4.model.RiskAssessment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.RiskAssessment tgt = new org.hl7.fhir.instance.model.RiskAssessment(); + copyDomainResource(src, tgt); + tgt.setSubject(convertReference(src.getSubject())); +// tgt.setDateElement(src.getOccurrenceDateTimeType()); + tgt.setCondition(convertReference(src.getCondition())); + tgt.setEncounter(convertReference(src.getContext())); + tgt.setPerformer(convertReference(src.getPerformer())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setMethod(convertCodeableConcept(src.getMethod())); + for (org.hl7.fhir.r4.model.Reference t : src.getBasis()) + tgt.addBasis(convertReference(t)); + for (org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction()) + tgt.addPrediction(convertRiskAssessmentPredictionComponent(t)); + tgt.setMitigation(src.getMitigation()); + return tgt; + } + + public org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent(); + copyElement(src, tgt); + tgt.setOutcome(convertCodeableConcept(src.getOutcome())); + tgt.setProbability(convertType(src.getProbability())); + tgt.setRelativeRisk(src.getRelativeRisk()); + tgt.setWhen(convertType(src.getWhen())); + tgt.setRationale(src.getRationale()); + return tgt; + } + + public org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent(); + copyElement(src, tgt); + tgt.setOutcome(convertCodeableConcept(src.getOutcome())); + tgt.setProbability(convertType(src.getProbability())); + tgt.setRelativeRisk(src.getRelativeRisk()); + tgt.setWhen(convertType(src.getWhen())); + tgt.setRationale(src.getRationale()); + return tgt; + } + + public org.hl7.fhir.r4.model.Schedule convertSchedule(org.hl7.fhir.instance.model.Schedule src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Schedule tgt = new org.hl7.fhir.r4.model.Schedule(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) + tgt.addServiceType(convertCodeableConcept(t)); + tgt.addActor(convertReference(src.getActor())); + tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon())); + tgt.setComment(src.getComment()); + return tgt; + } + + public org.hl7.fhir.instance.model.Schedule convertSchedule(org.hl7.fhir.r4.model.Schedule src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Schedule tgt = new org.hl7.fhir.instance.model.Schedule(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType()) + tgt.addType(convertCodeableConcept(t)); + tgt.setActor(convertReference(src.getActorFirstRep())); + tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon())); + tgt.setComment(src.getComment()); + return tgt; + } + + public org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.instance.model.SearchParameter src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent t : src.getContact()) + tgt.addContact(convertSearchParameterContactComponent(t)); + tgt.setPurpose(src.getRequirements()); + tgt.setCode(src.getCode()); + tgt.addBase(src.getBase()); + tgt.setType(convertSearchParamType(src.getType())); + tgt.setDescription(src.getDescription()); + tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); + tgt.setXpath(src.getXpath()); + tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage())); + for (org.hl7.fhir.instance.model.CodeType t : src.getTarget()) + tgt.addTarget(t.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SearchParameter tgt = new org.hl7.fhir.instance.model.SearchParameter(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertSearchParameterContactComponent(t)); + tgt.setRequirements(src.getPurpose()); + tgt.setCode(src.getCode()); + for (org.hl7.fhir.r4.model.CodeType t : src.getBase()) + tgt.setBase(t.asStringValue()); + tgt.setType(convertSearchParamType(src.getType())); + tgt.setDescription(src.getDescription()); + org.hl7.fhir.instance.utils.ToolingExtensions.setStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); + tgt.setXpath(src.getXpath()); + tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage())); + for (org.hl7.fhir.r4.model.CodeType t : src.getTarget()) + tgt.addTarget(t.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.instance.model.SearchParameter.XPathUsageType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NORMAL: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL; + case PHONETIC: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC; + case NEARBY: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY; + case DISTANCE: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE; + case OTHER: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER; + default: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL; + } + } + + public org.hl7.fhir.instance.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case NORMAL: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NORMAL; + case PHONETIC: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.PHONETIC; + case NEARBY: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NEARBY; + case DISTANCE: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.DISTANCE; + case OTHER: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.OTHER; + default: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NULL; + } + } + + public org.hl7.fhir.r4.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Slot convertSlot(org.hl7.fhir.instance.model.Slot src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Slot tgt = new org.hl7.fhir.r4.model.Slot(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + if (src.hasType()) + tgt.addServiceType(convertCodeableConcept(src.getType())); + tgt.setSchedule(convertReference(src.getSchedule())); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + tgt.setOverbooked(src.getOverbooked()); + tgt.setComment(src.getComment()); + return tgt; + } + + public org.hl7.fhir.instance.model.Slot convertSlot(org.hl7.fhir.r4.model.Slot src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Slot tgt = new org.hl7.fhir.instance.model.Slot(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType()) + tgt.setType(convertCodeableConcept(t)); + tgt.setSchedule(convertReference(src.getSchedule())); + tgt.setStart(src.getStart()); + tgt.setEnd(src.getEnd()); + tgt.setOverbooked(src.getOverbooked()); + tgt.setComment(src.getComment()); + return tgt; + } + + public org.hl7.fhir.r4.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.instance.model.Slot.SlotStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case BUSY: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSY; + case FREE: return org.hl7.fhir.r4.model.Slot.SlotStatus.FREE; + case BUSYUNAVAILABLE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYUNAVAILABLE; + case BUSYTENTATIVE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYTENTATIVE; + default: return org.hl7.fhir.r4.model.Slot.SlotStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.r4.model.Slot.SlotStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case BUSY: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSY; + case FREE: return org.hl7.fhir.instance.model.Slot.SlotStatus.FREE; + case BUSYUNAVAILABLE: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSYUNAVAILABLE; + case BUSYTENTATIVE: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSYTENTATIVE; + default: return org.hl7.fhir.instance.model.Slot.SlotStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.instance.model.StructureDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setTitle(src.getDisplay()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact()) + tgt.addContact(convertStructureDefinitionContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) + if (isJurisdiction(t)) + tgt.addJurisdiction(convertCodeableConcept(t)); + else + tgt.addUseContext(convertCodeableConceptToUsageContext(t)); + tgt.setPurpose(src.getRequirements()); + tgt.setCopyright(src.getCopyright()); + for (org.hl7.fhir.instance.model.Coding t : src.getCode()) + tgt.addKeyword(convertCoding(t)); + tgt.setFhirVersion(src.getFhirVersion()); + for (org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertStructureDefinitionMappingComponent(t)); + tgt.setKind(convertStructureDefinitionKind(src.getKind(), tgt.getId())); + tgt.setAbstract(src.getAbstract()); + tgt.setContextType(convertExtensionContext(src.getContextType())); + for (org.hl7.fhir.instance.model.StringType t : src.getContext()) + tgt.addContext(t.getValue()); + if (src.hasConstrainedType()) + tgt.setType(src.getConstrainedType()); + else if (src.getSnapshot().hasElement()) + tgt.setType(src.getSnapshot().getElement().get(0).getPath()); + else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains(".")) + tgt.setType(src.getDifferential().getElement().get(0).getPath()); + else + tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf("."))); + tgt.setBaseDefinition(src.getBase()); + tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION); + tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); + tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); + if (tgt.hasSnapshot()) + tgt.getSnapshot().getElementFirstRep().getType().clear(); + if (tgt.hasDifferential()) + tgt.getDifferential().getElementFirstRep().getType().clear(); + if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) { + tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); + tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+tgt.getType()); +// for (ElementDefinition ed : tgt.getSnapshot().getElement()) { +// ed.setPath(ed.getPath().replace(tgt.getType()+".", tgt.getId()+".")); +// } +// for (ElementDefinition ed : tgt.getDifferential().getElement()) { +// ed.setPath(ed.getPath().replace(tgt.getType()+".", tgt.getId()+".")); +// } + tgt.setType(tgt.getId()); + } + return tgt; + } + + public org.hl7.fhir.instance.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r4.model.StructureDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.StructureDefinition tgt = new org.hl7.fhir.instance.model.StructureDefinition(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setDisplay(src.getTitle()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertStructureDefinitionContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) + if (t.hasValueCodeableConcept()) + tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) + tgt.addUseContext(convertCodeableConcept(t)); + tgt.setRequirements(src.getPurpose()); + tgt.setCopyright(src.getCopyright()); + for (org.hl7.fhir.r4.model.Coding t : src.getKeyword()) + tgt.addCode(convertCoding(t)); + tgt.setFhirVersion(src.getFhirVersion()); + for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertStructureDefinitionMappingComponent(t)); + tgt.setKind(convertStructureDefinitionKind(src.getKind())); + tgt.setAbstract(src.getAbstract()); + tgt.setContextType(convertExtensionContext(src.getContextType())); + for (org.hl7.fhir.r4.model.StringType t : src.getContext()) + tgt.addContext(t.getValue()); + tgt.setConstrainedType(src.getType()); + tgt.setBase(src.getBaseDefinition()); + tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); + tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); + if (tgt.hasBase()) { + if (tgt.hasDifferential()) + tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase())); + if (tgt.hasSnapshot()) + tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase())); + } + return tgt; + } + + private String tail(String base) { + return base.substring(base.lastIndexOf("/")+1); + } + + public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind src, String dtName) throws FHIRException { + if (src == null) + return null; + switch (src) { + case DATATYPE: + if (Utilities.existsInList(dtName, "boolean", "integer", "decimal", "base64Binary", "instant", "string", "uri", "date", "dateTime", "time", "code", "oid", "uuid", "id", "unsignedInt", "positiveInt", "markdown", "xhtml")) + return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE; + else + return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE; + case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.RESOURCE; + case LOGICAL: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.LOGICAL; + default: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.NULL; + } + } + + public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case PRIMITIVETYPE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.DATATYPE; + case COMPLEXTYPE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.DATATYPE; + case RESOURCE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.RESOURCE; + case LOGICAL: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.LOGICAL; + default: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.NULL; + } + } + + public org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.RESOURCE; + case DATATYPE: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.DATATYPE; + case EXTENSION: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.EXTENSION; + default: return org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext.NULL; + } + } + + public org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext convertExtensionContext(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContext src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESOURCE: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.RESOURCE; + case DATATYPE: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.DATATYPE; + case EXTENSION: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.EXTENSION; + default: return org.hl7.fhir.instance.model.StructureDefinition.ExtensionContext.NULL; + } + } + + public org.hl7.fhir.r4.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent(); + copyElement(src, tgt); + tgt.setIdentity(src.getIdentity()); + tgt.setUri(src.getUri()); + tgt.setName(src.getName()); + tgt.setComment(src.getComments()); + return tgt; + } + + public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent(); + copyElement(src, tgt); + tgt.setIdentity(src.getIdentity()); + tgt.setUri(src.getUri()); + tgt.setName(src.getName()); + tgt.setComments(src.getComment()); + return tgt; + } + + public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent(); + copyElement(src, tgt); + List slicePaths = new ArrayList(); + for (org.hl7.fhir.instance.model.ElementDefinition t : src.getElement()) { + if (t.hasSlicing()) + slicePaths.add(t.getPath()); + tgt.addElement(convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t))); + } + return tgt; + } + + public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) + tgt.addElement(convertElementDefinition(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent(); + copyElement(src, tgt); + List slicePaths = new ArrayList(); + for (org.hl7.fhir.instance.model.ElementDefinition t : src.getElement()) { + if (t.hasSlicing()) + slicePaths.add(t.getPath()); + tgt.addElement(convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t))); + } + return tgt; + } + + public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) + tgt.addElement(convertElementDefinition(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Subscription convertSubscription(org.hl7.fhir.instance.model.Subscription src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Subscription tgt = new org.hl7.fhir.r4.model.Subscription(); + copyDomainResource(src, tgt); + tgt.setCriteria(src.getCriteria()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getContact()) + tgt.addContact(convertContactPoint(t)); + tgt.setReason(src.getReason()); + tgt.setStatus(convertSubscriptionStatus(src.getStatus())); + tgt.setError(src.getError()); + tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); + tgt.setEnd(src.getEnd()); + for (org.hl7.fhir.instance.model.Coding t : src.getTag()) + tgt.addTag(convertCoding(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Subscription convertSubscription(org.hl7.fhir.r4.model.Subscription src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Subscription tgt = new org.hl7.fhir.instance.model.Subscription(); + copyDomainResource(src, tgt); + tgt.setCriteria(src.getCriteria()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact()) + tgt.addContact(convertContactPoint(t)); + tgt.setReason(src.getReason()); + tgt.setStatus(convertSubscriptionStatus(src.getStatus())); + tgt.setError(src.getError()); + tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); + tgt.setEnd(src.getEnd()); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) + tgt.addTag(convertCoding(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.instance.model.Subscription.SubscriptionStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUESTED: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.REQUESTED; + case ACTIVE: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ACTIVE; + case ERROR: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ERROR; + case OFF: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.OFF; + default: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUESTED: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.REQUESTED; + case ACTIVE: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.ACTIVE; + case ERROR: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.ERROR; + case OFF: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.OFF; + default: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent(); + copyElement(src, tgt); + tgt.setType(convertSubscriptionChannelType(src.getType())); + tgt.setEndpoint(src.getEndpoint()); + tgt.setPayload(src.getPayload()); + tgt.addHeader(src.getHeader()); + return tgt; + } + + public org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent(); + copyElement(src, tgt); + tgt.setType(convertSubscriptionChannelType(src.getType())); + tgt.setEndpoint(src.getEndpoint()); + tgt.setPayload(src.getPayload()); + if (src.hasHeader()) + tgt.setHeaderElement(convertString(src.getHeader().get(0))); + return tgt; + } + + public org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESTHOOK: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.RESTHOOK; + case WEBSOCKET: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.WEBSOCKET; + case EMAIL: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.EMAIL; + case SMS: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.SMS; + case MESSAGE: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.MESSAGE; + default: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.NULL; + } + } + + public org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESTHOOK: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.RESTHOOK; + case WEBSOCKET: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.WEBSOCKET; + case EMAIL: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.EMAIL; + case SMS: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.SMS; + case MESSAGE: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.MESSAGE; + default: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.NULL; + } + } + + public org.hl7.fhir.r4.model.Substance convertSubstance(org.hl7.fhir.instance.model.Substance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Substance tgt = new org.hl7.fhir.r4.model.Substance(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getCategory()) + tgt.addCategory(convertCodeableConcept(t)); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent t : src.getInstance()) + tgt.addInstance(convertSubstanceInstanceComponent(t)); + for (org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent t : src.getIngredient()) + tgt.addIngredient(convertSubstanceIngredientComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.Substance convertSubstance(org.hl7.fhir.r4.model.Substance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Substance tgt = new org.hl7.fhir.instance.model.Substance(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) + tgt.addCategory(convertCodeableConcept(t)); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent t : src.getInstance()) + tgt.addInstance(convertSubstanceInstanceComponent(t)); + for (org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent t : src.getIngredient()) + tgt.addIngredient(convertSubstanceIngredientComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent(); + copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setExpiry(src.getExpiry()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + return tgt; + } + + public org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent(); + copyElement(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setExpiry(src.getExpiry()); + tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); + return tgt; + } + + public org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent(); + copyElement(src, tgt); + tgt.setQuantity(convertRatio(src.getQuantity())); + tgt.setSubstance(convertReference(src.getSubstance())); + return tgt; + } + + public org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent(); + copyElement(src, tgt); + tgt.setQuantity(convertRatio(src.getQuantity())); +// tgt.setSubstance(convertReference(src.getSubstance())); + return tgt; + } + + public org.hl7.fhir.r4.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.instance.model.SupplyDelivery src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.SupplyDelivery tgt = new org.hl7.fhir.r4.model.SupplyDelivery(); + copyDomainResource(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus())); + tgt.setPatient(convertReference(src.getPatient())); + tgt.setType(convertCodeableConcept(src.getType())); +// tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); +// tgt.setSuppliedItem(convertReference(src.getSuppliedItem())); + tgt.setSupplier(convertReference(src.getSupplier())); +// tgt.setWhenPrepared(convertPeriod(src.getWhenPrepared())); +// tgt.setTime(src.getTime()); + tgt.setDestination(convertReference(src.getDestination())); + for (org.hl7.fhir.instance.model.Reference t : src.getReceiver()) + tgt.addReceiver(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SupplyDelivery tgt = new org.hl7.fhir.instance.model.SupplyDelivery(); + copyDomainResource(src, tgt); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus())); + tgt.setPatient(convertReference(src.getPatient())); + tgt.setType(convertCodeableConcept(src.getType())); +// tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); +// tgt.setSuppliedItem(convertReference(src.getSuppliedItem())); + tgt.setSupplier(convertReference(src.getSupplier())); +// tgt.setWhenPrepared(convertPeriod(src.getWhenPrepared())); +// tgt.setTime(src.getTime()); + tgt.setDestination(convertReference(src.getDestination())); + for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) + tgt.addReceiver(convertReference(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED; + case ABANDONED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED; + default: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case INPROGRESS: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS; + case COMPLETED: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED; + case ABANDONED: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED; + default: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.instance.model.SupplyRequest src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.SupplyRequest tgt = new org.hl7.fhir.r4.model.SupplyRequest(); + copyDomainResource(src, tgt); +// tgt.setPatient(convertReference(src.getPatient())); +// tgt.setSource(convertReference(src.getSource())); +// if (src.hasDate()) +// tgt.setDate(src.getDate()); +// tgt.setIdentifier(convertIdentifier(src.getIdentifier())); +// tgt.setStatus(convertSupplyRequestStatus(src.getStatus())); +// tgt.setKind(convertCodeableConcept(src.getKind())); +// tgt.getOrderedItem().setItem(convertReference(src.getOrderedItem())); +// for (org.hl7.fhir.instance.model.Reference t : src.getSupplier()) +// tgt.addSupplier(convertReference(t)); +// tgt.setReason(convertType(src.getReason())); +// tgt.setWhen(convertSupplyRequestWhenComponent(src.getWhen())); + return tgt; + } + + public org.hl7.fhir.instance.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.r4.model.SupplyRequest src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.SupplyRequest tgt = new org.hl7.fhir.instance.model.SupplyRequest(); +// copyDomainResource(src, tgt); +// tgt.setPatient(convertReference(src.getPatient())); +// tgt.setSource(convertReference(src.getSource())); +// if (src.hasDate()) +// tgt.setDate(src.getDate()); +// tgt.setIdentifier(convertIdentifier(src.getIdentifier())); +// tgt.setStatus(convertSupplyRequestStatus(src.getStatus())); +// tgt.setKind(convertCodeableConcept(src.getKind())); +// tgt.setOrderedItem(convertReference(src.getOrderedItem().getItemReference())); +// for (org.hl7.fhir.r4.model.Reference t : src.getSupplier()) +// tgt.addSupplier(convertReference(t)); +// tgt.setReason(convertType(src.getReason())); +// tgt.setWhen(convertSupplyRequestWhenComponent(src.getWhen())); + return tgt; + } + + public org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case REQUESTED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE; + case COMPLETED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED; + case FAILED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED; + case CANCELLED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED; + default: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case ACTIVE: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.REQUESTED; + case COMPLETED: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.COMPLETED; + case CANCELLED: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.CANCELLED; + default: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.TestScript convertTestScript(org.hl7.fhir.instance.model.TestScript src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript tgt = new org.hl7.fhir.r4.model.TestScript(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent t : src.getContact()) + tgt.addContact(convertTestScriptContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) + if (isJurisdiction(t)) + tgt.addJurisdiction(convertCodeableConcept(t)); + else + tgt.addUseContext(convertCodeableConceptToUsageContext(t)); + tgt.setPurpose(src.getRequirements()); + tgt.setCopyright(src.getCopyright()); + tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata())); + for (org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent t : src.getFixture()) + tgt.addFixture(convertTestScriptFixtureComponent(t)); + for (org.hl7.fhir.instance.model.Reference t : src.getProfile()) + tgt.addProfile(convertReference(t)); + for (org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent t : src.getVariable()) + tgt.addVariable(convertTestScriptVariableComponent(t)); + tgt.setSetup(convertTestScriptSetupComponent(src.getSetup())); + for (org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent t : src.getTest()) + tgt.addTest(convertTestScriptTestComponent(t)); + tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript convertTestScript(org.hl7.fhir.r4.model.TestScript src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript tgt = new org.hl7.fhir.instance.model.TestScript(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertTestScriptContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) + if (t.hasValueCodeableConcept()) + tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) + tgt.addUseContext(convertCodeableConcept(t)); + tgt.setRequirements(src.getPurpose()); + tgt.setCopyright(src.getCopyright()); + tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata())); + for (org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent t : src.getFixture()) + tgt.addFixture(convertTestScriptFixtureComponent(t)); + for (org.hl7.fhir.r4.model.Reference t : src.getProfile()) + tgt.addProfile(convertReference(t)); + for (org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent t : src.getVariable()) + tgt.addVariable(convertTestScriptVariableComponent(t)); + tgt.setSetup(convertTestScriptSetupComponent(src.getSetup())); + for (org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent t : src.getTest()) + tgt.addTest(convertTestScriptTestComponent(t)); + tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown())); + return tgt; + } + + public org.hl7.fhir.r4.model.ContactDetail convertTestScriptContactComponent(org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent convertTestScriptContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink()) + tgt.addLink(convertTestScriptMetadataLinkComponent(t)); + for (org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability()) + tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink()) + tgt.addLink(convertTestScriptMetadataLinkComponent(t)); + for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability()) + tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent(); + copyElement(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setDescription(src.getDescription()); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent(); + copyElement(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.setDescription(src.getDescription()); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent(); + copyElement(src, tgt); + tgt.setRequired(src.getRequired()); + tgt.setValidated(src.getValidated()); + tgt.setDescription(src.getDescription()); + tgt.setDestination(src.getDestination()); + for (org.hl7.fhir.instance.model.UriType t : src.getLink()) + tgt.addLink(t.getValue()); + tgt.setCapabilities(convertReference(src.getConformance())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent(); + copyElement(src, tgt); + tgt.setRequired(src.getRequired()); + tgt.setValidated(src.getValidated()); + tgt.setDescription(src.getDescription()); + tgt.setDestination(src.getDestination()); + for (org.hl7.fhir.r4.model.UriType t : src.getLink()) + tgt.addLink(t.getValue()); + tgt.setConformance(convertReference(src.getCapabilities())); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent(); + copyElement(src, tgt); + tgt.setAutocreate(src.getAutocreate()); + tgt.setAutodelete(src.getAutodelete()); + tgt.setResource(convertReference(src.getResource())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent(); + copyElement(src, tgt); + tgt.setAutocreate(src.getAutocreate()); + tgt.setAutodelete(src.getAutodelete()); + tgt.setResource(convertReference(src.getResource())); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setHeaderField(src.getHeaderField()); + tgt.setPath(src.getPath()); + tgt.setSourceId(src.getSourceId()); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setHeaderField(src.getHeaderField()); + tgt.setPath(src.getPath()); + tgt.setSourceId(src.getSourceId()); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent t : src.getAction()) + tgt.addAction(convertSetupActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.TestScript.SetupActionComponent t : src.getAction()) + tgt.addAction(convertSetupActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestScript.SetupActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent(); + copyElement(src, tgt); + tgt.setType(convertCoding(src.getType())); + tgt.setResource(src.getResource()); + tgt.setLabel(src.getLabel()); + tgt.setDescription(src.getDescription()); + tgt.setAccept(convertContentType(src.getAccept())); + tgt.setContentType(convertContentType(src.getContentType())); + tgt.setDestination(src.getDestination()); + tgt.setEncodeRequestUrl(src.getEncodeRequestUrl()); + tgt.setParams(src.getParams()); + for (org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + tgt.setResponseId(src.getResponseId()); + tgt.setSourceId(src.getSourceId()); + tgt.setTargetId(src.getTargetId()); + tgt.setUrl(src.getUrl()); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent(); + copyElement(src, tgt); + tgt.setType(convertCoding(src.getType())); + tgt.setResource(src.getResource()); + tgt.setLabel(src.getLabel()); + tgt.setDescription(src.getDescription()); + tgt.setAccept(convertContentType(src.getAccept())); + tgt.setContentType(convertContentType(src.getContentType())); + tgt.setDestination(src.getDestination()); + tgt.setEncodeRequestUrl(src.getEncodeRequestUrl()); + tgt.setParams(src.getParams()); + for (org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + tgt.setResponseId(src.getResponseId()); + tgt.setSourceId(src.getSourceId()); + tgt.setTargetId(src.getTargetId()); + tgt.setUrl(src.getUrl()); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.ContentType convertContentType(org.hl7.fhir.instance.model.TestScript.ContentType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case XML: return org.hl7.fhir.r4.model.TestScript.ContentType.XML; + case JSON: return org.hl7.fhir.r4.model.TestScript.ContentType.JSON; + default: return org.hl7.fhir.r4.model.TestScript.ContentType.NULL; + } + } + + public org.hl7.fhir.instance.model.TestScript.ContentType convertContentType(org.hl7.fhir.r4.model.TestScript.ContentType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case XML: return org.hl7.fhir.instance.model.TestScript.ContentType.XML; + case JSON: return org.hl7.fhir.instance.model.TestScript.ContentType.JSON; + default: return org.hl7.fhir.instance.model.TestScript.ContentType.NULL; + } + } + + public org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + tgt.setField(src.getField()); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + tgt.setField(src.getField()); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent(); + copyElement(src, tgt); + tgt.setLabel(src.getLabel()); + tgt.setDescription(src.getDescription()); + tgt.setDirection(convertAssertionDirectionType(src.getDirection())); + tgt.setCompareToSourceId(src.getCompareToSourceId()); + tgt.setCompareToSourcePath(src.getCompareToSourcePath()); + tgt.setContentType(convertContentType(src.getContentType())); + tgt.setHeaderField(src.getHeaderField()); + tgt.setMinimumId(src.getMinimumId()); + tgt.setNavigationLinks(src.getNavigationLinks()); + tgt.setOperator(convertAssertionOperatorType(src.getOperator())); + tgt.setPath(src.getPath()); + tgt.setResource(src.getResource()); + tgt.setResponse(convertAssertionResponseTypes(src.getResponse())); + tgt.setResponseCode(src.getResponseCode()); + tgt.setSourceId(src.getSourceId()); + tgt.setValidateProfileId(src.getValidateProfileId()); + tgt.setValue(src.getValue()); + tgt.setWarningOnly(src.getWarningOnly()); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent(); + copyElement(src, tgt); + tgt.setLabel(src.getLabel()); + tgt.setDescription(src.getDescription()); + tgt.setDirection(convertAssertionDirectionType(src.getDirection())); + tgt.setCompareToSourceId(src.getCompareToSourceId()); + tgt.setCompareToSourcePath(src.getCompareToSourcePath()); + tgt.setContentType(convertContentType(src.getContentType())); + tgt.setHeaderField(src.getHeaderField()); + tgt.setMinimumId(src.getMinimumId()); + tgt.setNavigationLinks(src.getNavigationLinks()); + tgt.setOperator(convertAssertionOperatorType(src.getOperator())); + tgt.setPath(src.getPath()); + tgt.setResource(src.getResource()); + tgt.setResponse(convertAssertionResponseTypes(src.getResponse())); + tgt.setResponseCode(src.getResponseCode()); + tgt.setSourceId(src.getSourceId()); + tgt.setValidateProfileId(src.getValidateProfileId()); + tgt.setValue(src.getValue()); + tgt.setWarningOnly(src.getWarningOnly()); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.instance.model.TestScript.AssertionDirectionType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESPONSE: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.RESPONSE; + case REQUEST: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.REQUEST; + default: return org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL; + } + } + + public org.hl7.fhir.instance.model.TestScript.AssertionDirectionType convertAssertionDirectionType(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case RESPONSE: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.RESPONSE; + case REQUEST: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.REQUEST; + default: return org.hl7.fhir.instance.model.TestScript.AssertionDirectionType.NULL; + } + } + + public org.hl7.fhir.r4.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.instance.model.TestScript.AssertionOperatorType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case EQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EQUALS; + case NOTEQUALS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEQUALS; + case IN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.IN; + case NOTIN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTIN; + case GREATERTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.GREATERTHAN; + case LESSTHAN: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.LESSTHAN; + case EMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EMPTY; + case NOTEMPTY: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEMPTY; + case CONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.CONTAINS; + case NOTCONTAINS: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTCONTAINS; + default: return org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL; + } + } + + public org.hl7.fhir.instance.model.TestScript.AssertionOperatorType convertAssertionOperatorType(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case EQUALS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.EQUALS; + case NOTEQUALS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTEQUALS; + case IN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.IN; + case NOTIN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTIN; + case GREATERTHAN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.GREATERTHAN; + case LESSTHAN: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.LESSTHAN; + case EMPTY: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.EMPTY; + case NOTEMPTY: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTEMPTY; + case CONTAINS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.CONTAINS; + case NOTCONTAINS: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NOTCONTAINS; + default: return org.hl7.fhir.instance.model.TestScript.AssertionOperatorType.NULL; + } + } + + public org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OKAY: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.OKAY; + case CREATED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CREATED; + case NOCONTENT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOCONTENT; + case NOTMODIFIED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTMODIFIED; + case BAD: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.BAD; + case FORBIDDEN: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.FORBIDDEN; + case NOTFOUND: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTFOUND; + case METHODNOTALLOWED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED; + case CONFLICT: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CONFLICT; + case GONE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.GONE; + case PRECONDITIONFAILED: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED; + case UNPROCESSABLE: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.UNPROCESSABLE; + default: return org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL; + } + } + + public org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes convertAssertionResponseTypes(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case OKAY: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.OKAY; + case CREATED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.CREATED; + case NOCONTENT: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOCONTENT; + case NOTMODIFIED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOTMODIFIED; + case BAD: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.BAD; + case FORBIDDEN: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.FORBIDDEN; + case NOTFOUND: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NOTFOUND; + case METHODNOTALLOWED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED; + case CONFLICT: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.CONFLICT; + case GONE: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.GONE; + case PRECONDITIONFAILED: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED; + case UNPROCESSABLE: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.UNPROCESSABLE; + default: return org.hl7.fhir.instance.model.TestScript.AssertionResponseTypes.NULL; + } + } + + + public org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent t : src.getAction()) + tgt.addAction(convertTestActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.TestScript.TestActionComponent t : src.getAction()) + tgt.addAction(convertTestActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestScript.TestActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent t : src.getAction()) + tgt.addAction(convertTeardownActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.TestScript.TeardownActionComponent t : src.getAction()) + tgt.addAction(convertTeardownActionComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TeardownActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestScript.TeardownActionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent(); + copyElement(src, tgt); + tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent(); + copyElement(src, tgt); + tgt.setSystem(src.getUrl()); + tgt.setVersion(src.getVersion()); + tgt.setCaseSensitive(src.getCaseSensitive()); + + for (ConceptDefinitionComponent cc : src.getConcept()) + tgt.addConcept(convertCodeSystemConcept(src, cc)); + return tgt; + } + +public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); + copyElement(src, tgt); + tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); + tgt.setCode(src.getCode()); + tgt.setDefinition(src.getDefinition()); + tgt.setDisplay(src.getDisplay()); + + for (ConceptDefinitionComponent cc : src.getConcept()) + tgt.addConcept(convertCodeSystemConcept(cs, cc)); + for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) + tgt.addDesignation(convertCodeSystemDesignation(cc)); + return tgt; + } + +public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); + copyElement(src, tgt); + tgt.setUse(convertCoding(src.getUse())); + tgt.setLanguage(src.getLanguage()); + tgt.setValue(src.getValue()); + + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.instance.model.ValueSet src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + tgt.addIdentifier(convertIdentifier(src.getIdentifier())); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent t : src.getContact()) + tgt.addContact(convertValueSetContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) + if (isJurisdiction(t)) + tgt.addJurisdiction(convertCodeableConcept(t)); + else + tgt.addUseContext(convertCodeableConceptToUsageContext(t)); + tgt.setImmutable(src.getImmutable()); + tgt.setPurpose(src.getRequirements()); + tgt.setCopyright(src.getCopyright()); + tgt.setExtensible(src.getExtensible()); + if (src.hasCompose()) { + tgt.setCompose(convertValueSetComposeComponent(src.getCompose())); + tgt.getCompose().setLockedDate(src.getLockedDate()); + } + if (src.hasCodeSystem() && advisor != null) { + org.hl7.fhir.r4.model.CodeSystem tgtcs = new org.hl7.fhir.r4.model.CodeSystem(); + copyDomainResource(src, tgtcs); + tgtcs.setUrl(src.getCodeSystem().getSystem()); + tgtcs.setIdentifier(convertIdentifier(src.getIdentifier())); + tgtcs.setVersion(src.getCodeSystem().getVersion()); + tgtcs.setName(src.getName()+" Code System"); + tgtcs.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgtcs.setExperimental(src.getExperimental()); + tgtcs.setPublisher(src.getPublisher()); + for (org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent t : src.getContact()) + tgtcs.addContact(convertValueSetContactComponent(t)); + if (src.hasDate()) + tgtcs.setDate(src.getDate()); + tgtcs.setDescription(src.getDescription()); + for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) + if (isJurisdiction(t)) + tgtcs.addJurisdiction(convertCodeableConcept(t)); + else + tgtcs.addUseContext(convertCodeableConceptToUsageContext(t)); + tgtcs.setPurpose(src.getRequirements()); + tgtcs.setCopyright(src.getCopyright()); + tgtcs.setContent(CodeSystemContentMode.COMPLETE); + tgtcs.setCaseSensitive(src.getCodeSystem().getCaseSensitive()); + for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs : src.getCodeSystem().getConcept()) + processConcept(tgtcs.getConcept(), cs, tgtcs); + advisor.handleCodeSystem(tgtcs, tgt); + tgt.setUserData("r2-cs", tgtcs); + tgt.getCompose().addInclude().setSystem(tgtcs.getUrl()); + } + tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); + return tgt; + } + + private void processConcept(List concepts, org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException { + org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent(); + concepts.add(ct); + ct.setCode(cs.getCode()); + ct.setDisplay(cs.getDisplay()); + ct.setDefinition(cs.getDefinition()); + if (cs.getAbstract()) + CodeSystemUtilities.setNotSelectable(tgtcs, ct); + for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { + org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent(); + cst.setLanguage(csd.getLanguage()); + cst.setUse(convertCoding(csd.getUse())); + cst.setValue(csd.getValue()); + } + + for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) + processConcept(ct.getConcept(), csc, tgtcs); + } + + private void processConcept(List concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException { + org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); + concepts.add(ct); + ct.setCode(cs.getCode()); + ct.setDisplay(cs.getDisplay()); + ct.setDefinition(cs.getDefinition()); + if (CodeSystemUtilities.isNotSelectable(srcCS, cs)) + ct.setAbstract(true); + for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { + org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); + cst.setLanguage(csd.getLanguage()); + cst.setUse(convertCoding(csd.getUse())); + cst.setValue(csd.getValue()); + } + + for (ConceptDefinitionComponent csc : cs.getConcept()) + processConcept(ct.getConcept(), csc, srcCS); + } + + public org.hl7.fhir.instance.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet tgt = new org.hl7.fhir.instance.model.ValueSet(); + copyDomainResource(src, tgt); + tgt.setUrl(src.getUrl()); + for (org.hl7.fhir.r4.model.Identifier i : src.getIdentifier()) + tgt.setIdentifier(convertIdentifier(i)); + tgt.setVersion(src.getVersion()); + tgt.setName(src.getName()); + tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); + if (src.hasExperimental()) + tgt.setExperimental(src.getExperimental()); + tgt.setPublisher(src.getPublisher()); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) + tgt.addContact(convertValueSetContactComponent(t)); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setLockedDate(src.getCompose().getLockedDate()); + tgt.setDescription(src.getDescription()); + for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) + if (t.hasValueCodeableConcept()) + tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) + tgt.addUseContext(convertCodeableConcept(t)); + tgt.setImmutable(src.getImmutable()); + tgt.setRequirements(src.getPurpose()); + tgt.setCopyright(src.getCopyright()); + tgt.setExtensible(src.getExtensible()); + org.hl7.fhir.r4.model.CodeSystem srcCS = (CodeSystem) src.getUserData("r2-cs"); + if (srcCS == null) + srcCS = advisor.getCodeSystem(src); + if (srcCS != null) { + tgt.getCodeSystem().setSystem(srcCS.getUrl()); + tgt.getCodeSystem().setVersion(srcCS.getVersion()); + tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); + for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) + processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS); + + } + tgt.setCompose(convertValueSetComposeComponent(src.getCompose(), srcCS == null ? null : srcCS.getUrl())); + tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); + return tgt; + } + + private static boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) + || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + + public org.hl7.fhir.r4.model.ContactDetail convertValueSetContactComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent convertValueSetContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) + tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.instance.model.UriType t : src.getImport()) + tgt.addInclude().addValueSet(t.getValue()); + for (org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent t : src.getInclude()) + tgt.addInclude(convertConceptSetComponent(t)); + for (org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent t : src.getExclude()) + tgt.addExclude(convertConceptSetComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent src, String noSystem) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getInclude()) { + for (org.hl7.fhir.r4.model.UriType ti : t.getValueSet()) + tgt.addImport(ti.getValue()); + if (noSystem == null || !t.getSystem().equals(noSystem)) + tgt.addInclude(convertConceptSetComponent(t)); + } + for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getExclude()) + tgt.addExclude(convertConceptSetComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setVersion(src.getVersion()); + for (org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) + tgt.addConcept(convertConceptReferenceComponent(t)); + for (org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) + tgt.addFilter(convertConceptSetFilterComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setVersion(src.getVersion()); + for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) + tgt.addConcept(convertConceptReferenceComponent(t)); + for (org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) + tgt.addFilter(convertConceptSetFilterComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent t : src.getDesignation()) + tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptReferenceComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation()) + tgt.addDesignation(convertConceptReferenceDesignationComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent(); + copyElement(src, tgt); + tgt.setLanguage(src.getLanguage()); + tgt.setUse(convertCoding(src.getUse())); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); + copyElement(src, tgt); + tgt.setLanguage(src.getLanguage()); + tgt.setUse(convertCoding(src.getUse())); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent(); + copyElement(src, tgt); + tgt.setProperty(src.getProperty()); + tgt.setOp(convertFilterOperator(src.getOp())); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptSetFilterComponent(); + copyElement(src, tgt); + tgt.setProperty(src.getProperty()); + tgt.setOp(convertFilterOperator(src.getOp())); + tgt.setValue(src.getValue()); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.instance.model.ValueSet.FilterOperator src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case EQUAL: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL; + case ISA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA; + case ISNOTA: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA; + case REGEX: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX; + case IN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN; + case NOTIN: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN; + default: return org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL; + } + } + + public org.hl7.fhir.instance.model.ValueSet.FilterOperator convertFilterOperator(org.hl7.fhir.r4.model.ValueSet.FilterOperator src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case EQUAL: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.EQUAL; + case ISA: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.ISA; + case ISNOTA: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.ISNOTA; + case REGEX: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.REGEX; + case IN: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.IN; + case NOTIN: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.NOTIN; + default: return org.hl7.fhir.instance.model.ValueSet.FilterOperator.NULL; + } + } + + public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent(); + copyElement(src, tgt); + tgt.setIdentifier(src.getIdentifier()); + tgt.setTimestamp(src.getTimestamp()); + tgt.setTotal(src.getTotal()); + tgt.setOffset(src.getOffset()); + for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) + tgt.addParameter(convertValueSetExpansionParameterComponent(t)); + for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) + tgt.addContains(convertValueSetExpansionContainsComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent(); + copyElement(src, tgt); + tgt.setIdentifier(src.getIdentifier()); + tgt.setTimestamp(src.getTimestamp()); + tgt.setTotal(src.getTotal()); + tgt.setOffset(src.getOffset()); + for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) + tgt.addParameter(convertValueSetExpansionParameterComponent(t)); + for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) + tgt.addContains(convertValueSetExpansionContainsComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent(); + copyElement(src, tgt); + tgt.setName(src.getName()); + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setAbstract(src.getAbstract()); + tgt.setVersion(src.getVersion()); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) + tgt.addContains(convertValueSetExpansionContainsComponent(t)); + return tgt; + } + + public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent(); + copyElement(src, tgt); + tgt.setSystem(src.getSystem()); + tgt.setAbstract(src.getAbstract()); + tgt.setVersion(src.getVersion()); + tgt.setCode(src.getCode()); + tgt.setDisplay(src.getDisplay()); + for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) + tgt.addContains(convertValueSetExpansionContainsComponent(t)); + return tgt; + } + + public org.hl7.fhir.r4.model.ListResource convertList(org.hl7.fhir.instance.model.List_ src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ListResource tgt = new org.hl7.fhir.r4.model.ListResource(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setTitle(src.getTitle()); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setSubject(convertReference(src.getSubject())); + tgt.setSource(convertReference(src.getSource())); + tgt.setEncounter(convertReference(src.getEncounter())); + tgt.setStatus(convertListStatus(src.getStatus())); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); + tgt.setMode(convertListMode(src.getMode())); + if (src.hasNote()) + tgt.addNote(new org.hl7.fhir.r4.model.Annotation().setText(src.getNote())); + for (org.hl7.fhir.instance.model.List_.ListEntryComponent t : src.getEntry()) + tgt.addEntry(convertListEntry(t)); + return tgt; + } + + + public org.hl7.fhir.r4.model.ListResource.ListStatus convertListStatus(org.hl7.fhir.instance.model.List_.ListStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CURRENT: return org.hl7.fhir.r4.model.ListResource.ListStatus.CURRENT; + case RETIRED: return org.hl7.fhir.r4.model.ListResource.ListStatus.RETIRED; + case ENTEREDINERROR: return org.hl7.fhir.r4.model.ListResource.ListStatus.ENTEREDINERROR; + default: return org.hl7.fhir.r4.model.ListResource.ListStatus.NULL; + } + } + + public org.hl7.fhir.r4.model.ListResource.ListMode convertListMode(org.hl7.fhir.instance.model.List_.ListMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case WORKING: return org.hl7.fhir.r4.model.ListResource.ListMode.WORKING; + case SNAPSHOT: return org.hl7.fhir.r4.model.ListResource.ListMode.SNAPSHOT; + case CHANGES: return org.hl7.fhir.r4.model.ListResource.ListMode.CHANGES; + default: return org.hl7.fhir.r4.model.ListResource.ListMode.NULL; + } + } + + public org.hl7.fhir.r4.model.ListResource.ListEntryComponent convertListEntry(org.hl7.fhir.instance.model.List_.ListEntryComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.r4.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.r4.model.ListResource.ListEntryComponent(); + copyBackboneElement(src, tgt); + tgt.setFlag(convertCodeableConcept(src.getFlag())); + tgt.setDeleted(src.getDeleted()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setItem(convertReference(src.getItem())); + return tgt; + } + + public org.hl7.fhir.instance.model.List_ convertList(org.hl7.fhir.r4.model.ListResource src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.List_ tgt = new org.hl7.fhir.instance.model.List_(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(convertIdentifier(t)); + tgt.setTitle(src.getTitle()); + tgt.setCode(convertCodeableConcept(src.getCode())); + tgt.setSubject(convertReference(src.getSubject())); + tgt.setSource(convertReference(src.getSource())); + tgt.setEncounter(convertReference(src.getEncounter())); + tgt.setStatus(convertListStatus(src.getStatus())); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); + tgt.setMode(convertListMode(src.getMode())); + for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) + tgt.setNote(t.getText()); + for (org.hl7.fhir.r4.model.ListResource.ListEntryComponent t : src.getEntry()) + tgt.addEntry(convertListEntry(t)); + return tgt; + } + + + public org.hl7.fhir.instance.model.List_.ListStatus convertListStatus(org.hl7.fhir.r4.model.ListResource.ListStatus src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case CURRENT: return org.hl7.fhir.instance.model.List_.ListStatus.CURRENT; + case RETIRED: return org.hl7.fhir.instance.model.List_.ListStatus.RETIRED; + case ENTEREDINERROR: return org.hl7.fhir.instance.model.List_.ListStatus.ENTEREDINERROR; + default: return org.hl7.fhir.instance.model.List_.ListStatus.NULL; + } + } + + public org.hl7.fhir.instance.model.List_.ListMode convertListMode(org.hl7.fhir.r4.model.ListResource.ListMode src) throws FHIRException { + if (src == null) + return null; + switch (src) { + case WORKING: return org.hl7.fhir.instance.model.List_.ListMode.WORKING; + case SNAPSHOT: return org.hl7.fhir.instance.model.List_.ListMode.SNAPSHOT; + case CHANGES: return org.hl7.fhir.instance.model.List_.ListMode.CHANGES; + default: return org.hl7.fhir.instance.model.List_.ListMode.NULL; + } + } + + public org.hl7.fhir.instance.model.List_.ListEntryComponent convertListEntry(org.hl7.fhir.r4.model.ListResource.ListEntryComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.instance.model.List_.ListEntryComponent tgt = new org.hl7.fhir.instance.model.List_.ListEntryComponent(); + copyBackboneElement(src, tgt); + tgt.setFlag(convertCodeableConcept(src.getFlag())); + tgt.setDeleted(src.getDeleted()); + if (src.hasDate()) + tgt.setDate(src.getDate()); + tgt.setItem(convertReference(src.getItem())); + return tgt; + } + + + public org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.instance.model.Resource src) throws FHIRException { if (src == null || src.isEmpty()) return null; @@ -10319,2653 +12994,4 @@ public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponen throw new Error("Unknown resource "+src.fhirType()); } - public org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent(); - copyElement(src, tgt); - tgt.setCode(convertTypeRestfulInteraction(src.getCode())); - tgt.setDocumentation(src.getDocumentation()); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent tgt = new org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent(); - copyElement(src, tgt); - tgt.setCode(convertTypeRestfulInteraction(src.getCode())); - tgt.setDocumentation(src.getDocumentation()); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NOVERSION: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NOVERSION; - case VERSIONED: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONED; - case VERSIONEDUPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONEDUPDATE; - default: return org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy convertResourceVersionPolicy(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NOVERSION: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.NOVERSION; - case VERSIONED: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.VERSIONED; - case VERSIONEDUPDATE: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.VERSIONEDUPDATE; - default: return org.hl7.fhir.instance.model.Conformance.ResourceVersionPolicy.NULL; - } - } - - public org.hl7.fhir.r4.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.instance.model.MessageHeader.ResponseType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OK: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.OK; - case TRANSIENTERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.TRANSIENTERROR; - case FATALERROR: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.FATALERROR; - default: return org.hl7.fhir.r4.model.MessageHeader.ResponseType.NULL; - } - } - - public org.hl7.fhir.instance.model.MessageHeader.ResponseType convertResponseType(org.hl7.fhir.r4.model.MessageHeader.ResponseType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case OK: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.OK; - case TRANSIENTERROR: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.TRANSIENTERROR; - case FATALERROR: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.FATALERROR; - default: return org.hl7.fhir.instance.model.MessageHeader.ResponseType.NULL; - } - } - - public org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode convertRestfulConformanceMode(org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CLIENT: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.CLIENT; - case SERVER: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.SERVER; - default: return org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode convertRestfulConformanceMode(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CLIENT: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.CLIENT; - case SERVER: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.SERVER; - default: return org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode.NULL; - } - } - - public org.hl7.fhir.r4.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.instance.model.RiskAssessment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.RiskAssessment tgt = new org.hl7.fhir.r4.model.RiskAssessment(); - copyDomainResource(src, tgt); - tgt.setSubject(convertReference(src.getSubject())); -// tgt.setDate(src.getDate()); - tgt.setCondition(convertReference(src.getCondition())); - tgt.setContext(convertReference(src.getEncounter())); - tgt.setPerformer(convertReference(src.getPerformer())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - for (org.hl7.fhir.instance.model.Reference t : src.getBasis()) - tgt.addBasis(convertReference(t)); - for (org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction()) - tgt.addPrediction(convertRiskAssessmentPredictionComponent(t)); - tgt.setMitigation(src.getMitigation()); - return tgt; - } - - public org.hl7.fhir.instance.model.RiskAssessment convertRiskAssessment(org.hl7.fhir.r4.model.RiskAssessment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.RiskAssessment tgt = new org.hl7.fhir.instance.model.RiskAssessment(); - copyDomainResource(src, tgt); - tgt.setSubject(convertReference(src.getSubject())); -// tgt.setDateElement(src.getOccurrenceDateTimeType()); - tgt.setCondition(convertReference(src.getCondition())); - tgt.setEncounter(convertReference(src.getContext())); - tgt.setPerformer(convertReference(src.getPerformer())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setMethod(convertCodeableConcept(src.getMethod())); - for (org.hl7.fhir.r4.model.Reference t : src.getBasis()) - tgt.addBasis(convertReference(t)); - for (org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent t : src.getPrediction()) - tgt.addPrediction(convertRiskAssessmentPredictionComponent(t)); - tgt.setMitigation(src.getMitigation()); - return tgt; - } - - public org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent(); - copyElement(src, tgt); - tgt.setOutcome(convertCodeableConcept(src.getOutcome())); - tgt.setProbability(convertType(src.getProbability())); - tgt.setRelativeRisk(src.getRelativeRisk()); - tgt.setWhen(convertType(src.getWhen())); - tgt.setRationale(src.getRationale()); - return tgt; - } - - public org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent convertRiskAssessmentPredictionComponent(org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent tgt = new org.hl7.fhir.instance.model.RiskAssessment.RiskAssessmentPredictionComponent(); - copyElement(src, tgt); - tgt.setOutcome(convertCodeableConcept(src.getOutcome())); - tgt.setProbability(convertType(src.getProbability())); - tgt.setRelativeRisk(src.getRelativeRisk()); - tgt.setWhen(convertType(src.getWhen())); - tgt.setRationale(src.getRationale()); - return tgt; - } - - public org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.instance.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); - copyElement(src, tgt); - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - tgt.setPeriod(src.getPeriod()); - tgt.setFactor(src.getFactor()); - tgt.setLowerLimit(src.getLowerLimit()); - tgt.setUpperLimit(src.getUpperLimit()); - tgt.setDimensions(src.getDimensions()); - tgt.setData(src.getData()); - return tgt; - } - - public org.hl7.fhir.instance.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SampledData tgt = new org.hl7.fhir.instance.model.SampledData(); - copyElement(src, tgt); - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - tgt.setPeriod(src.getPeriod()); - tgt.setFactor(src.getFactor()); - tgt.setLowerLimit(src.getLowerLimit()); - tgt.setUpperLimit(src.getUpperLimit()); - tgt.setDimensions(src.getDimensions()); - tgt.setData(src.getData()); - return tgt; - } - - public org.hl7.fhir.r4.model.Schedule convertSchedule(org.hl7.fhir.instance.model.Schedule src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Schedule tgt = new org.hl7.fhir.r4.model.Schedule(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getType()) - tgt.addServiceType(convertCodeableConcept(t)); - tgt.addActor(convertReference(src.getActor())); - tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon())); - tgt.setComment(src.getComment()); - return tgt; - } - - public org.hl7.fhir.instance.model.Schedule convertSchedule(org.hl7.fhir.r4.model.Schedule src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Schedule tgt = new org.hl7.fhir.instance.model.Schedule(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType()) - tgt.addType(convertCodeableConcept(t)); - tgt.setActor(convertReference(src.getActorFirstRep())); - tgt.setPlanningHorizon(convertPeriod(src.getPlanningHorizon())); - tgt.setComment(src.getComment()); - return tgt; - } - - public org.hl7.fhir.r4.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.instance.model.Bundle.SearchEntryMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MATCH: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.MATCH; - case INCLUDE: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.INCLUDE; - case OUTCOME: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.OUTCOME; - default: return org.hl7.fhir.r4.model.Bundle.SearchEntryMode.NULL; - } - } - - public org.hl7.fhir.instance.model.Bundle.SearchEntryMode convertSearchEntryMode(org.hl7.fhir.r4.model.Bundle.SearchEntryMode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case MATCH: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.MATCH; - case INCLUDE: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.INCLUDE; - case OUTCOME: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.OUTCOME; - default: return org.hl7.fhir.instance.model.Bundle.SearchEntryMode.NULL; - } - } - - public org.hl7.fhir.r4.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.instance.model.Enumerations.SearchParamType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NUMBER: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER; - case DATE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE; - case STRING: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING; - case TOKEN: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN; - case REFERENCE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE; - case COMPOSITE: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE; - case QUANTITY: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY; - case URI: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI; - default: return org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL; - } - } - - public org.hl7.fhir.instance.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.r4.model.Enumerations.SearchParamType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NUMBER: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.NUMBER; - case DATE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.DATE; - case STRING: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.STRING; - case TOKEN: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.TOKEN; - case REFERENCE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.REFERENCE; - case COMPOSITE: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.COMPOSITE; - case QUANTITY: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.QUANTITY; - case URI: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.URI; - default: return org.hl7.fhir.instance.model.Enumerations.SearchParamType.NULL; - } - } - - public org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.instance.model.SearchParameter src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent t : src.getContact()) - tgt.addContact(convertSearchParameterContactComponent(t)); - tgt.setPurpose(src.getRequirements()); - tgt.setCode(src.getCode()); - tgt.addBase(src.getBase()); - tgt.setType(convertSearchParamType(src.getType())); - tgt.setDescription(src.getDescription()); - tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - tgt.setXpath(src.getXpath()); - tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage())); - for (org.hl7.fhir.instance.model.CodeType t : src.getTarget()) - tgt.addTarget(t.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SearchParameter tgt = new org.hl7.fhir.instance.model.SearchParameter(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertSearchParameterContactComponent(t)); - tgt.setRequirements(src.getPurpose()); - tgt.setCode(src.getCode()); - for (org.hl7.fhir.r4.model.CodeType t : src.getBase()) - tgt.setBase(t.asStringValue()); - tgt.setType(convertSearchParamType(src.getType())); - tgt.setDescription(src.getDescription()); - org.hl7.fhir.instance.utils.ToolingExtensions.setStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - tgt.setXpath(src.getXpath()); - tgt.setXpathUsage(convertXPathUsageType(src.getXpathUsage())); - for (org.hl7.fhir.r4.model.CodeType t : src.getTarget()) - tgt.addTarget(t.getValue()); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.instance.model.SearchParameter.SearchParameterContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.instance.model.Composition.SectionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Composition.SectionComponent tgt = new org.hl7.fhir.r4.model.Composition.SectionComponent(); - copyElement(src, tgt); - tgt.setTitle(src.getTitle()); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setText(convertNarrative(src.getText())); - try { - tgt.setMode(org.hl7.fhir.r4.model.Composition.SectionMode.fromCode(src.getMode())); - } catch (org.hl7.fhir.exceptions.FHIRException e) { - throw new FHIRException(e); - } - tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); - for (org.hl7.fhir.instance.model.Reference t : src.getEntry()) - tgt.addEntry(convertReference(t)); - tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason())); - for (org.hl7.fhir.instance.model.Composition.SectionComponent t : src.getSection()) - tgt.addSection(convertSectionComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Composition.SectionComponent convertSectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Composition.SectionComponent tgt = new org.hl7.fhir.instance.model.Composition.SectionComponent(); - copyElement(src, tgt); - tgt.setTitle(src.getTitle()); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setText(convertNarrative(src.getText())); - tgt.setMode(src.getMode().toCode()); - tgt.setOrderedBy(convertCodeableConcept(src.getOrderedBy())); - for (org.hl7.fhir.r4.model.Reference t : src.getEntry()) - tgt.addEntry(convertReference(t)); - tgt.setEmptyReason(convertCodeableConcept(src.getEmptyReason())); - for (org.hl7.fhir.r4.model.Composition.SectionComponent t : src.getSection()) - tgt.addSection(convertSectionComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent(); - copyElement(src, tgt); - tgt.setLabel(src.getLabel()); - tgt.setDescription(src.getDescription()); - tgt.setDirection(convertAssertionDirectionType(src.getDirection())); - tgt.setCompareToSourceId(src.getCompareToSourceId()); - tgt.setCompareToSourcePath(src.getCompareToSourcePath()); - tgt.setContentType(convertContentType(src.getContentType())); - tgt.setHeaderField(src.getHeaderField()); - tgt.setMinimumId(src.getMinimumId()); - tgt.setNavigationLinks(src.getNavigationLinks()); - tgt.setOperator(convertAssertionOperatorType(src.getOperator())); - tgt.setPath(src.getPath()); - tgt.setResource(src.getResource()); - tgt.setResponse(convertAssertionResponseTypes(src.getResponse())); - tgt.setResponseCode(src.getResponseCode()); - tgt.setSourceId(src.getSourceId()); - tgt.setValidateProfileId(src.getValidateProfileId()); - tgt.setValue(src.getValue()); - tgt.setWarningOnly(src.getWarningOnly()); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionAssertComponent(); - copyElement(src, tgt); - tgt.setLabel(src.getLabel()); - tgt.setDescription(src.getDescription()); - tgt.setDirection(convertAssertionDirectionType(src.getDirection())); - tgt.setCompareToSourceId(src.getCompareToSourceId()); - tgt.setCompareToSourcePath(src.getCompareToSourcePath()); - tgt.setContentType(convertContentType(src.getContentType())); - tgt.setHeaderField(src.getHeaderField()); - tgt.setMinimumId(src.getMinimumId()); - tgt.setNavigationLinks(src.getNavigationLinks()); - tgt.setOperator(convertAssertionOperatorType(src.getOperator())); - tgt.setPath(src.getPath()); - tgt.setResource(src.getResource()); - tgt.setResponse(convertAssertionResponseTypes(src.getResponse())); - tgt.setResponseCode(src.getResponseCode()); - tgt.setSourceId(src.getSourceId()); - tgt.setValidateProfileId(src.getValidateProfileId()); - tgt.setValue(src.getValue()); - tgt.setWarningOnly(src.getWarningOnly()); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestScript.SetupActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent(); - copyElement(src, tgt); - tgt.setType(convertCoding(src.getType())); - tgt.setResource(src.getResource()); - tgt.setLabel(src.getLabel()); - tgt.setDescription(src.getDescription()); - tgt.setAccept(convertContentType(src.getAccept())); - tgt.setContentType(convertContentType(src.getContentType())); - tgt.setDestination(src.getDestination()); - tgt.setEncodeRequestUrl(src.getEncodeRequestUrl()); - tgt.setParams(src.getParams()); - for (org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) - tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - tgt.setResponseId(src.getResponseId()); - tgt.setSourceId(src.getSourceId()); - tgt.setTargetId(src.getTargetId()); - tgt.setUrl(src.getUrl()); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationComponent(); - copyElement(src, tgt); - tgt.setType(convertCoding(src.getType())); - tgt.setResource(src.getResource()); - tgt.setLabel(src.getLabel()); - tgt.setDescription(src.getDescription()); - tgt.setAccept(convertContentType(src.getAccept())); - tgt.setContentType(convertContentType(src.getContentType())); - tgt.setDestination(src.getDestination()); - tgt.setEncodeRequestUrl(src.getEncodeRequestUrl()); - tgt.setParams(src.getParams()); - for (org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) - tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - tgt.setResponseId(src.getResponseId()); - tgt.setSourceId(src.getSourceId()); - tgt.setTargetId(src.getTargetId()); - tgt.setUrl(src.getUrl()); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - tgt.setField(src.getField()); - tgt.setValue(src.getValue()); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - tgt.setField(src.getField()); - tgt.setValue(src.getValue()); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.instance.model.Contract.SignatoryComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.r4.model.Contract.SignatoryComponent(); - copyElement(src, tgt); - tgt.setType(convertCoding(src.getType())); - tgt.setParty(convertReference(src.getParty())); - if (src.hasSignature()) - tgt.addSignature(new org.hl7.fhir.r4.model.Signature().setBlob(src.getSignature().getBytes())); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.SignatoryComponent convertSignatoryComponent(org.hl7.fhir.r4.model.Contract.SignatoryComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.SignatoryComponent tgt = new org.hl7.fhir.instance.model.Contract.SignatoryComponent(); - copyElement(src, tgt); - tgt.setType(convertCoding(src.getType())); - tgt.setParty(convertReference(src.getParty())); - for (org.hl7.fhir.r4.model.Signature t : src.getSignature()) - tgt.setSignature(Base64.encodeBase64String(t.getBlob())); - return tgt; - } - - public org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.instance.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.Coding t : src.getType()) - tgt.addType(convertCoding(t)); - tgt.setWhen(src.getWhen()); - tgt.setWho(convertType(src.getWho())); - tgt.setContentType(src.getContentType()); - tgt.setBlob(src.getBlob()); - return tgt; - } - - public org.hl7.fhir.instance.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Signature tgt = new org.hl7.fhir.instance.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getType()) - tgt.addType(convertCoding(t)); - tgt.setWhen(src.getWhen()); - tgt.setWho(convertType(src.getWho())); - tgt.setContentType(src.getContentType()); - tgt.setBlob(src.getBlob()); - return tgt; - } - - public org.hl7.fhir.r4.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.instance.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.instance.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SimpleQuantity tgt = new org.hl7.fhir.instance.model.SimpleQuantity(); - copyElement(src, tgt); - tgt.setValue(src.getValue()); - tgt.setComparator(convertQuantityComparator(src.getComparator())); - tgt.setUnit(src.getUnit()); - tgt.setSystem(src.getSystem()); - tgt.setCode(src.getCode()); - return tgt; - } - - public org.hl7.fhir.r4.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.instance.model.ElementDefinition.SlicingRules src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CLOSED: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED; - case OPEN: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN; - case OPENATEND: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND; - default: return org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL; - } - } - - public org.hl7.fhir.instance.model.ElementDefinition.SlicingRules convertSlicingRules(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case CLOSED: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.CLOSED; - case OPEN: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.OPEN; - case OPENATEND: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.OPENATEND; - default: return org.hl7.fhir.instance.model.ElementDefinition.SlicingRules.NULL; - } - } - - public org.hl7.fhir.r4.model.Slot convertSlot(org.hl7.fhir.instance.model.Slot src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Slot tgt = new org.hl7.fhir.r4.model.Slot(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - if (src.hasType()) - tgt.addServiceType(convertCodeableConcept(src.getType())); - tgt.setSchedule(convertReference(src.getSchedule())); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - tgt.setOverbooked(src.getOverbooked()); - tgt.setComment(src.getComment()); - return tgt; - } - - public org.hl7.fhir.instance.model.Slot convertSlot(org.hl7.fhir.r4.model.Slot src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Slot tgt = new org.hl7.fhir.instance.model.Slot(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType()) - tgt.setType(convertCodeableConcept(t)); - tgt.setSchedule(convertReference(src.getSchedule())); - tgt.setStart(src.getStart()); - tgt.setEnd(src.getEnd()); - tgt.setOverbooked(src.getOverbooked()); - tgt.setComment(src.getComment()); - return tgt; - } - - public org.hl7.fhir.r4.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.instance.model.Slot.SlotStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case BUSY: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSY; - case FREE: return org.hl7.fhir.r4.model.Slot.SlotStatus.FREE; - case BUSYUNAVAILABLE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYUNAVAILABLE; - case BUSYTENTATIVE: return org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYTENTATIVE; - default: return org.hl7.fhir.r4.model.Slot.SlotStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Slot.SlotStatus convertSlotStatus(org.hl7.fhir.r4.model.Slot.SlotStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case BUSY: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSY; - case FREE: return org.hl7.fhir.instance.model.Slot.SlotStatus.FREE; - case BUSYUNAVAILABLE: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSYUNAVAILABLE; - case BUSYTENTATIVE: return org.hl7.fhir.instance.model.Slot.SlotStatus.BUSYTENTATIVE; - default: return org.hl7.fhir.instance.model.Slot.SlotStatus.NULL; - } - } - - public List convertSourceElementComponent(org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent src) throws FHIRException { - List res = new ArrayList(); - if (src == null || src.isEmpty()) - return res; - for (org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent t : src.getTarget()) { - org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - tgt.addTarget(convertTargetElementComponent(t)); - res.add(new SourceElementComponentWrapper(tgt, src.getCodeSystem(), t.getCodeSystem())); - } - return res; - } - - public org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent src, org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.SourceElementComponent(); - copyElement(src, tgt); - tgt.setCodeSystem(g.getSource()); - tgt.setCode(src.getCode()); - for (org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent t : src.getTarget()) - tgt.addTarget(convertTargetElementComponent(t, g)); - return tgt; - } - - public org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.instance.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.instance.model.StringType tgt = new org.hl7.fhir.instance.model.StringType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.instance.model.StructureDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setTitle(src.getDisplay()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact()) - tgt.addContact(convertStructureDefinitionContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) - if (isJurisdiction(t)) - tgt.addJurisdiction(convertCodeableConcept(t)); - else - tgt.addUseContext(convertCodeableConceptToUsageContext(t)); - tgt.setPurpose(src.getRequirements()); - tgt.setCopyright(src.getCopyright()); - for (org.hl7.fhir.instance.model.Coding t : src.getCode()) - tgt.addKeyword(convertCoding(t)); - tgt.setFhirVersion(src.getFhirVersion()); - for (org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertStructureDefinitionMappingComponent(t)); - tgt.setKind(convertStructureDefinitionKind(src.getKind(), tgt.getId())); - tgt.setAbstract(src.getAbstract()); - tgt.setContextType(convertExtensionContext(src.getContextType())); - for (org.hl7.fhir.instance.model.StringType t : src.getContext()) - tgt.addContext(t.getValue()); - if (src.hasConstrainedType()) - tgt.setType(src.getConstrainedType()); - else if (src.getSnapshot().hasElement()) - tgt.setType(src.getSnapshot().getElement().get(0).getPath()); - else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains(".")) - tgt.setType(src.getDifferential().getElement().get(0).getPath()); - else - tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf("."))); - tgt.setBaseDefinition(src.getBase()); - tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION); - tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); - tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); - if (tgt.hasSnapshot()) - tgt.getSnapshot().getElementFirstRep().getType().clear(); - if (tgt.hasDifferential()) - tgt.getDifferential().getElementFirstRep().getType().clear(); - if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) { - tgt.setDerivation(TypeDerivationRule.SPECIALIZATION); - tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/"+tgt.getType()); -// for (ElementDefinition ed : tgt.getSnapshot().getElement()) { -// ed.setPath(ed.getPath().replace(tgt.getType()+".", tgt.getId()+".")); -// } -// for (ElementDefinition ed : tgt.getDifferential().getElement()) { -// ed.setPath(ed.getPath().replace(tgt.getType()+".", tgt.getId()+".")); -// } - tgt.setType(tgt.getId()); - } - return tgt; - } - - public org.hl7.fhir.instance.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r4.model.StructureDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.StructureDefinition tgt = new org.hl7.fhir.instance.model.StructureDefinition(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setDisplay(src.getTitle()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertStructureDefinitionContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) - if (t.hasValueCodeableConcept()) - tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) - tgt.addUseContext(convertCodeableConcept(t)); - tgt.setRequirements(src.getPurpose()); - tgt.setCopyright(src.getCopyright()); - for (org.hl7.fhir.r4.model.Coding t : src.getKeyword()) - tgt.addCode(convertCoding(t)); - tgt.setFhirVersion(src.getFhirVersion()); - for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertStructureDefinitionMappingComponent(t)); - tgt.setKind(convertStructureDefinitionKind(src.getKind())); - tgt.setAbstract(src.getAbstract()); - tgt.setContextType(convertExtensionContext(src.getContextType())); - for (org.hl7.fhir.r4.model.StringType t : src.getContext()) - tgt.addContext(t.getValue()); - tgt.setConstrainedType(src.getType()); - tgt.setBase(src.getBaseDefinition()); - tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); - tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); - if (tgt.hasBase()) { - if (tgt.hasDifferential()) - tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase())); - if (tgt.hasSnapshot()) - tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase())); - } - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent(); - copyElement(src, tgt); - List slicePaths = new ArrayList(); - for (org.hl7.fhir.instance.model.ElementDefinition t : src.getElement()) { - if (t.hasSlicing()) - slicePaths.add(t.getPath()); - tgt.addElement(convertElementDefinition(t, slicePaths)); - } - return tgt; - } - - public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionDifferentialComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) - tgt.addElement(convertElementDefinition(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind src, String dtName) throws FHIRException { - if (src == null) - return null; - switch (src) { - case DATATYPE: - if (Utilities.existsInList(dtName, "boolean", "integer", "decimal", "base64Binary", "instant", "string", "uri", "date", "dateTime", "time", "code", "oid", "uuid", "id", "unsignedInt", "positiveInt", "markdown", "xhtml")) - return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE; - else - return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE; - case RESOURCE: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.RESOURCE; - case LOGICAL: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.LOGICAL; - default: return org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.NULL; - } - } - - public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind convertStructureDefinitionKind(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case PRIMITIVETYPE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.DATATYPE; - case COMPLEXTYPE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.DATATYPE; - case RESOURCE: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.RESOURCE; - case LOGICAL: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.LOGICAL; - default: return org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionKind.NULL; - } - } - - public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent(); - copyElement(src, tgt); - tgt.setIdentity(src.getIdentity()); - tgt.setUri(src.getUri()); - tgt.setName(src.getName()); - tgt.setComment(src.getComments()); - return tgt; - } - - public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionMappingComponent(); - copyElement(src, tgt); - tgt.setIdentity(src.getIdentity()); - tgt.setUri(src.getUri()); - tgt.setName(src.getName()); - tgt.setComments(src.getComment()); - return tgt; - } - - public org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent(); - copyElement(src, tgt); - List slicePaths = new ArrayList(); - for (org.hl7.fhir.instance.model.ElementDefinition t : src.getElement()) { - if (t.hasSlicing()) - slicePaths.add(t.getPath()); - tgt.addElement(convertElementDefinition(t, slicePaths)); - } - return tgt; - } - - public org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.instance.model.StructureDefinition.StructureDefinitionSnapshotComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement()) - tgt.addElement(convertElementDefinition(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Subscription convertSubscription(org.hl7.fhir.instance.model.Subscription src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Subscription tgt = new org.hl7.fhir.r4.model.Subscription(); - copyDomainResource(src, tgt); - tgt.setCriteria(src.getCriteria()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getContact()) - tgt.addContact(convertContactPoint(t)); - tgt.setReason(src.getReason()); - tgt.setStatus(convertSubscriptionStatus(src.getStatus())); - tgt.setError(src.getError()); - tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); - tgt.setEnd(src.getEnd()); - for (org.hl7.fhir.instance.model.Coding t : src.getTag()) - tgt.addTag(convertCoding(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Subscription convertSubscription(org.hl7.fhir.r4.model.Subscription src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Subscription tgt = new org.hl7.fhir.instance.model.Subscription(); - copyDomainResource(src, tgt); - tgt.setCriteria(src.getCriteria()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact()) - tgt.addContact(convertContactPoint(t)); - tgt.setReason(src.getReason()); - tgt.setStatus(convertSubscriptionStatus(src.getStatus())); - tgt.setError(src.getError()); - tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); - tgt.setEnd(src.getEnd()); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) - tgt.addTag(convertCoding(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent(); - copyElement(src, tgt); - tgt.setType(convertSubscriptionChannelType(src.getType())); - tgt.setEndpoint(src.getEndpoint()); - tgt.setPayload(src.getPayload()); - tgt.addHeader(src.getHeader()); - return tgt; - } - - public org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.instance.model.Subscription.SubscriptionChannelComponent(); - copyElement(src, tgt); - tgt.setType(convertSubscriptionChannelType(src.getType())); - tgt.setEndpoint(src.getEndpoint()); - tgt.setPayload(src.getPayload()); - if (src.hasHeader()) - tgt.setHeaderElement(convertString(src.getHeader().get(0))); - return tgt; - } - - public org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESTHOOK: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.RESTHOOK; - case WEBSOCKET: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.WEBSOCKET; - case EMAIL: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.EMAIL; - case SMS: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.SMS; - case MESSAGE: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.MESSAGE; - default: return org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.NULL; - } - } - - public org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType convertSubscriptionChannelType(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case RESTHOOK: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.RESTHOOK; - case WEBSOCKET: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.WEBSOCKET; - case EMAIL: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.EMAIL; - case SMS: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.SMS; - case MESSAGE: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.MESSAGE; - default: return org.hl7.fhir.instance.model.Subscription.SubscriptionChannelType.NULL; - } - } - - public org.hl7.fhir.r4.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.instance.model.Subscription.SubscriptionStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REQUESTED: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.REQUESTED; - case ACTIVE: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ACTIVE; - case ERROR: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ERROR; - case OFF: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.OFF; - default: return org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.Subscription.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REQUESTED: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.REQUESTED; - case ACTIVE: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.ACTIVE; - case ERROR: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.ERROR; - case OFF: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.OFF; - default: return org.hl7.fhir.instance.model.Subscription.SubscriptionStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.Substance convertSubstance(org.hl7.fhir.instance.model.Substance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Substance tgt = new org.hl7.fhir.r4.model.Substance(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getCategory()) - tgt.addCategory(convertCodeableConcept(t)); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent t : src.getInstance()) - tgt.addInstance(convertSubstanceInstanceComponent(t)); - for (org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent t : src.getIngredient()) - tgt.addIngredient(convertSubstanceIngredientComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Substance convertSubstance(org.hl7.fhir.r4.model.Substance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Substance tgt = new org.hl7.fhir.instance.model.Substance(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) - tgt.addIdentifier(convertIdentifier(t)); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) - tgt.addCategory(convertCodeableConcept(t)); - tgt.setCode(convertCodeableConcept(src.getCode())); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent t : src.getInstance()) - tgt.addInstance(convertSubstanceInstanceComponent(t)); - for (org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent t : src.getIngredient()) - tgt.addIngredient(convertSubstanceIngredientComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent(); - copyElement(src, tgt); - tgt.setQuantity(convertRatio(src.getQuantity())); - tgt.setSubstance(convertReference(src.getSubstance())); - return tgt; - } - - public org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent convertSubstanceIngredientComponent(org.hl7.fhir.r4.model.Substance.SubstanceIngredientComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent tgt = new org.hl7.fhir.instance.model.Substance.SubstanceIngredientComponent(); - copyElement(src, tgt); - tgt.setQuantity(convertRatio(src.getQuantity())); -// tgt.setSubstance(convertReference(src.getSubstance())); - return tgt; - } - - public org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setExpiry(src.getExpiry()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - return tgt; - } - - public org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent convertSubstanceInstanceComponent(org.hl7.fhir.r4.model.Substance.SubstanceInstanceComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent tgt = new org.hl7.fhir.instance.model.Substance.SubstanceInstanceComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setExpiry(src.getExpiry()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - return tgt; - } - - public org.hl7.fhir.r4.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.instance.model.SupplyDelivery src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SupplyDelivery tgt = new org.hl7.fhir.r4.model.SupplyDelivery(); - copyDomainResource(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus())); - tgt.setPatient(convertReference(src.getPatient())); - tgt.setType(convertCodeableConcept(src.getType())); -// tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); -// tgt.setSuppliedItem(convertReference(src.getSuppliedItem())); - tgt.setSupplier(convertReference(src.getSupplier())); -// tgt.setWhenPrepared(convertPeriod(src.getWhenPrepared())); -// tgt.setTime(src.getTime()); - tgt.setDestination(convertReference(src.getDestination())); - for (org.hl7.fhir.instance.model.Reference t : src.getReceiver()) - tgt.addReceiver(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SupplyDelivery tgt = new org.hl7.fhir.instance.model.SupplyDelivery(); - copyDomainResource(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setStatus(convertSupplyDeliveryStatus(src.getStatus())); - tgt.setPatient(convertReference(src.getPatient())); - tgt.setType(convertCodeableConcept(src.getType())); -// tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); -// tgt.setSuppliedItem(convertReference(src.getSuppliedItem())); - tgt.setSupplier(convertReference(src.getSupplier())); -// tgt.setWhenPrepared(convertPeriod(src.getWhenPrepared())); -// tgt.setTime(src.getTime()); - tgt.setDestination(convertReference(src.getDestination())); - for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) - tgt.addReceiver(convertReference(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED; - case ABANDONED: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED; - default: return org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus convertSupplyDeliveryStatus(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case INPROGRESS: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS; - case COMPLETED: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED; - case ABANDONED: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED; - default: return org.hl7.fhir.instance.model.SupplyDelivery.SupplyDeliveryStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.instance.model.SupplyRequest src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SupplyRequest tgt = new org.hl7.fhir.r4.model.SupplyRequest(); - copyDomainResource(src, tgt); -// tgt.setPatient(convertReference(src.getPatient())); -// tgt.setSource(convertReference(src.getSource())); -// if (src.hasDate()) -// tgt.setDate(src.getDate()); -// tgt.setIdentifier(convertIdentifier(src.getIdentifier())); -// tgt.setStatus(convertSupplyRequestStatus(src.getStatus())); -// tgt.setKind(convertCodeableConcept(src.getKind())); -// tgt.getOrderedItem().setItem(convertReference(src.getOrderedItem())); -// for (org.hl7.fhir.instance.model.Reference t : src.getSupplier()) -// tgt.addSupplier(convertReference(t)); -// tgt.setReason(convertType(src.getReason())); -// tgt.setWhen(convertSupplyRequestWhenComponent(src.getWhen())); - return tgt; - } - - public org.hl7.fhir.instance.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.r4.model.SupplyRequest src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.SupplyRequest tgt = new org.hl7.fhir.instance.model.SupplyRequest(); -// copyDomainResource(src, tgt); -// tgt.setPatient(convertReference(src.getPatient())); -// tgt.setSource(convertReference(src.getSource())); -// if (src.hasDate()) -// tgt.setDate(src.getDate()); -// tgt.setIdentifier(convertIdentifier(src.getIdentifier())); -// tgt.setStatus(convertSupplyRequestStatus(src.getStatus())); -// tgt.setKind(convertCodeableConcept(src.getKind())); -// tgt.setOrderedItem(convertReference(src.getOrderedItem().getItemReference())); -// for (org.hl7.fhir.r4.model.Reference t : src.getSupplier()) -// tgt.addSupplier(convertReference(t)); -// tgt.setReason(convertType(src.getReason())); -// tgt.setWhen(convertSupplyRequestWhenComponent(src.getWhen())); - return tgt; - } - - public org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case REQUESTED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE; - case COMPLETED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED; - case FAILED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED; - case CANCELLED: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED; - default: return org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL; - } - } - - public org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus convertSupplyRequestStatus(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case ACTIVE: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.REQUESTED; - case COMPLETED: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.COMPLETED; - case CANCELLED: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.CANCELLED; - default: return org.hl7.fhir.instance.model.SupplyRequest.SupplyRequestStatus.NULL; - } - } - - public org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent(); - copyElement(src, tgt); - tgt.setCode(convertSystemRestfulInteraction(src.getCode())); - tgt.setDocumentation(src.getDocumentation()); - return tgt; - } - - public org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent tgt = new org.hl7.fhir.instance.model.Conformance.SystemInteractionComponent(); - copyElement(src, tgt); - tgt.setCode(convertSystemRestfulInteraction(src.getCode())); - tgt.setDocumentation(src.getDocumentation()); - return tgt; - } - - public org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case TRANSACTION: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.TRANSACTION; - case SEARCHSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.SEARCHSYSTEM; - case HISTORYSYSTEM: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.HISTORYSYSTEM; - default: return org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction convertSystemRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case TRANSACTION: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.TRANSACTION; - case SEARCHSYSTEM: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.SEARCHSYSTEM; - case HISTORYSYSTEM: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.HISTORYSYSTEM; - default: return org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction.NULL; - } - } - - public org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence())); - tgt.setComment(src.getComments()); - for (org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) - tgt.addDependsOn(convertOtherElementComponent(t)); - for (org.hl7.fhir.instance.model.ConceptMap.OtherElementComponent t : src.getProduct()) - tgt.addProduct(convertOtherElementComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent src, org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent g) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.instance.model.ConceptMap.TargetElementComponent(); - copyElement(src, tgt); - tgt.setCodeSystem(g.getTarget()); - tgt.setCode(src.getCode()); - tgt.setEquivalence(convertConceptMapEquivalence(src.getEquivalence())); - tgt.setComments(src.getComment()); - for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) - tgt.addDependsOn(convertOtherElementComponent(t)); - for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getProduct()) - tgt.addProduct(convertOtherElementComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TeardownActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestScript.TeardownActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.AgentComponent convertTermAgentComponent(org.hl7.fhir.instance.model.Contract.TermActorComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.AgentComponent tgt = new org.hl7.fhir.r4.model.Contract.AgentComponent(); - copyElement(src, tgt); - tgt.setActor(convertReference(src.getEntity())); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getRole()) - tgt.addRole(convertCodeableConcept(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.TermActorComponent convertTermAgentComponent(org.hl7.fhir.r4.model.Contract.AgentComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.TermActorComponent tgt = new org.hl7.fhir.instance.model.Contract.TermActorComponent(); - copyElement(src, tgt); - tgt.setEntity(convertReference(src.getActor())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) - tgt.addRole(convertCodeableConcept(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.instance.model.Contract.TermComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.TermComponent tgt = new org.hl7.fhir.r4.model.Contract.TermComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setIssued(src.getIssued()); - tgt.setApplies(convertPeriod(src.getApplies())); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setSubType(convertCodeableConcept(src.getSubType())); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getAction()) - tgt.addAction(convertCodeableConcept(t)); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getActionReason()) - tgt.addActionReason(convertCodeableConcept(t)); - for (org.hl7.fhir.instance.model.Contract.TermActorComponent t : src.getActor()) - tgt.addAgent(convertTermAgentComponent(t)); - for (org.hl7.fhir.instance.model.Contract.TermComponent t : src.getGroup()) - tgt.addGroup(convertTermComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.TermComponent convertTermComponent(org.hl7.fhir.r4.model.Contract.TermComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.TermComponent tgt = new org.hl7.fhir.instance.model.Contract.TermComponent(); - copyElement(src, tgt); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setIssued(src.getIssued()); - tgt.setApplies(convertPeriod(src.getApplies())); - tgt.setType(convertCodeableConcept(src.getType())); - tgt.setSubType(convertCodeableConcept(src.getSubType())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction()) - tgt.addAction(convertCodeableConcept(t)); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getActionReason()) - tgt.addActionReason(convertCodeableConcept(t)); - for (org.hl7.fhir.r4.model.Contract.AgentComponent t : src.getAgent()) - tgt.addActor(convertTermAgentComponent(t)); - for (org.hl7.fhir.r4.model.Contract.TermComponent t : src.getGroup()) - tgt.addGroup(convertTermComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.instance.model.Contract.TermValuedItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent(); - copyElement(src, tgt); - tgt.setEntity(convertType(src.getEntity())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setEffectiveTime(src.getEffectiveTime()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setUnitPrice(convertMoney(src.getUnitPrice())); - tgt.setFactor(src.getFactor()); - tgt.setPoints(src.getPoints()); - tgt.setNet(convertMoney(src.getNet())); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.TermValuedItemComponent convertTermValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.TermValuedItemComponent tgt = new org.hl7.fhir.instance.model.Contract.TermValuedItemComponent(); - copyElement(src, tgt); - tgt.setEntity(convertType(src.getEntity())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setEffectiveTime(src.getEffectiveTime()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setUnitPrice(convertMoney(src.getUnitPrice())); - tgt.setFactor(src.getFactor()); - tgt.setPoints(src.getPoints()); - tgt.setNet(convertMoney(src.getNet())); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestScript.TestActionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent(); - copyElement(src, tgt); - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript convertTestScript(org.hl7.fhir.instance.model.TestScript src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript tgt = new org.hl7.fhir.r4.model.TestScript(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent t : src.getContact()) - tgt.addContact(convertTestScriptContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) - if (isJurisdiction(t)) - tgt.addJurisdiction(convertCodeableConcept(t)); - else - tgt.addUseContext(convertCodeableConceptToUsageContext(t)); - tgt.setPurpose(src.getRequirements()); - tgt.setCopyright(src.getCopyright()); - tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata())); - for (org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent t : src.getFixture()) - tgt.addFixture(convertTestScriptFixtureComponent(t)); - for (org.hl7.fhir.instance.model.Reference t : src.getProfile()) - tgt.addProfile(convertReference(t)); - for (org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent t : src.getVariable()) - tgt.addVariable(convertTestScriptVariableComponent(t)); - tgt.setSetup(convertTestScriptSetupComponent(src.getSetup())); - for (org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent t : src.getTest()) - tgt.addTest(convertTestScriptTestComponent(t)); - tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript convertTestScript(org.hl7.fhir.r4.model.TestScript src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript tgt = new org.hl7.fhir.instance.model.TestScript(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertTestScriptContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) - if (t.hasValueCodeableConcept()) - tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) - tgt.addUseContext(convertCodeableConcept(t)); - tgt.setRequirements(src.getPurpose()); - tgt.setCopyright(src.getCopyright()); - tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata())); - for (org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent t : src.getFixture()) - tgt.addFixture(convertTestScriptFixtureComponent(t)); - for (org.hl7.fhir.r4.model.Reference t : src.getProfile()) - tgt.addProfile(convertReference(t)); - for (org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent t : src.getVariable()) - tgt.addVariable(convertTestScriptVariableComponent(t)); - tgt.setSetup(convertTestScriptSetupComponent(src.getSetup())); - for (org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent t : src.getTest()) - tgt.addTest(convertTestScriptTestComponent(t)); - tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown())); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertTestScriptContactComponent(org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent convertTestScriptContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent(); - copyElement(src, tgt); - tgt.setAutocreate(src.getAutocreate()); - tgt.setAutodelete(src.getAutodelete()); - tgt.setResource(convertReference(src.getResource())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent convertTestScriptFixtureComponent(org.hl7.fhir.r4.model.TestScript.TestScriptFixtureComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptFixtureComponent(); - copyElement(src, tgt); - tgt.setAutocreate(src.getAutocreate()); - tgt.setAutodelete(src.getAutodelete()); - tgt.setResource(convertReference(src.getResource())); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent(); - copyElement(src, tgt); - tgt.setRequired(src.getRequired()); - tgt.setValidated(src.getValidated()); - tgt.setDescription(src.getDescription()); - tgt.setDestination(src.getDestination()); - for (org.hl7.fhir.instance.model.UriType t : src.getLink()) - tgt.addLink(t.getValue()); - tgt.setCapabilities(convertReference(src.getConformance())); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent convertTestScriptMetadataCapabilityComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent(); - copyElement(src, tgt); - tgt.setRequired(src.getRequired()); - tgt.setValidated(src.getValidated()); - tgt.setDescription(src.getDescription()); - tgt.setDestination(src.getDestination()); - for (org.hl7.fhir.r4.model.UriType t : src.getLink()) - tgt.addLink(t.getValue()); - tgt.setConformance(convertReference(src.getCapabilities())); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink()) - tgt.addLink(convertTestScriptMetadataLinkComponent(t)); - for (org.hl7.fhir.instance.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability()) - tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent convertTestScriptMetadataComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent t : src.getLink()) - tgt.addLink(convertTestScriptMetadataLinkComponent(t)); - for (org.hl7.fhir.r4.model.TestScript.TestScriptMetadataCapabilityComponent t : src.getCapability()) - tgt.addCapability(convertTestScriptMetadataCapabilityComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent(); - copyElement(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setDescription(src.getDescription()); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent convertTestScriptMetadataLinkComponent(org.hl7.fhir.r4.model.TestScript.TestScriptMetadataLinkComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptMetadataLinkComponent(); - copyElement(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.setDescription(src.getDescription()); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.TestScript.TestScriptSetupActionComponent t : src.getAction()) - tgt.addAction(convertSetupActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent convertTestScriptSetupComponent(org.hl7.fhir.r4.model.TestScript.TestScriptSetupComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptSetupComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.TestScript.SetupActionComponent t : src.getAction()) - tgt.addAction(convertSetupActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.TestScript.TestScriptTeardownActionComponent t : src.getAction()) - tgt.addAction(convertTeardownActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent convertTestScriptTeardownComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTeardownComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTeardownComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.TestScript.TeardownActionComponent t : src.getAction()) - tgt.addAction(convertTeardownActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.TestScript.TestScriptTestActionComponent t : src.getAction()) - tgt.addAction(convertTestActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent convertTestScriptTestComponent(org.hl7.fhir.r4.model.TestScript.TestScriptTestComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptTestComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.TestScript.TestActionComponent t : src.getAction()) - tgt.addAction(convertTestActionComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setHeaderField(src.getHeaderField()); - tgt.setPath(src.getPath()); - tgt.setSourceId(src.getSourceId()); - return tgt; - } - - public org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent convertTestScriptVariableComponent(org.hl7.fhir.r4.model.TestScript.TestScriptVariableComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent tgt = new org.hl7.fhir.instance.model.TestScript.TestScriptVariableComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setHeaderField(src.getHeaderField()); - tgt.setPath(src.getPath()); - tgt.setSourceId(src.getSourceId()); - return tgt; - } - - public org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.instance.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.instance.model.TimeType tgt = new org.hl7.fhir.instance.model.TimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.instance.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.DateTimeType t : src.getEvent()) - tgt.addEvent(t.getValue()); - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public org.hl7.fhir.instance.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Timing tgt = new org.hl7.fhir.instance.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) - tgt.addEvent(t.getValue()); - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.instance.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - tgt.setBounds(convertType(src.getBounds())); - tgt.setCount(src.getCount()); - tgt.setDuration(src.getDuration()); - tgt.setDurationMax(src.getDurationMax()); - tgt.setDurationUnit(convertUnitsOfTime(src.getDurationUnits())); - tgt.setFrequency(src.getFrequency()); - tgt.setFrequencyMax(src.getFrequencyMax()); - tgt.setPeriod(src.getPeriod()); - tgt.setPeriodMax(src.getPeriodMax()); - tgt.setPeriodUnit(convertUnitsOfTime(src.getPeriodUnits())); - tgt.addWhen(convertEventTiming(src.getWhen())); - return tgt; - } - - public org.hl7.fhir.instance.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.instance.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - tgt.setBounds(convertType(src.getBounds())); - tgt.setCount(src.getCount()); - tgt.setDuration(src.getDuration()); - tgt.setDurationMax(src.getDurationMax()); - tgt.setDurationUnits(convertUnitsOfTime(src.getDurationUnit())); - tgt.setFrequency(src.getFrequency()); - tgt.setFrequencyMax(src.getFrequencyMax()); - tgt.setPeriod(src.getPeriod()); - tgt.setPeriodMax(src.getPeriodMax()); - tgt.setPeriodUnits(convertUnitsOfTime(src.getPeriodUnit())); - for (Enumeration t : src.getWhen()) - tgt.setWhen(convertEventTiming(t.getValue())); - return tgt; - } - - public org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.instance.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.instance.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.instance.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.instance.model.BooleanType) - return convertBoolean((org.hl7.fhir.instance.model.BooleanType) src); - if (src instanceof org.hl7.fhir.instance.model.CodeType) - return convertCode((org.hl7.fhir.instance.model.CodeType) src); - if (src instanceof org.hl7.fhir.instance.model.DateType) - return convertDate((org.hl7.fhir.instance.model.DateType) src); - if (src instanceof org.hl7.fhir.instance.model.DateTimeType) - return convertDateTime((org.hl7.fhir.instance.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.instance.model.DecimalType) - return convertDecimal((org.hl7.fhir.instance.model.DecimalType) src); - if (src instanceof org.hl7.fhir.instance.model.IdType) - return convertId((org.hl7.fhir.instance.model.IdType) src); - if (src instanceof org.hl7.fhir.instance.model.InstantType) - return convertInstant((org.hl7.fhir.instance.model.InstantType) src); - if (src instanceof org.hl7.fhir.instance.model.IntegerType) - return convertInteger((org.hl7.fhir.instance.model.IntegerType) src); - if (src instanceof org.hl7.fhir.instance.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.instance.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.instance.model.OidType) - return convertOid((org.hl7.fhir.instance.model.OidType) src); - if (src instanceof org.hl7.fhir.instance.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.instance.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.instance.model.StringType) - return convertString((org.hl7.fhir.instance.model.StringType) src); - if (src instanceof org.hl7.fhir.instance.model.TimeType) - return convertTime((org.hl7.fhir.instance.model.TimeType) src); - if (src instanceof org.hl7.fhir.instance.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.instance.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.instance.model.UriType) - return convertUri((org.hl7.fhir.instance.model.UriType) src); - if (src instanceof org.hl7.fhir.instance.model.UuidType) - return convertUuid((org.hl7.fhir.instance.model.UuidType) src); - if (src instanceof org.hl7.fhir.instance.model.Extension) - return convertExtension((org.hl7.fhir.instance.model.Extension) src); - if (src instanceof org.hl7.fhir.instance.model.Narrative) - return convertNarrative((org.hl7.fhir.instance.model.Narrative) src); - if (src instanceof org.hl7.fhir.instance.model.Annotation) - return convertAnnotation((org.hl7.fhir.instance.model.Annotation) src); - if (src instanceof org.hl7.fhir.instance.model.Attachment) - return convertAttachment((org.hl7.fhir.instance.model.Attachment) src); - if (src instanceof org.hl7.fhir.instance.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.instance.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.instance.model.Coding) - return convertCoding((org.hl7.fhir.instance.model.Coding) src); - if (src instanceof org.hl7.fhir.instance.model.Identifier) - return convertIdentifier((org.hl7.fhir.instance.model.Identifier) src); - if (src instanceof org.hl7.fhir.instance.model.Period) - return convertPeriod((org.hl7.fhir.instance.model.Period) src); - if (src instanceof org.hl7.fhir.instance.model.Quantity) - return convertQuantity((org.hl7.fhir.instance.model.Quantity) src); - if (src instanceof org.hl7.fhir.instance.model.Range) - return convertRange((org.hl7.fhir.instance.model.Range) src); - if (src instanceof org.hl7.fhir.instance.model.Ratio) - return convertRatio((org.hl7.fhir.instance.model.Ratio) src); - if (src instanceof org.hl7.fhir.instance.model.Reference) - return convertReference((org.hl7.fhir.instance.model.Reference) src); - if (src instanceof org.hl7.fhir.instance.model.SampledData) - return convertSampledData((org.hl7.fhir.instance.model.SampledData) src); - if (src instanceof org.hl7.fhir.instance.model.Signature) - return convertSignature((org.hl7.fhir.instance.model.Signature) src); - if (src instanceof org.hl7.fhir.instance.model.Address) - return convertAddress((org.hl7.fhir.instance.model.Address) src); - if (src instanceof org.hl7.fhir.instance.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.instance.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.instance.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.instance.model.ElementDefinition) src, new ArrayList()); - if (src instanceof org.hl7.fhir.instance.model.HumanName) - return convertHumanName((org.hl7.fhir.instance.model.HumanName) src); - if (src instanceof org.hl7.fhir.instance.model.Meta) - return convertMeta((org.hl7.fhir.instance.model.Meta) src); - if (src instanceof org.hl7.fhir.instance.model.Timing) - return convertTiming((org.hl7.fhir.instance.model.Timing) src); - if (src instanceof org.hl7.fhir.instance.model.Age) - return convertAge((org.hl7.fhir.instance.model.Age) src); - if (src instanceof org.hl7.fhir.instance.model.Count) - return convertCount((org.hl7.fhir.instance.model.Count) src); - if (src instanceof org.hl7.fhir.instance.model.Distance) - return convertDistance((org.hl7.fhir.instance.model.Distance) src); - if (src instanceof org.hl7.fhir.instance.model.Duration) - return convertDuration((org.hl7.fhir.instance.model.Duration) src); - if (src instanceof org.hl7.fhir.instance.model.Money) - return convertMoney((org.hl7.fhir.instance.model.Money) src); - if (src instanceof org.hl7.fhir.instance.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.instance.model.SimpleQuantity) src); - throw new Error("Unknown type "+src.fhirType()); - } - - public org.hl7.fhir.instance.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r4.model.BooleanType) - return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r4.model.CodeType) - return convertCode((org.hl7.fhir.r4.model.CodeType) src); - if (src instanceof org.hl7.fhir.r4.model.DateType) - return convertDate((org.hl7.fhir.r4.model.DateType) src); - if (src instanceof org.hl7.fhir.r4.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r4.model.DecimalType) - return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r4.model.IdType) - return convertId((org.hl7.fhir.r4.model.IdType) src); - if (src instanceof org.hl7.fhir.r4.model.InstantType) - return convertInstant((org.hl7.fhir.r4.model.InstantType) src); - if (src instanceof org.hl7.fhir.r4.model.IntegerType) - return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r4.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r4.model.OidType) - return convertOid((org.hl7.fhir.r4.model.OidType) src); - if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r4.model.StringType) - return convertString((org.hl7.fhir.r4.model.StringType) src); - if (src instanceof org.hl7.fhir.r4.model.TimeType) - return convertTime((org.hl7.fhir.r4.model.TimeType) src); - if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); - if (src instanceof org.hl7.fhir.r4.model.UuidType) - return convertUuid((org.hl7.fhir.r4.model.UuidType) src); - if (src instanceof org.hl7.fhir.r4.model.Extension) - return convertExtension((org.hl7.fhir.r4.model.Extension) src); - if (src instanceof org.hl7.fhir.r4.model.Narrative) - return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); - if (src instanceof org.hl7.fhir.r4.model.Annotation) - return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); - if (src instanceof org.hl7.fhir.r4.model.Attachment) - return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); - if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r4.model.Coding) - return convertCoding((org.hl7.fhir.r4.model.Coding) src); - if (src instanceof org.hl7.fhir.r4.model.Identifier) - return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); - if (src instanceof org.hl7.fhir.r4.model.Period) - return convertPeriod((org.hl7.fhir.r4.model.Period) src); - if (src instanceof org.hl7.fhir.r4.model.Quantity) - return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); - if (src instanceof org.hl7.fhir.r4.model.Range) - return convertRange((org.hl7.fhir.r4.model.Range) src); - if (src instanceof org.hl7.fhir.r4.model.Ratio) - return convertRatio((org.hl7.fhir.r4.model.Ratio) src); - if (src instanceof org.hl7.fhir.r4.model.Reference) - return convertReference((org.hl7.fhir.r4.model.Reference) src); - if (src instanceof org.hl7.fhir.r4.model.SampledData) - return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); - if (src instanceof org.hl7.fhir.r4.model.Signature) - return convertSignature((org.hl7.fhir.r4.model.Signature) src); - if (src instanceof org.hl7.fhir.r4.model.Address) - return convertAddress((org.hl7.fhir.r4.model.Address) src); - if (src instanceof org.hl7.fhir.r4.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.HumanName) - return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); - if (src instanceof org.hl7.fhir.r4.model.Meta) - return convertMeta((org.hl7.fhir.r4.model.Meta) src); - if (src instanceof org.hl7.fhir.r4.model.Timing) - return convertTiming((org.hl7.fhir.r4.model.Timing) src); - if (src instanceof org.hl7.fhir.r4.model.Age) - return convertAge((org.hl7.fhir.r4.model.Age) src); - if (src instanceof org.hl7.fhir.r4.model.Count) - return convertCount((org.hl7.fhir.r4.model.Count) src); - if (src instanceof org.hl7.fhir.r4.model.Distance) - return convertDistance((org.hl7.fhir.r4.model.Distance) src); - if (src instanceof org.hl7.fhir.r4.model.Duration) - return convertDuration((org.hl7.fhir.r4.model.Duration) src); - if (src instanceof org.hl7.fhir.r4.model.Money) - return convertMoney((org.hl7.fhir.r4.model.Money) src); - if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); - throw new Error("Unknown type "+src.fhirType()); - } - - public org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case READ: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.READ; - case VREAD: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.VREAD; - case UPDATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.UPDATE; - case DELETE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.DELETE; - case HISTORYINSTANCE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYINSTANCE; - case HISTORYTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYTYPE; - case CREATE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.CREATE; - case SEARCHTYPE: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.SEARCHTYPE; - default: return org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction convertTypeRestfulInteraction(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case READ: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.READ; - case VREAD: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.VREAD; - case UPDATE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.UPDATE; - case DELETE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.DELETE; - case HISTORYINSTANCE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.HISTORYINSTANCE; - case HISTORYTYPE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.HISTORYTYPE; - case CREATE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.CREATE; - case SEARCHTYPE: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.SEARCHTYPE; - default: return org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction.NULL; - } - } - - public org.hl7.fhir.r4.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.instance.model.Timing.UnitsOfTime src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case S: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.S; - case MIN: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN; - case H: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.H; - case D: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.D; - case WK: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK; - case MO: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO; - case A: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.A; - default: return org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL; - } - } - - public org.hl7.fhir.instance.model.Timing.UnitsOfTime convertUnitsOfTime(org.hl7.fhir.r4.model.Timing.UnitsOfTime src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case S: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.S; - case MIN: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.MIN; - case H: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.H; - case D: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.D; - case WK: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.WK; - case MO: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.MO; - case A: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.A; - default: return org.hl7.fhir.instance.model.Timing.UnitsOfTime.NULL; - } - } - - public org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.instance.model.Conformance.UnknownContentCode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NO: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NO; - case EXTENSIONS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.EXTENSIONS; - case ELEMENTS: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.ELEMENTS; - case BOTH: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.BOTH; - default: return org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode.NULL; - } - } - - public org.hl7.fhir.instance.model.Conformance.UnknownContentCode convertUnknownContentCode(org.hl7.fhir.r4.model.CapabilityStatement.UnknownContentCode src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NO: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.NO; - case EXTENSIONS: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.EXTENSIONS; - case ELEMENTS: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.ELEMENTS; - case BOTH: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.BOTH; - default: return org.hl7.fhir.instance.model.Conformance.UnknownContentCode.NULL; - } - } - - public org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.instance.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.instance.model.UnsignedIntType tgt = new org.hl7.fhir.instance.model.UnsignedIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.instance.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.instance.model.UriType tgt = new org.hl7.fhir.instance.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.CodeType convertUriToCode(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.instance.model.CodeType tgt = new org.hl7.fhir.instance.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.instance.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.instance.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.instance.model.UuidType tgt = new org.hl7.fhir.instance.model.UuidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.instance.model.ValueSet src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - tgt.addIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent t : src.getContact()) - tgt.addContact(convertValueSetContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) - if (isJurisdiction(t)) - tgt.addJurisdiction(convertCodeableConcept(t)); - else - tgt.addUseContext(convertCodeableConceptToUsageContext(t)); - tgt.setImmutable(src.getImmutable()); - tgt.setPurpose(src.getRequirements()); - tgt.setCopyright(src.getCopyright()); - tgt.setExtensible(src.getExtensible()); - if (src.hasCompose()) { - tgt.setCompose(convertValueSetComposeComponent(src.getCompose())); - tgt.getCompose().setLockedDate(src.getLockedDate()); - } - if (src.hasCodeSystem() && advisor != null) { - org.hl7.fhir.r4.model.CodeSystem tgtcs = new org.hl7.fhir.r4.model.CodeSystem(); - copyDomainResource(src, tgtcs); - tgtcs.setUrl(src.getCodeSystem().getSystem()); - tgtcs.setIdentifier(convertIdentifier(src.getIdentifier())); - tgtcs.setVersion(src.getCodeSystem().getVersion()); - tgtcs.setName(src.getName()+" Code System"); - tgtcs.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgtcs.setExperimental(src.getExperimental()); - tgtcs.setPublisher(src.getPublisher()); - for (org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent t : src.getContact()) - tgtcs.addContact(convertValueSetContactComponent(t)); - if (src.hasDate()) - tgtcs.setDate(src.getDate()); - tgtcs.setDescription(src.getDescription()); - for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) - if (isJurisdiction(t)) - tgtcs.addJurisdiction(convertCodeableConcept(t)); - else - tgtcs.addUseContext(convertCodeableConceptToUsageContext(t)); - tgtcs.setPurpose(src.getRequirements()); - tgtcs.setCopyright(src.getCopyright()); - tgtcs.setContent(CodeSystemContentMode.COMPLETE); - tgtcs.setCaseSensitive(src.getCodeSystem().getCaseSensitive()); - for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs : src.getCodeSystem().getConcept()) - processConcept(tgtcs.getConcept(), cs, tgtcs); - advisor.handleCodeSystem(tgtcs, tgt); - tgt.setUserData("r2-cs", tgtcs); - tgt.getCompose().addInclude().setSystem(tgtcs.getUrl()); - } - tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet tgt = new org.hl7.fhir.instance.model.ValueSet(); - copyDomainResource(src, tgt); - tgt.setUrl(src.getUrl()); - for (org.hl7.fhir.r4.model.Identifier i : src.getIdentifier()) - tgt.setIdentifier(convertIdentifier(i)); - tgt.setVersion(src.getVersion()); - tgt.setName(src.getName()); - tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); - if (src.hasExperimental()) - tgt.setExperimental(src.getExperimental()); - tgt.setPublisher(src.getPublisher()); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) - tgt.addContact(convertValueSetContactComponent(t)); - if (src.hasDate()) - tgt.setDate(src.getDate()); - tgt.setLockedDate(src.getCompose().getLockedDate()); - tgt.setDescription(src.getDescription()); - for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) - if (t.hasValueCodeableConcept()) - tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) - tgt.addUseContext(convertCodeableConcept(t)); - tgt.setImmutable(src.getImmutable()); - tgt.setRequirements(src.getPurpose()); - tgt.setCopyright(src.getCopyright()); - tgt.setExtensible(src.getExtensible()); - org.hl7.fhir.r4.model.CodeSystem srcCS = (CodeSystem) src.getUserData("r2-cs"); - if (srcCS == null) - srcCS = advisor.getCodeSystem(src); - if (srcCS != null) { - tgt.getCodeSystem().setSystem(srcCS.getUrl()); - tgt.getCodeSystem().setVersion(srcCS.getVersion()); - tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); - for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) - processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS); - - } - tgt.setCompose(convertValueSetComposeComponent(src.getCompose(), srcCS == null ? null : srcCS.getUrl())); - tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.UriType t : src.getImport()) - tgt.addInclude().addValueSet(t.getValue()); - for (org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent t : src.getInclude()) - tgt.addInclude(convertConceptSetComponent(t)); - for (org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent t : src.getExclude()) - tgt.addExclude(convertConceptSetComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent src, String noSystem) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetComposeComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getInclude()) { - for (org.hl7.fhir.r4.model.UriType ti : t.getValueSet()) - tgt.addImport(ti.getValue()); - if (noSystem == null || !t.getSystem().equals(noSystem)) - tgt.addInclude(convertConceptSetComponent(t)); - } - for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getExclude()) - tgt.addExclude(convertConceptSetComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ContactDetail convertValueSetContactComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent convertValueSetContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) - tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent(); - copyElement(src, tgt); - tgt.setIdentifier(src.getIdentifier()); - tgt.setTimestamp(src.getTimestamp()); - tgt.setTotal(src.getTotal()); - tgt.setOffset(src.getOffset()); - for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) - tgt.addParameter(convertValueSetExpansionParameterComponent(t)); - for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) - tgt.addContains(convertValueSetExpansionContainsComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent(); - copyElement(src, tgt); - tgt.setIdentifier(src.getIdentifier()); - tgt.setTimestamp(src.getTimestamp()); - tgt.setTotal(src.getTotal()); - tgt.setOffset(src.getOffset()); - for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) - tgt.addParameter(convertValueSetExpansionParameterComponent(t)); - for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) - tgt.addContains(convertValueSetExpansionContainsComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setAbstract(src.getAbstract()); - tgt.setVersion(src.getVersion()); - tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - for (org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) - tgt.addContains(convertValueSetExpansionContainsComponent(t)); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent(); - copyElement(src, tgt); - tgt.setSystem(src.getSystem()); - tgt.setAbstract(src.getAbstract()); - tgt.setVersion(src.getVersion()); - tgt.setCode(src.getCode()); - tgt.setDisplay(src.getDisplay()); - for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) - tgt.addContains(convertValueSetExpansionContainsComponent(t)); - return tgt; - } - - public org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionParameterComponent(); - copyElement(src, tgt); - tgt.setName(src.getName()); - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public org.hl7.fhir.r4.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.instance.model.Contract.ValuedItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.r4.model.Contract.ValuedItemComponent(); - copyElement(src, tgt); - tgt.setEntity(convertType(src.getEntity())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setEffectiveTime(src.getEffectiveTime()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setUnitPrice(convertMoney(src.getUnitPrice())); - tgt.setFactor(src.getFactor()); - tgt.setPoints(src.getPoints()); - tgt.setNet(convertMoney(src.getNet())); - return tgt; - } - - public org.hl7.fhir.instance.model.Contract.ValuedItemComponent convertValuedItemComponent(org.hl7.fhir.r4.model.Contract.ValuedItemComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.instance.model.Contract.ValuedItemComponent tgt = new org.hl7.fhir.instance.model.Contract.ValuedItemComponent(); - copyElement(src, tgt); - tgt.setEntity(convertType(src.getEntity())); - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - tgt.setEffectiveTime(src.getEffectiveTime()); - tgt.setQuantity(convertSimpleQuantity(src.getQuantity())); - tgt.setUnitPrice(convertMoney(src.getUnitPrice())); - tgt.setFactor(src.getFactor()); - tgt.setPoints(src.getPoints()); - tgt.setNet(convertMoney(src.getNet())); - return tgt; - } - - public org.hl7.fhir.r4.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.instance.model.SearchParameter.XPathUsageType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NORMAL: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL; - case PHONETIC: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC; - case NEARBY: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY; - case DISTANCE: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE; - case OTHER: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER; - default: return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL; - } - } - - public org.hl7.fhir.instance.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case NORMAL: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NORMAL; - case PHONETIC: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.PHONETIC; - case NEARBY: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NEARBY; - case DISTANCE: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.DISTANCE; - case OTHER: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.OTHER; - default: return org.hl7.fhir.instance.model.SearchParameter.XPathUsageType.NULL; - } - } - - public void copyBackboneElement(org.hl7.fhir.instance.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.instance.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.instance.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public void copyDomainResource(org.hl7.fhir.instance.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.instance.model.Resource t : src.getContained()) - tgt.addContained(convertResource(t)); - for (org.hl7.fhir.instance.model.Extension t : src.getExtension()) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.instance.model.Extension t : src.getModifierExtension()) - tgt.addModifierExtension(convertExtension(t)); - } - - public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.instance.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r4.model.Resource t : src.getContained()) - tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) - tgt.addModifierExtension(convertExtension(t)); - } - - public void copyElement(org.hl7.fhir.instance.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.instance.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.instance.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public void copyElement(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.instance.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public void copyResource(org.hl7.fhir.instance.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - tgt.setMeta(convertMeta(src.getMeta())); - tgt.setImplicitRules(src.getImplicitRules()); - tgt.setLanguage(src.getLanguage()); - } - - public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.instance.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - private ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) { - for (ConceptMapGroupComponent grp : map.getGroup()) { - if (grp.getSource().equals(srcs) && grp.getTarget().equals(tgts)) - return grp; - } - ConceptMapGroupComponent grp = map.addGroup(); - grp.setSource(srcs); - grp.setTarget(tgts); - return grp; - } - - private org.hl7.fhir.r4.model.Reference getPerformer(List practitioner) { - for (ImmunizationPractitionerComponent p : practitioner) { - if (hasConcept(p.getRole(), "http://hl7.org/fhir/v2/0443", "AP")) - return p.getActor(); - } - return null; - } - - private org.hl7.fhir.r4.model.Reference getRequester(List practitioner) { - for (ImmunizationPractitionerComponent p : practitioner) { - if (hasConcept(p.getRole(), "http://hl7.org/fhir/v2/0443", "OP")) - return p.getActor(); - } - return null; - } - - private boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - private boolean hasConcept(org.hl7.fhir.instance.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.instance.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - private void processConcept(List concepts, org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException { - org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent(); - concepts.add(ct); - ct.setCode(cs.getCode()); - ct.setDisplay(cs.getDisplay()); - ct.setDefinition(cs.getDefinition()); - if (cs.getAbstract()) - CodeSystemUtilities.setNotSelectable(tgtcs, ct); - for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { - org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent(); - cst.setLanguage(csd.getLanguage()); - cst.setUse(convertCoding(csd.getUse())); - cst.setValue(csd.getValue()); - } - - for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) - processConcept(ct.getConcept(), csc, tgtcs); - } - - private void processConcept(List concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException { - org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); - concepts.add(ct); - ct.setCode(cs.getCode()); - ct.setDisplay(cs.getDisplay()); - ct.setDefinition(cs.getDefinition()); - if (CodeSystemUtilities.isNotSelectable(srcCS, cs)) - ct.setAbstract(true); - for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { - org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); - cst.setLanguage(csd.getLanguage()); - cst.setUse(convertCoding(csd.getUse())); - cst.setValue(csd.getValue()); - } - - for (ConceptDefinitionComponent csc : cs.getConcept()) - processConcept(ct.getConcept(), csc, srcCS); - } - - private String tail(String base) { - return base.substring(base.lastIndexOf("/")+1); - } - - private static org.hl7.fhir.r4.model.Enumerations.PublicationStatus convertQuestionnaireStatus(org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case DRAFT: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT; - case PUBLISHED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE; - case RETIRED: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED; - default: return org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL; - } - } - - private static org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus convertQuestionnaireStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case DRAFT: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.DRAFT; - case ACTIVE: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.PUBLISHED; - case RETIRED: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.RETIRED; - default: return org.hl7.fhir.instance.model.Questionnaire.QuestionnaireStatus.NULL; - } - } - - private static boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) - || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - private class SourceElementComponentWrapper { - private String source; - private String target; - private org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - } - } diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java index 1e0955c7aac..6a1e32f1b12 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java @@ -1346,7 +1346,7 @@ public class VersionConvertor_14_40 { org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); copyElement(src, tgt); for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), true)); if (src.hasDescription()) tgt.setDescription(src.getDescription()); if (src.hasOrdered()) diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/OIDUtils.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/OIDUtils.java deleted file mode 100644 index 67c5bd5fd51..00000000000 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/OIDUtils.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.hl7.fhir.utilities; - -/* - * #%L - * HAPI FHIR - Converter - * %% - * Copyright (C) 2014 - 2017 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - - -public class OIDUtils { - - /* - 2.16.840.1.113883.3.72.5.2 - NIST owns this - 2.16.840.1.113883.4.6 - National Provider Identifier - 2.16.840.1.113883.6.21 - UB92 - 2.16.840.1.113883.6.69 - NDC - */ - - public static String getUriForOid(String r) { - if (r.equals("2.16.840.1.113883.6.96")) - return "http://snomed.info/sct"; - if (r.equals("2.16.840.1.113883.6.1")) - return "http://loinc.org"; - if (r.equals("2.16.840.1.113883.6.8")) - return "http://unitsofmeasure.org"; - if (r.equals("2.16.840.1.113883.6.3")) - return "http://hl7.org/fhir/sid/icd-10"; - if (r.equals("2.16.840.1.113883.6.42")) - return "http://hl7.org/fhir/sid/icd-9"; - if (r.equals("2.16.840.1.113883.6.104")) - return "http://hl7.org/fhir/sid/icd-9"; - if (r.equals("2.16.840.1.113883.6.103")) - return "http://hl7.org/fhir/sid/icd-9"; //todo: confirm this - if (r.equals("2.16.840.1.113883.6.73")) - return "http://hl7.org/fhir/sid/atc"; - if (r.equals("2.16.840.1.113883.3.26.1.1")) - return "http://ncimeta.nci.nih.gov"; - if (r.equals("2.16.840.1.113883.3.26.1.1.1")) - return "http://ncimeta.nci.nih.gov"; - if (r.equals("2.16.840.1.113883.6.88")) - return "http://www.nlm.nih.gov/research/umls/rxnorm"; // todo: confirm this - - if (r.equals("2.16.840.1.113883.5.1008")) - return "http://hl7.org/fhir/v3/NullFlavor"; - if (r.equals("2.16.840.1.113883.5.111")) - return "http://hl7.org/fhir/v3/RoleCode"; - if (r.equals("2.16.840.1.113883.5.4")) - return "http://hl7.org/fhir/v3/ActCode"; - if (r.equals("2.16.840.1.113883.5.8")) - return "http://hl7.org/fhir/v3/ActReason"; - if (r.equals("2.16.840.1.113883.5.83")) - return "http://hl7.org/fhir/v3/ObservationInterpretation"; - if (r.equals("2.16.840.1.113883.6.238")) - return "http://hl7.org/fhir/v3/Race"; - - if (r.equals("2.16.840.1.113883.6.59")) - return "http://hl7.org/fhir/sid/cvx"; - if (r.equals("2.16.840.1.113883.12.292")) - return "http://hl7.org/fhir/sid/cvx"; - - if (r.equals("2.16.840.1.113883.6.12")) - return "http://www.ama-assn.org/go/cpt"; - - if (r.startsWith("2.16.840.1.113883.12.")) - return "http://hl7.org/fhir/sid/v2-"+r.substring(21); - return null; - } - -} diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/ucum/UcumService.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/ucum/UcumService.java deleted file mode 100644 index dc39030e5b6..00000000000 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/utilities/ucum/UcumService.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.hl7.fhir.utilities.ucum; - -/* - * #%L - * HAPI FHIR - Converter - * %% - * Copyright (C) 2014 - 2017 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -/******************************************************************************* - * Crown Copyright (c) 2006+, Copyright (c) 2006 - 2014 Kestral Computing & Health Intersections. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Kestral Computing P/L - initial implementation - * Health Intersections - ongoing maintenance - *******************************************************************************/ - -import java.util.Date; -import java.util.List; -import java.util.Set; - -import org.hl7.fhir.exceptions.UcumException; - - -/** - * General Ucum Service - * - * UCUM functionality that is useful for applications that make use of UCUM codes - * - * This is a tightly bound interface - consumers use the internal model classes - * - * @author Grahame Grieve - * - */ -public interface UcumService { - - public class UcumVersionDetails { - private Date releaseDate; - private String version; - /** - * @param releaseDate - * @param version - */ - public UcumVersionDetails(Date releaseDate, String version) { - super(); - this.releaseDate = releaseDate; - this.version = version; - } - /** - * @return the releaseDate - */ - public Date getReleaseDate() { - return releaseDate; - } - /** - * @return the version - */ - public String getVersion() { - return version; - } - - } - - /** - * return Ucum Identification details for the version in use - */ - public abstract UcumVersionDetails ucumIdentification(); - - - /** - * Check UCUM. Note that this stands as a test of the service - * more than UCUM itself (for version 1.7, there are no known - * semantic errors in UCUM). But you should always run this test at least - * once with the version of UCUM you are using to ensure that - * the service implementation correctly understands the UCUM data - * to which it is bound - * - * @return a list of internal errors in the UCUM spec. - * - */ - public abstract List validateUCUM(); - - - /** - * return a list of the defined types of units in this UCUM version - * - * @return - */ - public abstract Set getProperties(); - - /** - * validate whether a unit code are valid UCUM units - * - * @param units - the unit code to check - * @return nil if valid, or an error message describing the problem - */ - public abstract String validate(String unit); - - /** - * given a unit, return a formal description of what the units stand for using - * full names - * @param units the unit code - * @return formal description - * @throws UcumException - * @throws OHFException - */ - public String analyse(String unit) throws UcumException ; - - /** - * validate whether a units are valid UCUM units and additionally require that the - * units from a particular property - * - * @param units - the unit code to check - * @return nil if valid, or an error message describing the problem - */ - public abstract String validateInProperty(String unit, String property); - - /** - * validate whether a units are valid UCUM units and additionally require that the - * units match a particular base canonical unit - * - * @param units - the unit code to check - * @return nil if valid, or an error message describing the problem - */ - public abstract String validateCanonicalUnits(String unit, String canonical); - - /** - * given a set of units, return their canonical form - * @param unit - * @return the canonical form - * @throws UcumException - * @throws OHFException - */ - public abstract String getCanonicalUnits(String unit) throws UcumException ; - - /** - * given two pairs of units, return true if they sahre the same canonical base - * - * @param units1 - * @param units2 - * @return - * @throws UcumException - * @ - */ - public abstract boolean isComparable(String units1, String units2) throws UcumException ; - - - /** - * given a value and source unit, return the value in the given dest unit - * an exception is thrown if the conversion is not possible - * - * @param value - * @param sourceUnit - * @param destUnit - * @return the value if a conversion is possible - * @throws UcumException - * @throws OHFException - */ - public abstract Decimal convert(Decimal value, String sourceUnit, String destUnit) throws UcumException ; - - - - /** - * given a set of UCUM units, return a likely preferred human dense form - * - * SI units - as is. - * Other units - improved by manual fixes, or the removal of [] - * - * @param code - * @return the preferred human display form - */ - public abstract String getCommonDisplay(String code); - - - -} diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index 4fae00dd908..4069846907f 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -1,8 +1,13 @@ - + 4.0.0 - + ca.uhn.hapi.fhir hapi-deployable-pom @@ -139,7 +144,7 @@ jetty-util test - + net.sf.json-lib json-lib @@ -225,14 +230,14 @@ spring-web - - - javax.interceptor - javax.interceptor-api - provided - + + javax.interceptor + javax.interceptor-api + provided + @@ -253,6 +258,13 @@ + + org.basepom.maven + duplicate-finder-maven-plugin + + true + + org.jacoco jacoco-maven-plugin @@ -285,19 +297,17 @@ - - post-integration-test - install - - report - - - ${project.build.directory}/jacoco.exec - ${project.reporting.outputDirectory}/jacoco-report - - - - + + post-integration-test + install + + report + + + ${project.build.directory}/jacoco.exec + ${project.reporting.outputDirectory}/jacoco-report + + diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 9bc78bd71ff..022a7a0ccf5 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -163,7 +163,7 @@ thymeleaf-spring4 - + org.jscience jscience @@ -233,10 +233,12 @@ + org.springframework spring-core @@ -358,6 +360,7 @@ javax.mail javax.mail-api + provided com.sun.mail diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamRegistryDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamRegistryDstu3.java index d2c6e5cd38a..598e42ece8d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamRegistryDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamRegistryDstu3.java @@ -215,6 +215,9 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry { case RETIRED: status = RuntimeSearchParamStatusEnum.RETIRED; break; + case UNKNOWN: + status = RuntimeSearchParamStatusEnum.UNKNOWN; + break; case NULL: break; } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/SearchParamRegistryR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/SearchParamRegistryR4.java index e82e575423a..2702ccfca83 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/SearchParamRegistryR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/SearchParamRegistryR4.java @@ -216,6 +216,9 @@ public class SearchParamRegistryR4 extends BaseSearchParamRegistry { case RETIRED: status = RuntimeSearchParamStatusEnum.RETIRED; break; + case UNKNOWN: + status = RuntimeSearchParamStatusEnum.UNKNOWN; + break; case NULL: break; } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/graphql/JpaStorageServices.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/graphql/JpaStorageServices.java index cba8963940c..fce3910d95b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/graphql/JpaStorageServices.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/graphql/JpaStorageServices.java @@ -115,6 +115,8 @@ public class JpaStorageServices extends BaseHapiFhirDao implement break; case URI: break; + case HAS: + break; } params.add(nextArgument.getName(), param); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingSubscriber.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingSubscriber.java index fd5919eaa75..7c41102055f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingSubscriber.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingSubscriber.java @@ -103,6 +103,8 @@ public class SubscriptionActivatingSubscriber { } activateAndRegisterSubscriptionIfRequired(theSubscription); break; + default: + break; } } diff --git a/hapi-fhir-jpaserver-base/src/main/resources/.keep b/hapi-fhir-jpaserver-base/src/main/resources/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hapi-fhir-structures-dstu2.1/src/main/resources/.keep b/hapi-fhir-structures-dstu2.1/src/main/resources/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hapi-fhir-structures-dstu2/src/main/resources/.keep b/hapi-fhir-structures-dstu2/src/main/resources/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index 5041b34bbb6..02015f89e56 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -77,35 +77,6 @@ true - - org.basepom.maven - duplicate-finder-maven-plugin - 1.2.1 - - - default - verify - - check - - - - - false - true - true - true - true - false - false - false - false - true - true - 2 - ${project.build.directory}/duplicate-finder-result.xml - - diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ProfileUtilities.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ProfileUtilities.java index 31bd506f2cd..452472e7545 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ProfileUtilities.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ProfileUtilities.java @@ -1532,7 +1532,7 @@ public class ProfileUtilities extends TranslatingUtilities { private boolean hasBindableType(ElementDefinition ed) { for (TypeRefComponent tr : ed.getType()) { - if (Utilities.existsInList(tr.getCode(), "Coding", "CodeableConcept", "Quantity", "url", "string", "code")) + if (Utilities.existsInList(tr.getCode(), "Coding", "CodeableConcept", "Quantity", "uri", "string", "code")) return true; } return false; @@ -1918,8 +1918,8 @@ public class ProfileUtilities extends TranslatingUtilities { case BUNDLED : return "b"; case CONTAINED : return "c"; case REFERENCED: return "r"; + default: return "?"; } - return "?"; } @@ -2366,7 +2366,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (definition != null && definition.hasShort()) { if (!c.getPieces().isEmpty()) c.addPiece(gen.new Piece("br")); c.addPiece(checkForNoChange(definition.getShortElement(), gen.new Piece(null, gt(definition.getShortElement()), null))); - } else if (fallback != null && fallback != null && fallback.hasShort()) { + } else if (fallback != null && fallback.hasShort()) { if (!c.getPieces().isEmpty()) c.addPiece(gen.new Piece("br")); c.addPiece(checkForNoChange(fallback.getShortElement(), gen.new Piece(null, gt(fallback.getShortElement()), null))); } @@ -2604,6 +2604,13 @@ public class ProfileUtilities extends TranslatingUtilities { } } } + if (definition.hasDefinition()) { + if (!c.getPieces().isEmpty()) c.addPiece(gen.new Piece("br")); + c.getPieces().add(gen.new Piece(null, "Definition: ", null).addStyle("font-weight:bold")); + c.addPiece(gen.new Piece("br")); + c.addMarkdown(definition.getDefinition()); +// c.getPieces().add(checkForNoChange(definition.getCommentElement(), gen.new Piece(null, definition.getComment(), null))); + } if (definition.getComment()!=null) { if (!c.getPieces().isEmpty()) c.addPiece(gen.new Piece("br")); c.getPieces().add(gen.new Piece(null, "Comments: ", null).addStyle("font-weight:bold")); @@ -3734,17 +3741,21 @@ public class ProfileUtilities extends TranslatingUtilities { } - public static ElementDefinitionSlicingDiscriminatorComponent interpretR2Discriminator(String discriminator) { + public static ElementDefinitionSlicingDiscriminatorComponent interpretR2Discriminator(String discriminator, boolean isExists) { if (discriminator.endsWith("@profile")) return makeDiscriminator(DiscriminatorType.PROFILE, discriminator.length() == 8 ? "" : discriminator.substring(discriminator.length()-9)); if (discriminator.endsWith("@type")) - return makeDiscriminator(DiscriminatorType.TYPE, discriminator.length() == 5 ? "" : discriminator.substring(discriminator.length()-6)); + return makeDiscriminator(DiscriminatorType.TYPE, discriminator.length() == 5 ? "" : discriminator.substring(discriminator.length()-6)); + if (discriminator.endsWith("@exists")) + return makeDiscriminator(DiscriminatorType.EXISTS, discriminator.length() == 7 ? "" : discriminator.substring(discriminator.length()-8)); + if (isExists) + return makeDiscriminator(DiscriminatorType.EXISTS, discriminator); return new ElementDefinitionSlicingDiscriminatorComponent().setType(DiscriminatorType.VALUE).setPath(discriminator); } - private static ElementDefinitionSlicingDiscriminatorComponent makeDiscriminator(DiscriminatorType profile, String str) { - return new ElementDefinitionSlicingDiscriminatorComponent().setType(DiscriminatorType.VALUE).setPath(Utilities.noString(str)? "$this" : str); + private static ElementDefinitionSlicingDiscriminatorComponent makeDiscriminator(DiscriminatorType dType, String str) { + return new ElementDefinitionSlicingDiscriminatorComponent().setType(dType).setPath(Utilities.noString(str)? "$this" : str); } diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java index 392e289bd7c..608f0c48fd2 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java @@ -208,14 +208,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.DAY_OF_MONTH); } - /** - * Sets the month with 1-index, e.g. 1=the first day of the month - */ - public BaseDateTimeType setDay(int theDay) { - setFieldValue(Calendar.DAY_OF_MONTH, theDay, null, 0, 31); - return this; - } - /** * Returns the default precision for the given datatype */ @@ -236,14 +228,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.HOUR_OF_DAY); } - /** - * Sets the hour of the day in a 24h clock, e.g. 13=1pm - */ - public BaseDateTimeType setHour(int theHour) { - setFieldValue(Calendar.HOUR_OF_DAY, theHour, null, 0, 23); - return this; - } - /** * Returns the milliseconds within the current second. *

@@ -255,18 +239,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.MILLISECOND); } - /** - * Sets the milliseconds within the current second. - *

- * Note that this method sets the - * same value as {@link #setNanos(long)} but with less precision. - *

- */ - public BaseDateTimeType setMillis(int theMillis) { - setFieldValue(Calendar.MILLISECOND, theMillis, null, 0, 999); - return this; - } - /** * Returns the minute of the hour in the range 0-59 */ @@ -274,14 +246,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.MINUTE); } - /** - * Sets the minute of the hour in the range 0-59 - */ - public BaseDateTimeType setMinute(int theMinute) { - setFieldValue(Calendar.MINUTE, theMinute, null, 0, 59); - return this; - } - /** * Returns the month with 0-index, e.g. 0=January */ @@ -289,14 +253,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.MONTH); } - /** - * Sets the month with 0-index, e.g. 0=January - */ - public BaseDateTimeType setMonth(int theMonth) { - setFieldValue(Calendar.MONTH, theMonth, null, 0, 11); - return this; - } - /** * Returns the nanoseconds within the current second *

@@ -313,29 +269,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return Long.parseLong(retVal); } - /** - * Sets the nanoseconds within the current second - *

- * Note that this method sets the - * same value as {@link #setMillis(int)} but with more precision. - *

- */ - public BaseDateTimeType setNanos(long theNanos) { - validateValueInRange(theNanos, 0, NANOS_PER_SECOND - 1); - String fractionalSeconds = StringUtils.leftPad(Long.toString(theNanos), 9, '0'); - - // Strip trailing 0s - for (int i = fractionalSeconds.length(); i > 0; i--) { - if (fractionalSeconds.charAt(i - 1) != '0') { - fractionalSeconds = fractionalSeconds.substring(0, i); - break; - } - } - int millis = (int) (theNanos / NANOS_PER_MILLIS); - setFieldValue(Calendar.MILLISECOND, millis, fractionalSeconds, 0, 999); - return this; - } - private int getOffsetIndex(String theValueString) { int plusIndex = theValueString.indexOf('+', 16); int minusIndex = theValueString.indexOf('-', 16); @@ -352,7 +285,7 @@ public abstract class BaseDateTimeType extends PrimitiveType { /** * Gets the precision for this datatype (using the default for the given type if not set) - * + * * @see #setPrecision(TemporalPrecisionEnum) */ public TemporalPrecisionEnum getPrecision() { @@ -362,19 +295,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return myPrecision; } - /** - * Sets the precision for this datatype - * - * @throws DataFormatException - */ - public void setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException { - if (thePrecision == null) { - throw new NullPointerException("Precision may not be null"); - } - myPrecision = thePrecision; - updateStringValue(); - } - /** * Returns the second of the minute in the range 0-59 */ @@ -382,32 +302,17 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.SECOND); } - /** - * Sets the second of the minute in the range 0-59 - */ - public BaseDateTimeType setSecond(int theSecond) { - setFieldValue(Calendar.SECOND, theSecond, null, 0, 59); - return this; - } - /** * Returns the TimeZone associated with this dateTime's value. May return null if no timezone was * supplied. */ public TimeZone getTimeZone() { if (myTimeZoneZulu) { - return TimeZone.getTimeZone("Z"); + return TimeZone.getTimeZone("GMT"); } return myTimeZone; } - public BaseDateTimeType setTimeZone(TimeZone theTimeZone) { - myTimeZone = theTimeZone; - myTimeZoneZulu = false; - updateStringValue(); - return this; - } - /** * Returns the value of this object as a {@link GregorianCalendar} */ @@ -432,14 +337,6 @@ public abstract class BaseDateTimeType extends PrimitiveType { return getFieldValue(Calendar.YEAR); } - /** - * Sets the year, e.g. 2015 - */ - public BaseDateTimeType setYear(int theYear) { - setFieldValue(Calendar.YEAR, theYear, null, 0, 9999); - return this; - } - /** * To be implemented by subclasses to indicate whether the given precision is allowed by this type */ @@ -452,16 +349,9 @@ public abstract class BaseDateTimeType extends PrimitiveType { return myTimeZoneZulu; } - public BaseDateTimeType setTimeZoneZulu(boolean theTimeZoneZulu) { - myTimeZoneZulu = theTimeZoneZulu; - myTimeZone = null; - updateStringValue(); - return this; - } - /** * Returns true if this object represents a date that is today's date - * + * * @throws NullPointerException * if {@link #getValue()} returns null */ @@ -602,6 +492,14 @@ public abstract class BaseDateTimeType extends PrimitiveType { return retVal; } + /** + * Sets the month with 1-index, e.g. 1=the first day of the month + */ + public BaseDateTimeType setDay(int theDay) { + setFieldValue(Calendar.DAY_OF_MONTH, theDay, null, 0, 31); + return this; + } + private void setFieldValue(int theField, int theValue, String theFractionalSeconds, int theMinimum, int theMaximum) { validateValueInRange(theValue, theMinimum, theMaximum); Calendar cal; @@ -621,6 +519,86 @@ public abstract class BaseDateTimeType extends PrimitiveType { super.setValue(cal.getTime()); } + /** + * Sets the hour of the day in a 24h clock, e.g. 13=1pm + */ + public BaseDateTimeType setHour(int theHour) { + setFieldValue(Calendar.HOUR_OF_DAY, theHour, null, 0, 23); + return this; + } + + /** + * Sets the milliseconds within the current second. + *

+ * Note that this method sets the + * same value as {@link #setNanos(long)} but with less precision. + *

+ */ + public BaseDateTimeType setMillis(int theMillis) { + setFieldValue(Calendar.MILLISECOND, theMillis, null, 0, 999); + return this; + } + + /** + * Sets the minute of the hour in the range 0-59 + */ + public BaseDateTimeType setMinute(int theMinute) { + setFieldValue(Calendar.MINUTE, theMinute, null, 0, 59); + return this; + } + + /** + * Sets the month with 0-index, e.g. 0=January + */ + public BaseDateTimeType setMonth(int theMonth) { + setFieldValue(Calendar.MONTH, theMonth, null, 0, 11); + return this; + } + + /** + * Sets the nanoseconds within the current second + *

+ * Note that this method sets the + * same value as {@link #setMillis(int)} but with more precision. + *

+ */ + public BaseDateTimeType setNanos(long theNanos) { + validateValueInRange(theNanos, 0, NANOS_PER_SECOND - 1); + String fractionalSeconds = StringUtils.leftPad(Long.toString(theNanos), 9, '0'); + + // Strip trailing 0s + for (int i = fractionalSeconds.length(); i > 0; i--) { + if (fractionalSeconds.charAt(i - 1) != '0') { + fractionalSeconds = fractionalSeconds.substring(0, i); + break; + } + } + int millis = (int) (theNanos / NANOS_PER_MILLIS); + setFieldValue(Calendar.MILLISECOND, millis, fractionalSeconds, 0, 999); + return this; + } + + /** + * Sets the precision for this datatype + * + * @throws DataFormatException + */ + public void setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException { + if (thePrecision == null) { + throw new NullPointerException("Precision may not be null"); + } + myPrecision = thePrecision; + updateStringValue(); + } + + /** + * Sets the second of the minute in the range 0-59 + */ + public BaseDateTimeType setSecond(int theSecond) { + setFieldValue(Calendar.SECOND, theSecond, null, 0, 59); + return this; + } + private BaseDateTimeType setTimeZone(String theWholeValue, String theValue) { if (isBlank(theValue)) { @@ -642,6 +620,20 @@ public abstract class BaseDateTimeType extends PrimitiveType { return this; } + public BaseDateTimeType setTimeZone(TimeZone theTimeZone) { + myTimeZone = theTimeZone; + myTimeZoneZulu = false; + updateStringValue(); + return this; + } + + public BaseDateTimeType setTimeZoneZulu(boolean theTimeZoneZulu) { + myTimeZoneZulu = theTimeZoneZulu; + myTimeZone = null; + updateStringValue(); + return this; + } + /** * Sets the value for this type using the given Java Date object as the time, and using the default precision for * this datatype (unless the precision is already set), as well as the local timezone as determined by the local operating @@ -657,7 +649,7 @@ public abstract class BaseDateTimeType extends PrimitiveType { * Sets the value for this type using the given Java Date object as the time, and using the specified precision, as * well as the local timezone as determined by the local operating system. Both of * these properties may be modified in subsequent calls if neccesary. - * + * * @param theValue * The date value * @param thePrecision @@ -729,6 +721,14 @@ public abstract class BaseDateTimeType extends PrimitiveType { } } + /** + * Sets the year, e.g. 2015 + */ + public BaseDateTimeType setYear(int theYear) { + setFieldValue(Calendar.YEAR, theYear, null, 0, 9999); + return this; + } + private void throwBadDateFormat(String theValue) { throw new DataFormatException("Invalid date/time format: \"" + theValue + "\""); } diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ResourceAddress.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ResourceAddress.java index 368b9b2c0ba..ef2b841547b 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ResourceAddress.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ResourceAddress.java @@ -1,417 +1,417 @@ -package org.hl7.fhir.r4.utils.client; - - -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*/ - - -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.utils.URIBuilder; -import org.hl7.fhir.r4.model.Resource; -import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.utilities.Utilities; - -//Make resources address subclass of URI -/** - * Helper class to manage FHIR Resource URIs - * - * @author Claude Nanjo - * - */ -public class ResourceAddress { - - public static final String REGEX_ID_WITH_HISTORY = "(.*)(/)([a-zA-Z0-9]*)(/)([a-z0-9\\-\\.]{1,64})(/_history/)([a-z0-9\\-\\.]{1,64})$"; - - private URI baseServiceUri; - - public ResourceAddress(String endpointPath) throws URISyntaxException {//TODO Revisit this exception - this.baseServiceUri = ResourceAddress.buildAbsoluteURI(endpointPath); - } - - public ResourceAddress(URI baseServiceUri) { - this.baseServiceUri = baseServiceUri; - } - - public URI getBaseServiceUri() { - return this.baseServiceUri; - } - - public URI resolveOperationURLFromClass(Class resourceClass, String name, String parameters) { - return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+name+"?"+ parameters); - } - - public URI resolveSearchUri(Class resourceClass, Map parameters) { - return appendHttpParameters(baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"_search"), parameters); - } - - private String nameForClassWithSlash(Class resourceClass) { - String n = nameForClass(resourceClass); - return n == null ? "" : n +"/"; - } - - public URI resolveOperationUri(Class resourceClass, String opName) { - return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"/"+opName); - } - - public URI resolveOperationUri(Class resourceClass, String opName, Map parameters) { - return appendHttpParameters(baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+opName), parameters); - } - - public URI resolveValidateUri(Class resourceClass, String id) { - return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$validate/"+id); - } - - public URI resolveGetUriFromResourceClass(Class resourceClass) { - return baseServiceUri.resolve(nameForClass(resourceClass)); - } - - public URI resolveGetUriFromResourceClassAndId(Class resourceClass, String id) { - return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id); - } - - public URI resolveGetUriFromResourceClassAndIdAndVersion(Class resourceClass, String id, String version) { - return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version); - } - - public URI resolveGetHistoryForAllResources(int count) { - if(count > 0) { - return appendHttpParameter(baseServiceUri.resolve("_history"), "_count", ""+count); - } else { - return baseServiceUri.resolve("_history"); - } -} - - public URI resolveGetHistoryForResourceId(Class resourceClass, String id, int count) { - return resolveGetHistoryUriForResourceId(resourceClass, id, null, count); - } - - protected URI resolveGetHistoryUriForResourceId(Class resourceClass, String id, Object since, int count) { - Map parameters = getHistoryParameters(since, count); - return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/" + id + "/_history"), parameters); - } - - public URI resolveGetHistoryForResourceType(Class resourceClass, int count) { - Map parameters = getHistoryParameters(null, count); - return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/_history"), parameters); - } - - public URI resolveGetHistoryForResourceType(Class resourceClass, Object since, int count) { - Map parameters = getHistoryParameters(since, count); - return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/_history"), parameters); - } - - public URI resolveGetHistoryForAllResources(Calendar since, int count) { - Map parameters = getHistoryParameters(since, count); - return appendHttpParameters(baseServiceUri.resolve("_history"), parameters); - } - - public URI resolveGetHistoryForAllResources(Date since, int count) { - Map parameters = getHistoryParameters(since, count); - return appendHttpParameters(baseServiceUri.resolve("_history"), parameters); - } - - public Map getHistoryParameters(Object since, int count) { - Map parameters = new HashMap(); - if (since != null) { - parameters.put("_since", since.toString()); - } - if(count > 0) { - parameters.put("_count", ""+count); - } - return parameters; - } - - public URI resolveGetHistoryForResourceId(Class resourceClass, String id, Calendar since, int count) { - return resolveGetHistoryUriForResourceId(resourceClass, id, since, count); - } - - public URI resolveGetHistoryForResourceId(Class resourceClass, String id, Date since, int count) { - return resolveGetHistoryUriForResourceId(resourceClass, id, since, count); - } - - public URI resolveGetHistoryForResourceType(Class resourceClass, Calendar since, int count) { - return resolveGetHistoryForResourceType(resourceClass, getCalendarDateInIsoTimeFormat(since), count); - } - - public URI resolveGetHistoryForResourceType(Class resourceClass, Date since, int count) { - return resolveGetHistoryForResourceType(resourceClass, since.toString(), count); - } - - public URI resolveGetAllTags() { - return baseServiceUri.resolve("_tags"); - } - - public URI resolveGetAllTagsForResourceType(Class resourceClass) { - return baseServiceUri.resolve(nameForClass(resourceClass) + "/_tags"); - } - - public URI resolveGetTagsForReference(Class resourceClass, String id) { - return baseServiceUri.resolve(nameForClass(resourceClass) + "/" + id + "/_tags"); - } - - public URI resolveGetTagsForResourceVersion(Class resourceClass, String id, String version) { - return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version + "/_tags"); - } - - public URI resolveDeleteTagsForResourceVersion(Class resourceClass, String id, String version) { - return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version + "/_tags/_delete"); - } - - - public String nameForClass(Class resourceClass) { - if (resourceClass == null) - return null; - String res = resourceClass.getSimpleName(); - if (res.equals("List_")) - return "List"; - else - return res; - } - - public URI resolveMetadataUri(boolean quick) { - return baseServiceUri.resolve(quick ? "metadata?_summary=true" : "metadata"); - } - - /** - * For now, assume this type of location header structure. - * Generalize later: http://hl7connect.healthintersections.com.au/svc/fhir/318/_history/1 - * - * @param serviceBase - * @param locationHeader - */ - public static ResourceAddress.ResourceVersionedIdentifier parseCreateLocation(String locationResponseHeader) { - Pattern pattern = Pattern.compile(REGEX_ID_WITH_HISTORY); - Matcher matcher = pattern.matcher(locationResponseHeader); - ResourceVersionedIdentifier parsedHeader = null; - if(matcher.matches()){ - String serviceRoot = matcher.group(1); - String resourceType = matcher.group(3); - String id = matcher.group(5); - String version = matcher.group(7); - parsedHeader = new ResourceVersionedIdentifier(serviceRoot, resourceType, id, version); - } - return parsedHeader; - } - - public static URI buildAbsoluteURI(String absoluteURI) { - - if(StringUtils.isBlank(absoluteURI)) { - throw new EFhirClientException("Invalid URI", new URISyntaxException(absoluteURI, "URI/URL cannot be blank")); - } - - String endpoint = appendForwardSlashToPath(absoluteURI); - - return buildEndpointUriFromString(endpoint); - } - - public static String appendForwardSlashToPath(String path) { - if(path.lastIndexOf('/') != path.length() - 1) { - path += "/"; - } - return path; - } - - public static URI buildEndpointUriFromString(String endpointPath) { - URI uri = null; - try { - URIBuilder uriBuilder = new URIBuilder(endpointPath); - uri = uriBuilder.build(); - String scheme = uri.getScheme(); - String host = uri.getHost(); - if(!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) { - throw new EFhirClientException("Scheme must be 'http' or 'https': " + uri); - } - if(StringUtils.isBlank(host)) { - throw new EFhirClientException("host cannot be blank: " + uri); - } - } catch(URISyntaxException e) { - throw new EFhirClientException("Invalid URI", e); - } - return uri; - } - - public static URI appendQueryStringToUri(URI uri, String parameterName, String parameterValue) { - URI modifiedUri = null; - try { - URIBuilder uriBuilder = new URIBuilder(uri); - uriBuilder.setQuery(parameterName + "=" + parameterValue); - modifiedUri = uriBuilder.build(); - } catch(Exception e) { - throw new EFhirClientException("Unable to append query parameter '" + parameterName + "=" + parameterValue + " to URI " + uri, e); - } - return modifiedUri; - } - - public static String buildRelativePathFromResourceType(ResourceType resourceType) { - //return resourceType.toString().toLowerCase()+"/"; - return resourceType.toString() + "/"; - } - - public static String buildRelativePathFromResourceType(ResourceType resourceType, String id) { - return buildRelativePathFromResourceType(resourceType)+ "@" + id; - } - - public static String buildRelativePathFromReference(Resource resource) { - return buildRelativePathFromResourceType(resource.getResourceType()); - } - - public static String buildRelativePathFromReference(Resource resource, String id) { - return buildRelativePathFromResourceType(resource.getResourceType(), id); - } - - public static class ResourceVersionedIdentifier { - - private String serviceRoot; - private String resourceType; - private String id; - private String version; - private URI resourceLocation; - - public ResourceVersionedIdentifier(String serviceRoot, String resourceType, String id, String version, URI resourceLocation) { - this.serviceRoot = serviceRoot; - this.resourceType = resourceType; - this.id = id; - this.version = version; - this.resourceLocation = resourceLocation; - } - - public ResourceVersionedIdentifier(String resourceType, String id, String version, URI resourceLocation) { - this(null, resourceType, id, version, resourceLocation); - } - - public ResourceVersionedIdentifier(String serviceRoot, String resourceType, String id, String version) { - this(serviceRoot, resourceType, id, version, null); - } - - public ResourceVersionedIdentifier(String resourceType, String id, String version) { - this(null, resourceType, id, version, null); - } - - public ResourceVersionedIdentifier(String resourceType, String id) { - this.id = id; - } - - public String getId() { - return this.id; - } - - protected void setId(String id) { - this.id = id; - } - - public String getVersionId() { - return this.version; - } - - protected void setVersionId(String version) { - this.version = version; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getServiceRoot() { - return serviceRoot; - } - - public void setServiceRoot(String serviceRoot) { - this.serviceRoot = serviceRoot; - } - - public String getResourcePath() { - return this.serviceRoot + "/" + this.resourceType + "/" + this.id; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public URI getResourceLocation() { - return this.resourceLocation; - } - - public void setResourceLocation(URI resourceLocation) { - this.resourceLocation = resourceLocation; - } - } - - public static String getCalendarDateInIsoTimeFormat(Calendar calendar) { - SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd'T'hh:mm:ss");//TODO Move out - format.setTimeZone(TimeZone.getTimeZone("GMT")); - return format.format(calendar.getTime()); - } - - public static URI appendHttpParameter(URI basePath, String httpParameterName, String httpParameterValue) { - Map parameters = new HashMap(); - parameters.put(httpParameterName, httpParameterValue); - return appendHttpParameters(basePath, parameters); - } - - public static URI appendHttpParameters(URI basePath, Map parameters) { - try { - Set httpParameterNames = parameters.keySet(); - String query = basePath.getQuery(); - - for(String httpParameterName : httpParameterNames) { - if(query != null) { - query += "&"; - } else { - query = ""; - } - query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName)); - } - - return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(),basePath.getPort(), basePath.getPath(), query, basePath.getFragment()); - } catch(Exception e) { - throw new EFhirClientException("Error appending http parameter", e); - } - } - -} \ No newline at end of file +package org.hl7.fhir.r4.utils.client; + + +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*/ + + +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.utils.URIBuilder; +import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.ResourceType; +import org.hl7.fhir.utilities.Utilities; + +//Make resources address subclass of URI +/** + * Helper class to manage FHIR Resource URIs + * + * @author Claude Nanjo + * + */ +public class ResourceAddress { + + public static final String REGEX_ID_WITH_HISTORY = "(.*)(/)([a-zA-Z0-9]*)(/)([a-z0-9\\-\\.]{1,64})(/_history/)([a-z0-9\\-\\.]{1,64})$"; + + private URI baseServiceUri; + + public ResourceAddress(String endpointPath) throws URISyntaxException {//TODO Revisit this exception + this.baseServiceUri = ResourceAddress.buildAbsoluteURI(endpointPath); + } + + public ResourceAddress(URI baseServiceUri) { + this.baseServiceUri = baseServiceUri; + } + + public URI getBaseServiceUri() { + return this.baseServiceUri; + } + + public URI resolveOperationURLFromClass(Class resourceClass, String name, String parameters) { + return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+name+"?"+ parameters); + } + + public URI resolveSearchUri(Class resourceClass, Map parameters) { + return appendHttpParameters(baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"_search"), parameters); + } + + private String nameForClassWithSlash(Class resourceClass) { + String n = nameForClass(resourceClass); + return n == null ? "" : n +"/"; + } + + public URI resolveOperationUri(Class resourceClass, String opName) { + return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"/"+opName); + } + + public URI resolveOperationUri(Class resourceClass, String opName, Map parameters) { + return appendHttpParameters(baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+opName), parameters); + } + + public URI resolveValidateUri(Class resourceClass, String id) { + return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$validate/"+id); + } + + public URI resolveGetUriFromResourceClass(Class resourceClass) { + return baseServiceUri.resolve(nameForClass(resourceClass)); + } + + public URI resolveGetUriFromResourceClassAndId(Class resourceClass, String id) { + return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id); + } + + public URI resolveGetUriFromResourceClassAndIdAndVersion(Class resourceClass, String id, String version) { + return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version); + } + + public URI resolveGetHistoryForAllResources(int count) { + if(count > 0) { + return appendHttpParameter(baseServiceUri.resolve("_history"), "_count", ""+count); + } else { + return baseServiceUri.resolve("_history"); + } +} + + public URI resolveGetHistoryForResourceId(Class resourceClass, String id, int count) { + return resolveGetHistoryUriForResourceId(resourceClass, id, null, count); + } + + protected URI resolveGetHistoryUriForResourceId(Class resourceClass, String id, Object since, int count) { + Map parameters = getHistoryParameters(since, count); + return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/" + id + "/_history"), parameters); + } + + public URI resolveGetHistoryForResourceType(Class resourceClass, int count) { + Map parameters = getHistoryParameters(null, count); + return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/_history"), parameters); + } + + public URI resolveGetHistoryForResourceType(Class resourceClass, Object since, int count) { + Map parameters = getHistoryParameters(since, count); + return appendHttpParameters(baseServiceUri.resolve(nameForClass(resourceClass) + "/_history"), parameters); + } + + public URI resolveGetHistoryForAllResources(Calendar since, int count) { + Map parameters = getHistoryParameters(since, count); + return appendHttpParameters(baseServiceUri.resolve("_history"), parameters); + } + + public URI resolveGetHistoryForAllResources(Date since, int count) { + Map parameters = getHistoryParameters(since, count); + return appendHttpParameters(baseServiceUri.resolve("_history"), parameters); + } + + public Map getHistoryParameters(Object since, int count) { + Map parameters = new HashMap(); + if (since != null) { + parameters.put("_since", since.toString()); + } + if(count > 0) { + parameters.put("_count", ""+count); + } + return parameters; + } + + public URI resolveGetHistoryForResourceId(Class resourceClass, String id, Calendar since, int count) { + return resolveGetHistoryUriForResourceId(resourceClass, id, since, count); + } + + public URI resolveGetHistoryForResourceId(Class resourceClass, String id, Date since, int count) { + return resolveGetHistoryUriForResourceId(resourceClass, id, since, count); + } + + public URI resolveGetHistoryForResourceType(Class resourceClass, Calendar since, int count) { + return resolveGetHistoryForResourceType(resourceClass, getCalendarDateInIsoTimeFormat(since), count); + } + + public URI resolveGetHistoryForResourceType(Class resourceClass, Date since, int count) { + return resolveGetHistoryForResourceType(resourceClass, since.toString(), count); + } + + public URI resolveGetAllTags() { + return baseServiceUri.resolve("_tags"); + } + + public URI resolveGetAllTagsForResourceType(Class resourceClass) { + return baseServiceUri.resolve(nameForClass(resourceClass) + "/_tags"); + } + + public URI resolveGetTagsForReference(Class resourceClass, String id) { + return baseServiceUri.resolve(nameForClass(resourceClass) + "/" + id + "/_tags"); + } + + public URI resolveGetTagsForResourceVersion(Class resourceClass, String id, String version) { + return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version + "/_tags"); + } + + public URI resolveDeleteTagsForResourceVersion(Class resourceClass, String id, String version) { + return baseServiceUri.resolve(nameForClass(resourceClass) +"/"+id+"/_history/"+version + "/_tags/_delete"); + } + + + public String nameForClass(Class resourceClass) { + if (resourceClass == null) + return null; + String res = resourceClass.getSimpleName(); + if (res.equals("List_")) + return "List"; + else + return res; + } + + public URI resolveMetadataUri(boolean quick) { + return baseServiceUri.resolve(quick ? "metadata?_summary=true" : "metadata"); + } + + /** + * For now, assume this type of location header structure. + * Generalize later: http://hl7connect.healthintersections.com.au/svc/fhir/318/_history/1 + * + * @param serviceBase + * @param locationHeader + */ + public static ResourceAddress.ResourceVersionedIdentifier parseCreateLocation(String locationResponseHeader) { + Pattern pattern = Pattern.compile(REGEX_ID_WITH_HISTORY); + Matcher matcher = pattern.matcher(locationResponseHeader); + ResourceVersionedIdentifier parsedHeader = null; + if(matcher.matches()){ + String serviceRoot = matcher.group(1); + String resourceType = matcher.group(3); + String id = matcher.group(5); + String version = matcher.group(7); + parsedHeader = new ResourceVersionedIdentifier(serviceRoot, resourceType, id, version); + } + return parsedHeader; + } + + public static URI buildAbsoluteURI(String absoluteURI) { + + if(StringUtils.isBlank(absoluteURI)) { + throw new EFhirClientException("Invalid URI", new URISyntaxException(absoluteURI, "URI/URL cannot be blank")); + } + + String endpoint = appendForwardSlashToPath(absoluteURI); + + return buildEndpointUriFromString(endpoint); + } + + public static String appendForwardSlashToPath(String path) { + if(path.lastIndexOf('/') != path.length() - 1) { + path += "/"; + } + return path; + } + + public static URI buildEndpointUriFromString(String endpointPath) { + URI uri = null; + try { + URIBuilder uriBuilder = new URIBuilder(endpointPath); + uri = uriBuilder.build(); + String scheme = uri.getScheme(); + String host = uri.getHost(); + if(!scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) { + throw new EFhirClientException("Scheme must be 'http' or 'https': " + uri); + } + if(StringUtils.isBlank(host)) { + throw new EFhirClientException("host cannot be blank: " + uri); + } + } catch(URISyntaxException e) { + throw new EFhirClientException("Invalid URI", e); + } + return uri; + } + + public static URI appendQueryStringToUri(URI uri, String parameterName, String parameterValue) { + URI modifiedUri = null; + try { + URIBuilder uriBuilder = new URIBuilder(uri); + uriBuilder.setQuery(parameterName + "=" + parameterValue); + modifiedUri = uriBuilder.build(); + } catch(Exception e) { + throw new EFhirClientException("Unable to append query parameter '" + parameterName + "=" + parameterValue + " to URI " + uri, e); + } + return modifiedUri; + } + + public static String buildRelativePathFromResourceType(ResourceType resourceType) { + //return resourceType.toString().toLowerCase()+"/"; + return resourceType.toString() + "/"; + } + + public static String buildRelativePathFromResourceType(ResourceType resourceType, String id) { + return buildRelativePathFromResourceType(resourceType)+ "@" + id; + } + + public static String buildRelativePathFromReference(Resource resource) { + return buildRelativePathFromResourceType(resource.getResourceType()); + } + + public static String buildRelativePathFromReference(Resource resource, String id) { + return buildRelativePathFromResourceType(resource.getResourceType(), id); + } + + public static class ResourceVersionedIdentifier { + + private String serviceRoot; + private String resourceType; + private String id; + private String version; + private URI resourceLocation; + + public ResourceVersionedIdentifier(String serviceRoot, String resourceType, String id, String version, URI resourceLocation) { + this.serviceRoot = serviceRoot; + this.resourceType = resourceType; + this.id = id; + this.version = version; + this.resourceLocation = resourceLocation; + } + + public ResourceVersionedIdentifier(String resourceType, String id, String version, URI resourceLocation) { + this(null, resourceType, id, version, resourceLocation); + } + + public ResourceVersionedIdentifier(String serviceRoot, String resourceType, String id, String version) { + this(serviceRoot, resourceType, id, version, null); + } + + public ResourceVersionedIdentifier(String resourceType, String id, String version) { + this(null, resourceType, id, version, null); + } + + public ResourceVersionedIdentifier(String resourceType, String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + protected void setId(String id) { + this.id = id; + } + + public String getVersionId() { + return this.version; + } + + protected void setVersionId(String version) { + this.version = version; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getServiceRoot() { + return serviceRoot; + } + + public void setServiceRoot(String serviceRoot) { + this.serviceRoot = serviceRoot; + } + + public String getResourcePath() { + return this.serviceRoot + "/" + this.resourceType + "/" + this.id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public URI getResourceLocation() { + return this.resourceLocation; + } + + public void setResourceLocation(URI resourceLocation) { + this.resourceLocation = resourceLocation; + } + } + + public static String getCalendarDateInIsoTimeFormat(Calendar calendar) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");//TODO Move out + format.setTimeZone(TimeZone.getTimeZone("GMT")); + return format.format(calendar.getTime()); + } + + public static URI appendHttpParameter(URI basePath, String httpParameterName, String httpParameterValue) { + Map parameters = new HashMap(); + parameters.put(httpParameterName, httpParameterValue); + return appendHttpParameters(basePath, parameters); + } + + public static URI appendHttpParameters(URI basePath, Map parameters) { + try { + Set httpParameterNames = parameters.keySet(); + String query = basePath.getQuery(); + + for(String httpParameterName : httpParameterNames) { + if(query != null) { + query += "&"; + } else { + query = ""; + } + query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName)); + } + + return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(),basePath.getPort(), basePath.getPath(), query, basePath.getFragment()); + } catch(Exception e) { + throw new EFhirClientException("Error appending http parameter", e); + } + } + +} diff --git a/hapi-fhir-testpage-overlay/src/main/resources/.keep b/hapi-fhir-testpage-overlay/src/main/resources/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hapi-fhir-validation-resources-dstu3/src/main/java/.keep b/hapi-fhir-validation-resources-dstu3/src/main/java/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/validation/InstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/validation/InstanceValidator.java index 1b388001c7e..6be1b775f87 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/validation/InstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/validation/InstanceValidator.java @@ -339,10 +339,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat switch (bpWarnings) { case Error: rule(errors, invalid, line, col, literalPath, test, message); + break; case Warning: warning(errors, invalid, line, col, literalPath, test, message); + break; case Hint: hint(errors, invalid, line, col, literalPath, test, message); + break; default: // do nothing } } @@ -2452,6 +2455,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat else if (itemType.equals("integer")) checkOption(errors, answer, ns, qsrc, qItem, "integer"); else if (itemType.equals("string")) checkOption(errors, answer, ns, qsrc, qItem, "string", true); break; + case QUESTION: + case NULL: + break; } validateQuestionannaireResponseItems(qsrc, qItem.getItem(), errors, answer, stack, inProgress); } @@ -3050,11 +3056,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (ei.path.endsWith(".extension")) rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition != null, "Element is unknown or does not match any slice (url=\"" + ei.element.getNamedChildValue("url") + "\")" + (profile==null ? "" : " for profile " + profile.getUrl())); else if (!unsupportedSlicing) - if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN) || ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) + if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) hint(errors, IssueType.INFORMATIONAL, ei.line(), ei.col(), ei.path, (ei.definition != null), "Element " + ei.element.getName() + " is unknown or does not match any slice " + sliceInfo + (profile==null ? "" : " for profile " + profile.getUrl())); else - if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN) || ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) + if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, (ei.definition != null), "Element " + ei.element.getName() + " is unknown or does not match any slice " + sliceInfo + (profile==null ? "" : " for profile " + profile.getUrl())); else @@ -3230,7 +3236,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat goodProfiles.put(typeProfile, profileErrors); } if (goodProfiles.size()==1) { - errors.addAll(goodProfiles.get(0)); + errors.addAll(goodProfiles.values().iterator().next()); } else if (goodProfiles.size()==0) { rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), ei.path, false, "Unable to find matching profile among choices: " + StringUtils.join("; ", profiles)); for (List messages : badProfiles) { diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/instance/validation/InstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/instance/validation/InstanceValidator.java index 6a2e1ac2cbe..e9fc8fec4fc 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/instance/validation/InstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/instance/validation/InstanceValidator.java @@ -1,2791 +1,2794 @@ -package org.hl7.fhir.instance.validation; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -import org.hl7.fhir.exceptions.*; -import org.hl7.fhir.instance.formats.FormatUtilities; -import org.hl7.fhir.instance.model.*; -import org.hl7.fhir.instance.model.ElementDefinition.*; -import org.hl7.fhir.instance.model.Enumerations.BindingStrength; -import org.hl7.fhir.instance.model.StructureDefinition.*; -import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent; -import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent; -import org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult; -//import org.hl7.fhir.instance.utils.ProfileUtilities; -import org.hl7.fhir.instance.utils.*; -import org.hl7.fhir.instance.utils.IResourceValidator.BestPracticeWarningLevel; -import org.hl7.fhir.instance.utils.IResourceValidator.CheckDisplayOption; -import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; -import org.hl7.fhir.utilities.Utilities; -import org.hl7.fhir.utilities.validation.ValidationMessage; -import org.hl7.fhir.utilities.validation.ValidationMessage.*; -import org.hl7.fhir.utilities.xml.XMLUtil; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import com.google.gson.*; - - -/* - * todo: - * check urn's don't start oid: or uuid: - */ -public class InstanceValidator extends BaseValidator implements IResourceValidator { - - private class ElementDefinitionOutcome { - public ElementDefinitionOutcome(ElementDefinition ed) { - definition = ed; - } - public ElementDefinitionOutcome(ElementDefinition ed, TypeRefComponent tr) { - definition = ed; - typename = tr.getCode(); - if (tr.hasProfile()) - profile = tr.getProfile().get(0).getValue(); - } - private ElementDefinition definition; - private String typename; - private String profile; - } - - public class ResourceOnWrapper extends Resource { - private static final long serialVersionUID = 1L; - private IWorkerContext services; - private WrapperElement wrapper; - private List elementList; - private StructureDefinition profile; - private ElementDefinition definition; - private List childDefinitions; - - public ResourceOnWrapper(IWorkerContext services, WrapperElement wrapper, StructureDefinition profile) { - super(); - this.services = services; - this.wrapper = wrapper; - this.profile = profile; - this.definition = profile.getSnapshot().getElement().get(0); - } - - private ElementDefinitionOutcome getDefinition(String name) throws DefinitionException { - if (childDefinitions == null) - childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); - for (ElementDefinition ed : childDefinitions) { - String tail = ed.getPath().substring(ed.getPath().lastIndexOf('.')+1); - if (tail.equals(name)) { - return new ElementDefinitionOutcome(ed); - } - if (tail.endsWith("[x]") && tail.substring(0, tail.length()-3).equals(name.substring(0, tail.length()-3))) { - TypeRefComponent tr = getType(ed, name.substring(tail.length()-3)); - if (tr != null) - return new ElementDefinitionOutcome(ed, tr); - } - } - return null; - } - - private TypeRefComponent getType(ElementDefinition ed, String type) { - for (TypeRefComponent t : ed.getType()) { - if (t.getCode().equals(type)) - return t; - } - return null; - } - - @Override - public List listChildrenByName(String child_name) { - List list = new ArrayList(); - List children = new ArrayList(); - wrapper.getNamedChildren(child_name, children); - for (WrapperElement child : children) { - ElementDefinitionOutcome definition; - try { - definition = getDefinition(child.getName()); - } catch (Exception e) { - definition = null; - } - if (definition != null) { - TypeRefComponent tr = getType(definition.definition, "Resource"); - if (tr != null && wrapper.isXml()) // special case for DomainResource.contained and Bundle.entry - list.add(new BaseOnWrapper(services, child.getFirstChild(), profile, definition.definition, definition.typename, definition.profile)); - else - list.add(new BaseOnWrapper(services, child, profile, definition.definition, definition.typename, definition.profile)); - } - } - return list; - } - - @Override - public String fhirType() { - return wrapper.getResourceType(); - } - - @Override - public Resource copy() { - throw new Error("copy() is not implemented here"); - } - - - @Override - public ResourceType getResourceType() { - try { - return ResourceType.fromCode(fhirType()); - } catch (Exception e) { - return null; - } - } - - @Override - protected boolean isMetadataBased() { - return true; - } - - @Override - public String toString() { - return fhirType(); - } - } - - public class BaseOnWrapper extends Base { - private static final long serialVersionUID = 1L; - private IWorkerContext services; - private WrapperElement wrapper; - private List elementList; - private StructureDefinition profile; - private ElementDefinition definition; - private List childDefinitions; - private String typeName; - private String typeProfile; - - - public BaseOnWrapper(IWorkerContext services, WrapperElement wrapper, StructureDefinition profile, - ElementDefinition definition, String typeName, String typeProfile) { - super(); - this.services = services; - this.wrapper = wrapper; - this.profile = profile; - this.definition = definition; - this.typeName = typeName; - this.typeProfile = typeProfile; - } - - private ElementDefinitionOutcome getDefinition(String name) throws DefinitionException { - if (childDefinitions == null) - childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); - - if (childDefinitions.size() == 0) { - String pn = typeProfile; - if (Utilities.noString(pn) && !Utilities.noString(typeName)) - pn = "http://hl7.org/fhir/StructureDefinition/"+typeName; - if (Utilities.noString(pn) && definition.getType().size() == 1) { - if (definition.getType().get(0).getProfile().size() > 0) - pn = definition.getType().get(0).getProfile().get(0).getValue(); - else - pn = "http://hl7.org/fhir/StructureDefinition/"+ definition.getType().get(0).getCode(); - } - if (!Utilities.noString(pn)) { - StructureDefinition profile = services.fetchResource(StructureDefinition.class, pn); - if (profile != null) { - this.profile = profile; - childDefinitions = ProfileUtilities.getChildMap(profile, null, profile.getSnapshot().getElement().get(0).getPath(), null); - } - } - } - - - for (ElementDefinition ed : childDefinitions) { - String tail = ed.getPath().substring(ed.getPath().lastIndexOf('.')+1); - if (tail.equals(name)) { - return new ElementDefinitionOutcome(ed); - } - if (tail.endsWith("[x]") && name.length() > tail.length()-1 && tail.substring(0, tail.length()-3).equals(name.substring(0, tail.length()-3))) { - TypeRefComponent tr = getType(ed, name.substring(tail.length()-3)); - if (tr != null) - return new ElementDefinitionOutcome(ed, tr); - } - } - return null; - } - - private TypeRefComponent getType(ElementDefinition ed, String type) { - for (TypeRefComponent t : ed.getType()) { - if (t.getCode().equalsIgnoreCase(type)) - return t; - } - return null; - } - - @Override - public List listChildrenByName(String child_name) { - List list = new ArrayList(); - List children = new ArrayList(); - wrapper.getNamedChildrenWithWildcard(child_name, children); - for (WrapperElement child : children) { - ElementDefinitionOutcome definition; - try { - definition = getDefinition(child.getName()); - } catch (Exception e) { - definition = null; - } - if (definition != null) { - TypeRefComponent tr = getType(definition.definition, "Resource"); - if (tr != null && wrapper.isXml()) // special case for DomainResource.contained and Bundle.entry - list.add(new BaseOnWrapper(services, child.getFirstChild(), profile, definition.definition, definition.typename, definition.profile)); - else - list.add(new BaseOnWrapper(services, child, profile, definition.definition, definition.typename, definition.profile)); - } - } - return list; - } - - public boolean isPrimitive() { - String t = fhirType(); - return t.equalsIgnoreCase("boolean") || t.equalsIgnoreCase("integer") || t.equalsIgnoreCase("string") || t.equalsIgnoreCase("decimal") || t.equalsIgnoreCase("uri") || t.equalsIgnoreCase("base64Binary") || - t.equalsIgnoreCase("instant") || t.equalsIgnoreCase("date") || t.equalsIgnoreCase("uuid") || t.equalsIgnoreCase("id") || t.equalsIgnoreCase("xhtml") || t.equalsIgnoreCase("markdown") || - t.equalsIgnoreCase("dateTime") || t.equalsIgnoreCase("time") || t.equalsIgnoreCase("code") || t.equalsIgnoreCase("oid") || t.equalsIgnoreCase("id"); - } - - public String primitiveValue() { - return wrapper.getAttribute("value"); - } - - @Override - public String fhirType() { - if (!Utilities.noString(typeName)) - return typeName; - else - return definition.getType().get(0).getCode(); - } - - @Override - protected void listChildren(List result) { - throw new Error("not done yet"); - } - - @Override - protected boolean isMetadataBased() { - return true; - } - - public boolean equalsDeep(Base other) { - if (!super.equalsDeep(other) || !fhirType().equals(other.fhirType())) - return false; - - // make sure we have child definitions - try { - getDefinition("xxxx"); - List childList = childDefinitions; - // there's a problem here - we're going to iterate by the definition, where as equality should - probably - be - // based on the underlying definitions. is it worth getting them? it's kind of complicated.... - for (ElementDefinition ed : childList) { - String tail = tail(ed.getPath()); - List thisList = listChildrenByName(tail); - List otherList = other.listChildrenByName(tail); - if (!compareDeep(thisList, otherList, false)) - return false; - } - return true; - } catch (Exception e) { - return false;// because we can't decide - } - } - - @Override - public String toString() { - if (isPrimitive()) - return primitiveValue(); - else - return fhirType(); - } - } - - private boolean anyExtensionsAllowed; - - private BestPracticeWarningLevel bpWarnings; - // configuration items - private CheckDisplayOption checkDisplay; - private IWorkerContext context; - - private List extensionDomains = new ArrayList(); - - private IdStatus resourceIdRule; - - // used during the build process to keep the overall volume of messages down - private boolean suppressLoincSnomedMessages; - - public InstanceValidator(IWorkerContext theContext) { - super(); - this.context = theContext; - source = Source.InstanceValidator; - } - - private boolean allowUnknownExtension(String url) { - if (url.contains("example.org") || url.contains("acme.com") || url.contains("nema.org")) - return true; - for (String s : extensionDomains) - if (url.startsWith(s)) - return true; - return anyExtensionsAllowed; - } - - private void bpCheck(List errors, IssueType invalid, int line, int col, String literalPath, boolean test, String message) { - if (bpWarnings != null) { - switch (bpWarnings) { - case Error: - rule(errors, invalid, line, col, literalPath, test, message); - case Warning: - warning(errors, invalid, line, col, literalPath, test, message); - case Hint: - hint(errors, invalid, line, col, literalPath, test, message); - default: // do nothing - } - } - } - - private boolean check(String v1, String v2) { - return v1 == null ? Utilities.noString(v1) : v1.equals(v2); - } - - private void checkAddress(List errors, String path, WrapperElement focus, Address fixed) { - checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); - checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); - checkFixedValue(errors, path + ".city", focus.getNamedChild("city"), fixed.getCityElement(), "city"); - checkFixedValue(errors, path + ".state", focus.getNamedChild("state"), fixed.getStateElement(), "state"); - checkFixedValue(errors, path + ".country", focus.getNamedChild("country"), fixed.getCountryElement(), "country"); - checkFixedValue(errors, path + ".zip", focus.getNamedChild("zip"), fixed.getPostalCodeElement(), "postalCode"); - - List lines = new ArrayList(); - focus.getNamedChildren("line", lines); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, lines.size() == fixed.getLine().size(), - "Expected " + Integer.toString(fixed.getLine().size()) + " but found " + Integer.toString(lines.size()) + " line elements")) { - for (int i = 0; i < lines.size(); i++) - checkFixedValue(errors, path + ".coding", lines.get(i), fixed.getLine().get(i), "coding"); - } - } - - private void checkAttachment(List errors, String path, WrapperElement focus, Attachment fixed) { - checkFixedValue(errors, path + ".contentType", focus.getNamedChild("contentType"), fixed.getContentTypeElement(), "contentType"); - checkFixedValue(errors, path + ".language", focus.getNamedChild("language"), fixed.getLanguageElement(), "language"); - checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), "data"); - checkFixedValue(errors, path + ".url", focus.getNamedChild("url"), fixed.getUrlElement(), "url"); - checkFixedValue(errors, path + ".size", focus.getNamedChild("size"), fixed.getSizeElement(), "size"); - checkFixedValue(errors, path + ".hash", focus.getNamedChild("hash"), fixed.getHashElement(), "hash"); - checkFixedValue(errors, path + ".title", focus.getNamedChild("title"), fixed.getTitleElement(), "title"); - } - - // public API - - private boolean checkCode(List errors, WrapperElement element, String path, String code, String system, String display) { - if (context.supportsSystem(system)) { - ValidationResult s = context.validateCode(system, code, display); - if (s == null || s.isOk()) - return true; - if (s.getSeverity() == IssueSeverity.INFORMATION) - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); - else if (s.getSeverity() == IssueSeverity.WARNING) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); - else - return rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); - return true; - } else if (system.startsWith("http://hl7.org/fhir")) { - if (system.equals("http://hl7.org/fhir/sid/icd-10")) - return true; // else don't check ICD-10 (for now) - else { - ValueSet vs = getValueSet(system); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, vs != null, "Unknown Code System " + system)) { - ConceptDefinitionComponent def = getCodeDefinition(vs, code); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, def != null, "Unknown Code (" + system + "#" + code + ")")) - return warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, display == null || display.equals(def.getDisplay()), "Display should be '" + def.getDisplay() + "'"); - } - return false; - } - } else if (system.startsWith("http://loinc.org")) { - return true; - } else if (system.startsWith("http://unitsofmeasure.org")) { - return true; - } else - return true; - } - - private void checkCodeableConcept(List errors, String path, WrapperElement focus, CodeableConcept fixed) { - checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); - List codings = new ArrayList(); - focus.getNamedChildren("coding", codings); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, codings.size() == fixed.getCoding().size(), - "Expected " + Integer.toString(fixed.getCoding().size()) + " but found " + Integer.toString(codings.size()) + " coding elements")) { - for (int i = 0; i < codings.size(); i++) - checkFixedValue(errors, path + ".coding", codings.get(i), fixed.getCoding().get(i), "coding"); - } - } - - private void checkCodeableConcept(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition theElementCntext) { - if (theElementCntext != null && theElementCntext.hasBinding()) { - ElementDefinitionBindingComponent binding = theElementCntext.getBinding(); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, binding != null, "Binding for " + path + " missing (cc)")) { - if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { - ValueSet valueset = resolveBindingReference(binding.getValueSet()); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, valueset != null, "ValueSet " + describeReference(binding.getValueSet()) + " not found")) { - try { - CodeableConcept cc = readAsCodeableConcept(element); - if (!cc.hasCoding()) { - if (binding.getStrength() == BindingStrength.REQUIRED) - rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "No code provided, and a code is required from the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()); - else if (binding.getStrength() == BindingStrength.EXTENSIBLE) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "No code provided, and a code should be provided from the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()); - } else { - ValidationResult vr = context.validateCode(cc, valueset); - if (!vr.isOk()) { - if (binding.getStrength() == BindingStrength.REQUIRED) - rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()+", and a code from this value set is required"); - else if (binding.getStrength() == BindingStrength.EXTENSIBLE) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); - else if (binding.getStrength() == BindingStrength.PREFERRED) - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is recommended to come from this value set)"); - } - } - } catch (Exception e) { - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept"); - } - } - } else if (binding.hasValueSet()) { - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding by URI reference cannot be checked"); - } else { - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding for path " + path + " has no source, so can't be checked"); - } - } - } - } - - private CodeableConcept readAsCodeableConcept(WrapperElement element) { - CodeableConcept cc = new CodeableConcept(); - List list = new ArrayList(); - element.getNamedChildren("coding", list); - for (WrapperElement item : list) - cc.addCoding(readAsCoding(item)); - cc.setText(element.getNamedChildValue("text")); - return cc; - } - - private Coding readAsCoding(WrapperElement item) { - Coding c = new Coding(); - c.setSystem(item.getNamedChildValue("system")); - c.setVersion(item.getNamedChildValue("version")); - c.setCode(item.getNamedChildValue("code")); - c.setDisplay(item.getNamedChildValue("display")); - return c; - } - - private void checkCoding(List errors, String path, WrapperElement focus, Coding fixed) { - checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); - checkFixedValue(errors, path + ".code", focus.getNamedChild("code"), fixed.getCodeElement(), "code"); - checkFixedValue(errors, path + ".display", focus.getNamedChild("display"), fixed.getDisplayElement(), "display"); - checkFixedValue(errors, path + ".userSelected", focus.getNamedChild("userSelected"), fixed.getUserSelectedElement(), "userSelected"); - } - - private void checkCoding(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition theElementCntext, boolean inCodeableConcept) { - String code = element.getNamedChildValue("code"); - String system = element.getNamedChildValue("system"); - String display = element.getNamedChildValue("display"); - rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(system), "Coding.system must be an absolute reference, not a local reference"); - - if (system != null && code != null) { - if (checkCode(errors, element, path, code, system, display)) - if (theElementCntext != null && theElementCntext.getBinding() != null) { - ElementDefinitionBindingComponent binding = theElementCntext.getBinding(); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, binding != null, "Binding for " + path + " missing")) { - if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { - ValueSet valueset = resolveBindingReference(binding.getValueSet()); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, valueset != null, "ValueSet " + describeReference(binding.getValueSet()) + " not found")) { - try { - Coding c = readAsCoding(element); - ValidationResult vr = context.validateCode(c, valueset); - if (!vr.isOk()) { - if (binding.getStrength() == BindingStrength.REQUIRED) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is required from this value set)"); - else if (binding.getStrength() == BindingStrength.EXTENSIBLE) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); - else if (binding.getStrength() == BindingStrength.PREFERRED) - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is recommended to come from this value set)"); - } - } catch (Exception e) { - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept"); - } - } - } else if (binding.hasValueSet()) { - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding by URI reference cannot be checked"); - } else if (!inCodeableConcept) { - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding for path " + path + " has no source, so can't be checked"); - } - } - } - } - } - - private void checkContactPoint(List errors, String path, WrapperElement focus, ContactPoint fixed) { - checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); - checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); - checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); - checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); - - } - - private void checkDeclaredProfiles(List errors, WrapperElement resource, WrapperElement element, NodeStack stack) throws FHIRException { - WrapperElement meta = element.getNamedChild("meta"); - if (meta != null) { - List profiles = new ArrayList(); - meta.getNamedChildren("profile", profiles); - int i = 0; - for (WrapperElement profile : profiles) { - String ref = profile.getAttribute("value"); - String p = stack.addToLiteralPath("meta", "profile", ":" + Integer.toString(i)); - if (rule(errors, IssueType.INVALID, element.line(), element.col(), p, !Utilities.noString(ref), "StructureDefinition reference invalid")) { - StructureDefinition pr = context.fetchResource(StructureDefinition.class, ref); - if (warning(errors, IssueType.INVALID, element.line(), element.col(), p, pr != null, "StructureDefinition reference \"{0}\" could not be resolved", ref)) { - if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), p, pr.hasSnapshot(), - "StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided")) { - validateElement(errors, pr, pr.getSnapshot().getElement().get(0), null, null, resource, element, element.getName(), stack, false); - } - } - i++; - } - } - } - } - - private StructureDefinition checkExtension(List errors, String path, WrapperElement element, ElementDefinition def, StructureDefinition profile, NodeStack stack) - { - String url = element.getAttribute("url"); - boolean isModifier = element.getName().equals("modifierExtension"); - - StructureDefinition ex = context.fetchResource(StructureDefinition.class, url); - if (ex == null) { - if (!rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, allowUnknownExtension(url), "The extension " + url + " is unknown, and not allowed here")) - warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, allowUnknownExtension(url), "Unknown extension " + url); - } else { - if (def.getIsModifier()) - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), - "Extension modifier mismatch: the extension element is labelled as a modifier, but the underlying extension is not"); - else - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", !ex.getSnapshot().getElement().get(0).getIsModifier(), - "Extension modifier mismatch: the extension element is not labelled as a modifier, but the underlying extension is"); - - // two questions - // 1. can this extension be used here? - checkExtensionContext(errors, element, /* path+"[url='"+url+"']", */ ex, stack, ex.getUrl()); - - if (isModifier) - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), - "The Extension '" + url + "' must be used as a modifierExtension"); - else - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", !ex.getSnapshot().getElement().get(0).getIsModifier(), - "The Extension '" + url + "' must not be used as an extension (it's a modifierExtension)"); - - // 2. is the content of the extension valid? - - } - return ex; - } - - private boolean checkExtensionContext(List errors, WrapperElement element, StructureDefinition definition, NodeStack stack, String extensionParent) { - String extUrl = definition.getUrl(); - CommaSeparatedStringBuilder p = new CommaSeparatedStringBuilder(); - for (String lp : stack.getLogicalPaths()) - p.append(lp); - if (definition.getContextType() == ExtensionContext.DATATYPE) { - boolean ok = false; - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - for (StringType ct : definition.getContext()) { - b.append(ct.getValue()); - if (ct.getValue().equals("*") || stack.getLogicalPaths().contains(ct.getValue() + ".extension")) - ok = true; - } - return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, - "The extension " + extUrl + " is not allowed to be used on the logical path set [" + p.toString() + "] (allowed: datatype=" + b.toString() + ")"); - } else if (definition.getContextType() == ExtensionContext.EXTENSION) { - boolean ok = false; - for (StringType ct : definition.getContext()) - if (ct.getValue().equals("*") || ct.getValue().equals(extensionParent)) - ok = true; - return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, - "The extension " + extUrl + " is not allowed to be used with the extension '" + extensionParent + "'"); - } else if (definition.getContextType() == ExtensionContext.MAPPING) { - throw new Error("Not handled yet (extensionContext)"); - } else if (definition.getContextType() == ExtensionContext.RESOURCE) { - boolean ok = false; - // String simplePath = container.getPath(); - // System.out.println(simplePath); - // if (effetive.endsWith(".extension") || simplePath.endsWith(".modifierExtension")) - // simplePath = simplePath.substring(0, simplePath.lastIndexOf('.')); - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - for (StringType ct : definition.getContext()) { - String c = ct.getValue(); - b.append(c); - if (c.equals("*") || stack.getLogicalPaths().contains(c + ".extension") || (c.startsWith("@") && stack.getLogicalPaths().contains(c.substring(1) + ".extension"))) - ; - ok = true; - } - return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, - "The extension " + extUrl + " is not allowed to be used on the logical path set " + p.toString() + " (allowed: resource=" + b.toString() + ")"); - } else - throw new Error("Unknown context type"); - } - // - // private String simplifyPath(String path) { - // String s = path.replace("/f:", "."); - // while (s.contains("[")) - // s = s.substring(0, s.indexOf("["))+s.substring(s.indexOf("]")+1); - // String[] parts = s.split("\\."); - // int i = 0; - // while (i < parts.length && !context.getProfiles().containsKey(parts[i].toLowerCase())) - // i++; - // if (i >= parts.length) - // throw new Error("Unable to process part "+path); - // int j = parts.length - 1; - // while (j > 0 && (parts[j].equals("extension") || parts[j].equals("modifierExtension"))) - // j--; - // StringBuilder b = new StringBuilder(); - // boolean first = true; - // for (int k = i; k <= j; k++) { - // if (k == j || !parts[k].equals(parts[k+1])) { - // if (first) - // first = false; - // else - // b.append("."); - // b.append(parts[k]); - // } - // } - // return b.toString(); - // } - // - - private void checkFixedValue(List errors, String path, WrapperElement focus, org.hl7.fhir.instance.model.Element fixed, String propName) { - if (fixed == null && focus == null) - ; // this is all good - else if (fixed == null && focus != null) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, false, "Unexpected element " + focus.getName()); - else if (fixed != null && focus == null) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, false, "Mising element " + propName); - else { - String value = focus.getAttribute("value"); - if (fixed instanceof org.hl7.fhir.instance.model.BooleanType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.BooleanType) fixed).asStringValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.BooleanType) fixed).asStringValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.IntegerType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.IntegerType) fixed).asStringValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.IntegerType) fixed).asStringValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.DecimalType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DecimalType) fixed).asStringValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DecimalType) fixed).asStringValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.Base64BinaryType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.Base64BinaryType) fixed).asStringValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.Base64BinaryType) fixed).asStringValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.InstantType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.InstantType) fixed).getValue().toString(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.InstantType) fixed).asStringValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.StringType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.StringType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.StringType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.UriType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.UriType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.UriType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.DateType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DateType) fixed).getValue().toString(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DateType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.DateTimeType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DateTimeType) fixed).getValue().toString(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DateTimeType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.OidType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.OidType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.OidType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.UuidType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.UuidType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.UuidType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.CodeType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.CodeType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.CodeType) fixed).getValue() + "'"); - else if (fixed instanceof org.hl7.fhir.instance.model.IdType) - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.IdType) fixed).getValue(), value), - "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.IdType) fixed).getValue() + "'"); - else if (fixed instanceof Quantity) - checkQuantity(errors, path, focus, (Quantity) fixed); - else if (fixed instanceof Address) - checkAddress(errors, path, focus, (Address) fixed); - else if (fixed instanceof ContactPoint) - checkContactPoint(errors, path, focus, (ContactPoint) fixed); - else if (fixed instanceof Attachment) - checkAttachment(errors, path, focus, (Attachment) fixed); - else if (fixed instanceof Identifier) - checkIdentifier(errors, path, focus, (Identifier) fixed); - else if (fixed instanceof Coding) - checkCoding(errors, path, focus, (Coding) fixed); - else if (fixed instanceof HumanName) - checkHumanName(errors, path, focus, (HumanName) fixed); - else if (fixed instanceof CodeableConcept) - checkCodeableConcept(errors, path, focus, (CodeableConcept) fixed); - else if (fixed instanceof Timing) - checkTiming(errors, path, focus, (Timing) fixed); - else if (fixed instanceof Period) - checkPeriod(errors, path, focus, (Period) fixed); - else if (fixed instanceof Range) - checkRange(errors, path, focus, (Range) fixed); - else if (fixed instanceof Ratio) - checkRatio(errors, path, focus, (Ratio) fixed); - else if (fixed instanceof SampledData) - checkSampledData(errors, path, focus, (SampledData) fixed); - - else - rule(errors, IssueType.EXCEPTION, focus.line(), focus.col(), path, false, "Unhandled fixed value type " + fixed.getClass().getName()); - List extensions = new ArrayList(); - focus.getNamedChildren("extension", extensions); - if (fixed.getExtension().size() == 0) { - rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, extensions.size() == 0, "No extensions allowed"); - } else if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, extensions.size() == fixed.getExtension().size(), - "Extensions count mismatch: expected " + Integer.toString(fixed.getExtension().size()) + " but found " + Integer.toString(extensions.size()))) { - for (Extension e : fixed.getExtension()) { - WrapperElement ex = getExtensionByUrl(extensions, e.getUrl()); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, ex != null, "Extension count mismatch: unable to find extension: " + e.getUrl())) { - checkFixedValue(errors, path, ex.getFirstChild().getNextSibling(), e.getValue(), "extension.value"); - } - } - } - } - } - - private void checkForProcessingInstruction(List errors, Document document) { - Node node = document.getFirstChild(); - while (node != null) { - rule(errors, IssueType.INVALID, -1, -1, "(document)", node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE, "No processing instructions allowed in resources"); - node = node.getNextSibling(); - } - } - - private void checkHumanName(List errors, String path, WrapperElement focus, HumanName fixed) { - checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); - checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); - checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); - - List parts = new ArrayList(); - focus.getNamedChildren("family", parts); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getFamily().size(), - "Expected " + Integer.toString(fixed.getFamily().size()) + " but found " + Integer.toString(parts.size()) + " family elements")) { - for (int i = 0; i < parts.size(); i++) - checkFixedValue(errors, path + ".family", parts.get(i), fixed.getFamily().get(i), "family"); - } - focus.getNamedChildren("given", parts); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getGiven().size(), - "Expected " + Integer.toString(fixed.getGiven().size()) + " but found " + Integer.toString(parts.size()) + " given elements")) { - for (int i = 0; i < parts.size(); i++) - checkFixedValue(errors, path + ".given", parts.get(i), fixed.getGiven().get(i), "given"); - } - focus.getNamedChildren("prefix", parts); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getPrefix().size(), - "Expected " + Integer.toString(fixed.getPrefix().size()) + " but found " + Integer.toString(parts.size()) + " prefix elements")) { - for (int i = 0; i < parts.size(); i++) - checkFixedValue(errors, path + ".prefix", parts.get(i), fixed.getPrefix().get(i), "prefix"); - } - focus.getNamedChildren("suffix", parts); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getSuffix().size(), - "Expected " + Integer.toString(fixed.getSuffix().size()) + " but found " + Integer.toString(parts.size()) + " suffix elements")) { - for (int i = 0; i < parts.size(); i++) - checkFixedValue(errors, path + ".suffix", parts.get(i), fixed.getSuffix().get(i), "suffix"); - } - } - - private void checkIdentifier(List errors, String path, WrapperElement element, ElementDefinition context) { - String system = element.getNamedChildValue("system"); - rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(system), "Identifier.system must be an absolute reference, not a local reference"); - } - - private void checkIdentifier(List errors, String path, WrapperElement focus, Identifier fixed) { - checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); - checkFixedValue(errors, path + ".type", focus.getNamedChild("type"), fixed.getType(), "type"); - checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); - checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); - checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); - checkFixedValue(errors, path + ".assigner", focus.getNamedChild("assigner"), fixed.getAssigner(), "assigner"); - } - - private void checkPeriod(List errors, String path, WrapperElement focus, Period fixed) { - checkFixedValue(errors, path + ".start", focus.getNamedChild("start"), fixed.getStartElement(), "start"); - checkFixedValue(errors, path + ".end", focus.getNamedChild("end"), fixed.getEndElement(), "end"); - } - - private void checkPrimitive(List errors, String path, String type, ElementDefinition context, WrapperElement e) { - if (type.equals("uri")) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.getAttribute("value").startsWith("oid:"), "URI values cannot start with oid:"); - rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.getAttribute("value").startsWith("uuid:"), "URI values cannot start with uuid:"); - rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").equals(e.getAttribute("value").trim()), "URI values cannot have leading or trailing whitespace"); - } - if (!type.equalsIgnoreCase("string") && e.hasAttribute("value")) { - if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").length() > 0, "@value cannot be empty")) { - warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").trim().equals(e.getAttribute("value")), "value should not start or finish with whitespace"); - } - } - if (type.equals("dateTime")) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, yearIsValid(e.getAttribute("value")), "The value '" + e.getAttribute("value") + "' does not have a valid year"); - boolean ok = e.getAttribute("value").matches("-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)?)?)?"); - if (!ok) - rule(errors, IssueType.INVALID, e.line(), e.col(), path,ok, "'"+e.getAttribute("value")+"' is not a valid date time"); - rule(errors, IssueType.INVALID, e.line(), e.col(), path, !hasTime(e.getAttribute("value")) || hasTimeZone(e.getAttribute("value")), "if a date has a time, it must have a timezone"); - - } - if (type.equals("instant")) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, - e.getAttribute("value").matches("-?[0-9]{4}-(0[1-9]|1[0-2])-(0[0-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))"), - "The instant '" + e.getAttribute("value") + "' is not valid (by regex)"); - rule(errors, IssueType.INVALID, e.line(), e.col(), path, yearIsValid(e.getAttribute("value")), "The value '" + e.getAttribute("value") + "' does not have a valid year"); - } - - if (type.equals("code")) { - // Technically, a code is restricted to string which has at least one character and no leading or trailing whitespace, and where there is no whitespace - // other than single spaces in the contents - rule(errors, IssueType.INVALID, e.line(), e.col(), path, passesCodeWhitespaceRules(e.getAttribute("value")), "The code '" + e.getAttribute("value") + "' is not valid (whitespace rules)"); - } - - if (context.hasBinding()) { - checkPrimitiveBinding(errors, path, type, context, e); - } - // for nothing to check - } - - // note that we don't check the type here; it could be string, uri or code. - private void checkPrimitiveBinding(List errors, String path, String type, ElementDefinition elementContext, WrapperElement element) { - if (!element.hasAttribute("value")) - return; - - String value = element.getAttribute("value"); - // System.out.println("check "+value+" in "+path); - - // firstly, resolve the value set - ElementDefinitionBindingComponent binding = elementContext.getBinding(); - if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { - ValueSet vs = resolveBindingReference(binding.getValueSet()); - if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, vs != null, "ValueSet {0} not found", describeReference(binding.getValueSet()))) { - ValidationResult vr = context.validateCode(null, value, null, vs); - if (!vr.isOk()) { - if (binding.getStrength() == BindingStrength.REQUIRED) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is required from this value set)"); - else if (binding.getStrength() == BindingStrength.EXTENSIBLE) - warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); - else if (binding.getStrength() == BindingStrength.PREFERRED) - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is recommended to come from this value set)"); - } - } - } else - hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding has no source, so can't be checked"); - } - - private void checkQuantity(List errors, String path, WrapperElement focus, Quantity fixed) { - checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); - checkFixedValue(errors, path + ".comparator", focus.getNamedChild("comparator"), fixed.getComparatorElement(), "comparator"); - checkFixedValue(errors, path + ".units", focus.getNamedChild("unit"), fixed.getUnitElement(), "units"); - checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); - checkFixedValue(errors, path + ".code", focus.getNamedChild("code"), fixed.getCodeElement(), "code"); - } - - // implementation - - private void checkRange(List errors, String path, WrapperElement focus, Range fixed) { - checkFixedValue(errors, path + ".low", focus.getNamedChild("low"), fixed.getLow(), "low"); - checkFixedValue(errors, path + ".high", focus.getNamedChild("high"), fixed.getHigh(), "high"); - - } - - private void checkRatio(List errors, String path, WrapperElement focus, Ratio fixed) { - checkFixedValue(errors, path + ".numerator", focus.getNamedChild("numerator"), fixed.getNumerator(), "numerator"); - checkFixedValue(errors, path + ".denominator", focus.getNamedChild("denominator"), fixed.getDenominator(), "denominator"); - } - - private void checkReference(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition container, String parentType, NodeStack stack) - { - String ref = element.getNamedChildValue("reference"); - if (Utilities.noString(ref)) { - // todo - what should we do in this case? - hint(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), - "A Reference without an actual reference should have a display"); - return; - } - - WrapperElement we = resolve(ref, stack); - String ft; - if (we != null) - ft = we.getResourceType(); - else - ft = tryParse(ref); - if (hint(errors, IssueType.STRUCTURE, element.line(), element.col(), path, ft != null, "Unable to determine type of target resource")) { - boolean ok = false; - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - for (TypeRefComponent type : container.getType()) { - if (!ok && type.getCode().equals("Reference")) { - // we validate as much as we can. First, can we infer a type from the profile? - if (!type.hasProfile() || type.getProfile().get(0).getValue().equals("http://hl7.org/fhir/StructureDefinition/Resource")) - ok = true; - else { - String pr = type.getProfile().get(0).getValue(); - - String bt = getBaseType(profile, pr); - if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, bt != null, "Unable to resolve the profile reference '" + pr + "'")) { - b.append(bt); - ok = bt.equals(ft); - } else - ok = true; // suppress following check - } - } - if (!ok && type.getCode().equals("*")) { - ok = true; // can refer to anything - } - } - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, ok, "Invalid Resource target type. Found " + ft + ", but expected one of (" + b.toString() + ")"); - } - } - - private String checkResourceType(String type) { - if (context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + type) != null) - return type; - else - return null; - } - - private void checkSampledData(List errors, String path, WrapperElement focus, SampledData fixed) { - checkFixedValue(errors, path + ".origin", focus.getNamedChild("origin"), fixed.getOrigin(), "origin"); - checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriodElement(), "period"); - checkFixedValue(errors, path + ".factor", focus.getNamedChild("factor"), fixed.getFactorElement(), "factor"); - checkFixedValue(errors, path + ".lowerLimit", focus.getNamedChild("lowerLimit"), fixed.getLowerLimitElement(), "lowerLimit"); - checkFixedValue(errors, path + ".upperLimit", focus.getNamedChild("upperLimit"), fixed.getUpperLimitElement(), "upperLimit"); - checkFixedValue(errors, path + ".dimensions", focus.getNamedChild("dimensions"), fixed.getDimensionsElement(), "dimensions"); - checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), "data"); - } - - private void checkTiming(List errors, String path, WrapperElement focus, Timing fixed) { - checkFixedValue(errors, path + ".repeat", focus.getNamedChild("repeat"), fixed.getRepeat(), "value"); - - List events = new ArrayList(); - focus.getNamedChildren("event", events); - if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, events.size() == fixed.getEvent().size(), - "Expected " + Integer.toString(fixed.getEvent().size()) + " but found " + Integer.toString(events.size()) + " event elements")) { - for (int i = 0; i < events.size(); i++) - checkFixedValue(errors, path + ".event", events.get(i), fixed.getEvent().get(i), "event"); - } - } - - private boolean codeinExpansion(ValueSetExpansionContainsComponent cnt, String system, String code) { - for (ValueSetExpansionContainsComponent c : cnt.getContains()) { - if (code.equals(c.getCode()) && system.equals(c.getSystem().toString())) - return true; - if (codeinExpansion(c, system, code)) - return true; - } - return false; - } - - private boolean codeInExpansion(ValueSet vs, String system, String code) { - for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { - if (code.equals(c.getCode()) && (system == null || system.equals(c.getSystem()))) - return true; - if (codeinExpansion(c, system, code)) - return true; - } - return false; - } - - private String describeReference(Type reference) { - if (reference == null) - return "null"; - if (reference instanceof UriType) - return ((UriType) reference).getValue(); - if (reference instanceof Reference) - return ((Reference) reference).getReference(); - return "??"; - } - - private String describeTypes(List types) { - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - for (TypeRefComponent t : types) { - b.append(t.getCode()); - } - return b.toString(); - } - - private boolean empty(WrapperElement element) { - if (element.hasAttribute("value")) - return false; - if (element.hasAttribute("xml:id")) - return false; - WrapperElement child = element.getFirstChild(); - while (child != null) { - if (!child.isXml() || FormatUtilities.FHIR_NS.equals(child.getNamespace())) { - return false; - } - child = child.getNextSibling(); - } - return true; - } - - private ElementDefinition findElement(StructureDefinition profile, String name) { - for (ElementDefinition c : profile.getSnapshot().getElement()) { - if (c.getPath().equals(name)) { - return c; - } - } - return null; - } - - private String genFullUrl(String bundleBase, String entryBase, String type, String id) { - String base = Utilities.noString(entryBase) ? bundleBase : entryBase; - if (Utilities.noString(base)) { - return type + "/" + id; - } else if ("urn:uuid".equals(base) || "urn:oid".equals(base)) - return base + id; - else - return Utilities.appendSlash(base) + type + "/" + id; - } - - public BestPracticeWarningLevel getBasePracticeWarningLevel() { - return bpWarnings; - } - - private String getBaseType(StructureDefinition profile, String pr) { - // if (pr.startsWith("http://hl7.org/fhir/StructureDefinition/")) { - // // this just has to be a base type - // return pr.substring(40); - // } else { - StructureDefinition p = resolveProfile(profile, pr); - if (p == null) - return null; - else if (p.getKind() == StructureDefinitionKind.RESOURCE) - return p.getSnapshot().getElement().get(0).getPath(); - else - return p.getSnapshot().getElement().get(0).getType().get(0).getCode(); - // } - } - - @Override - public CheckDisplayOption getCheckDisplay() { - return checkDisplay; - } - - // private String findProfileTag(WrapperElement element) { - // String uri = null; - // List list = new ArrayList(); - // element.getNamedChildren("category", list); - // for (WrapperElement c : list) { - // if ("http://hl7.org/fhir/tag/profile".equals(c.getAttribute("scheme"))) { - // uri = c.getAttribute("term"); - // } - // } - // return uri; - // } - - private ConceptDefinitionComponent getCodeDefinition(ConceptDefinitionComponent c, String code) { - if (code.equals(c.getCode())) - return c; - for (ConceptDefinitionComponent g : c.getConcept()) { - ConceptDefinitionComponent r = getCodeDefinition(g, code); - if (r != null) - return r; - } - return null; - } - - private ConceptDefinitionComponent getCodeDefinition(ValueSet vs, String code) { - for (ConceptDefinitionComponent c : vs.getCodeSystem().getConcept()) { - ConceptDefinitionComponent r = getCodeDefinition(c, code); - if (r != null) - return r; - } - return null; - } - - private WrapperElement getContainedById(WrapperElement container, String id) { - List contained = new ArrayList(); - container.getNamedChildren("contained", contained); - for (WrapperElement we : contained) { - WrapperElement res = we.isXml() ? we.getFirstChild() : we; - if (id.equals(res.getNamedChildValue("id"))) - return res; - } - return null; - } - - public IWorkerContext getContext() { - return context; - } - - private ElementDefinition getCriteriaForDiscriminator(String path, ElementDefinition ed, String discriminator, StructureDefinition profile) throws DefinitionException { - List childDefinitions = ProfileUtilities.getChildMap(profile, ed); - List snapshot = null; - if (childDefinitions.isEmpty()) { - // going to look at the type - if (ed.getType().size() == 0) - throw new DefinitionException("Error in profile for " + path + " no children, no type"); - if (ed.getType().size() > 1) - throw new DefinitionException("Error in profile for " + path + " multiple types defined in slice discriminator"); - StructureDefinition type; - if (ed.getType().get(0).hasProfile()) { - // need to do some special processing for reference here... - if (ed.getType().get(0).getCode().equals("Reference")) - discriminator = discriminator.substring(discriminator.indexOf(".")+1); - type = context.fetchResource(StructureDefinition.class, ed.getType().get(0).getProfile().get(0).getValue()); - } else - type = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + ed.getType().get(0).getCode()); - snapshot = type.getSnapshot().getElement(); - ed = snapshot.get(0); - } else { - snapshot = profile.getSnapshot().getElement(); - } - String originalPath = ed.getPath(); - String goal = originalPath + "." + discriminator; - - int index = snapshot.indexOf(ed); - assert(index > -1); - index++; - while (index < snapshot.size() && !snapshot.get(index).getPath().equals(originalPath)) { - if (snapshot.get(index).getPath().equals(goal)) - return snapshot.get(index); - index++; - } - throw new Error("Unable to find discriminator definition for " + goal + " in " + discriminator + " at " + path); - } - - private WrapperElement getExtensionByUrl(List extensions, String urlSimple) { - for (WrapperElement e : extensions) { - if (urlSimple.equals(e.getNamedChildValue("url"))) - return e; - } - return null; - } - - public List getExtensionDomains() { - return extensionDomains; - } - - private WrapperElement getFromBundle(WrapperElement bundle, String ref) { - List entries = new ArrayList(); - bundle.getNamedChildren("entry", entries); - for (WrapperElement we : entries) { - WrapperElement res = we.getNamedChild("resource").getFirstChild(); - if (res != null) { - String url = genFullUrl(bundle.getNamedChildValue("base"), we.getNamedChildValue("base"), res.getName(), res.getNamedChildValue("id")); - if (url.endsWith(ref)) - return res; - } - } - return null; - } - - private StructureDefinition getProfileForType(String type) { - return context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + type); - } - - private Element getValueForDiscriminator(WrapperElement element, String discriminator, ElementDefinition criteria) { - // throw new Error("validation of slices not done yet"); - return null; - } - - private ValueSet getValueSet(String system) { - return context.fetchCodeSystem(system); - } - - private boolean hasTime(String fmt) { - return fmt.contains("T"); - } - - private boolean hasTimeZone(String fmt) { - return fmt.length() > 10 && (fmt.substring(10).contains("-") || fmt.substring(10).contains("+") || fmt.substring(10).contains("Z")); - } - - private boolean isAbsolute(String uri) { - return Utilities.noString(uri) || uri.startsWith("http:") || uri.startsWith("https:") || uri.startsWith("urn:uuid:") || uri.startsWith("urn:oid:") || uri.startsWith("urn:ietf:") - || uri.startsWith("urn:iso:") || isValidFHIRUrn(uri); - } - - private boolean isValidFHIRUrn(String uri) { - return (uri.equals("urn:x-fhir:uk:id:nhs-number")); - } - - public boolean isAnyExtensionsAllowed() { - return anyExtensionsAllowed; - } - - private boolean isParametersEntry(String path) { - String[] parts = path.split("\\/"); - if (path.startsWith("/f:")) - return parts.length == 4 && parts[parts.length-3].equals("f:Parameters") && parts[parts.length-2].startsWith("f:parameter") && parts[parts.length-1].startsWith("f:resource"); - else - return parts.length == 4 && parts[parts.length-3].equals("Parameters") && parts[parts.length-2].startsWith("parameter") && parts[parts.length-1].startsWith("resource"); - } - - private boolean isBundleEntry(String path) { - String[] parts = path.split("\\/"); - if (path.startsWith("/f:")) - return parts.length > 2 && parts[parts.length - 1].startsWith("f:resource") && (parts[parts.length - 2].equals("f:entry") || parts[parts.length - 2].startsWith("f:entry[")); - else - return parts.length > 2 && parts[parts.length - 1].equals("resource") && ((parts.length > 2 && parts[parts.length - 3].equals("entry")) || parts[parts.length - 2].equals("entry")); - } - - private boolean isPrimitiveType(String type) { - return type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("string") || type.equalsIgnoreCase("decimal") || type.equalsIgnoreCase("uri") - || type.equalsIgnoreCase("base64Binary") || type.equalsIgnoreCase("instant") || type.equalsIgnoreCase("date") || type.equalsIgnoreCase("uuid") || type.equalsIgnoreCase("id") - || type.equalsIgnoreCase("xhtml") || type.equalsIgnoreCase("markdown") || type.equalsIgnoreCase("dateTime") || type.equalsIgnoreCase("time") || type.equalsIgnoreCase("code") - || type.equalsIgnoreCase("oid") || type.equalsIgnoreCase("id"); - } - - - - public boolean isSuppressLoincSnomedMessages() { - return suppressLoincSnomedMessages; - } - - private boolean nameMatches(String name, String tail) { - if (tail.endsWith("[x]")) - return name.startsWith(tail.substring(0, tail.length() - 3)); - else - return (name.equals(tail)); - } - - // private String mergePath(String path1, String path2) { - // // path1 is xpath path - // // path2 is dotted path - // String[] parts = path2.split("\\."); - // StringBuilder b = new StringBuilder(path1); - // for (int i = 1; i < parts.length -1; i++) - // b.append("/f:"+parts[i]); - // return b.toString(); - // } - - private boolean passesCodeWhitespaceRules(String v) { - if (!v.trim().equals(v)) - return false; - boolean lastWasSpace = true; - for (char c : v.toCharArray()) { - if (c == ' ') { - if (lastWasSpace) - return false; - else - lastWasSpace = true; - } else if (Character.isWhitespace(c)) - return false; - else - lastWasSpace = false; - } - return true; - } - - private WrapperElement resolve(String ref, NodeStack stack) { - if (ref.startsWith("#")) { - // work back through the contained list. - // really, there should only be one level for this (contained resources cannot contain - // contained resources), but we'll leave that to some other code to worry about - while (stack != null && stack.getElement() != null) { - WrapperElement res = getContainedById(stack.getElement(), ref.substring(1)); - if (res != null) - return res; - stack = stack.parent; - } - return null; - } else { - // work back through the contained list - if any of them are bundles, try to resolve - // the resource in the bundle - while (stack != null && stack.getElement() != null) { - if ("Bundle".equals(stack.getElement().getResourceType())) { - WrapperElement res = getFromBundle(stack.getElement(), ref.substring(1)); - if (res != null) - return res; - } - stack = stack.parent; - } - - // todo: consult the external host for resolution - return null; - - } - } - - private ValueSet resolveBindingReference(Type reference) { - if (reference instanceof UriType) - return context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString()); - else if (reference instanceof Reference) - return context.fetchResource(ValueSet.class, ((Reference) reference).getReference()); - else - return null; - } - - private WrapperElement resolveInBundle(List entries, String ref, String fullUrl, String type, String id) { - if (Utilities.isAbsoluteUrl(ref)) { - // if the reference is absolute, then you resolve by fullUrl. No other thinking is required. - for (WrapperElement entry : entries) { - String fu = entry.getNamedChildValue("fullUrl"); - if (ref.equals(fu)) - return entry; - } - return null; - } else { - // split into base, type, and id - String u = null; - if (fullUrl != null && fullUrl.endsWith(type+"/"+id)) - // fullUrl = complex - u = fullUrl.substring((type+"/"+id).length())+ref; - String[] parts = ref.split("\\/"); - if (parts.length >= 2) { - String t = parts[0]; - String i = parts[1]; - for (WrapperElement entry : entries) { - String fu = entry.getNamedChildValue("fullUrl"); - if (u != null && fullUrl.equals(u)) - return entry; - if (u == null) { - WrapperElement res = entry.getNamedChild("resource"); - WrapperElement resource = res.getFirstChild(); - String et = resource.getResourceType(); - String eid = resource.getNamedChildValue("id"); - if (t.equals(et) && i.equals(eid)) - return entry; - } - } - } - return null; - } - } - - private ElementDefinition resolveNameReference(StructureDefinitionSnapshotComponent snapshot, String name) { - for (ElementDefinition ed : snapshot.getElement()) - if (name.equals(ed.getName())) - return ed; - return null; - } - - private StructureDefinition resolveProfile(StructureDefinition profile, String pr) { - if (pr.startsWith("#")) { - for (Resource r : profile.getContained()) { - if (r.getId().equals(pr.substring(1)) && r instanceof StructureDefinition) - return (StructureDefinition) r; - } - return null; - } else - return context.fetchResource(StructureDefinition.class, pr); - } - - private ElementDefinition resolveType(String type) { - String url = "http://hl7.org/fhir/StructureDefinition/" + type; - StructureDefinition sd = context.fetchResource(StructureDefinition.class, url); - if (sd == null || !sd.hasSnapshot()) - return null; - else - return sd.getSnapshot().getElement().get(0); - } - - public void setAnyExtensionsAllowed(boolean anyExtensionsAllowed) { - this.anyExtensionsAllowed = anyExtensionsAllowed; - } - - public void setBestPracticeWarningLevel(BestPracticeWarningLevel value) { - bpWarnings = value; - } - - @Override - public void setCheckDisplay(CheckDisplayOption checkDisplay) { - this.checkDisplay = checkDisplay; - } - - public void setSuppressLoincSnomedMessages(boolean suppressLoincSnomedMessages) { - this.suppressLoincSnomedMessages = suppressLoincSnomedMessages; - } - - public IdStatus getResourceIdRule() { - return resourceIdRule; - } - - public void setResourceIdRule(IdStatus resourceIdRule) { - this.resourceIdRule = resourceIdRule; - } - - /** - * - * @param element - * - the candidate that might be in the slice - * @param path - * - for reporting any errors. the XPath for the element - * @param slice - * - the definition of how slicing is determined - * @param ed - * - the slice for which to test membership - * @return - * @throws DefinitionException - * @throws Exception - */ - private boolean sliceMatches(WrapperElement element, String path, ElementDefinition slice, ElementDefinition ed, StructureDefinition profile) throws DefinitionException { - if (!slice.getSlicing().hasDiscriminator()) - return false; // cannot validate in this case - for (StringType s : slice.getSlicing().getDiscriminator()) { - String discriminator = s.getValue(); - ElementDefinition criteria = getCriteriaForDiscriminator(path, ed, discriminator, profile); - if (discriminator.equals("url") && criteria.getPath().equals("Extension.url")) { - if (!element.getAttribute("url").equals(((UriType) criteria.getFixed()).asStringValue())) - return false; - } else { - Element value = getValueForDiscriminator(element, discriminator, criteria); - if (!valueMatchesCriteria(value, criteria)) - return false; - } - } - return true; - } - - // we assume that the following things are true: - // the instance at root is valid against the schema and schematron - // the instance validator had no issues against the base resource profile - private void start(List errors, WrapperElement resource, WrapperElement element, StructureDefinition profile, NodeStack stack) throws FHIRException { - // profile is valid, and matches the resource name - if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), profile.hasSnapshot(), - "StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided")) { - validateElement(errors, profile, profile.getSnapshot().getElement().get(0), null, null, resource, element, element.getName(), stack, false); - - checkDeclaredProfiles(errors, resource, element, stack); - - // specific known special validations - if (element.getResourceType().equals("Bundle")) - validateBundle(errors, element, stack); - if (element.getResourceType().equals("Observation")) - validateObservation(errors, element, stack); - } - } - - private String tail(String path) { - return path.substring(path.lastIndexOf(".") + 1); - } - - private String tryParse(String ref) { - String[] parts = ref.split("\\/"); - switch (parts.length) { - case 1: - return null; - case 2: - return checkResourceType(parts[0]); - default: - if (parts[parts.length - 2].equals("_history")) - return checkResourceType(parts[parts.length - 4]); - else - return checkResourceType(parts[parts.length - 2]); - } - } - - private boolean typesAreAllReference(List theType) { - for (TypeRefComponent typeRefComponent : theType) { - if (typeRefComponent.getCode().equals("Reference") == false) { - return false; - } - } - return true; - } - - @Override - public List validate(Document document) throws FHIRException { - List results = new ArrayList(); - validate(results, document); - return results; - } - - @Override - public List validate(Document document, String profile) throws FHIRException { - List results = new ArrayList(); - validate(results, document, profile); - return results; - } - - @Override - public List validate(Document document, StructureDefinition profile) throws FHIRException { - List results = new ArrayList(); - validate(results, document, profile); - return results; - } - - @Override - public List validate(Element element) throws FHIRException { - List results = new ArrayList(); - validate(results, element); - return results; - } - - @Override - public List validate(Element element, String profile) throws FHIRException { - List results = new ArrayList(); - validate(results, element, profile); - return results; - } - - @Override - public List validate(Element element, StructureDefinition profile) throws FHIRException { - List results = new ArrayList(); - validate(results, element, profile); - return results; - } - - @Override - public List validate(JsonObject obj) throws FHIRException { - List results = new ArrayList(); - validate(results, obj); - return results; - } - - @Override - public List validate(JsonObject obj, String profile) throws FHIRException { - List results = new ArrayList(); - validate(results, obj, profile); - return results; - } - - @Override - public List validate(JsonObject obj, StructureDefinition profile) throws FHIRException { - List results = new ArrayList(); - validate(results, obj, profile); - return results; - } - - @Override - public void validate(List errors, Document document) throws FHIRException { - checkForProcessingInstruction(errors, document); - validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), null, resourceIdRule, null); - } - - @Override - public void validate(List errors, Document document, String profile) throws FHIRException { - checkForProcessingInstruction(errors, document); - StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); - if (p == null) - throw new DefinitionException("StructureDefinition '" + profile + "' not found"); - validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), p, resourceIdRule, null); - } - - @Override - public void validate(List errors, Document document, StructureDefinition profile) throws FHIRException { - checkForProcessingInstruction(errors, document); - validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), profile, resourceIdRule, null); - } - - @Override - public void validate(List errors, Element element) throws FHIRException { - validateResource(errors, null, new DOMWrapperElement(element), null, resourceIdRule, null); - } - - @Override - public void validate(List errors, Element element, String profile) throws FHIRException { - StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); - if (p == null) - throw new DefinitionException("StructureDefinition '" + profile + "' not found"); - validateResource(errors, null, new DOMWrapperElement(element), p, resourceIdRule, null); - } - - @Override - public void validate(List errors, Element element, StructureDefinition profile) throws FHIRException { - validateResource(errors, null, new DOMWrapperElement(element), profile, resourceIdRule, null); - } - - @Override - public void validate(List errors, JsonObject object) throws FHIRException { - validateResource(errors, null, new JsonWrapperElement(object), null, resourceIdRule, null); - } - - @Override - public void validate(List errors, JsonObject object, String profile) throws FHIRException { - StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); - if (p == null) - throw new DefinitionException("StructureDefinition '" + profile + "' not found"); - validateResource(errors, null, new JsonWrapperElement(object), p, resourceIdRule, null); - } - - @Override - public void validate(List errors, JsonObject object, StructureDefinition profile) throws FHIRException { - validateResource(errors, null, new JsonWrapperElement(object), profile, resourceIdRule, null); - } - - private void validateBundle(List errors, WrapperElement bundle, NodeStack stack) { - List entries = new ArrayList(); - bundle.getNamedChildren("entry", entries); - String type = bundle.getNamedChildValue("type"); - if (entries.size() == 0) { - rule(errors, IssueType.INVALID, stack.getLiteralPath(), !(type.equals("document") || type.equals("message")), "Documents or Messages must contain at least one entry"); - } else { - WrapperElement firstEntry = entries.get(0); - NodeStack firstStack = stack.push(firstEntry, 0, null, null); - String fullUrl = firstEntry.getNamedChildValue("fullUrl"); - - if (type.equals("document")) { - WrapperElement res = firstEntry.getNamedChild("resource"); - NodeStack localStack = firstStack.push(res, -1, null, null); - WrapperElement resource = res.getFirstChild(); - String id = resource.getNamedChildValue("id"); - if (rule(errors, IssueType.INVALID, firstEntry.line(), firstEntry.col(), stack.addToLiteralPath("entry", ":0"), res != null, "No resource on first entry")) { - if (bundle.isXml()) - validateDocument(errors, entries, resource, localStack.push(resource, -1, null, null), fullUrl, id); - else - validateDocument(errors, entries, res, localStack, fullUrl, id); - } - } - if (type.equals("message")) - validateMessage(errors, bundle); - } - } - - // public class ProfileStructureIterator { - // - // private StructureDefinition profile; - // private ElementDefinition elementDefn; - // private List names = new ArrayList(); - // private Map> children = new HashMap>(); - // private int cursor; - // - // public ProfileStructureIterator(StructureDefinition profile, ElementDefinition elementDefn) { - // this.profile = profile; - // this.elementDefn = elementDefn; - // loadMap(); - // cursor = -1; - // } - // - // private void loadMap() { - // int i = profile.getSnapshot().getElement().indexOf(elementDefn) + 1; - // String lead = elementDefn.getPath(); - // while (i < profile.getSnapshot().getElement().size()) { - // String name = profile.getSnapshot().getElement().get(i).getPath(); - // if (name.length() <= lead.length()) - // return; // cause we've got to the end of the possible matches - // String tail = name.substring(lead.length()+1); - // if (Utilities.isToken(tail) && name.substring(0, lead.length()).equals(lead)) { - // List list = children.get(tail); - // if (list == null) { - // list = new ArrayList(); - // names.add(tail); - // children.put(tail, list); - // } - // list.add(profile.getSnapshot().getElement().get(i)); - // } - // i++; - // } - // } - // - // public boolean more() { - // cursor++; - // return cursor < names.size(); - // } - // - // public List current() { - // return children.get(name()); - // } - // - // public String name() { - // return names.get(cursor); - // } - // - // } - // - // private void checkByProfile(List errors, String path, WrapperElement focus, StructureDefinition profile, ElementDefinition elementDefn) - // { - // // we have an element, and the structure that describes it. - // // we know that's it's valid against the underlying spec - is it valid against this one? - // // in the instance validator above, we assume that schema or schmeatron has taken care of cardinalities, but here, we have no such reliance. - // // so the walking algorithm is different: we're going to walk the definitions - // String type; - // if (elementDefn.getPath().endsWith("[x]")) { - // String tail = elementDefn.getPath().substring(elementDefn.getPath().lastIndexOf(".")+1, elementDefn.getPath().length()-3); - // type = focus.getName().substring(tail.length()); - // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, typeAllowed(type, elementDefn.getType()), "The type '"+type+"' is not allowed at this - // point (must be one of '"+typeSummary(elementDefn)+")"); - // } else { - // if (elementDefn.getType().size() == 1) { - // type = elementDefn.getType().size() == 0 ? null : elementDefn.getType().get(0).getCode(); - // } else - // type = null; - // } - // // constraints: - // for (ElementDefinitionConstraintComponent c : elementDefn.getConstraint()) - // checkConstraint(errors, path, focus, c); - // if (elementDefn.hasBinding() && type != null) - // checkBinding(errors, path, focus, profile, elementDefn, type); - // - // // type specific checking: - // if (type != null && isPrimitiveType(type)) { - // checkPrimitiveByProfile(errors, path, focus, elementDefn); - // } else { - // if (elementDefn.hasFixed()) - // checkFixedValue(errors, path, focus, elementDefn.getFixed(), ""); - // - // ProfileStructureIterator walker = new ProfileStructureIterator(profile, elementDefn); - // while (walker.more()) { - // // collect all the slices for the path - // List childset = walker.current(); - // // collect all the elements that match it by name - // List children = new ArrayList(); - // focus.getNamedChildrenWithWildcard(walker.name(), children); - // - // if (children.size() == 0) { - // // well, there's no children - should there be? - // for (ElementDefinition defn : childset) { - // if (!rule(errors, IssueType.REQUIRED, focus.line(), focus.col(), path, defn.getMin() == 0, "Required Element '"+walker.name()+"' missing")) - // break; // no point complaining about missing ones after the first one - // } - // } else if (childset.size() == 1) { - // // simple case: one possible definition, and one or more children. - // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, childset.get(0).getMax().equals("*") || Integer.parseInt(childset.get(0).getMax()) >= - // children.size(), - // "Too many elements for '"+walker.name()+"'"); // todo: sort out structure - // for (WrapperElement child : children) { - // checkByProfile(errors, childset.get(0).getPath(), child, profile, childset.get(0)); - // } - // } else { - // // ok, this is the full case - we have a list of definitions, and a list of candidates for meeting those definitions. - // // we need to decide *if* that match a given definition - // } - // } - // } - // } - - // private void checkBinding(List errors, String path, WrapperElement focus, StructureDefinition profile, ElementDefinition elementDefn, - // String type) { - // ElementDefinitionBindingComponent bc = elementDefn.getBinding(); - // - // if (bc != null && bc.hasValueSet() && bc.getValueSet() instanceof Reference) { - // String url = ((Reference) bc.getValueSet()).getReference(); - // ValueSet vs = resolveValueSetReference(profile, (Reference) bc.getValueSet()); - // if (vs == null) { - // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, false, "Cannot check binding on type '"+type+"' as the value set '"+url+"' could not be - // located"); - // } else if (type.equals("code")) - // checkBindingCode(errors, path, focus, vs); - // else if (type.equals("Coding")) - // checkBindingCoding(errors, path, focus, vs); - // else if (type.equals("CodeableConcept")) - // checkBindingCodeableConcept(errors, path, focus, vs); - // else - // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, false, "Cannot check binding on type '"+type+"'"); - // } - // } - // - // private ValueSet resolveValueSetReference(StructureDefinition profile, Reference reference) { - // if (reference.getReference().startsWith("#")) { - // for (Resource r : profile.getContained()) { - // if (r instanceof ValueSet && r.getId().equals(reference.getReference().substring(1))) - // return (ValueSet) r; - // } - // return null; - // } else - // return resolveBindingReference(reference); - // - // } - // - // private void checkBindingCode(List errors, String path, WrapperElement focus, ValueSet vs) { - // // rule(errors, "exception", path, false, "checkBindingCode not done yet"); - // } - // - // private void checkBindingCoding(List errors, String path, WrapperElement focus, ValueSet vs) { - // // rule(errors, "exception", path, false, "checkBindingCoding not done yet"); - // } - // - // private void checkBindingCodeableConcept(List errors, String path, WrapperElement focus, ValueSet vs) { - // // rule(errors, "exception", path, false, "checkBindingCodeableConcept not done yet"); - // } - // - // private String typeSummary(ElementDefinition elementDefn) { - // StringBuilder b = new StringBuilder(); - // for (TypeRefComponent t : elementDefn.getType()) { - // b.append("|"+t.getCode()); - // } - // return b.toString().substring(1); - // } - // - // private boolean typeAllowed(String t, List types) { - // for (TypeRefComponent type : types) { - // if (t.equals(Utilities.capitalize(type.getCode()))) - // return true; - // if (t.equals("Resource") && Utilities.capitalize(type.getCode()).equals("Reference")) - // return true; - // } - // return false; - // } - // - // private void checkConstraint(List errors, String path, WrapperElement focus, ElementDefinitionConstraintComponent c) { - // - //// try - //// { - //// XPathFactory xpf = new net.sf.saxon.xpath.XPathFactoryImpl(); - //// NamespaceContext context = new NamespaceContextMap("f", "http://hl7.org/fhir", "h", "http://www.w3.org/1999/xhtml"); - //// - //// XPath xpath = xpf.newXPath(); - //// xpath.setNamespaceContext(context); - //// Boolean ok = (Boolean) xpath.evaluate(c.getXpath(), focus, XPathConstants.BOOLEAN); - //// if (ok == null || !ok) { - //// if (c.getSeverity() == ConstraintSeverity.warning) - //// warning(errors, "invariant", path, false, c.getHuman()); - //// else - //// rule(errors, "invariant", path, false, c.getHuman()); - //// } - //// } - //// catch (XPathExpressionException e) { - //// rule(errors, "invariant", path, false, "error executing invariant: "+e.getMessage()); - //// } - // } - // - // private void checkPrimitiveByProfile(List errors, String path, WrapperElement focus, ElementDefinition elementDefn) { - // // two things to check - length, and fixed value - // String value = focus.getAttribute("value"); - // if (elementDefn.hasMaxLengthElement()) { - // rule(errors, IssueType.TOOLONG, focus.line(), focus.col(), path, value.length() <= elementDefn.getMaxLength(), "The value '"+value+"' exceeds the allow - // length limit of "+Integer.toString(elementDefn.getMaxLength())); - // } - // if (elementDefn.hasFixed()) { - // checkFixedValue(errors, path, focus, elementDefn.getFixed(), ""); - // } - // } - - private void validateBundleReference(List errors, List entries, WrapperElement ref, String name, NodeStack stack, String fullUrl, String type, String id) { - if (ref != null && !Utilities.noString(ref.getNamedChildValue("reference"))) { - WrapperElement target = resolveInBundle(entries, ref.getNamedChildValue("reference"), fullUrl, type, id); - rule(errors, IssueType.INVALID, target.line(), target.col(), stack.addToLiteralPath("reference"), target != null, "Unable to resolve the target of the reference in the bundle (" + name + ")"); - } - } - - private void validateContains(List errors, String path, ElementDefinition child, ElementDefinition context, WrapperElement resource, WrapperElement element, NodeStack stack, IdStatus idstatus) throws FHIRException - { - WrapperElement e = element.isXml() ? element.getFirstChild() : element; - String resourceName = e.getResourceType(); - StructureDefinition profile = this.context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName); - // special case: resource wrapper is reset if we're crossing a bundle boundary, but not otherwise - if (path.endsWith("resource")) - resource = e; - if (rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for contained resource of type '" + resourceName + "'")) - validateResource(errors, resource, e, profile, idstatus, stack); - } - - private void validateDocument(List errors, List entries, WrapperElement composition, NodeStack stack, String fullUrl, String id) { - // first entry must be a composition - if (rule(errors, IssueType.INVALID, composition.line(), composition.col(), stack.getLiteralPath(), composition.getResourceType().equals("Composition"), - "The first entry in a document must be a composition")) { - // the composition subject and section references must resolve in the bundle - validateBundleReference(errors, entries, composition.getNamedChild("subject"), "Composition Subject", stack.push(composition.getNamedChild("subject"), -1, null, null), fullUrl, "Composition", - id); - validateSections(errors, entries, composition, stack, fullUrl, id); - } - } - // rule(errors, IssueType.INVALID, bundle.line(), bundle.col(), "Bundle", !"urn:guid:".equals(base), "The base 'urn:guid:' is not valid (use urn:uuid:)"); - // rule(errors, IssueType.INVALID, entry.line(), entry.col(), localStack.getLiteralPath(), !"urn:guid:".equals(ebase), "The base 'urn:guid:' is not valid"); - // rule(errors, IssueType.INVALID, entry.line(), entry.col(), localStack.getLiteralPath(), !Utilities.noString(base) || !Utilities.noString(ebase), "entry - // does not have a base"); - // String firstBase = null; - // firstBase = ebase == null ? base : ebase; - - private void validateElement(List errors, StructureDefinition profile, ElementDefinition definition, StructureDefinition cprofile, ElementDefinition context, - WrapperElement resource, WrapperElement element, String actualType, NodeStack stack, boolean inCodeableConcept) throws FHIRException { - element.setDefinition(definition); - element.setProfile(profile); - - // irrespective of what element it is, it cannot be empty - if (element.isXml()) { - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), FormatUtilities.FHIR_NS.equals(element.getNamespace()), - "Namespace mismatch - expected '" + FormatUtilities.FHIR_NS + "', found '" + element.getNamespace() + "'"); - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !element.hasNamespace("http://www.w3.org/2001/XMLSchema-instance"), - "Schema Instance Namespace is not allowed in instances"); - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !element.hasProcessingInstruction(), "No Processing Instructions in resources"); - } - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !empty(element), "Elements must have some content (@value, extensions, or children elements)"); - - checkInvariants(errors, stack.literalPath, profile, definition, null, null, resource, element); - - // get the list of direct defined children, including slices - List childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); - - // 1. List the children, and remember their exact path (convenience) - List children = new ArrayList(); - ChildIterator iter = new ChildIterator(stack.getLiteralPath(), element); - while (iter.next()) - children.add(new ElementInfo(iter.name(), iter.element(), iter.path(), iter.count())); - - // 2. assign children to a definition - // for each definition, for each child, check whether it belongs in the slice - ElementDefinition slice = null; - for (ElementDefinition ed : childDefinitions) { - boolean process = true; - // where are we with slicing - if (ed.hasSlicing()) { - if (slice != null && slice.getPath().equals(ed.getPath())) - throw new DefinitionException("Slice encountered midway through path on " + slice.getPath()); - slice = ed; - process = false; - } else if (slice != null && !slice.getPath().equals(ed.getPath())) - slice = null; - - if (process) { - for (ElementInfo ei : children) { - boolean match = false; - if (slice == null) { - match = nameMatches(ei.name, tail(ed.getPath())); - } else { - if (nameMatches(ei.name, tail(ed.getPath()))) - match = sliceMatches(ei.element, ei.path, slice, ed, profile); - } - if (match) { - if (rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition == null, "Element matches more than one slice")) - ei.definition = ed; - } - } - } - } - for (ElementInfo ei : children) - if (ei.path.endsWith(".extension")) - rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition != null, "Element is unknown or does not match any slice (url=\"" + ei.element.getAttribute("url") + "\")"); - else - rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, (ei.definition != null) || (!ei.element.isXml() && ei.element.getName().equals("fhir_comments")), - "Element is unknown or does not match any slice"); - - // 3. report any definitions that have a cardinality problem - for (ElementDefinition ed : childDefinitions) { - if (ed.getRepresentation().isEmpty()) { // ignore xml attributes - int count = 0; - for (ElementInfo ei : children) - if (ei.definition == ed) - count++; - if (ed.getMin() > 0) { - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), count >= ed.getMin(), - "Element '" + stack.getLiteralPath() + "." + tail(ed.getPath()) + "': minimum required = " + Integer.toString(ed.getMin()) + ", but only found " + Integer.toString(count)); - } - if (ed.hasMax() && !ed.getMax().equals("*")) { - rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), count <= Integer.parseInt(ed.getMax()), - "Element " + tail(ed.getPath()) + " @ " + stack.getLiteralPath() + ": max allowed = " + ed.getMax() + ", but found " + Integer.toString(count)); - } - - } - } - // 4. check order if any slices are orderd. (todo) - - // 5. inspect each child for validity - for (ElementInfo ei : children) { - if (ei.definition != null) { - String type = null; - ElementDefinition typeDefn = null; - if (ei.definition.getType().size() == 1 && !ei.definition.getType().get(0).getCode().equals("*") && !ei.definition.getType().get(0).getCode().equals("Element") - && !ei.definition.getType().get(0).getCode().equals("BackboneElement")) - type = ei.definition.getType().get(0).getCode(); - else if (ei.definition.getType().size() == 1 && ei.definition.getType().get(0).getCode().equals("*")) { - String prefix = tail(ei.definition.getPath()); - assert prefix.endsWith("[x]"); - type = ei.name.substring(prefix.length() - 3); - if (isPrimitiveType(type)) - type = Utilities.uncapitalize(type); - } else if (ei.definition.getType().size() > 1) { - - String prefix = tail(ei.definition.getPath()); - assert typesAreAllReference(ei.definition.getType()) || prefix.endsWith("[x]") : prefix; - - prefix = prefix.substring(0, prefix.length() - 3); - for (TypeRefComponent t : ei.definition.getType()) - if ((prefix + Utilities.capitalize(t.getCode())).equals(ei.name)) - type = t.getCode(); - if (type == null) { - TypeRefComponent trc = ei.definition.getType().get(0); - if (trc.getCode().equals("Reference")) - type = "Reference"; - else - rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), false, - "The element " + ei.name + " is illegal. Valid types at this point are " + describeTypes(ei.definition.getType())); - } - } else if (ei.definition.getNameReference() != null) { - typeDefn = resolveNameReference(profile.getSnapshot(), ei.definition.getNameReference()); - } - - if (type != null) { - if (type.startsWith("@")) { - ei.definition = findElement(profile, type.substring(1)); - type = null; - } - } - NodeStack localStack = stack.push(ei.element, ei.count, ei.definition, type == null ? typeDefn : resolveType(type)); - String localStackLiterapPath = localStack.getLiteralPath(); - String eiPath = ei.path; - assert(eiPath.equals(localStackLiterapPath)) : "ei.path: " + ei.path + " - localStack.getLiterapPath: " + localStackLiterapPath; - boolean thisIsCodeableConcept = false; - - if (type != null) { - if (isPrimitiveType(type)) - checkPrimitive(errors, ei.path, type, ei.definition, ei.element); - else { - if (type.equals("Identifier")) - checkIdentifier(errors, ei.path, ei.element, ei.definition); - else if (type.equals("Coding")) - checkCoding(errors, ei.path, ei.element, profile, ei.definition, inCodeableConcept); - else if (type.equals("CodeableConcept")) { - checkCodeableConcept(errors, ei.path, ei.element, profile, ei.definition); - thisIsCodeableConcept = true; - } else if (type.equals("Reference")) - checkReference(errors, ei.path, ei.element, profile, ei.definition, actualType, localStack); - - if (type.equals("Extension")) - checkExtension(errors, ei.path, ei.element, ei.definition, profile, localStack); - else if (type.equals("Resource")) - validateContains(errors, ei.path, ei.definition, definition, resource, ei.element, localStack, idStatusForEntry(element, ei)); // if - // (str.matches(".*([.,/])work\\1$")) - else { - StructureDefinition p = getProfileForType(type); - if (rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), ei.path, p != null, "Unknown type " + type)) { - validateElement(errors, p, p.getSnapshot().getElement().get(0), profile, ei.definition, resource, ei.element, type, localStack, thisIsCodeableConcept); - } - } - } - } else { - if (rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), ei.definition != null, "Unrecognised Content " + ei.name)) - validateElement(errors, profile, ei.definition, null, null, resource, ei.element, type, localStack, false); - } - } - } - } - - private IdStatus idStatusForEntry(WrapperElement ep, ElementInfo ei) { - if (isBundleEntry(ei.path)) { - WrapperElement req = ep.getNamedChild("request"); - WrapperElement resp = ep.getNamedChild("response"); - WrapperElement fullUrl = ep.getNamedChild("fullUrl"); - WrapperElement method = null; - WrapperElement url = null; - if (req != null) { - method = req.getNamedChild("method"); - url = req.getNamedChild("url"); - } - if (resp != null) { - return IdStatus.OPTIONAL; - } if (method == null) { - if (fullUrl == null) - return IdStatus.REQUIRED; - else if (fullUrl.getAttribute("value").startsWith("urn:uuid:")) - return IdStatus.OPTIONAL; - else - return IdStatus.REQUIRED; - } else { - String s = method.getAttribute("value"); - if (s.equals("PUT")) { - if (url == null) - return IdStatus.REQUIRED; - else - return IdStatus.OPTIONAL; // or maybe prohibited? not clear - } else if (s.equals("POST")) - return IdStatus.OPTIONAL; // this should be prohibited, but see task 9102 - else // actually, we should never get to here; a bundle entry with method get/delete should not have a resource - return IdStatus.OPTIONAL; - } - } else if (isParametersEntry(ei.path)) - return IdStatus.OPTIONAL; - else - return this.getResourceIdRule(); - } - - private void checkInvariants(List errors, String path, StructureDefinition profile, ElementDefinition ed, String typename, String typeProfile, WrapperElement resource, WrapperElement element) throws FHIRException { - for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { - if (inv.hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression")) { - ResourceOnWrapper res = new ResourceOnWrapper(context, resource, resource.getProfile()); - BaseOnWrapper e = new BaseOnWrapper(context, element, profile, ed, typename, typeProfile); - String expr = inv.getExtensionString("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression"); - FHIRPathEngine fpe = new FHIRPathEngine(context); - boolean ok = true; - try { - ok = fpe.evaluateToBoolean(res, e, expr); - } catch (PathEngineException e1) { - rule(errors, IssueType.INVARIANT, element.line(), element.col(), path, false, e1.getMessage()+": "+inv.getHuman()+fpe.forLog()); - } - if (!ok) { - if (inv.getSeverity() == ConstraintSeverity.ERROR) - rule(errors, IssueType.INVARIANT, element.line(), element.col(), path, ok, inv.getHuman()+fpe.forLog()); - else if (inv.getSeverity() == ConstraintSeverity.WARNING) - warning(errors, IssueType.INVARIANT, element.line(), element.line(), path, ok, inv.getHuman()+fpe.forLog()); - } - } - } - } - - private void validateMessage(List errors, WrapperElement bundle) { - // TODO Auto-generated method stub - - } - - private void validateObservation(List errors, WrapperElement element, NodeStack stack) { - // all observations should have a subject, a performer, and a time - - bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("subject") != null, "All observations should have a subject"); - bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("performer") != null, "All observations should have a performer"); - bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null, - "All observations should have an effectiveDateTime or an effectivePeriod"); - } - - /* - * The actual base entry point - */ - private void validateResource(List errors, WrapperElement resource, WrapperElement element, StructureDefinition profile, IdStatus idstatus, NodeStack stack) throws FHIRException { - if (stack == null) - stack = new NodeStack(element.isXml()); - if (resource == null) - resource = element; - - // getting going - either we got a profile, or not. - boolean ok = true; - if (element.isXml()) { - ok = rule(errors, IssueType.INVALID, element.line(), element.col(), "/", element.getNamespace().equals(FormatUtilities.FHIR_NS), - "Namespace mismatch - expected '" + FormatUtilities.FHIR_NS + "', found '" + element.getNamespace() + "'"); - } - if (ok) { - String resourceName = element.getResourceType(); - if (profile == null) { - profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName); - ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for resource type '" + resourceName + "'"); - } else { - String type = profile.hasConstrainedType() ? profile.getConstrainedType() : profile.getName(); - // special case: we have a bundle, and the profile is not for a bundle. We'll try the first entry instead - if (!type.equals(resourceName) && resourceName.equals("Bundle")) { - WrapperElement first = getFirstEntry(element); - if (first != null && first.getResourceType().equals(type)) { - element = first; - resourceName = element.getResourceType(); - idstatus = IdStatus.OPTIONAL; // why? - } - } - ok = rule(errors, IssueType.INVALID, -1, -1, stack.addToLiteralPath(resourceName), type.equals(resourceName), - "Specified profile type was '" + profile.getConstrainedType() + "', but resource type was '" + resourceName + "'"); - } - } - - if (ok) { - stack = stack.push(element, -1, profile.getSnapshot().getElement().get(0), profile.getSnapshot().getElement().get(0)); - if (idstatus == IdStatus.REQUIRED && (element.getNamedChild("id") == null)) - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource requires an id, but none is present"); - else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild("id") != null)) - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource has an id, but none is allowed"); - start(errors, resource, element, profile, stack); // root is both definition and type - } - } - - private WrapperElement getFirstEntry(WrapperElement bundle) { - List list = new ArrayList(); - bundle.getNamedChildren("entry", list); - if (list.isEmpty()) - return null; - WrapperElement resource = list.get(0).getNamedChild("resource"); - if (resource == null) - return null; - else - return resource.getFirstChild(); - } - - private void validateSections(List errors, List entries, WrapperElement focus, NodeStack stack, String fullUrl, String id) { - List sections = new ArrayList(); - focus.getNamedChildren("entry", sections); - int i = 0; - for (WrapperElement section : sections) { - NodeStack localStack = stack.push(section, 1, null, null); - validateBundleReference(errors, entries, section.getNamedChild("content"), "Section Content", localStack, fullUrl, "Composition", id); - validateSections(errors, entries, section, localStack, fullUrl, id); - i++; - } - } - - private boolean valueMatchesCriteria(Element value, ElementDefinition criteria) { - // throw new Error("validation of slices not done yet"); - return false; - } - - private boolean yearIsValid(String v) { - if (v == null) { - return false; - } - try { - int i = Integer.parseInt(v.substring(0, Math.min(4, v.length()))); - return i >= 1800 && i <= 2100; - } catch (NumberFormatException e) { - return false; - } - } - - public class ChildIterator { - private String basePath; - private WrapperElement child; - private int lastCount; - private WrapperElement parent; - - public ChildIterator(String path, WrapperElement element) { - parent = element; - basePath = path; - } - - public int count() { - WrapperElement n = child.getNextSibling(); - if (n != null && n.getName().equals(child.getName())) { - return lastCount + 1; - } else - return -1; - } - - public WrapperElement element() { - return child; - } - - public String name() { - return child.getName(); - } - - public boolean next() { - if (child == null) { - child = parent.getFirstChild(); - lastCount = 0; - } else { - String lastName = child.getName(); - child = child.getNextSibling(); - if (child != null && child.getName().equals(lastName)) - lastCount++; - else - lastCount = 0; - } - return child != null; - } - - public String path() { - WrapperElement n = child.getNextSibling(); - if (parent.isXml()) { - String sfx = ""; - if (n != null && n.getName().equals(child.getName())) { - sfx = "[" + Integer.toString(lastCount + 1) + "]"; - } - if (FormatUtilities.XHTML_NS.equals(child.getNamespace())) - return basePath + "/h:" + name() + sfx; - else - return basePath + "/f:" + name() + sfx; - } else { - String sfx = ""; - if (n != null && n.getName().equals(child.getName())) { - sfx = "/" + Integer.toString(lastCount + 1); - } - return basePath + "/" + name() + sfx; - } - } - } - - public class DOMWrapperElement extends WrapperElement { - - private int col; - private Element element; - private int line; - - public DOMWrapperElement(Element element) { - super(); - this.element = element; - XmlLocationData loc = (XmlLocationData) element.getUserData(XmlLocationData.LOCATION_DATA_KEY); - if (loc != null) { - line = loc.getStartLine(); - col = loc.getStartColumn(); - } else { - line = -1; - col = -1; - } - } - - @Override - public int col() { - return col; - } - - @Override - public String getAttribute(String name) { - return element.getAttribute(name); - } - - @Override - public WrapperElement getFirstChild() { - Element res = XMLUtil.getFirstChild(element); - return res == null ? null : new DOMWrapperElement(res); - } - - @Override - public String getName() { - return element.getLocalName(); - } - - @Override - public WrapperElement getNamedChild(String name) { - Element res = XMLUtil.getNamedChild(element, name); - return res == null ? null : new DOMWrapperElement(res); - } - - @Override - public void getNamedChildren(String name, List list) { - List el = new ArrayList(); - XMLUtil.getNamedChildren(element, name, el); - for (Element e : el) - list.add(new DOMWrapperElement(e)); - } - - @Override - public void getNamedChildrenWithWildcard(String name, List list) { - List el = new ArrayList(); - XMLUtil.getNamedChildrenWithWildcard(element, name, el); - for (Element e : el) - list.add(new DOMWrapperElement(e)); - } - - @Override - public String getNamedChildValue(String name) { - return XMLUtil.getNamedChildValue(element, name); - } - - @Override - public String getNamespace() { - return element.getNamespaceURI(); - } - - @Override - public WrapperElement getNextSibling() { - Element res = XMLUtil.getNextSibling(element); - return res == null ? null : new DOMWrapperElement(res); - } - - @Override - public String getResourceType() { - return element.getLocalName(); - } - - @Override - public String getText() { - return element.getTextContent(); - } - - @Override - public boolean hasAttribute(String name) { - return element.hasAttribute(name); - } - - @Override - public boolean hasNamespace(String ns) { - for (int i = 0; i < element.getAttributes().getLength(); i++) { - Node a = element.getAttributes().item(i); - if ((a.getNodeName().equals("xmlns") || a.getNodeName().startsWith("xmlns:")) && a.getNodeValue().equals(ns)) - return true; - } - return false; - } - - @Override - public boolean hasProcessingInstruction() { - Node node = element.getFirstChild(); - while (node != null) { - if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) - return true; - node = node.getNextSibling(); - } - return false; - } - - @Override - public boolean isXml() { - return true; - } - - @Override - public int line() { - return line; - } - } - - public class ElementInfo { - - public int count; - public ElementDefinition definition; - private WrapperElement element; - private String name; - private String path; - - public ElementInfo(String name, WrapperElement element, String path, int count) { - this.name = name; - this.element = element; - this.path = path; - this.count = count; - } - - public int col() { - return element.col(); - } - - public int line() { - return element.line(); - } - - } - - public class JsonWrapperElement extends WrapperElement { - - private JsonElement _element; - private List children = new ArrayList(); - private JsonElement element; - private int index; - private String name; - private JsonWrapperElement parent; - private String path; - private String resourceType; - - public JsonWrapperElement(JsonElement element) { - super(); - this.name = null; - this.resourceType = ((JsonObject) element).get("resourceType").getAsString(); - this.element = element; - this.path = ""; - createChildren(); - } - - public JsonWrapperElement(String path, String name, JsonElement element, JsonElement _element, JsonWrapperElement parent, int index) { - super(); - this.path = path + "/" + name; - this.name = name; - this.element = element; - if (element instanceof JsonObject && ((JsonObject) element).has("resourceType")) - this.resourceType = ((JsonObject) element).get("resourceType").getAsString(); - this._element = _element; - this.parent = parent; - this.index = index; - createChildren(); - } - - @Override - public int col() { - // TODO Auto-generated method stub - return -1; - } - - private void createChildren() { - // System.out.println(" ..: "+path); - // we're going to make this look like the XML - if (element != null) { - if (element instanceof JsonPrimitive) { - // we may have an element_ too - if (_element != null && _element instanceof JsonObject) - for (Entry t : ((JsonObject) _element).entrySet()) - processChild(t.getKey(), t.getValue()); - } else if (element instanceof JsonObject) { - for (Entry t : ((JsonObject) element).entrySet()) - if (!t.getKey().equals("resourceType")) { - processChild(t.getKey(), t.getValue()); - } - } else if (element instanceof JsonNull) { - // nothing to do - } else - throw new Error("unexpected condition: " + element.getClass().getName()); - } - if (_element != null) { - - } - } - - @Override - public String getAttribute(String name) { - if (name.equals("value")) { - if (element == null) - return null; - if (element instanceof JsonPrimitive) - return ((JsonPrimitive) element).getAsString(); - return null; - } - if (name.equals("xml:id")) { - WrapperElement c = getNamedChild("id"); - return c == null ? null : c.getAttribute("value"); - } - if (name.equals("url")) { - WrapperElement c = getNamedChild("url"); - return c == null ? null : c.getAttribute("value"); - } - throw new Error("not done yet: " + name); - } - - @Override - public WrapperElement getFirstChild() { - if (children.isEmpty()) - return null; - else - return children.get(0); - } - - @Override - public String getName() { - return name; - } - - @Override - public WrapperElement getNamedChild(String name) { - for (JsonWrapperElement j : children) - if (j.name.equals(name)) - return j; - return null; - } - - @Override - public void getNamedChildren(String name, List list) { - for (JsonWrapperElement j : children) - if (j.name.equals(name)) - list.add(j); - } - - @Override - public void getNamedChildrenWithWildcard(String name, List list) { - for (JsonWrapperElement j : children) { - String n = j.name; - if (n.equals(name) || (name.endsWith("[x]") && n.startsWith(name.substring(0, name.length() - 3)))) - list.add(j); - } - } - - @Override - public String getNamedChildValue(String name) { - WrapperElement c = getNamedChild(name); - return c == null ? null : c.getAttribute("value"); - } - - @Override - public String getNamespace() { - // return element.getNamespaceURI(); - throw new Error("not done yet"); - } - - @Override - public WrapperElement getNextSibling() { - if (parent == null) - return null; - if (index >= parent.children.size() - 1) - return null; - return parent.children.get(index + 1); - } - - @Override - public String getResourceType() { - return resourceType; - } - - @Override - public String getText() { - throw new Error("not done yet"); - } - - @Override - public boolean hasAttribute(String name) { - if (name.equals("value")) { - if (element == null) - return false; - if (element instanceof JsonPrimitive) - return true; - return false; - } - if (name.equals("xml:id")) { - return getNamedChild("id") != null; - } - throw new Error("not done yet: " + name); - } - - @Override - public boolean hasNamespace(String ns) { - throw new Error("not done"); - } - - @Override - public boolean hasProcessingInstruction() { - return false; - } - - @Override - public boolean isXml() { - return false; - } - - @Override - public int line() { - return -1; - } - - private void processChild(String name, JsonElement e) { - if (name.startsWith("_")) { - name = name.substring(1); - if (((JsonObject) element).has(name)) - return; // it will get processed anyway - e = null; - } - JsonElement _e = element instanceof JsonObject ? ((JsonObject) element).get("_" + name) : null; - - if (e instanceof JsonPrimitive || (e == null && _e != null && !(_e instanceof JsonArray))) { - children.add(new JsonWrapperElement(path, name, e, _e, this, children.size())); - } else if (e instanceof JsonArray || (e == null && _e != null)) { - JsonArray array = (JsonArray) e; - JsonArray _array = (JsonArray) _e; - int max = array != null ? array.size() : 0; - if (_array != null && _array.size() > max) - max = _array.size(); - for (int i = 0; i < max; i++) { - JsonElement a = array == null || array.size() < i ? null : array.get(i); - JsonElement _a = _array == null || _array.size() < i ? null : _array.get(i); - children.add(new JsonWrapperElement(path, name, a, _a, this, children.size())); - } - } else if (e instanceof JsonObject) { - children.add(new JsonWrapperElement(path, name, e, null, this, children.size())); - } else - throw new Error("not done yet: " + e.getClass().getName()); - } - - } - - private class NodeStack { - private ElementDefinition definition; - private WrapperElement element; - private ElementDefinition extension; - private String literalPath; // xpath format - private List logicalPaths; // dotted format, various entry points - private NodeStack parent; - private ElementDefinition type; - private boolean xml; - - public NodeStack(boolean xml) { - this.xml = xml; - } - - public String addToLiteralPath(String... path) { - StringBuilder b = new StringBuilder(); - b.append(getLiteralPath()); - if (xml) { - for (String p : path) { - if (p.startsWith(":")) { - b.append("["); - b.append(p.substring(1)); - b.append("]"); - } else { - b.append("/f:"); - b.append(p); - } - } - } else { - for (String p : path) { - b.append("/"); - if (p.startsWith(":")) { - b.append(p.substring(1)); - } else { - b.append(p); - } - } - } - return b.toString(); - } - - private ElementDefinition getDefinition() { - return definition; - } - - private WrapperElement getElement() { - return element; - } - - private String getLiteralPath() { - return literalPath == null ? "" : literalPath; - } - - private List getLogicalPaths() { - return logicalPaths == null ? new ArrayList() : logicalPaths; - } - - private ElementDefinition getType() { - return type; - } - - private NodeStack push(WrapperElement element, int count, ElementDefinition definition, ElementDefinition type) { - NodeStack res = new NodeStack(element.isXml()); - res.parent = this; - res.element = element; - res.definition = definition; - if (element.isXml()) { - res.literalPath = getLiteralPath() + (element.getNamespace().equals(FormatUtilities.XHTML_NS) ? "/h:" : "/f:") + element.getName(); - if (count > -1) - res.literalPath = res.literalPath + "[" + Integer.toString(count) + "]"; - } else { - if (element.getName() == null) - res.literalPath = ""; - else - res.literalPath = getLiteralPath() + "/" + element.getName(); - if (count > -1) - res.literalPath = res.literalPath + "/" + Integer.toString(count); - } - res.logicalPaths = new ArrayList(); - if (type != null) { - // type will be bull if we on a stitching point of a contained resource, or if.... - res.type = type; - String t = tail(definition.getPath()); - for (String lp : getLogicalPaths()) { - res.logicalPaths.add(lp + "." + t); - if (t.endsWith("[x]")) - res.logicalPaths.add(lp + "." + t.substring(0, t.length() - 3) + type.getPath()); - } - res.logicalPaths.add(type.getPath()); - } else if (definition != null) { - for (String lp : getLogicalPaths()) - res.logicalPaths.add(lp + "." + element.getName()); - } else - res.logicalPaths.addAll(getLogicalPaths()); - // CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - // for (String lp : res.logicalPaths) - // b.append(lp); - // System.out.println(res.literalPath+" : "+b.toString()); - return res; - } - - private void setType(ElementDefinition type) { - this.type = type; - } - } - - public abstract class WrapperElement { - private StructureDefinition profile; - private ElementDefinition definition; - - - public StructureDefinition getProfile() { - return profile; - } - - public void setProfile(StructureDefinition profile) { - this.profile = profile; - } - - public ElementDefinition getDefinition() { - return definition; - } - - public void setDefinition(ElementDefinition definition) { - this.definition = definition; - } - - public abstract int col(); - - public abstract String getAttribute(String name); - - public abstract WrapperElement getFirstChild(); - - public abstract String getName(); - - public abstract WrapperElement getNamedChild(String name); - - public abstract void getNamedChildren(String name, List list); - - public abstract void getNamedChildrenWithWildcard(String name, List list); - - public abstract String getNamedChildValue(String name); - - public abstract String getNamespace(); - - public abstract WrapperElement getNextSibling(); - - public abstract String getResourceType(); - - public abstract String getText(); - - public abstract boolean hasAttribute(String name); - - public abstract boolean hasNamespace(String string); - - public abstract boolean hasProcessingInstruction(); - - public abstract boolean isXml(); - - public abstract int line(); - } - -} +package org.hl7.fhir.instance.validation; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; + +import org.hl7.fhir.exceptions.*; +import org.hl7.fhir.instance.formats.FormatUtilities; +import org.hl7.fhir.instance.model.*; +import org.hl7.fhir.instance.model.ElementDefinition.*; +import org.hl7.fhir.instance.model.Enumerations.BindingStrength; +import org.hl7.fhir.instance.model.StructureDefinition.*; +import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent; +import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.instance.utils.IWorkerContext.ValidationResult; +//import org.hl7.fhir.instance.utils.ProfileUtilities; +import org.hl7.fhir.instance.utils.*; +import org.hl7.fhir.instance.utils.IResourceValidator.BestPracticeWarningLevel; +import org.hl7.fhir.instance.utils.IResourceValidator.CheckDisplayOption; +import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.validation.ValidationMessage; +import org.hl7.fhir.utilities.validation.ValidationMessage.*; +import org.hl7.fhir.utilities.xml.XMLUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import com.google.gson.*; + + +/* + * todo: + * check urn's don't start oid: or uuid: + */ +public class InstanceValidator extends BaseValidator implements IResourceValidator { + + private class ElementDefinitionOutcome { + public ElementDefinitionOutcome(ElementDefinition ed) { + definition = ed; + } + public ElementDefinitionOutcome(ElementDefinition ed, TypeRefComponent tr) { + definition = ed; + typename = tr.getCode(); + if (tr.hasProfile()) + profile = tr.getProfile().get(0).getValue(); + } + private ElementDefinition definition; + private String typename; + private String profile; + } + + public class ResourceOnWrapper extends Resource { + private static final long serialVersionUID = 1L; + private IWorkerContext services; + private WrapperElement wrapper; + private List elementList; + private StructureDefinition profile; + private ElementDefinition definition; + private List childDefinitions; + + public ResourceOnWrapper(IWorkerContext services, WrapperElement wrapper, StructureDefinition profile) { + super(); + this.services = services; + this.wrapper = wrapper; + this.profile = profile; + this.definition = profile.getSnapshot().getElement().get(0); + } + + private ElementDefinitionOutcome getDefinition(String name) throws DefinitionException { + if (childDefinitions == null) + childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); + for (ElementDefinition ed : childDefinitions) { + String tail = ed.getPath().substring(ed.getPath().lastIndexOf('.')+1); + if (tail.equals(name)) { + return new ElementDefinitionOutcome(ed); + } + if (tail.endsWith("[x]") && tail.substring(0, tail.length()-3).equals(name.substring(0, tail.length()-3))) { + TypeRefComponent tr = getType(ed, name.substring(tail.length()-3)); + if (tr != null) + return new ElementDefinitionOutcome(ed, tr); + } + } + return null; + } + + private TypeRefComponent getType(ElementDefinition ed, String type) { + for (TypeRefComponent t : ed.getType()) { + if (t.getCode().equals(type)) + return t; + } + return null; + } + + @Override + public List listChildrenByName(String child_name) { + List list = new ArrayList(); + List children = new ArrayList(); + wrapper.getNamedChildren(child_name, children); + for (WrapperElement child : children) { + ElementDefinitionOutcome definition; + try { + definition = getDefinition(child.getName()); + } catch (Exception e) { + definition = null; + } + if (definition != null) { + TypeRefComponent tr = getType(definition.definition, "Resource"); + if (tr != null && wrapper.isXml()) // special case for DomainResource.contained and Bundle.entry + list.add(new BaseOnWrapper(services, child.getFirstChild(), profile, definition.definition, definition.typename, definition.profile)); + else + list.add(new BaseOnWrapper(services, child, profile, definition.definition, definition.typename, definition.profile)); + } + } + return list; + } + + @Override + public String fhirType() { + return wrapper.getResourceType(); + } + + @Override + public Resource copy() { + throw new Error("copy() is not implemented here"); + } + + + @Override + public ResourceType getResourceType() { + try { + return ResourceType.fromCode(fhirType()); + } catch (Exception e) { + return null; + } + } + + @Override + protected boolean isMetadataBased() { + return true; + } + + @Override + public String toString() { + return fhirType(); + } + } + + public class BaseOnWrapper extends Base { + private static final long serialVersionUID = 1L; + private IWorkerContext services; + private WrapperElement wrapper; + private List elementList; + private StructureDefinition profile; + private ElementDefinition definition; + private List childDefinitions; + private String typeName; + private String typeProfile; + + + public BaseOnWrapper(IWorkerContext services, WrapperElement wrapper, StructureDefinition profile, + ElementDefinition definition, String typeName, String typeProfile) { + super(); + this.services = services; + this.wrapper = wrapper; + this.profile = profile; + this.definition = definition; + this.typeName = typeName; + this.typeProfile = typeProfile; + } + + private ElementDefinitionOutcome getDefinition(String name) throws DefinitionException { + if (childDefinitions == null) + childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); + + if (childDefinitions.size() == 0) { + String pn = typeProfile; + if (Utilities.noString(pn) && !Utilities.noString(typeName)) + pn = "http://hl7.org/fhir/StructureDefinition/"+typeName; + if (Utilities.noString(pn) && definition.getType().size() == 1) { + if (definition.getType().get(0).getProfile().size() > 0) + pn = definition.getType().get(0).getProfile().get(0).getValue(); + else + pn = "http://hl7.org/fhir/StructureDefinition/"+ definition.getType().get(0).getCode(); + } + if (!Utilities.noString(pn)) { + StructureDefinition profile = services.fetchResource(StructureDefinition.class, pn); + if (profile != null) { + this.profile = profile; + childDefinitions = ProfileUtilities.getChildMap(profile, null, profile.getSnapshot().getElement().get(0).getPath(), null); + } + } + } + + + for (ElementDefinition ed : childDefinitions) { + String tail = ed.getPath().substring(ed.getPath().lastIndexOf('.')+1); + if (tail.equals(name)) { + return new ElementDefinitionOutcome(ed); + } + if (tail.endsWith("[x]") && name.length() > tail.length()-1 && tail.substring(0, tail.length()-3).equals(name.substring(0, tail.length()-3))) { + TypeRefComponent tr = getType(ed, name.substring(tail.length()-3)); + if (tr != null) + return new ElementDefinitionOutcome(ed, tr); + } + } + return null; + } + + private TypeRefComponent getType(ElementDefinition ed, String type) { + for (TypeRefComponent t : ed.getType()) { + if (t.getCode().equalsIgnoreCase(type)) + return t; + } + return null; + } + + @Override + public List listChildrenByName(String child_name) { + List list = new ArrayList(); + List children = new ArrayList(); + wrapper.getNamedChildrenWithWildcard(child_name, children); + for (WrapperElement child : children) { + ElementDefinitionOutcome definition; + try { + definition = getDefinition(child.getName()); + } catch (Exception e) { + definition = null; + } + if (definition != null) { + TypeRefComponent tr = getType(definition.definition, "Resource"); + if (tr != null && wrapper.isXml()) // special case for DomainResource.contained and Bundle.entry + list.add(new BaseOnWrapper(services, child.getFirstChild(), profile, definition.definition, definition.typename, definition.profile)); + else + list.add(new BaseOnWrapper(services, child, profile, definition.definition, definition.typename, definition.profile)); + } + } + return list; + } + + public boolean isPrimitive() { + String t = fhirType(); + return t.equalsIgnoreCase("boolean") || t.equalsIgnoreCase("integer") || t.equalsIgnoreCase("string") || t.equalsIgnoreCase("decimal") || t.equalsIgnoreCase("uri") || t.equalsIgnoreCase("base64Binary") || + t.equalsIgnoreCase("instant") || t.equalsIgnoreCase("date") || t.equalsIgnoreCase("uuid") || t.equalsIgnoreCase("id") || t.equalsIgnoreCase("xhtml") || t.equalsIgnoreCase("markdown") || + t.equalsIgnoreCase("dateTime") || t.equalsIgnoreCase("time") || t.equalsIgnoreCase("code") || t.equalsIgnoreCase("oid") || t.equalsIgnoreCase("id"); + } + + public String primitiveValue() { + return wrapper.getAttribute("value"); + } + + @Override + public String fhirType() { + if (!Utilities.noString(typeName)) + return typeName; + else + return definition.getType().get(0).getCode(); + } + + @Override + protected void listChildren(List result) { + throw new Error("not done yet"); + } + + @Override + protected boolean isMetadataBased() { + return true; + } + + public boolean equalsDeep(Base other) { + if (!super.equalsDeep(other) || !fhirType().equals(other.fhirType())) + return false; + + // make sure we have child definitions + try { + getDefinition("xxxx"); + List childList = childDefinitions; + // there's a problem here - we're going to iterate by the definition, where as equality should - probably - be + // based on the underlying definitions. is it worth getting them? it's kind of complicated.... + for (ElementDefinition ed : childList) { + String tail = tail(ed.getPath()); + List thisList = listChildrenByName(tail); + List otherList = other.listChildrenByName(tail); + if (!compareDeep(thisList, otherList, false)) + return false; + } + return true; + } catch (Exception e) { + return false;// because we can't decide + } + } + + @Override + public String toString() { + if (isPrimitive()) + return primitiveValue(); + else + return fhirType(); + } + } + + private boolean anyExtensionsAllowed; + + private BestPracticeWarningLevel bpWarnings; + // configuration items + private CheckDisplayOption checkDisplay; + private IWorkerContext context; + + private List extensionDomains = new ArrayList(); + + private IdStatus resourceIdRule; + + // used during the build process to keep the overall volume of messages down + private boolean suppressLoincSnomedMessages; + + public InstanceValidator(IWorkerContext theContext) { + super(); + this.context = theContext; + source = Source.InstanceValidator; + } + + private boolean allowUnknownExtension(String url) { + if (url.contains("example.org") || url.contains("acme.com") || url.contains("nema.org")) + return true; + for (String s : extensionDomains) + if (url.startsWith(s)) + return true; + return anyExtensionsAllowed; + } + + private void bpCheck(List errors, IssueType invalid, int line, int col, String literalPath, boolean test, String message) { + if (bpWarnings != null) { + switch (bpWarnings) { + case Error: + rule(errors, invalid, line, col, literalPath, test, message); + break; + case Warning: + warning(errors, invalid, line, col, literalPath, test, message); + break; + case Hint: + hint(errors, invalid, line, col, literalPath, test, message); + break; + default: // do nothing + } + } + } + + private boolean check(String v1, String v2) { + return v1 == null ? Utilities.noString(v1) : v1.equals(v2); + } + + private void checkAddress(List errors, String path, WrapperElement focus, Address fixed) { + checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); + checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); + checkFixedValue(errors, path + ".city", focus.getNamedChild("city"), fixed.getCityElement(), "city"); + checkFixedValue(errors, path + ".state", focus.getNamedChild("state"), fixed.getStateElement(), "state"); + checkFixedValue(errors, path + ".country", focus.getNamedChild("country"), fixed.getCountryElement(), "country"); + checkFixedValue(errors, path + ".zip", focus.getNamedChild("zip"), fixed.getPostalCodeElement(), "postalCode"); + + List lines = new ArrayList(); + focus.getNamedChildren("line", lines); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, lines.size() == fixed.getLine().size(), + "Expected " + Integer.toString(fixed.getLine().size()) + " but found " + Integer.toString(lines.size()) + " line elements")) { + for (int i = 0; i < lines.size(); i++) + checkFixedValue(errors, path + ".coding", lines.get(i), fixed.getLine().get(i), "coding"); + } + } + + private void checkAttachment(List errors, String path, WrapperElement focus, Attachment fixed) { + checkFixedValue(errors, path + ".contentType", focus.getNamedChild("contentType"), fixed.getContentTypeElement(), "contentType"); + checkFixedValue(errors, path + ".language", focus.getNamedChild("language"), fixed.getLanguageElement(), "language"); + checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), "data"); + checkFixedValue(errors, path + ".url", focus.getNamedChild("url"), fixed.getUrlElement(), "url"); + checkFixedValue(errors, path + ".size", focus.getNamedChild("size"), fixed.getSizeElement(), "size"); + checkFixedValue(errors, path + ".hash", focus.getNamedChild("hash"), fixed.getHashElement(), "hash"); + checkFixedValue(errors, path + ".title", focus.getNamedChild("title"), fixed.getTitleElement(), "title"); + } + + // public API + + private boolean checkCode(List errors, WrapperElement element, String path, String code, String system, String display) { + if (context.supportsSystem(system)) { + ValidationResult s = context.validateCode(system, code, display); + if (s == null || s.isOk()) + return true; + if (s.getSeverity() == IssueSeverity.INFORMATION) + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); + else if (s.getSeverity() == IssueSeverity.WARNING) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); + else + return rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, s == null, s.getMessage()); + return true; + } else if (system.startsWith("http://hl7.org/fhir")) { + if (system.equals("http://hl7.org/fhir/sid/icd-10")) + return true; // else don't check ICD-10 (for now) + else { + ValueSet vs = getValueSet(system); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, vs != null, "Unknown Code System " + system)) { + ConceptDefinitionComponent def = getCodeDefinition(vs, code); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, def != null, "Unknown Code (" + system + "#" + code + ")")) + return warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, display == null || display.equals(def.getDisplay()), "Display should be '" + def.getDisplay() + "'"); + } + return false; + } + } else if (system.startsWith("http://loinc.org")) { + return true; + } else if (system.startsWith("http://unitsofmeasure.org")) { + return true; + } else + return true; + } + + private void checkCodeableConcept(List errors, String path, WrapperElement focus, CodeableConcept fixed) { + checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); + List codings = new ArrayList(); + focus.getNamedChildren("coding", codings); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, codings.size() == fixed.getCoding().size(), + "Expected " + Integer.toString(fixed.getCoding().size()) + " but found " + Integer.toString(codings.size()) + " coding elements")) { + for (int i = 0; i < codings.size(); i++) + checkFixedValue(errors, path + ".coding", codings.get(i), fixed.getCoding().get(i), "coding"); + } + } + + private void checkCodeableConcept(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition theElementCntext) { + if (theElementCntext != null && theElementCntext.hasBinding()) { + ElementDefinitionBindingComponent binding = theElementCntext.getBinding(); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, binding != null, "Binding for " + path + " missing (cc)")) { + if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { + ValueSet valueset = resolveBindingReference(binding.getValueSet()); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, valueset != null, "ValueSet " + describeReference(binding.getValueSet()) + " not found")) { + try { + CodeableConcept cc = readAsCodeableConcept(element); + if (!cc.hasCoding()) { + if (binding.getStrength() == BindingStrength.REQUIRED) + rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "No code provided, and a code is required from the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()); + else if (binding.getStrength() == BindingStrength.EXTENSIBLE) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "No code provided, and a code should be provided from the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()); + } else { + ValidationResult vr = context.validateCode(cc, valueset); + if (!vr.isOk()) { + if (binding.getStrength() == BindingStrength.REQUIRED) + rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl()+", and a code from this value set is required"); + else if (binding.getStrength() == BindingStrength.EXTENSIBLE) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); + else if (binding.getStrength() == BindingStrength.PREFERRED) + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is recommended to come from this value set)"); + } + } + } catch (Exception e) { + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept"); + } + } + } else if (binding.hasValueSet()) { + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding by URI reference cannot be checked"); + } else { + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding for path " + path + " has no source, so can't be checked"); + } + } + } + } + + private CodeableConcept readAsCodeableConcept(WrapperElement element) { + CodeableConcept cc = new CodeableConcept(); + List list = new ArrayList(); + element.getNamedChildren("coding", list); + for (WrapperElement item : list) + cc.addCoding(readAsCoding(item)); + cc.setText(element.getNamedChildValue("text")); + return cc; + } + + private Coding readAsCoding(WrapperElement item) { + Coding c = new Coding(); + c.setSystem(item.getNamedChildValue("system")); + c.setVersion(item.getNamedChildValue("version")); + c.setCode(item.getNamedChildValue("code")); + c.setDisplay(item.getNamedChildValue("display")); + return c; + } + + private void checkCoding(List errors, String path, WrapperElement focus, Coding fixed) { + checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); + checkFixedValue(errors, path + ".code", focus.getNamedChild("code"), fixed.getCodeElement(), "code"); + checkFixedValue(errors, path + ".display", focus.getNamedChild("display"), fixed.getDisplayElement(), "display"); + checkFixedValue(errors, path + ".userSelected", focus.getNamedChild("userSelected"), fixed.getUserSelectedElement(), "userSelected"); + } + + private void checkCoding(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition theElementCntext, boolean inCodeableConcept) { + String code = element.getNamedChildValue("code"); + String system = element.getNamedChildValue("system"); + String display = element.getNamedChildValue("display"); + rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(system), "Coding.system must be an absolute reference, not a local reference"); + + if (system != null && code != null) { + if (checkCode(errors, element, path, code, system, display)) + if (theElementCntext != null && theElementCntext.getBinding() != null) { + ElementDefinitionBindingComponent binding = theElementCntext.getBinding(); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, binding != null, "Binding for " + path + " missing")) { + if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { + ValueSet valueset = resolveBindingReference(binding.getValueSet()); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, valueset != null, "ValueSet " + describeReference(binding.getValueSet()) + " not found")) { + try { + Coding c = readAsCoding(element); + ValidationResult vr = context.validateCode(c, valueset); + if (!vr.isOk()) { + if (binding.getStrength() == BindingStrength.REQUIRED) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is required from this value set)"); + else if (binding.getStrength() == BindingStrength.EXTENSIBLE) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); + else if (binding.getStrength() == BindingStrength.PREFERRED) + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code is recommended to come from this value set)"); + } + } catch (Exception e) { + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept"); + } + } + } else if (binding.hasValueSet()) { + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding by URI reference cannot be checked"); + } else if (!inCodeableConcept) { + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding for path " + path + " has no source, so can't be checked"); + } + } + } + } + } + + private void checkContactPoint(List errors, String path, WrapperElement focus, ContactPoint fixed) { + checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); + checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); + checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); + checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); + + } + + private void checkDeclaredProfiles(List errors, WrapperElement resource, WrapperElement element, NodeStack stack) throws FHIRException { + WrapperElement meta = element.getNamedChild("meta"); + if (meta != null) { + List profiles = new ArrayList(); + meta.getNamedChildren("profile", profiles); + int i = 0; + for (WrapperElement profile : profiles) { + String ref = profile.getAttribute("value"); + String p = stack.addToLiteralPath("meta", "profile", ":" + Integer.toString(i)); + if (rule(errors, IssueType.INVALID, element.line(), element.col(), p, !Utilities.noString(ref), "StructureDefinition reference invalid")) { + StructureDefinition pr = context.fetchResource(StructureDefinition.class, ref); + if (warning(errors, IssueType.INVALID, element.line(), element.col(), p, pr != null, "StructureDefinition reference \"{0}\" could not be resolved", ref)) { + if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), p, pr.hasSnapshot(), + "StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided")) { + validateElement(errors, pr, pr.getSnapshot().getElement().get(0), null, null, resource, element, element.getName(), stack, false); + } + } + i++; + } + } + } + } + + private StructureDefinition checkExtension(List errors, String path, WrapperElement element, ElementDefinition def, StructureDefinition profile, NodeStack stack) + { + String url = element.getAttribute("url"); + boolean isModifier = element.getName().equals("modifierExtension"); + + StructureDefinition ex = context.fetchResource(StructureDefinition.class, url); + if (ex == null) { + if (!rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, allowUnknownExtension(url), "The extension " + url + " is unknown, and not allowed here")) + warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, allowUnknownExtension(url), "Unknown extension " + url); + } else { + if (def.getIsModifier()) + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), + "Extension modifier mismatch: the extension element is labelled as a modifier, but the underlying extension is not"); + else + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", !ex.getSnapshot().getElement().get(0).getIsModifier(), + "Extension modifier mismatch: the extension element is not labelled as a modifier, but the underlying extension is"); + + // two questions + // 1. can this extension be used here? + checkExtensionContext(errors, element, /* path+"[url='"+url+"']", */ ex, stack, ex.getUrl()); + + if (isModifier) + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), + "The Extension '" + url + "' must be used as a modifierExtension"); + else + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", !ex.getSnapshot().getElement().get(0).getIsModifier(), + "The Extension '" + url + "' must not be used as an extension (it's a modifierExtension)"); + + // 2. is the content of the extension valid? + + } + return ex; + } + + private boolean checkExtensionContext(List errors, WrapperElement element, StructureDefinition definition, NodeStack stack, String extensionParent) { + String extUrl = definition.getUrl(); + CommaSeparatedStringBuilder p = new CommaSeparatedStringBuilder(); + for (String lp : stack.getLogicalPaths()) + p.append(lp); + if (definition.getContextType() == ExtensionContext.DATATYPE) { + boolean ok = false; + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (StringType ct : definition.getContext()) { + b.append(ct.getValue()); + if (ct.getValue().equals("*") || stack.getLogicalPaths().contains(ct.getValue() + ".extension")) + ok = true; + } + return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, + "The extension " + extUrl + " is not allowed to be used on the logical path set [" + p.toString() + "] (allowed: datatype=" + b.toString() + ")"); + } else if (definition.getContextType() == ExtensionContext.EXTENSION) { + boolean ok = false; + for (StringType ct : definition.getContext()) + if (ct.getValue().equals("*") || ct.getValue().equals(extensionParent)) + ok = true; + return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, + "The extension " + extUrl + " is not allowed to be used with the extension '" + extensionParent + "'"); + } else if (definition.getContextType() == ExtensionContext.MAPPING) { + throw new Error("Not handled yet (extensionContext)"); + } else if (definition.getContextType() == ExtensionContext.RESOURCE) { + boolean ok = false; + // String simplePath = container.getPath(); + // System.out.println(simplePath); + // if (effetive.endsWith(".extension") || simplePath.endsWith(".modifierExtension")) + // simplePath = simplePath.substring(0, simplePath.lastIndexOf('.')); + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (StringType ct : definition.getContext()) { + String c = ct.getValue(); + b.append(c); + if (c.equals("*") || stack.getLogicalPaths().contains(c + ".extension") || (c.startsWith("@") && stack.getLogicalPaths().contains(c.substring(1) + ".extension"))) + ; + ok = true; + } + return rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), ok, + "The extension " + extUrl + " is not allowed to be used on the logical path set " + p.toString() + " (allowed: resource=" + b.toString() + ")"); + } else + throw new Error("Unknown context type"); + } + // + // private String simplifyPath(String path) { + // String s = path.replace("/f:", "."); + // while (s.contains("[")) + // s = s.substring(0, s.indexOf("["))+s.substring(s.indexOf("]")+1); + // String[] parts = s.split("\\."); + // int i = 0; + // while (i < parts.length && !context.getProfiles().containsKey(parts[i].toLowerCase())) + // i++; + // if (i >= parts.length) + // throw new Error("Unable to process part "+path); + // int j = parts.length - 1; + // while (j > 0 && (parts[j].equals("extension") || parts[j].equals("modifierExtension"))) + // j--; + // StringBuilder b = new StringBuilder(); + // boolean first = true; + // for (int k = i; k <= j; k++) { + // if (k == j || !parts[k].equals(parts[k+1])) { + // if (first) + // first = false; + // else + // b.append("."); + // b.append(parts[k]); + // } + // } + // return b.toString(); + // } + // + + private void checkFixedValue(List errors, String path, WrapperElement focus, org.hl7.fhir.instance.model.Element fixed, String propName) { + if (fixed == null && focus == null) + ; // this is all good + else if (fixed == null && focus != null) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, false, "Unexpected element " + focus.getName()); + else if (fixed != null && focus == null) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, false, "Mising element " + propName); + else { + String value = focus.getAttribute("value"); + if (fixed instanceof org.hl7.fhir.instance.model.BooleanType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.BooleanType) fixed).asStringValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.BooleanType) fixed).asStringValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.IntegerType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.IntegerType) fixed).asStringValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.IntegerType) fixed).asStringValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.DecimalType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DecimalType) fixed).asStringValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DecimalType) fixed).asStringValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.Base64BinaryType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.Base64BinaryType) fixed).asStringValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.Base64BinaryType) fixed).asStringValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.InstantType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.InstantType) fixed).getValue().toString(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.InstantType) fixed).asStringValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.StringType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.StringType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.StringType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.UriType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.UriType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.UriType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.DateType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DateType) fixed).getValue().toString(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DateType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.DateTimeType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.DateTimeType) fixed).getValue().toString(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.DateTimeType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.OidType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.OidType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.OidType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.UuidType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.UuidType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.UuidType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.CodeType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.CodeType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.CodeType) fixed).getValue() + "'"); + else if (fixed instanceof org.hl7.fhir.instance.model.IdType) + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, check(((org.hl7.fhir.instance.model.IdType) fixed).getValue(), value), + "Value is '" + value + "' but must be '" + ((org.hl7.fhir.instance.model.IdType) fixed).getValue() + "'"); + else if (fixed instanceof Quantity) + checkQuantity(errors, path, focus, (Quantity) fixed); + else if (fixed instanceof Address) + checkAddress(errors, path, focus, (Address) fixed); + else if (fixed instanceof ContactPoint) + checkContactPoint(errors, path, focus, (ContactPoint) fixed); + else if (fixed instanceof Attachment) + checkAttachment(errors, path, focus, (Attachment) fixed); + else if (fixed instanceof Identifier) + checkIdentifier(errors, path, focus, (Identifier) fixed); + else if (fixed instanceof Coding) + checkCoding(errors, path, focus, (Coding) fixed); + else if (fixed instanceof HumanName) + checkHumanName(errors, path, focus, (HumanName) fixed); + else if (fixed instanceof CodeableConcept) + checkCodeableConcept(errors, path, focus, (CodeableConcept) fixed); + else if (fixed instanceof Timing) + checkTiming(errors, path, focus, (Timing) fixed); + else if (fixed instanceof Period) + checkPeriod(errors, path, focus, (Period) fixed); + else if (fixed instanceof Range) + checkRange(errors, path, focus, (Range) fixed); + else if (fixed instanceof Ratio) + checkRatio(errors, path, focus, (Ratio) fixed); + else if (fixed instanceof SampledData) + checkSampledData(errors, path, focus, (SampledData) fixed); + + else + rule(errors, IssueType.EXCEPTION, focus.line(), focus.col(), path, false, "Unhandled fixed value type " + fixed.getClass().getName()); + List extensions = new ArrayList(); + focus.getNamedChildren("extension", extensions); + if (fixed.getExtension().size() == 0) { + rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, extensions.size() == 0, "No extensions allowed"); + } else if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, extensions.size() == fixed.getExtension().size(), + "Extensions count mismatch: expected " + Integer.toString(fixed.getExtension().size()) + " but found " + Integer.toString(extensions.size()))) { + for (Extension e : fixed.getExtension()) { + WrapperElement ex = getExtensionByUrl(extensions, e.getUrl()); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, ex != null, "Extension count mismatch: unable to find extension: " + e.getUrl())) { + checkFixedValue(errors, path, ex.getFirstChild().getNextSibling(), e.getValue(), "extension.value"); + } + } + } + } + } + + private void checkForProcessingInstruction(List errors, Document document) { + Node node = document.getFirstChild(); + while (node != null) { + rule(errors, IssueType.INVALID, -1, -1, "(document)", node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE, "No processing instructions allowed in resources"); + node = node.getNextSibling(); + } + } + + private void checkHumanName(List errors, String path, WrapperElement focus, HumanName fixed) { + checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); + checkFixedValue(errors, path + ".text", focus.getNamedChild("text"), fixed.getTextElement(), "text"); + checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); + + List parts = new ArrayList(); + focus.getNamedChildren("family", parts); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getFamily().size(), + "Expected " + Integer.toString(fixed.getFamily().size()) + " but found " + Integer.toString(parts.size()) + " family elements")) { + for (int i = 0; i < parts.size(); i++) + checkFixedValue(errors, path + ".family", parts.get(i), fixed.getFamily().get(i), "family"); + } + focus.getNamedChildren("given", parts); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getGiven().size(), + "Expected " + Integer.toString(fixed.getGiven().size()) + " but found " + Integer.toString(parts.size()) + " given elements")) { + for (int i = 0; i < parts.size(); i++) + checkFixedValue(errors, path + ".given", parts.get(i), fixed.getGiven().get(i), "given"); + } + focus.getNamedChildren("prefix", parts); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getPrefix().size(), + "Expected " + Integer.toString(fixed.getPrefix().size()) + " but found " + Integer.toString(parts.size()) + " prefix elements")) { + for (int i = 0; i < parts.size(); i++) + checkFixedValue(errors, path + ".prefix", parts.get(i), fixed.getPrefix().get(i), "prefix"); + } + focus.getNamedChildren("suffix", parts); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, parts.size() == fixed.getSuffix().size(), + "Expected " + Integer.toString(fixed.getSuffix().size()) + " but found " + Integer.toString(parts.size()) + " suffix elements")) { + for (int i = 0; i < parts.size(); i++) + checkFixedValue(errors, path + ".suffix", parts.get(i), fixed.getSuffix().get(i), "suffix"); + } + } + + private void checkIdentifier(List errors, String path, WrapperElement element, ElementDefinition context) { + String system = element.getNamedChildValue("system"); + rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(system), "Identifier.system must be an absolute reference, not a local reference"); + } + + private void checkIdentifier(List errors, String path, WrapperElement focus, Identifier fixed) { + checkFixedValue(errors, path + ".use", focus.getNamedChild("use"), fixed.getUseElement(), "use"); + checkFixedValue(errors, path + ".type", focus.getNamedChild("type"), fixed.getType(), "type"); + checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); + checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); + checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriod(), "period"); + checkFixedValue(errors, path + ".assigner", focus.getNamedChild("assigner"), fixed.getAssigner(), "assigner"); + } + + private void checkPeriod(List errors, String path, WrapperElement focus, Period fixed) { + checkFixedValue(errors, path + ".start", focus.getNamedChild("start"), fixed.getStartElement(), "start"); + checkFixedValue(errors, path + ".end", focus.getNamedChild("end"), fixed.getEndElement(), "end"); + } + + private void checkPrimitive(List errors, String path, String type, ElementDefinition context, WrapperElement e) { + if (type.equals("uri")) { + rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.getAttribute("value").startsWith("oid:"), "URI values cannot start with oid:"); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.getAttribute("value").startsWith("uuid:"), "URI values cannot start with uuid:"); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").equals(e.getAttribute("value").trim()), "URI values cannot have leading or trailing whitespace"); + } + if (!type.equalsIgnoreCase("string") && e.hasAttribute("value")) { + if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").length() > 0, "@value cannot be empty")) { + warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.getAttribute("value").trim().equals(e.getAttribute("value")), "value should not start or finish with whitespace"); + } + } + if (type.equals("dateTime")) { + rule(errors, IssueType.INVALID, e.line(), e.col(), path, yearIsValid(e.getAttribute("value")), "The value '" + e.getAttribute("value") + "' does not have a valid year"); + boolean ok = e.getAttribute("value").matches("-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)?)?)?"); + if (!ok) + rule(errors, IssueType.INVALID, e.line(), e.col(), path,ok, "'"+e.getAttribute("value")+"' is not a valid date time"); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, !hasTime(e.getAttribute("value")) || hasTimeZone(e.getAttribute("value")), "if a date has a time, it must have a timezone"); + + } + if (type.equals("instant")) { + rule(errors, IssueType.INVALID, e.line(), e.col(), path, + e.getAttribute("value").matches("-?[0-9]{4}-(0[1-9]|1[0-2])-(0[0-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))"), + "The instant '" + e.getAttribute("value") + "' is not valid (by regex)"); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, yearIsValid(e.getAttribute("value")), "The value '" + e.getAttribute("value") + "' does not have a valid year"); + } + + if (type.equals("code")) { + // Technically, a code is restricted to string which has at least one character and no leading or trailing whitespace, and where there is no whitespace + // other than single spaces in the contents + rule(errors, IssueType.INVALID, e.line(), e.col(), path, passesCodeWhitespaceRules(e.getAttribute("value")), "The code '" + e.getAttribute("value") + "' is not valid (whitespace rules)"); + } + + if (context.hasBinding()) { + checkPrimitiveBinding(errors, path, type, context, e); + } + // for nothing to check + } + + // note that we don't check the type here; it could be string, uri or code. + private void checkPrimitiveBinding(List errors, String path, String type, ElementDefinition elementContext, WrapperElement element) { + if (!element.hasAttribute("value")) + return; + + String value = element.getAttribute("value"); + // System.out.println("check "+value+" in "+path); + + // firstly, resolve the value set + ElementDefinitionBindingComponent binding = elementContext.getBinding(); + if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) { + ValueSet vs = resolveBindingReference(binding.getValueSet()); + if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, vs != null, "ValueSet {0} not found", describeReference(binding.getValueSet()))) { + ValidationResult vr = context.validateCode(null, value, null, vs); + if (!vr.isOk()) { + if (binding.getStrength() == BindingStrength.REQUIRED) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is required from this value set)"); + else if (binding.getStrength() == BindingStrength.EXTENSIBLE) + warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); + else if (binding.getStrength() == BindingStrength.PREFERRED) + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is recommended to come from this value set)"); + } + } + } else + hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Binding has no source, so can't be checked"); + } + + private void checkQuantity(List errors, String path, WrapperElement focus, Quantity fixed) { + checkFixedValue(errors, path + ".value", focus.getNamedChild("value"), fixed.getValueElement(), "value"); + checkFixedValue(errors, path + ".comparator", focus.getNamedChild("comparator"), fixed.getComparatorElement(), "comparator"); + checkFixedValue(errors, path + ".units", focus.getNamedChild("unit"), fixed.getUnitElement(), "units"); + checkFixedValue(errors, path + ".system", focus.getNamedChild("system"), fixed.getSystemElement(), "system"); + checkFixedValue(errors, path + ".code", focus.getNamedChild("code"), fixed.getCodeElement(), "code"); + } + + // implementation + + private void checkRange(List errors, String path, WrapperElement focus, Range fixed) { + checkFixedValue(errors, path + ".low", focus.getNamedChild("low"), fixed.getLow(), "low"); + checkFixedValue(errors, path + ".high", focus.getNamedChild("high"), fixed.getHigh(), "high"); + + } + + private void checkRatio(List errors, String path, WrapperElement focus, Ratio fixed) { + checkFixedValue(errors, path + ".numerator", focus.getNamedChild("numerator"), fixed.getNumerator(), "numerator"); + checkFixedValue(errors, path + ".denominator", focus.getNamedChild("denominator"), fixed.getDenominator(), "denominator"); + } + + private void checkReference(List errors, String path, WrapperElement element, StructureDefinition profile, ElementDefinition container, String parentType, NodeStack stack) + { + String ref = element.getNamedChildValue("reference"); + if (Utilities.noString(ref)) { + // todo - what should we do in this case? + hint(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), + "A Reference without an actual reference should have a display"); + return; + } + + WrapperElement we = resolve(ref, stack); + String ft; + if (we != null) + ft = we.getResourceType(); + else + ft = tryParse(ref); + if (hint(errors, IssueType.STRUCTURE, element.line(), element.col(), path, ft != null, "Unable to determine type of target resource")) { + boolean ok = false; + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (TypeRefComponent type : container.getType()) { + if (!ok && type.getCode().equals("Reference")) { + // we validate as much as we can. First, can we infer a type from the profile? + if (!type.hasProfile() || type.getProfile().get(0).getValue().equals("http://hl7.org/fhir/StructureDefinition/Resource")) + ok = true; + else { + String pr = type.getProfile().get(0).getValue(); + + String bt = getBaseType(profile, pr); + if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, bt != null, "Unable to resolve the profile reference '" + pr + "'")) { + b.append(bt); + ok = bt.equals(ft); + } else + ok = true; // suppress following check + } + } + if (!ok && type.getCode().equals("*")) { + ok = true; // can refer to anything + } + } + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, ok, "Invalid Resource target type. Found " + ft + ", but expected one of (" + b.toString() + ")"); + } + } + + private String checkResourceType(String type) { + if (context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + type) != null) + return type; + else + return null; + } + + private void checkSampledData(List errors, String path, WrapperElement focus, SampledData fixed) { + checkFixedValue(errors, path + ".origin", focus.getNamedChild("origin"), fixed.getOrigin(), "origin"); + checkFixedValue(errors, path + ".period", focus.getNamedChild("period"), fixed.getPeriodElement(), "period"); + checkFixedValue(errors, path + ".factor", focus.getNamedChild("factor"), fixed.getFactorElement(), "factor"); + checkFixedValue(errors, path + ".lowerLimit", focus.getNamedChild("lowerLimit"), fixed.getLowerLimitElement(), "lowerLimit"); + checkFixedValue(errors, path + ".upperLimit", focus.getNamedChild("upperLimit"), fixed.getUpperLimitElement(), "upperLimit"); + checkFixedValue(errors, path + ".dimensions", focus.getNamedChild("dimensions"), fixed.getDimensionsElement(), "dimensions"); + checkFixedValue(errors, path + ".data", focus.getNamedChild("data"), fixed.getDataElement(), "data"); + } + + private void checkTiming(List errors, String path, WrapperElement focus, Timing fixed) { + checkFixedValue(errors, path + ".repeat", focus.getNamedChild("repeat"), fixed.getRepeat(), "value"); + + List events = new ArrayList(); + focus.getNamedChildren("event", events); + if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, events.size() == fixed.getEvent().size(), + "Expected " + Integer.toString(fixed.getEvent().size()) + " but found " + Integer.toString(events.size()) + " event elements")) { + for (int i = 0; i < events.size(); i++) + checkFixedValue(errors, path + ".event", events.get(i), fixed.getEvent().get(i), "event"); + } + } + + private boolean codeinExpansion(ValueSetExpansionContainsComponent cnt, String system, String code) { + for (ValueSetExpansionContainsComponent c : cnt.getContains()) { + if (code.equals(c.getCode()) && system.equals(c.getSystem().toString())) + return true; + if (codeinExpansion(c, system, code)) + return true; + } + return false; + } + + private boolean codeInExpansion(ValueSet vs, String system, String code) { + for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { + if (code.equals(c.getCode()) && (system == null || system.equals(c.getSystem()))) + return true; + if (codeinExpansion(c, system, code)) + return true; + } + return false; + } + + private String describeReference(Type reference) { + if (reference == null) + return "null"; + if (reference instanceof UriType) + return ((UriType) reference).getValue(); + if (reference instanceof Reference) + return ((Reference) reference).getReference(); + return "??"; + } + + private String describeTypes(List types) { + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (TypeRefComponent t : types) { + b.append(t.getCode()); + } + return b.toString(); + } + + private boolean empty(WrapperElement element) { + if (element.hasAttribute("value")) + return false; + if (element.hasAttribute("xml:id")) + return false; + WrapperElement child = element.getFirstChild(); + while (child != null) { + if (!child.isXml() || FormatUtilities.FHIR_NS.equals(child.getNamespace())) { + return false; + } + child = child.getNextSibling(); + } + return true; + } + + private ElementDefinition findElement(StructureDefinition profile, String name) { + for (ElementDefinition c : profile.getSnapshot().getElement()) { + if (c.getPath().equals(name)) { + return c; + } + } + return null; + } + + private String genFullUrl(String bundleBase, String entryBase, String type, String id) { + String base = Utilities.noString(entryBase) ? bundleBase : entryBase; + if (Utilities.noString(base)) { + return type + "/" + id; + } else if ("urn:uuid".equals(base) || "urn:oid".equals(base)) + return base + id; + else + return Utilities.appendSlash(base) + type + "/" + id; + } + + public BestPracticeWarningLevel getBasePracticeWarningLevel() { + return bpWarnings; + } + + private String getBaseType(StructureDefinition profile, String pr) { + // if (pr.startsWith("http://hl7.org/fhir/StructureDefinition/")) { + // // this just has to be a base type + // return pr.substring(40); + // } else { + StructureDefinition p = resolveProfile(profile, pr); + if (p == null) + return null; + else if (p.getKind() == StructureDefinitionKind.RESOURCE) + return p.getSnapshot().getElement().get(0).getPath(); + else + return p.getSnapshot().getElement().get(0).getType().get(0).getCode(); + // } + } + + @Override + public CheckDisplayOption getCheckDisplay() { + return checkDisplay; + } + + // private String findProfileTag(WrapperElement element) { + // String uri = null; + // List list = new ArrayList(); + // element.getNamedChildren("category", list); + // for (WrapperElement c : list) { + // if ("http://hl7.org/fhir/tag/profile".equals(c.getAttribute("scheme"))) { + // uri = c.getAttribute("term"); + // } + // } + // return uri; + // } + + private ConceptDefinitionComponent getCodeDefinition(ConceptDefinitionComponent c, String code) { + if (code.equals(c.getCode())) + return c; + for (ConceptDefinitionComponent g : c.getConcept()) { + ConceptDefinitionComponent r = getCodeDefinition(g, code); + if (r != null) + return r; + } + return null; + } + + private ConceptDefinitionComponent getCodeDefinition(ValueSet vs, String code) { + for (ConceptDefinitionComponent c : vs.getCodeSystem().getConcept()) { + ConceptDefinitionComponent r = getCodeDefinition(c, code); + if (r != null) + return r; + } + return null; + } + + private WrapperElement getContainedById(WrapperElement container, String id) { + List contained = new ArrayList(); + container.getNamedChildren("contained", contained); + for (WrapperElement we : contained) { + WrapperElement res = we.isXml() ? we.getFirstChild() : we; + if (id.equals(res.getNamedChildValue("id"))) + return res; + } + return null; + } + + public IWorkerContext getContext() { + return context; + } + + private ElementDefinition getCriteriaForDiscriminator(String path, ElementDefinition ed, String discriminator, StructureDefinition profile) throws DefinitionException { + List childDefinitions = ProfileUtilities.getChildMap(profile, ed); + List snapshot = null; + if (childDefinitions.isEmpty()) { + // going to look at the type + if (ed.getType().size() == 0) + throw new DefinitionException("Error in profile for " + path + " no children, no type"); + if (ed.getType().size() > 1) + throw new DefinitionException("Error in profile for " + path + " multiple types defined in slice discriminator"); + StructureDefinition type; + if (ed.getType().get(0).hasProfile()) { + // need to do some special processing for reference here... + if (ed.getType().get(0).getCode().equals("Reference")) + discriminator = discriminator.substring(discriminator.indexOf(".")+1); + type = context.fetchResource(StructureDefinition.class, ed.getType().get(0).getProfile().get(0).getValue()); + } else + type = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + ed.getType().get(0).getCode()); + snapshot = type.getSnapshot().getElement(); + ed = snapshot.get(0); + } else { + snapshot = profile.getSnapshot().getElement(); + } + String originalPath = ed.getPath(); + String goal = originalPath + "." + discriminator; + + int index = snapshot.indexOf(ed); + assert(index > -1); + index++; + while (index < snapshot.size() && !snapshot.get(index).getPath().equals(originalPath)) { + if (snapshot.get(index).getPath().equals(goal)) + return snapshot.get(index); + index++; + } + throw new Error("Unable to find discriminator definition for " + goal + " in " + discriminator + " at " + path); + } + + private WrapperElement getExtensionByUrl(List extensions, String urlSimple) { + for (WrapperElement e : extensions) { + if (urlSimple.equals(e.getNamedChildValue("url"))) + return e; + } + return null; + } + + public List getExtensionDomains() { + return extensionDomains; + } + + private WrapperElement getFromBundle(WrapperElement bundle, String ref) { + List entries = new ArrayList(); + bundle.getNamedChildren("entry", entries); + for (WrapperElement we : entries) { + WrapperElement res = we.getNamedChild("resource").getFirstChild(); + if (res != null) { + String url = genFullUrl(bundle.getNamedChildValue("base"), we.getNamedChildValue("base"), res.getName(), res.getNamedChildValue("id")); + if (url.endsWith(ref)) + return res; + } + } + return null; + } + + private StructureDefinition getProfileForType(String type) { + return context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + type); + } + + private Element getValueForDiscriminator(WrapperElement element, String discriminator, ElementDefinition criteria) { + // throw new Error("validation of slices not done yet"); + return null; + } + + private ValueSet getValueSet(String system) { + return context.fetchCodeSystem(system); + } + + private boolean hasTime(String fmt) { + return fmt.contains("T"); + } + + private boolean hasTimeZone(String fmt) { + return fmt.length() > 10 && (fmt.substring(10).contains("-") || fmt.substring(10).contains("+") || fmt.substring(10).contains("Z")); + } + + private boolean isAbsolute(String uri) { + return Utilities.noString(uri) || uri.startsWith("http:") || uri.startsWith("https:") || uri.startsWith("urn:uuid:") || uri.startsWith("urn:oid:") || uri.startsWith("urn:ietf:") + || uri.startsWith("urn:iso:") || isValidFHIRUrn(uri); + } + + private boolean isValidFHIRUrn(String uri) { + return (uri.equals("urn:x-fhir:uk:id:nhs-number")); + } + + public boolean isAnyExtensionsAllowed() { + return anyExtensionsAllowed; + } + + private boolean isParametersEntry(String path) { + String[] parts = path.split("\\/"); + if (path.startsWith("/f:")) + return parts.length == 4 && parts[parts.length-3].equals("f:Parameters") && parts[parts.length-2].startsWith("f:parameter") && parts[parts.length-1].startsWith("f:resource"); + else + return parts.length == 4 && parts[parts.length-3].equals("Parameters") && parts[parts.length-2].startsWith("parameter") && parts[parts.length-1].startsWith("resource"); + } + + private boolean isBundleEntry(String path) { + String[] parts = path.split("\\/"); + if (path.startsWith("/f:")) + return parts.length > 2 && parts[parts.length - 1].startsWith("f:resource") && (parts[parts.length - 2].equals("f:entry") || parts[parts.length - 2].startsWith("f:entry[")); + else + return parts.length > 2 && parts[parts.length - 1].equals("resource") && ((parts.length > 2 && parts[parts.length - 3].equals("entry")) || parts[parts.length - 2].equals("entry")); + } + + private boolean isPrimitiveType(String type) { + return type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("string") || type.equalsIgnoreCase("decimal") || type.equalsIgnoreCase("uri") + || type.equalsIgnoreCase("base64Binary") || type.equalsIgnoreCase("instant") || type.equalsIgnoreCase("date") || type.equalsIgnoreCase("uuid") || type.equalsIgnoreCase("id") + || type.equalsIgnoreCase("xhtml") || type.equalsIgnoreCase("markdown") || type.equalsIgnoreCase("dateTime") || type.equalsIgnoreCase("time") || type.equalsIgnoreCase("code") + || type.equalsIgnoreCase("oid") || type.equalsIgnoreCase("id"); + } + + + + public boolean isSuppressLoincSnomedMessages() { + return suppressLoincSnomedMessages; + } + + private boolean nameMatches(String name, String tail) { + if (tail.endsWith("[x]")) + return name.startsWith(tail.substring(0, tail.length() - 3)); + else + return (name.equals(tail)); + } + + // private String mergePath(String path1, String path2) { + // // path1 is xpath path + // // path2 is dotted path + // String[] parts = path2.split("\\."); + // StringBuilder b = new StringBuilder(path1); + // for (int i = 1; i < parts.length -1; i++) + // b.append("/f:"+parts[i]); + // return b.toString(); + // } + + private boolean passesCodeWhitespaceRules(String v) { + if (!v.trim().equals(v)) + return false; + boolean lastWasSpace = true; + for (char c : v.toCharArray()) { + if (c == ' ') { + if (lastWasSpace) + return false; + else + lastWasSpace = true; + } else if (Character.isWhitespace(c)) + return false; + else + lastWasSpace = false; + } + return true; + } + + private WrapperElement resolve(String ref, NodeStack stack) { + if (ref.startsWith("#")) { + // work back through the contained list. + // really, there should only be one level for this (contained resources cannot contain + // contained resources), but we'll leave that to some other code to worry about + while (stack != null && stack.getElement() != null) { + WrapperElement res = getContainedById(stack.getElement(), ref.substring(1)); + if (res != null) + return res; + stack = stack.parent; + } + return null; + } else { + // work back through the contained list - if any of them are bundles, try to resolve + // the resource in the bundle + while (stack != null && stack.getElement() != null) { + if ("Bundle".equals(stack.getElement().getResourceType())) { + WrapperElement res = getFromBundle(stack.getElement(), ref.substring(1)); + if (res != null) + return res; + } + stack = stack.parent; + } + + // todo: consult the external host for resolution + return null; + + } + } + + private ValueSet resolveBindingReference(Type reference) { + if (reference instanceof UriType) + return context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString()); + else if (reference instanceof Reference) + return context.fetchResource(ValueSet.class, ((Reference) reference).getReference()); + else + return null; + } + + private WrapperElement resolveInBundle(List entries, String ref, String fullUrl, String type, String id) { + if (Utilities.isAbsoluteUrl(ref)) { + // if the reference is absolute, then you resolve by fullUrl. No other thinking is required. + for (WrapperElement entry : entries) { + String fu = entry.getNamedChildValue("fullUrl"); + if (ref.equals(fu)) + return entry; + } + return null; + } else { + // split into base, type, and id + String u = null; + if (fullUrl != null && fullUrl.endsWith(type+"/"+id)) + // fullUrl = complex + u = fullUrl.substring((type+"/"+id).length())+ref; + String[] parts = ref.split("\\/"); + if (parts.length >= 2) { + String t = parts[0]; + String i = parts[1]; + for (WrapperElement entry : entries) { + String fu = entry.getNamedChildValue("fullUrl"); + if (u != null && fullUrl.equals(u)) + return entry; + if (u == null) { + WrapperElement res = entry.getNamedChild("resource"); + WrapperElement resource = res.getFirstChild(); + String et = resource.getResourceType(); + String eid = resource.getNamedChildValue("id"); + if (t.equals(et) && i.equals(eid)) + return entry; + } + } + } + return null; + } + } + + private ElementDefinition resolveNameReference(StructureDefinitionSnapshotComponent snapshot, String name) { + for (ElementDefinition ed : snapshot.getElement()) + if (name.equals(ed.getName())) + return ed; + return null; + } + + private StructureDefinition resolveProfile(StructureDefinition profile, String pr) { + if (pr.startsWith("#")) { + for (Resource r : profile.getContained()) { + if (r.getId().equals(pr.substring(1)) && r instanceof StructureDefinition) + return (StructureDefinition) r; + } + return null; + } else + return context.fetchResource(StructureDefinition.class, pr); + } + + private ElementDefinition resolveType(String type) { + String url = "http://hl7.org/fhir/StructureDefinition/" + type; + StructureDefinition sd = context.fetchResource(StructureDefinition.class, url); + if (sd == null || !sd.hasSnapshot()) + return null; + else + return sd.getSnapshot().getElement().get(0); + } + + public void setAnyExtensionsAllowed(boolean anyExtensionsAllowed) { + this.anyExtensionsAllowed = anyExtensionsAllowed; + } + + public void setBestPracticeWarningLevel(BestPracticeWarningLevel value) { + bpWarnings = value; + } + + @Override + public void setCheckDisplay(CheckDisplayOption checkDisplay) { + this.checkDisplay = checkDisplay; + } + + public void setSuppressLoincSnomedMessages(boolean suppressLoincSnomedMessages) { + this.suppressLoincSnomedMessages = suppressLoincSnomedMessages; + } + + public IdStatus getResourceIdRule() { + return resourceIdRule; + } + + public void setResourceIdRule(IdStatus resourceIdRule) { + this.resourceIdRule = resourceIdRule; + } + + /** + * + * @param element + * - the candidate that might be in the slice + * @param path + * - for reporting any errors. the XPath for the element + * @param slice + * - the definition of how slicing is determined + * @param ed + * - the slice for which to test membership + * @return + * @throws DefinitionException + * @throws Exception + */ + private boolean sliceMatches(WrapperElement element, String path, ElementDefinition slice, ElementDefinition ed, StructureDefinition profile) throws DefinitionException { + if (!slice.getSlicing().hasDiscriminator()) + return false; // cannot validate in this case + for (StringType s : slice.getSlicing().getDiscriminator()) { + String discriminator = s.getValue(); + ElementDefinition criteria = getCriteriaForDiscriminator(path, ed, discriminator, profile); + if (discriminator.equals("url") && criteria.getPath().equals("Extension.url")) { + if (!element.getAttribute("url").equals(((UriType) criteria.getFixed()).asStringValue())) + return false; + } else { + Element value = getValueForDiscriminator(element, discriminator, criteria); + if (!valueMatchesCriteria(value, criteria)) + return false; + } + } + return true; + } + + // we assume that the following things are true: + // the instance at root is valid against the schema and schematron + // the instance validator had no issues against the base resource profile + private void start(List errors, WrapperElement resource, WrapperElement element, StructureDefinition profile, NodeStack stack) throws FHIRException { + // profile is valid, and matches the resource name + if (rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), profile.hasSnapshot(), + "StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided")) { + validateElement(errors, profile, profile.getSnapshot().getElement().get(0), null, null, resource, element, element.getName(), stack, false); + + checkDeclaredProfiles(errors, resource, element, stack); + + // specific known special validations + if (element.getResourceType().equals("Bundle")) + validateBundle(errors, element, stack); + if (element.getResourceType().equals("Observation")) + validateObservation(errors, element, stack); + } + } + + private String tail(String path) { + return path.substring(path.lastIndexOf(".") + 1); + } + + private String tryParse(String ref) { + String[] parts = ref.split("\\/"); + switch (parts.length) { + case 1: + return null; + case 2: + return checkResourceType(parts[0]); + default: + if (parts[parts.length - 2].equals("_history")) + return checkResourceType(parts[parts.length - 4]); + else + return checkResourceType(parts[parts.length - 2]); + } + } + + private boolean typesAreAllReference(List theType) { + for (TypeRefComponent typeRefComponent : theType) { + if (typeRefComponent.getCode().equals("Reference") == false) { + return false; + } + } + return true; + } + + @Override + public List validate(Document document) throws FHIRException { + List results = new ArrayList(); + validate(results, document); + return results; + } + + @Override + public List validate(Document document, String profile) throws FHIRException { + List results = new ArrayList(); + validate(results, document, profile); + return results; + } + + @Override + public List validate(Document document, StructureDefinition profile) throws FHIRException { + List results = new ArrayList(); + validate(results, document, profile); + return results; + } + + @Override + public List validate(Element element) throws FHIRException { + List results = new ArrayList(); + validate(results, element); + return results; + } + + @Override + public List validate(Element element, String profile) throws FHIRException { + List results = new ArrayList(); + validate(results, element, profile); + return results; + } + + @Override + public List validate(Element element, StructureDefinition profile) throws FHIRException { + List results = new ArrayList(); + validate(results, element, profile); + return results; + } + + @Override + public List validate(JsonObject obj) throws FHIRException { + List results = new ArrayList(); + validate(results, obj); + return results; + } + + @Override + public List validate(JsonObject obj, String profile) throws FHIRException { + List results = new ArrayList(); + validate(results, obj, profile); + return results; + } + + @Override + public List validate(JsonObject obj, StructureDefinition profile) throws FHIRException { + List results = new ArrayList(); + validate(results, obj, profile); + return results; + } + + @Override + public void validate(List errors, Document document) throws FHIRException { + checkForProcessingInstruction(errors, document); + validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), null, resourceIdRule, null); + } + + @Override + public void validate(List errors, Document document, String profile) throws FHIRException { + checkForProcessingInstruction(errors, document); + StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); + if (p == null) + throw new DefinitionException("StructureDefinition '" + profile + "' not found"); + validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), p, resourceIdRule, null); + } + + @Override + public void validate(List errors, Document document, StructureDefinition profile) throws FHIRException { + checkForProcessingInstruction(errors, document); + validateResource(errors, null, new DOMWrapperElement(document.getDocumentElement()), profile, resourceIdRule, null); + } + + @Override + public void validate(List errors, Element element) throws FHIRException { + validateResource(errors, null, new DOMWrapperElement(element), null, resourceIdRule, null); + } + + @Override + public void validate(List errors, Element element, String profile) throws FHIRException { + StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); + if (p == null) + throw new DefinitionException("StructureDefinition '" + profile + "' not found"); + validateResource(errors, null, new DOMWrapperElement(element), p, resourceIdRule, null); + } + + @Override + public void validate(List errors, Element element, StructureDefinition profile) throws FHIRException { + validateResource(errors, null, new DOMWrapperElement(element), profile, resourceIdRule, null); + } + + @Override + public void validate(List errors, JsonObject object) throws FHIRException { + validateResource(errors, null, new JsonWrapperElement(object), null, resourceIdRule, null); + } + + @Override + public void validate(List errors, JsonObject object, String profile) throws FHIRException { + StructureDefinition p = context.fetchResource(StructureDefinition.class, profile); + if (p == null) + throw new DefinitionException("StructureDefinition '" + profile + "' not found"); + validateResource(errors, null, new JsonWrapperElement(object), p, resourceIdRule, null); + } + + @Override + public void validate(List errors, JsonObject object, StructureDefinition profile) throws FHIRException { + validateResource(errors, null, new JsonWrapperElement(object), profile, resourceIdRule, null); + } + + private void validateBundle(List errors, WrapperElement bundle, NodeStack stack) { + List entries = new ArrayList(); + bundle.getNamedChildren("entry", entries); + String type = bundle.getNamedChildValue("type"); + if (entries.size() == 0) { + rule(errors, IssueType.INVALID, stack.getLiteralPath(), !(type.equals("document") || type.equals("message")), "Documents or Messages must contain at least one entry"); + } else { + WrapperElement firstEntry = entries.get(0); + NodeStack firstStack = stack.push(firstEntry, 0, null, null); + String fullUrl = firstEntry.getNamedChildValue("fullUrl"); + + if (type.equals("document")) { + WrapperElement res = firstEntry.getNamedChild("resource"); + NodeStack localStack = firstStack.push(res, -1, null, null); + WrapperElement resource = res.getFirstChild(); + String id = resource.getNamedChildValue("id"); + if (rule(errors, IssueType.INVALID, firstEntry.line(), firstEntry.col(), stack.addToLiteralPath("entry", ":0"), res != null, "No resource on first entry")) { + if (bundle.isXml()) + validateDocument(errors, entries, resource, localStack.push(resource, -1, null, null), fullUrl, id); + else + validateDocument(errors, entries, res, localStack, fullUrl, id); + } + } + if (type.equals("message")) + validateMessage(errors, bundle); + } + } + + // public class ProfileStructureIterator { + // + // private StructureDefinition profile; + // private ElementDefinition elementDefn; + // private List names = new ArrayList(); + // private Map> children = new HashMap>(); + // private int cursor; + // + // public ProfileStructureIterator(StructureDefinition profile, ElementDefinition elementDefn) { + // this.profile = profile; + // this.elementDefn = elementDefn; + // loadMap(); + // cursor = -1; + // } + // + // private void loadMap() { + // int i = profile.getSnapshot().getElement().indexOf(elementDefn) + 1; + // String lead = elementDefn.getPath(); + // while (i < profile.getSnapshot().getElement().size()) { + // String name = profile.getSnapshot().getElement().get(i).getPath(); + // if (name.length() <= lead.length()) + // return; // cause we've got to the end of the possible matches + // String tail = name.substring(lead.length()+1); + // if (Utilities.isToken(tail) && name.substring(0, lead.length()).equals(lead)) { + // List list = children.get(tail); + // if (list == null) { + // list = new ArrayList(); + // names.add(tail); + // children.put(tail, list); + // } + // list.add(profile.getSnapshot().getElement().get(i)); + // } + // i++; + // } + // } + // + // public boolean more() { + // cursor++; + // return cursor < names.size(); + // } + // + // public List current() { + // return children.get(name()); + // } + // + // public String name() { + // return names.get(cursor); + // } + // + // } + // + // private void checkByProfile(List errors, String path, WrapperElement focus, StructureDefinition profile, ElementDefinition elementDefn) + // { + // // we have an element, and the structure that describes it. + // // we know that's it's valid against the underlying spec - is it valid against this one? + // // in the instance validator above, we assume that schema or schmeatron has taken care of cardinalities, but here, we have no such reliance. + // // so the walking algorithm is different: we're going to walk the definitions + // String type; + // if (elementDefn.getPath().endsWith("[x]")) { + // String tail = elementDefn.getPath().substring(elementDefn.getPath().lastIndexOf(".")+1, elementDefn.getPath().length()-3); + // type = focus.getName().substring(tail.length()); + // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, typeAllowed(type, elementDefn.getType()), "The type '"+type+"' is not allowed at this + // point (must be one of '"+typeSummary(elementDefn)+")"); + // } else { + // if (elementDefn.getType().size() == 1) { + // type = elementDefn.getType().size() == 0 ? null : elementDefn.getType().get(0).getCode(); + // } else + // type = null; + // } + // // constraints: + // for (ElementDefinitionConstraintComponent c : elementDefn.getConstraint()) + // checkConstraint(errors, path, focus, c); + // if (elementDefn.hasBinding() && type != null) + // checkBinding(errors, path, focus, profile, elementDefn, type); + // + // // type specific checking: + // if (type != null && isPrimitiveType(type)) { + // checkPrimitiveByProfile(errors, path, focus, elementDefn); + // } else { + // if (elementDefn.hasFixed()) + // checkFixedValue(errors, path, focus, elementDefn.getFixed(), ""); + // + // ProfileStructureIterator walker = new ProfileStructureIterator(profile, elementDefn); + // while (walker.more()) { + // // collect all the slices for the path + // List childset = walker.current(); + // // collect all the elements that match it by name + // List children = new ArrayList(); + // focus.getNamedChildrenWithWildcard(walker.name(), children); + // + // if (children.size() == 0) { + // // well, there's no children - should there be? + // for (ElementDefinition defn : childset) { + // if (!rule(errors, IssueType.REQUIRED, focus.line(), focus.col(), path, defn.getMin() == 0, "Required Element '"+walker.name()+"' missing")) + // break; // no point complaining about missing ones after the first one + // } + // } else if (childset.size() == 1) { + // // simple case: one possible definition, and one or more children. + // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, childset.get(0).getMax().equals("*") || Integer.parseInt(childset.get(0).getMax()) >= + // children.size(), + // "Too many elements for '"+walker.name()+"'"); // todo: sort out structure + // for (WrapperElement child : children) { + // checkByProfile(errors, childset.get(0).getPath(), child, profile, childset.get(0)); + // } + // } else { + // // ok, this is the full case - we have a list of definitions, and a list of candidates for meeting those definitions. + // // we need to decide *if* that match a given definition + // } + // } + // } + // } + + // private void checkBinding(List errors, String path, WrapperElement focus, StructureDefinition profile, ElementDefinition elementDefn, + // String type) { + // ElementDefinitionBindingComponent bc = elementDefn.getBinding(); + // + // if (bc != null && bc.hasValueSet() && bc.getValueSet() instanceof Reference) { + // String url = ((Reference) bc.getValueSet()).getReference(); + // ValueSet vs = resolveValueSetReference(profile, (Reference) bc.getValueSet()); + // if (vs == null) { + // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, false, "Cannot check binding on type '"+type+"' as the value set '"+url+"' could not be + // located"); + // } else if (type.equals("code")) + // checkBindingCode(errors, path, focus, vs); + // else if (type.equals("Coding")) + // checkBindingCoding(errors, path, focus, vs); + // else if (type.equals("CodeableConcept")) + // checkBindingCodeableConcept(errors, path, focus, vs); + // else + // rule(errors, IssueType.STRUCTURE, focus.line(), focus.col(), path, false, "Cannot check binding on type '"+type+"'"); + // } + // } + // + // private ValueSet resolveValueSetReference(StructureDefinition profile, Reference reference) { + // if (reference.getReference().startsWith("#")) { + // for (Resource r : profile.getContained()) { + // if (r instanceof ValueSet && r.getId().equals(reference.getReference().substring(1))) + // return (ValueSet) r; + // } + // return null; + // } else + // return resolveBindingReference(reference); + // + // } + // + // private void checkBindingCode(List errors, String path, WrapperElement focus, ValueSet vs) { + // // rule(errors, "exception", path, false, "checkBindingCode not done yet"); + // } + // + // private void checkBindingCoding(List errors, String path, WrapperElement focus, ValueSet vs) { + // // rule(errors, "exception", path, false, "checkBindingCoding not done yet"); + // } + // + // private void checkBindingCodeableConcept(List errors, String path, WrapperElement focus, ValueSet vs) { + // // rule(errors, "exception", path, false, "checkBindingCodeableConcept not done yet"); + // } + // + // private String typeSummary(ElementDefinition elementDefn) { + // StringBuilder b = new StringBuilder(); + // for (TypeRefComponent t : elementDefn.getType()) { + // b.append("|"+t.getCode()); + // } + // return b.toString().substring(1); + // } + // + // private boolean typeAllowed(String t, List types) { + // for (TypeRefComponent type : types) { + // if (t.equals(Utilities.capitalize(type.getCode()))) + // return true; + // if (t.equals("Resource") && Utilities.capitalize(type.getCode()).equals("Reference")) + // return true; + // } + // return false; + // } + // + // private void checkConstraint(List errors, String path, WrapperElement focus, ElementDefinitionConstraintComponent c) { + // + //// try + //// { + //// XPathFactory xpf = new net.sf.saxon.xpath.XPathFactoryImpl(); + //// NamespaceContext context = new NamespaceContextMap("f", "http://hl7.org/fhir", "h", "http://www.w3.org/1999/xhtml"); + //// + //// XPath xpath = xpf.newXPath(); + //// xpath.setNamespaceContext(context); + //// Boolean ok = (Boolean) xpath.evaluate(c.getXpath(), focus, XPathConstants.BOOLEAN); + //// if (ok == null || !ok) { + //// if (c.getSeverity() == ConstraintSeverity.warning) + //// warning(errors, "invariant", path, false, c.getHuman()); + //// else + //// rule(errors, "invariant", path, false, c.getHuman()); + //// } + //// } + //// catch (XPathExpressionException e) { + //// rule(errors, "invariant", path, false, "error executing invariant: "+e.getMessage()); + //// } + // } + // + // private void checkPrimitiveByProfile(List errors, String path, WrapperElement focus, ElementDefinition elementDefn) { + // // two things to check - length, and fixed value + // String value = focus.getAttribute("value"); + // if (elementDefn.hasMaxLengthElement()) { + // rule(errors, IssueType.TOOLONG, focus.line(), focus.col(), path, value.length() <= elementDefn.getMaxLength(), "The value '"+value+"' exceeds the allow + // length limit of "+Integer.toString(elementDefn.getMaxLength())); + // } + // if (elementDefn.hasFixed()) { + // checkFixedValue(errors, path, focus, elementDefn.getFixed(), ""); + // } + // } + + private void validateBundleReference(List errors, List entries, WrapperElement ref, String name, NodeStack stack, String fullUrl, String type, String id) { + if (ref != null && !Utilities.noString(ref.getNamedChildValue("reference"))) { + WrapperElement target = resolveInBundle(entries, ref.getNamedChildValue("reference"), fullUrl, type, id); + rule(errors, IssueType.INVALID, target.line(), target.col(), stack.addToLiteralPath("reference"), target != null, "Unable to resolve the target of the reference in the bundle (" + name + ")"); + } + } + + private void validateContains(List errors, String path, ElementDefinition child, ElementDefinition context, WrapperElement resource, WrapperElement element, NodeStack stack, IdStatus idstatus) throws FHIRException + { + WrapperElement e = element.isXml() ? element.getFirstChild() : element; + String resourceName = e.getResourceType(); + StructureDefinition profile = this.context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName); + // special case: resource wrapper is reset if we're crossing a bundle boundary, but not otherwise + if (path.endsWith("resource")) + resource = e; + if (rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for contained resource of type '" + resourceName + "'")) + validateResource(errors, resource, e, profile, idstatus, stack); + } + + private void validateDocument(List errors, List entries, WrapperElement composition, NodeStack stack, String fullUrl, String id) { + // first entry must be a composition + if (rule(errors, IssueType.INVALID, composition.line(), composition.col(), stack.getLiteralPath(), composition.getResourceType().equals("Composition"), + "The first entry in a document must be a composition")) { + // the composition subject and section references must resolve in the bundle + validateBundleReference(errors, entries, composition.getNamedChild("subject"), "Composition Subject", stack.push(composition.getNamedChild("subject"), -1, null, null), fullUrl, "Composition", + id); + validateSections(errors, entries, composition, stack, fullUrl, id); + } + } + // rule(errors, IssueType.INVALID, bundle.line(), bundle.col(), "Bundle", !"urn:guid:".equals(base), "The base 'urn:guid:' is not valid (use urn:uuid:)"); + // rule(errors, IssueType.INVALID, entry.line(), entry.col(), localStack.getLiteralPath(), !"urn:guid:".equals(ebase), "The base 'urn:guid:' is not valid"); + // rule(errors, IssueType.INVALID, entry.line(), entry.col(), localStack.getLiteralPath(), !Utilities.noString(base) || !Utilities.noString(ebase), "entry + // does not have a base"); + // String firstBase = null; + // firstBase = ebase == null ? base : ebase; + + private void validateElement(List errors, StructureDefinition profile, ElementDefinition definition, StructureDefinition cprofile, ElementDefinition context, + WrapperElement resource, WrapperElement element, String actualType, NodeStack stack, boolean inCodeableConcept) throws FHIRException { + element.setDefinition(definition); + element.setProfile(profile); + + // irrespective of what element it is, it cannot be empty + if (element.isXml()) { + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), FormatUtilities.FHIR_NS.equals(element.getNamespace()), + "Namespace mismatch - expected '" + FormatUtilities.FHIR_NS + "', found '" + element.getNamespace() + "'"); + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !element.hasNamespace("http://www.w3.org/2001/XMLSchema-instance"), + "Schema Instance Namespace is not allowed in instances"); + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !element.hasProcessingInstruction(), "No Processing Instructions in resources"); + } + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), !empty(element), "Elements must have some content (@value, extensions, or children elements)"); + + checkInvariants(errors, stack.literalPath, profile, definition, null, null, resource, element); + + // get the list of direct defined children, including slices + List childDefinitions = ProfileUtilities.getChildMap(profile, definition.getName(), definition.getPath(), definition.getNameReference()); + + // 1. List the children, and remember their exact path (convenience) + List children = new ArrayList(); + ChildIterator iter = new ChildIterator(stack.getLiteralPath(), element); + while (iter.next()) + children.add(new ElementInfo(iter.name(), iter.element(), iter.path(), iter.count())); + + // 2. assign children to a definition + // for each definition, for each child, check whether it belongs in the slice + ElementDefinition slice = null; + for (ElementDefinition ed : childDefinitions) { + boolean process = true; + // where are we with slicing + if (ed.hasSlicing()) { + if (slice != null && slice.getPath().equals(ed.getPath())) + throw new DefinitionException("Slice encountered midway through path on " + slice.getPath()); + slice = ed; + process = false; + } else if (slice != null && !slice.getPath().equals(ed.getPath())) + slice = null; + + if (process) { + for (ElementInfo ei : children) { + boolean match = false; + if (slice == null) { + match = nameMatches(ei.name, tail(ed.getPath())); + } else { + if (nameMatches(ei.name, tail(ed.getPath()))) + match = sliceMatches(ei.element, ei.path, slice, ed, profile); + } + if (match) { + if (rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition == null, "Element matches more than one slice")) + ei.definition = ed; + } + } + } + } + for (ElementInfo ei : children) + if (ei.path.endsWith(".extension")) + rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition != null, "Element is unknown or does not match any slice (url=\"" + ei.element.getAttribute("url") + "\")"); + else + rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, (ei.definition != null) || (!ei.element.isXml() && ei.element.getName().equals("fhir_comments")), + "Element is unknown or does not match any slice"); + + // 3. report any definitions that have a cardinality problem + for (ElementDefinition ed : childDefinitions) { + if (ed.getRepresentation().isEmpty()) { // ignore xml attributes + int count = 0; + for (ElementInfo ei : children) + if (ei.definition == ed) + count++; + if (ed.getMin() > 0) { + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), count >= ed.getMin(), + "Element '" + stack.getLiteralPath() + "." + tail(ed.getPath()) + "': minimum required = " + Integer.toString(ed.getMin()) + ", but only found " + Integer.toString(count)); + } + if (ed.hasMax() && !ed.getMax().equals("*")) { + rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), count <= Integer.parseInt(ed.getMax()), + "Element " + tail(ed.getPath()) + " @ " + stack.getLiteralPath() + ": max allowed = " + ed.getMax() + ", but found " + Integer.toString(count)); + } + + } + } + // 4. check order if any slices are orderd. (todo) + + // 5. inspect each child for validity + for (ElementInfo ei : children) { + if (ei.definition != null) { + String type = null; + ElementDefinition typeDefn = null; + if (ei.definition.getType().size() == 1 && !ei.definition.getType().get(0).getCode().equals("*") && !ei.definition.getType().get(0).getCode().equals("Element") + && !ei.definition.getType().get(0).getCode().equals("BackboneElement")) + type = ei.definition.getType().get(0).getCode(); + else if (ei.definition.getType().size() == 1 && ei.definition.getType().get(0).getCode().equals("*")) { + String prefix = tail(ei.definition.getPath()); + assert prefix.endsWith("[x]"); + type = ei.name.substring(prefix.length() - 3); + if (isPrimitiveType(type)) + type = Utilities.uncapitalize(type); + } else if (ei.definition.getType().size() > 1) { + + String prefix = tail(ei.definition.getPath()); + assert typesAreAllReference(ei.definition.getType()) || prefix.endsWith("[x]") : prefix; + + prefix = prefix.substring(0, prefix.length() - 3); + for (TypeRefComponent t : ei.definition.getType()) + if ((prefix + Utilities.capitalize(t.getCode())).equals(ei.name)) + type = t.getCode(); + if (type == null) { + TypeRefComponent trc = ei.definition.getType().get(0); + if (trc.getCode().equals("Reference")) + type = "Reference"; + else + rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), false, + "The element " + ei.name + " is illegal. Valid types at this point are " + describeTypes(ei.definition.getType())); + } + } else if (ei.definition.getNameReference() != null) { + typeDefn = resolveNameReference(profile.getSnapshot(), ei.definition.getNameReference()); + } + + if (type != null) { + if (type.startsWith("@")) { + ei.definition = findElement(profile, type.substring(1)); + type = null; + } + } + NodeStack localStack = stack.push(ei.element, ei.count, ei.definition, type == null ? typeDefn : resolveType(type)); + String localStackLiterapPath = localStack.getLiteralPath(); + String eiPath = ei.path; + assert(eiPath.equals(localStackLiterapPath)) : "ei.path: " + ei.path + " - localStack.getLiterapPath: " + localStackLiterapPath; + boolean thisIsCodeableConcept = false; + + if (type != null) { + if (isPrimitiveType(type)) + checkPrimitive(errors, ei.path, type, ei.definition, ei.element); + else { + if (type.equals("Identifier")) + checkIdentifier(errors, ei.path, ei.element, ei.definition); + else if (type.equals("Coding")) + checkCoding(errors, ei.path, ei.element, profile, ei.definition, inCodeableConcept); + else if (type.equals("CodeableConcept")) { + checkCodeableConcept(errors, ei.path, ei.element, profile, ei.definition); + thisIsCodeableConcept = true; + } else if (type.equals("Reference")) + checkReference(errors, ei.path, ei.element, profile, ei.definition, actualType, localStack); + + if (type.equals("Extension")) + checkExtension(errors, ei.path, ei.element, ei.definition, profile, localStack); + else if (type.equals("Resource")) + validateContains(errors, ei.path, ei.definition, definition, resource, ei.element, localStack, idStatusForEntry(element, ei)); // if + // (str.matches(".*([.,/])work\\1$")) + else { + StructureDefinition p = getProfileForType(type); + if (rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), ei.path, p != null, "Unknown type " + type)) { + validateElement(errors, p, p.getSnapshot().getElement().get(0), profile, ei.definition, resource, ei.element, type, localStack, thisIsCodeableConcept); + } + } + } + } else { + if (rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), ei.definition != null, "Unrecognised Content " + ei.name)) + validateElement(errors, profile, ei.definition, null, null, resource, ei.element, type, localStack, false); + } + } + } + } + + private IdStatus idStatusForEntry(WrapperElement ep, ElementInfo ei) { + if (isBundleEntry(ei.path)) { + WrapperElement req = ep.getNamedChild("request"); + WrapperElement resp = ep.getNamedChild("response"); + WrapperElement fullUrl = ep.getNamedChild("fullUrl"); + WrapperElement method = null; + WrapperElement url = null; + if (req != null) { + method = req.getNamedChild("method"); + url = req.getNamedChild("url"); + } + if (resp != null) { + return IdStatus.OPTIONAL; + } if (method == null) { + if (fullUrl == null) + return IdStatus.REQUIRED; + else if (fullUrl.getAttribute("value").startsWith("urn:uuid:")) + return IdStatus.OPTIONAL; + else + return IdStatus.REQUIRED; + } else { + String s = method.getAttribute("value"); + if (s.equals("PUT")) { + if (url == null) + return IdStatus.REQUIRED; + else + return IdStatus.OPTIONAL; // or maybe prohibited? not clear + } else if (s.equals("POST")) + return IdStatus.OPTIONAL; // this should be prohibited, but see task 9102 + else // actually, we should never get to here; a bundle entry with method get/delete should not have a resource + return IdStatus.OPTIONAL; + } + } else if (isParametersEntry(ei.path)) + return IdStatus.OPTIONAL; + else + return this.getResourceIdRule(); + } + + private void checkInvariants(List errors, String path, StructureDefinition profile, ElementDefinition ed, String typename, String typeProfile, WrapperElement resource, WrapperElement element) throws FHIRException { + for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { + if (inv.hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression")) { + ResourceOnWrapper res = new ResourceOnWrapper(context, resource, resource.getProfile()); + BaseOnWrapper e = new BaseOnWrapper(context, element, profile, ed, typename, typeProfile); + String expr = inv.getExtensionString("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression"); + FHIRPathEngine fpe = new FHIRPathEngine(context); + boolean ok = true; + try { + ok = fpe.evaluateToBoolean(res, e, expr); + } catch (PathEngineException e1) { + rule(errors, IssueType.INVARIANT, element.line(), element.col(), path, false, e1.getMessage()+": "+inv.getHuman()+fpe.forLog()); + } + if (!ok) { + if (inv.getSeverity() == ConstraintSeverity.ERROR) + rule(errors, IssueType.INVARIANT, element.line(), element.col(), path, ok, inv.getHuman()+fpe.forLog()); + else if (inv.getSeverity() == ConstraintSeverity.WARNING) + warning(errors, IssueType.INVARIANT, element.line(), element.line(), path, ok, inv.getHuman()+fpe.forLog()); + } + } + } + } + + private void validateMessage(List errors, WrapperElement bundle) { + // TODO Auto-generated method stub + + } + + private void validateObservation(List errors, WrapperElement element, NodeStack stack) { + // all observations should have a subject, a performer, and a time + + bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("subject") != null, "All observations should have a subject"); + bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("performer") != null, "All observations should have a performer"); + bpCheck(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), element.getNamedChild("effectiveDateTime") != null || element.getNamedChild("effectivePeriod") != null, + "All observations should have an effectiveDateTime or an effectivePeriod"); + } + + /* + * The actual base entry point + */ + private void validateResource(List errors, WrapperElement resource, WrapperElement element, StructureDefinition profile, IdStatus idstatus, NodeStack stack) throws FHIRException { + if (stack == null) + stack = new NodeStack(element.isXml()); + if (resource == null) + resource = element; + + // getting going - either we got a profile, or not. + boolean ok = true; + if (element.isXml()) { + ok = rule(errors, IssueType.INVALID, element.line(), element.col(), "/", element.getNamespace().equals(FormatUtilities.FHIR_NS), + "Namespace mismatch - expected '" + FormatUtilities.FHIR_NS + "', found '" + element.getNamespace() + "'"); + } + if (ok) { + String resourceName = element.getResourceType(); + if (profile == null) { + profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName); + ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for resource type '" + resourceName + "'"); + } else { + String type = profile.hasConstrainedType() ? profile.getConstrainedType() : profile.getName(); + // special case: we have a bundle, and the profile is not for a bundle. We'll try the first entry instead + if (!type.equals(resourceName) && resourceName.equals("Bundle")) { + WrapperElement first = getFirstEntry(element); + if (first != null && first.getResourceType().equals(type)) { + element = first; + resourceName = element.getResourceType(); + idstatus = IdStatus.OPTIONAL; // why? + } + } + ok = rule(errors, IssueType.INVALID, -1, -1, stack.addToLiteralPath(resourceName), type.equals(resourceName), + "Specified profile type was '" + profile.getConstrainedType() + "', but resource type was '" + resourceName + "'"); + } + } + + if (ok) { + stack = stack.push(element, -1, profile.getSnapshot().getElement().get(0), profile.getSnapshot().getElement().get(0)); + if (idstatus == IdStatus.REQUIRED && (element.getNamedChild("id") == null)) + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource requires an id, but none is present"); + else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild("id") != null)) + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource has an id, but none is allowed"); + start(errors, resource, element, profile, stack); // root is both definition and type + } + } + + private WrapperElement getFirstEntry(WrapperElement bundle) { + List list = new ArrayList(); + bundle.getNamedChildren("entry", list); + if (list.isEmpty()) + return null; + WrapperElement resource = list.get(0).getNamedChild("resource"); + if (resource == null) + return null; + else + return resource.getFirstChild(); + } + + private void validateSections(List errors, List entries, WrapperElement focus, NodeStack stack, String fullUrl, String id) { + List sections = new ArrayList(); + focus.getNamedChildren("entry", sections); + int i = 0; + for (WrapperElement section : sections) { + NodeStack localStack = stack.push(section, 1, null, null); + validateBundleReference(errors, entries, section.getNamedChild("content"), "Section Content", localStack, fullUrl, "Composition", id); + validateSections(errors, entries, section, localStack, fullUrl, id); + i++; + } + } + + private boolean valueMatchesCriteria(Element value, ElementDefinition criteria) { + // throw new Error("validation of slices not done yet"); + return false; + } + + private boolean yearIsValid(String v) { + if (v == null) { + return false; + } + try { + int i = Integer.parseInt(v.substring(0, Math.min(4, v.length()))); + return i >= 1800 && i <= 2100; + } catch (NumberFormatException e) { + return false; + } + } + + public class ChildIterator { + private String basePath; + private WrapperElement child; + private int lastCount; + private WrapperElement parent; + + public ChildIterator(String path, WrapperElement element) { + parent = element; + basePath = path; + } + + public int count() { + WrapperElement n = child.getNextSibling(); + if (n != null && n.getName().equals(child.getName())) { + return lastCount + 1; + } else + return -1; + } + + public WrapperElement element() { + return child; + } + + public String name() { + return child.getName(); + } + + public boolean next() { + if (child == null) { + child = parent.getFirstChild(); + lastCount = 0; + } else { + String lastName = child.getName(); + child = child.getNextSibling(); + if (child != null && child.getName().equals(lastName)) + lastCount++; + else + lastCount = 0; + } + return child != null; + } + + public String path() { + WrapperElement n = child.getNextSibling(); + if (parent.isXml()) { + String sfx = ""; + if (n != null && n.getName().equals(child.getName())) { + sfx = "[" + Integer.toString(lastCount + 1) + "]"; + } + if (FormatUtilities.XHTML_NS.equals(child.getNamespace())) + return basePath + "/h:" + name() + sfx; + else + return basePath + "/f:" + name() + sfx; + } else { + String sfx = ""; + if (n != null && n.getName().equals(child.getName())) { + sfx = "/" + Integer.toString(lastCount + 1); + } + return basePath + "/" + name() + sfx; + } + } + } + + public class DOMWrapperElement extends WrapperElement { + + private int col; + private Element element; + private int line; + + public DOMWrapperElement(Element element) { + super(); + this.element = element; + XmlLocationData loc = (XmlLocationData) element.getUserData(XmlLocationData.LOCATION_DATA_KEY); + if (loc != null) { + line = loc.getStartLine(); + col = loc.getStartColumn(); + } else { + line = -1; + col = -1; + } + } + + @Override + public int col() { + return col; + } + + @Override + public String getAttribute(String name) { + return element.getAttribute(name); + } + + @Override + public WrapperElement getFirstChild() { + Element res = XMLUtil.getFirstChild(element); + return res == null ? null : new DOMWrapperElement(res); + } + + @Override + public String getName() { + return element.getLocalName(); + } + + @Override + public WrapperElement getNamedChild(String name) { + Element res = XMLUtil.getNamedChild(element, name); + return res == null ? null : new DOMWrapperElement(res); + } + + @Override + public void getNamedChildren(String name, List list) { + List el = new ArrayList(); + XMLUtil.getNamedChildren(element, name, el); + for (Element e : el) + list.add(new DOMWrapperElement(e)); + } + + @Override + public void getNamedChildrenWithWildcard(String name, List list) { + List el = new ArrayList(); + XMLUtil.getNamedChildrenWithWildcard(element, name, el); + for (Element e : el) + list.add(new DOMWrapperElement(e)); + } + + @Override + public String getNamedChildValue(String name) { + return XMLUtil.getNamedChildValue(element, name); + } + + @Override + public String getNamespace() { + return element.getNamespaceURI(); + } + + @Override + public WrapperElement getNextSibling() { + Element res = XMLUtil.getNextSibling(element); + return res == null ? null : new DOMWrapperElement(res); + } + + @Override + public String getResourceType() { + return element.getLocalName(); + } + + @Override + public String getText() { + return element.getTextContent(); + } + + @Override + public boolean hasAttribute(String name) { + return element.hasAttribute(name); + } + + @Override + public boolean hasNamespace(String ns) { + for (int i = 0; i < element.getAttributes().getLength(); i++) { + Node a = element.getAttributes().item(i); + if ((a.getNodeName().equals("xmlns") || a.getNodeName().startsWith("xmlns:")) && a.getNodeValue().equals(ns)) + return true; + } + return false; + } + + @Override + public boolean hasProcessingInstruction() { + Node node = element.getFirstChild(); + while (node != null) { + if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) + return true; + node = node.getNextSibling(); + } + return false; + } + + @Override + public boolean isXml() { + return true; + } + + @Override + public int line() { + return line; + } + } + + public class ElementInfo { + + public int count; + public ElementDefinition definition; + private WrapperElement element; + private String name; + private String path; + + public ElementInfo(String name, WrapperElement element, String path, int count) { + this.name = name; + this.element = element; + this.path = path; + this.count = count; + } + + public int col() { + return element.col(); + } + + public int line() { + return element.line(); + } + + } + + public class JsonWrapperElement extends WrapperElement { + + private JsonElement _element; + private List children = new ArrayList(); + private JsonElement element; + private int index; + private String name; + private JsonWrapperElement parent; + private String path; + private String resourceType; + + public JsonWrapperElement(JsonElement element) { + super(); + this.name = null; + this.resourceType = ((JsonObject) element).get("resourceType").getAsString(); + this.element = element; + this.path = ""; + createChildren(); + } + + public JsonWrapperElement(String path, String name, JsonElement element, JsonElement _element, JsonWrapperElement parent, int index) { + super(); + this.path = path + "/" + name; + this.name = name; + this.element = element; + if (element instanceof JsonObject && ((JsonObject) element).has("resourceType")) + this.resourceType = ((JsonObject) element).get("resourceType").getAsString(); + this._element = _element; + this.parent = parent; + this.index = index; + createChildren(); + } + + @Override + public int col() { + // TODO Auto-generated method stub + return -1; + } + + private void createChildren() { + // System.out.println(" ..: "+path); + // we're going to make this look like the XML + if (element != null) { + if (element instanceof JsonPrimitive) { + // we may have an element_ too + if (_element != null && _element instanceof JsonObject) + for (Entry t : ((JsonObject) _element).entrySet()) + processChild(t.getKey(), t.getValue()); + } else if (element instanceof JsonObject) { + for (Entry t : ((JsonObject) element).entrySet()) + if (!t.getKey().equals("resourceType")) { + processChild(t.getKey(), t.getValue()); + } + } else if (element instanceof JsonNull) { + // nothing to do + } else + throw new Error("unexpected condition: " + element.getClass().getName()); + } + if (_element != null) { + + } + } + + @Override + public String getAttribute(String name) { + if (name.equals("value")) { + if (element == null) + return null; + if (element instanceof JsonPrimitive) + return ((JsonPrimitive) element).getAsString(); + return null; + } + if (name.equals("xml:id")) { + WrapperElement c = getNamedChild("id"); + return c == null ? null : c.getAttribute("value"); + } + if (name.equals("url")) { + WrapperElement c = getNamedChild("url"); + return c == null ? null : c.getAttribute("value"); + } + throw new Error("not done yet: " + name); + } + + @Override + public WrapperElement getFirstChild() { + if (children.isEmpty()) + return null; + else + return children.get(0); + } + + @Override + public String getName() { + return name; + } + + @Override + public WrapperElement getNamedChild(String name) { + for (JsonWrapperElement j : children) + if (j.name.equals(name)) + return j; + return null; + } + + @Override + public void getNamedChildren(String name, List list) { + for (JsonWrapperElement j : children) + if (j.name.equals(name)) + list.add(j); + } + + @Override + public void getNamedChildrenWithWildcard(String name, List list) { + for (JsonWrapperElement j : children) { + String n = j.name; + if (n.equals(name) || (name.endsWith("[x]") && n.startsWith(name.substring(0, name.length() - 3)))) + list.add(j); + } + } + + @Override + public String getNamedChildValue(String name) { + WrapperElement c = getNamedChild(name); + return c == null ? null : c.getAttribute("value"); + } + + @Override + public String getNamespace() { + // return element.getNamespaceURI(); + throw new Error("not done yet"); + } + + @Override + public WrapperElement getNextSibling() { + if (parent == null) + return null; + if (index >= parent.children.size() - 1) + return null; + return parent.children.get(index + 1); + } + + @Override + public String getResourceType() { + return resourceType; + } + + @Override + public String getText() { + throw new Error("not done yet"); + } + + @Override + public boolean hasAttribute(String name) { + if (name.equals("value")) { + if (element == null) + return false; + if (element instanceof JsonPrimitive) + return true; + return false; + } + if (name.equals("xml:id")) { + return getNamedChild("id") != null; + } + throw new Error("not done yet: " + name); + } + + @Override + public boolean hasNamespace(String ns) { + throw new Error("not done"); + } + + @Override + public boolean hasProcessingInstruction() { + return false; + } + + @Override + public boolean isXml() { + return false; + } + + @Override + public int line() { + return -1; + } + + private void processChild(String name, JsonElement e) { + if (name.startsWith("_")) { + name = name.substring(1); + if (((JsonObject) element).has(name)) + return; // it will get processed anyway + e = null; + } + JsonElement _e = element instanceof JsonObject ? ((JsonObject) element).get("_" + name) : null; + + if (e instanceof JsonPrimitive || (e == null && _e != null && !(_e instanceof JsonArray))) { + children.add(new JsonWrapperElement(path, name, e, _e, this, children.size())); + } else if (e instanceof JsonArray || (e == null && _e != null)) { + JsonArray array = (JsonArray) e; + JsonArray _array = (JsonArray) _e; + int max = array != null ? array.size() : 0; + if (_array != null && _array.size() > max) + max = _array.size(); + for (int i = 0; i < max; i++) { + JsonElement a = array == null || array.size() < i ? null : array.get(i); + JsonElement _a = _array == null || _array.size() < i ? null : _array.get(i); + children.add(new JsonWrapperElement(path, name, a, _a, this, children.size())); + } + } else if (e instanceof JsonObject) { + children.add(new JsonWrapperElement(path, name, e, null, this, children.size())); + } else + throw new Error("not done yet: " + e.getClass().getName()); + } + + } + + private class NodeStack { + private ElementDefinition definition; + private WrapperElement element; + private ElementDefinition extension; + private String literalPath; // xpath format + private List logicalPaths; // dotted format, various entry points + private NodeStack parent; + private ElementDefinition type; + private boolean xml; + + public NodeStack(boolean xml) { + this.xml = xml; + } + + public String addToLiteralPath(String... path) { + StringBuilder b = new StringBuilder(); + b.append(getLiteralPath()); + if (xml) { + for (String p : path) { + if (p.startsWith(":")) { + b.append("["); + b.append(p.substring(1)); + b.append("]"); + } else { + b.append("/f:"); + b.append(p); + } + } + } else { + for (String p : path) { + b.append("/"); + if (p.startsWith(":")) { + b.append(p.substring(1)); + } else { + b.append(p); + } + } + } + return b.toString(); + } + + private ElementDefinition getDefinition() { + return definition; + } + + private WrapperElement getElement() { + return element; + } + + private String getLiteralPath() { + return literalPath == null ? "" : literalPath; + } + + private List getLogicalPaths() { + return logicalPaths == null ? new ArrayList() : logicalPaths; + } + + private ElementDefinition getType() { + return type; + } + + private NodeStack push(WrapperElement element, int count, ElementDefinition definition, ElementDefinition type) { + NodeStack res = new NodeStack(element.isXml()); + res.parent = this; + res.element = element; + res.definition = definition; + if (element.isXml()) { + res.literalPath = getLiteralPath() + (element.getNamespace().equals(FormatUtilities.XHTML_NS) ? "/h:" : "/f:") + element.getName(); + if (count > -1) + res.literalPath = res.literalPath + "[" + Integer.toString(count) + "]"; + } else { + if (element.getName() == null) + res.literalPath = ""; + else + res.literalPath = getLiteralPath() + "/" + element.getName(); + if (count > -1) + res.literalPath = res.literalPath + "/" + Integer.toString(count); + } + res.logicalPaths = new ArrayList(); + if (type != null) { + // type will be bull if we on a stitching point of a contained resource, or if.... + res.type = type; + String t = tail(definition.getPath()); + for (String lp : getLogicalPaths()) { + res.logicalPaths.add(lp + "." + t); + if (t.endsWith("[x]")) + res.logicalPaths.add(lp + "." + t.substring(0, t.length() - 3) + type.getPath()); + } + res.logicalPaths.add(type.getPath()); + } else if (definition != null) { + for (String lp : getLogicalPaths()) + res.logicalPaths.add(lp + "." + element.getName()); + } else + res.logicalPaths.addAll(getLogicalPaths()); + // CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + // for (String lp : res.logicalPaths) + // b.append(lp); + // System.out.println(res.literalPath+" : "+b.toString()); + return res; + } + + private void setType(ElementDefinition type) { + this.type = type; + } + } + + public abstract class WrapperElement { + private StructureDefinition profile; + private ElementDefinition definition; + + + public StructureDefinition getProfile() { + return profile; + } + + public void setProfile(StructureDefinition profile) { + this.profile = profile; + } + + public ElementDefinition getDefinition() { + return definition; + } + + public void setDefinition(ElementDefinition definition) { + this.definition = definition; + } + + public abstract int col(); + + public abstract String getAttribute(String name); + + public abstract WrapperElement getFirstChild(); + + public abstract String getName(); + + public abstract WrapperElement getNamedChild(String name); + + public abstract void getNamedChildren(String name, List list); + + public abstract void getNamedChildrenWithWildcard(String name, List list); + + public abstract String getNamedChildValue(String name); + + public abstract String getNamespace(); + + public abstract WrapperElement getNextSibling(); + + public abstract String getResourceType(); + + public abstract String getText(); + + public abstract boolean hasAttribute(String name); + + public abstract boolean hasNamespace(String string); + + public abstract boolean hasProcessingInstruction(); + + public abstract boolean isXml(); + + public abstract int line(); + } + +} diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java index 854f42521ba..6614a0777d8 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java @@ -379,10 +379,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat switch (bpWarnings) { case Error: rule(errors, invalid, line, col, literalPath, test, message); + break; case Warning: warning(errors, invalid, line, col, literalPath, test, message); + break; case Hint: hint(errors, invalid, line, col, literalPath, test, message); + break; default: // do nothing } } @@ -2419,6 +2422,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat else if (itemType.equals("integer")) checkOption(errors, answer, ns, qsrc, qItem, "integer"); else if (itemType.equals("string")) checkOption(errors, answer, ns, qsrc, qItem, "string", true); break; + case QUESTION: + // TODO: how to validate this??? + break; + case NULL: + // Should not happen + break; } validateQuestionannaireResponseItems(qsrc, qItem.getItem(), errors, answer, stack, inProgress); } @@ -3019,11 +3028,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (ei.path.endsWith(".extension")) rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, ei.definition != null, "Element is unknown or does not match any slice (url=\"" + ei.element.getNamedChildValue("url") + "\")" + (profile==null ? "" : " for profile " + profile.getUrl())); else if (!unsupportedSlicing) - if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN) || ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) + if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) hint(errors, IssueType.INFORMATIONAL, ei.line(), ei.col(), ei.path, (ei.definition != null), "Element " + ei.element.getName() + " is unknown or does not match any slice " + sliceInfo + (profile==null ? "" : " for profile " + profile.getUrl())); else - if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN) || ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) + if (ei.slice!=null && (ei.slice.getSlicing().getRules().equals(ElementDefinition.SlicingRules.OPEN))) rule(errors, IssueType.INVALID, ei.line(), ei.col(), ei.path, (ei.definition != null), "Element " + ei.element.getName() + " is unknown or does not match any slice " + sliceInfo + (profile==null ? "" : " for profile " + profile.getUrl())); else @@ -3220,7 +3229,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat goodProfiles.put(typeProfile, profileErrors); } if (goodProfiles.size()==1) { - errors.addAll(goodProfiles.get(0)); + /* TODO: this was goodProfiless.get(0) which will always + * return null - Is the first value what was wanted? */ + errors.addAll(goodProfiles.values().iterator().next()); } else if (goodProfiles.size()==0) { rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), ei.path, false, "Unable to find matching profile among choices: " + StringUtils.join("; ", profiles)); for (List messages : badProfiles) { diff --git a/pom.xml b/pom.xml index 1bb8cc416ad..9554e253869 100644 --- a/pom.xml +++ b/pom.xml @@ -994,6 +994,11 @@ + + org.basepom.maven + duplicate-finder-maven-plugin + 1.2.1 + de.juplo hibernate-maven-plugin @@ -1908,6 +1913,9 @@ ERRORPRONE + + true +