diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 037e7ca6a..5c3aa7296 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2016MayToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2016MayToR5Loader.java index a4894ae31..ff2384feb 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2016MayToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2016MayToR5Loader.java @@ -32,7 +32,7 @@ import org.hl7.fhir.dstu2016may.formats.XmlParser; import org.hl7.fhir.dstu2016may.model.Resource; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.conformance.ProfileUtilities; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2ToR5Loader.java index 32fc4de00..ff252e692 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R2ToR5Loader.java @@ -31,7 +31,7 @@ import org.hl7.fhir.dstu2.formats.JsonParser; import org.hl7.fhir.dstu2.formats.XmlParser; import org.hl7.fhir.dstu2.model.Resource; import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R3ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R3ToR5Loader.java index 2074447a3..0aceee7f9 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R3ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R3ToR5Loader.java @@ -31,7 +31,7 @@ import org.hl7.fhir.dstu3.formats.JsonParser; import org.hl7.fhir.dstu3.formats.XmlParser; import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R4ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R4ToR5Loader.java index d6db5a7a3..52fe5c59f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R4ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R4ToR5Loader.java @@ -31,7 +31,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.formats.JsonParser; import org.hl7.fhir.r4.formats.XmlParser; import org.hl7.fhir.r4.model.Resource; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R5ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R5ToR5Loader.java index c58804863..3102879d0 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R5ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/R5ToR5Loader.java @@ -31,7 +31,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Resource; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java index 4cdd96124..616f64158 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java @@ -1,9 +1,23 @@ package org.hl7.fhir.convertors; +import org.hl7.fhir.convertors.conv10_30.*; +import org.hl7.fhir.dstu2.model.CodeableConcept; +import org.hl7.fhir.dstu2.utils.ToolingExtensions; +import org.hl7.fhir.dstu3.conformance.ProfileUtilities; +import org.hl7.fhir.dstu3.model.CodeSystem; +import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent; +import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; +import org.hl7.fhir.dstu3.terminologies.CodeSystemUtilities; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.utilities.Utilities; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; + /*- * #%L * org.hl7.fhir.convertors @@ -13,9 +27,9 @@ import java.util.stream.Collectors; * 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. @@ -23,91 +37,6 @@ import java.util.stream.Collectors; * limitations under the License. * #L% */ -import org.hl7.fhir.convertors.conv10_30.Account10_30; -import org.hl7.fhir.convertors.conv10_30.Appointment10_30; -import org.hl7.fhir.convertors.conv10_30.AppointmentResponse10_30; -import org.hl7.fhir.convertors.conv10_30.AuditEvent10_30; -import org.hl7.fhir.convertors.conv10_30.Basic10_30; -import org.hl7.fhir.convertors.conv10_30.Binary10_30; -import org.hl7.fhir.convertors.conv10_30.Bundle10_30; -import org.hl7.fhir.convertors.conv10_30.CarePlan10_30; -import org.hl7.fhir.convertors.conv10_30.ClinicalImpression10_30; -import org.hl7.fhir.convertors.conv10_30.Communication10_30; -import org.hl7.fhir.convertors.conv10_30.CommunicationRequest10_30; -import org.hl7.fhir.convertors.conv10_30.Composition10_30; -import org.hl7.fhir.convertors.conv10_30.ConceptMap10_30; -import org.hl7.fhir.convertors.conv10_30.Condition10_30; -import org.hl7.fhir.convertors.conv10_30.Conformance10_30; -import org.hl7.fhir.convertors.conv10_30.Contract10_30; -import org.hl7.fhir.convertors.conv10_30.DataElement10_30; -import org.hl7.fhir.convertors.conv10_30.DetectedIssue10_30; -import org.hl7.fhir.convertors.conv10_30.Device10_30; -import org.hl7.fhir.convertors.conv10_30.DeviceComponent10_30; -import org.hl7.fhir.convertors.conv10_30.DeviceMetric10_30; -import org.hl7.fhir.convertors.conv10_30.DeviceUseStatement10_30; -import org.hl7.fhir.convertors.conv10_30.DiagnosticReport10_30; -import org.hl7.fhir.convertors.conv10_30.DocumentManifest10_30; -import org.hl7.fhir.convertors.conv10_30.DocumentReference10_30; -import org.hl7.fhir.convertors.conv10_30.Encounter10_30; -import org.hl7.fhir.convertors.conv10_30.EnrollmentRequest10_30; -import org.hl7.fhir.convertors.conv10_30.EnrollmentResponse10_30; -import org.hl7.fhir.convertors.conv10_30.EpisodeOfCare10_30; -import org.hl7.fhir.convertors.conv10_30.FamilyMemberHistory10_30; -import org.hl7.fhir.convertors.conv10_30.Flag10_30; -import org.hl7.fhir.convertors.conv10_30.Group10_30; -import org.hl7.fhir.convertors.conv10_30.HealthcareService10_30; -import org.hl7.fhir.convertors.conv10_30.ImagingStudy10_30; -import org.hl7.fhir.convertors.conv10_30.Immunization10_30; -import org.hl7.fhir.convertors.conv10_30.ImmunizationRecommendation10_30; -import org.hl7.fhir.convertors.conv10_30.ImplementationGuide10_30; -import org.hl7.fhir.convertors.conv10_30.List10_30; -import org.hl7.fhir.convertors.conv10_30.Location10_30; -import org.hl7.fhir.convertors.conv10_30.Media10_30; -import org.hl7.fhir.convertors.conv10_30.Medication10_30; -import org.hl7.fhir.convertors.conv10_30.MedicationDispense10_30; -import org.hl7.fhir.convertors.conv10_30.MedicationStatement10_30; -import org.hl7.fhir.convertors.conv10_30.MessageHeader10_30; -import org.hl7.fhir.convertors.conv10_30.NamingSystem10_30; -import org.hl7.fhir.convertors.conv10_30.Observation10_30; -import org.hl7.fhir.convertors.conv10_30.OperationDefinition10_30; -import org.hl7.fhir.convertors.conv10_30.OperationOutcome10_30; -import org.hl7.fhir.convertors.conv10_30.Organization10_30; -import org.hl7.fhir.convertors.conv10_30.Parameters10_30; -import org.hl7.fhir.convertors.conv10_30.Patient10_30; -import org.hl7.fhir.convertors.conv10_30.Person10_30; -import org.hl7.fhir.convertors.conv10_30.Practitioner10_30; -import org.hl7.fhir.convertors.conv10_30.Procedure10_30; -import org.hl7.fhir.convertors.conv10_30.ProcedureRequest10_30; -import org.hl7.fhir.convertors.conv10_30.Provenance10_30; -import org.hl7.fhir.convertors.conv10_30.Questionnaire10_30; -import org.hl7.fhir.convertors.conv10_30.QuestionnaireResponse10_30; -import org.hl7.fhir.convertors.conv10_30.ReferralRequest10_30; -import org.hl7.fhir.convertors.conv10_30.RelatedPerson10_30; -import org.hl7.fhir.convertors.conv10_30.RiskAssessment10_30; -import org.hl7.fhir.convertors.conv10_30.Schedule10_30; -import org.hl7.fhir.convertors.conv10_30.SearchParameter10_30; -import org.hl7.fhir.convertors.conv10_30.Slot10_30; -import org.hl7.fhir.convertors.conv10_30.Specimen10_30; -import org.hl7.fhir.convertors.conv10_30.StructureDefinition10_30; -import org.hl7.fhir.convertors.conv10_30.Subscription10_30; -import org.hl7.fhir.convertors.conv10_30.Substance10_30; -import org.hl7.fhir.convertors.conv10_30.SupplyDelivery10_30; -import org.hl7.fhir.convertors.conv10_30.SupplyRequest10_30; -import org.hl7.fhir.convertors.conv10_30.TestScript10_30; -import org.hl7.fhir.convertors.conv10_30.ValueSet10_30; -import org.hl7.fhir.dstu2.model.CodeableConcept; -import org.hl7.fhir.dstu2.utils.ToolingExtensions; -import org.hl7.fhir.dstu3.conformance.ProfileUtilities; -import org.hl7.fhir.dstu3.model.CodeSystem; -import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; -import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent; -import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent; -import org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; -import org.hl7.fhir.dstu3.model.Enumeration; -import org.hl7.fhir.dstu3.model.Timing.EventTiming; -import org.hl7.fhir.dstu3.terminologies.CodeSystemUtilities; -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.utilities.Utilities; /* Copyright (c) 2011+, HL7, Inc. @@ -139,2558 +68,2569 @@ import org.hl7.fhir.utilities.Utilities; */ public class VersionConvertor_10_30 { - public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public static void copyElement(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2.model.BooleanType tgt = new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateTimeType tgt = new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DecimalType tgt = new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IdType tgt = new org.hl7.fhir.dstu2.model.IdType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2.model.InstantType tgt = new org.hl7.fhir.dstu2.model.InstantType(src.getValueAsString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IntegerType tgt = new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.MarkdownType tgt = new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.OidType tgt = new org.hl7.fhir.dstu2.model.OidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.PositiveIntType tgt = new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = new org.hl7.fhir.dstu2.model.StringType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.TimeType tgt = new org.hl7.fhir.dstu2.model.TimeType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UriType tgt = new org.hl7.fhir.dstu2.model.UriType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UuidType tgt = new org.hl7.fhir.dstu2.model.UuidType(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRankElement()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_30::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) { - if (slicePaths.contains(src.getPath())) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasNameElement()) - tgt.setIdElement(convertString(src.getNameElement())); - } - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasNameReference()) - tgt.setContentReference("#" + src.getNameReference()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertElementDefinitionTypeComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - 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.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_30::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - else - tgt.setNameElement(convertString(src.getIdElement())); - if (src.hasLabelElement()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShortElement()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinitionElement()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasCommentElement()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setNameReference(src.getContentReference().substring(1)); - for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertElementDefinitionTypeComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissingElement()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExampleFirstRep().getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLengthElement()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupportElement()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifierElement()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummaryElement()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); - for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) if (src.hasTarget()) - tgt.setTargetProfile(t.getValueAsString()); - else - tgt.setProfile(t.getValue()); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_10_30::convertAggregationMode) - .collect(Collectors.toList())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - if (src.hasCodeElement()) - tgt.setCodeElement(convertUriToCode(src.getCodeElement())); - if (src.hasTarget()) { - if (src.hasTargetProfile()) - tgt.addProfile(src.getTargetProfile()); - } else if (src.hasProfile()) - tgt.addProfile(src.getProfile()); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_10_30::convertAggregationMode) - .collect(Collectors.toList())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCountElement()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnits()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); - if (src.hasFrequencyElement()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMaxElement()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnits()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCountElement()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequencyElement()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMaxElement()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeType) - return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateType) - return convertDate((org.hl7.fhir.dstu2.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IdType) - return convertId((org.hl7.fhir.dstu2.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2.model.OidType) - return convertOid((org.hl7.fhir.dstu2.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.StringType) - return convertString((org.hl7.fhir.dstu2.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2.model.TimeType) - return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UriType) - return convertUri((org.hl7.fhir.dstu2.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2.model.Extension) - return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2.model.Coding) - return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2.model.Period) - return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2.model.Age) - return convertAge((org.hl7.fhir.dstu2.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2.model.Count) - return convertCount((org.hl7.fhir.dstu2.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2.model.Distance) - return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Duration) - return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2.model.Money) - return convertMoney((org.hl7.fhir.dstu2.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.dstu2.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2.model.Range) - return convertRange((org.hl7.fhir.dstu2.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2.model.Reference) - return convertReference((org.hl7.fhir.dstu2.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2.model.Signature) - return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2.model.Address) - return convertAddress((org.hl7.fhir.dstu2.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu2.model.ElementDefinition) src, new ArrayList()); - if (src instanceof org.hl7.fhir.dstu2.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2.model.Meta) - return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2.model.Timing) - return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeType) - return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateType) - return convertDate((org.hl7.fhir.dstu3.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IdType) - return convertId((org.hl7.fhir.dstu3.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu3.model.InstantType) - return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu3.model.OidType) - return convertOid((org.hl7.fhir.dstu3.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.StringType) - return convertString((org.hl7.fhir.dstu3.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu3.model.TimeType) - return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UuidType) - return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UriType) - return convertUri((org.hl7.fhir.dstu3.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu3.model.Extension) - return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu3.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu3.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu3.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coding) - return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu3.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu3.model.Period) - return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); - if (src instanceof org.hl7.fhir.dstu3.model.Age) - return convertAge((org.hl7.fhir.dstu3.model.Age) src); - if (src instanceof org.hl7.fhir.dstu3.model.Count) - return convertCount((org.hl7.fhir.dstu3.model.Count) src); - if (src instanceof org.hl7.fhir.dstu3.model.Distance) - return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Duration) - return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu3.model.Money) - return convertMoney((org.hl7.fhir.dstu3.model.Money) src); - if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Range) - return convertRange((org.hl7.fhir.dstu3.model.Range) src); - if (src instanceof org.hl7.fhir.dstu3.model.Ratio) - return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu3.model.Reference) - return convertReference((org.hl7.fhir.dstu3.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu3.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu3.model.Signature) - return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu3.model.Address) - return convertAddress((org.hl7.fhir.dstu3.model.Address) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu3.model.Meta) - return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu3.model.Timing) - return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu3.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu3.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu3.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - tgt.setMeta(convertMeta(src.getMeta())); - tgt.setImplicitRules(src.getImplicitRules()); - tgt.setLanguage(src.getLanguage()); - } - - public static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2.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()); - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - tgt.setValue(convertSearchParamType(src.getValue())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType src) throws FHIRException { - switch(src) { + public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public static void copyElement(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) + tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) + tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) + tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) + tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) + tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) + tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) + tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) + tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) + tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) + tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) + tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) + tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrlElement()) + tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSizeElement()) + tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) + tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) + tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) + tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) + tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) + tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) + tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrlElement()) + tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSizeElement()) + tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) + tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) + tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) + tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) + tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) + tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) + tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) + tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) + tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) + tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) + tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValueElement()) + tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) + tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) + tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) + tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) + tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) + tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) + tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) + tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) + tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) + tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) + tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) + tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) + tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) + tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) + tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) + tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) + tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) + tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) + tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) + tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) + tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) + tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) + tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) + tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) + tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) + tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) + tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) + tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) + tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) + tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) + tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) + tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) + tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) + tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) + tgt.setWho(convertType(src.getWho())); + if (src.hasContentTypeElement()) + tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) + tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) + tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) + tgt.setWho(convertType(src.getWho())); + if (src.hasContentTypeElement()) + tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) + tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) + tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) + tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) + tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) + tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) + tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) + tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) + tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) + tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) + tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) + tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) + tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) + tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) + tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) + tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) + tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) + tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) + tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) + tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) + tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRankElement()) + tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) + tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream() + .map(VersionConvertor_10_30::convertPropertyRepresentation) + .collect(Collectors.toList())); + if (src.hasName()) { + if (slicePaths.contains(src.getPath())) + tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasNameElement()) + tgt.setIdElement(convertString(src.getNameElement())); + } + if (src.hasLabel()) + tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) + tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) + tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) + tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) + tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) + tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) + tgt.setMin(src.getMin()); + if (src.hasMax()) + tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) + tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasNameReference()) + tgt.setContentReference("#" + src.getNameReference()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertElementDefinitionTypeComponent(t)); + if (src.hasDefaultValue()) + tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + 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.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) + tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) + tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummary()) + tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) + tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) + tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream() + .map(VersionConvertor_10_30::convertPropertyRepresentation) + .collect(Collectors.toList())); + if (src.hasSliceName()) + tgt.setNameElement(convertString(src.getSliceNameElement())); + else + tgt.setNameElement(convertString(src.getIdElement())); + if (src.hasLabelElement()) + tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) + tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShortElement()) + tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinitionElement()) + tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasCommentElement()) + tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirementsElement()) + tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) + tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) + tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) + tgt.setNameReference(src.getContentReference().substring(1)); + for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertElementDefinitionTypeComponent(t)); + if (src.hasDefaultValue()) + tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissingElement()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) + tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) + tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) + tgt.setExample(convertType(src.getExampleFirstRep().getValue())); + if (src.hasMinValue()) + tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) + tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLengthElement()) + tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupportElement()) + tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifierElement()) + tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummaryElement()) + tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) + tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); + if (src.hasDescriptionElement()) + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) + tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) + tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescriptionElement()) + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) + tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) + tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) + tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) + tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) + tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) + tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); + for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) + if (src.hasTarget()) + tgt.setTargetProfile(t.getValueAsString()); + else + tgt.setProfile(t.getValue()); + tgt.setAggregation(src.getAggregation().stream() + .map(VersionConvertor_10_30::convertAggregationMode) + .collect(Collectors.toList())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + if (src.hasCodeElement()) + tgt.setCodeElement(convertUriToCode(src.getCodeElement())); + if (src.hasTarget()) { + if (src.hasTargetProfile()) + tgt.addProfile(src.getTargetProfile()); + } else if (src.hasProfile()) + tgt.addProfile(src.getProfile()); + tgt.setAggregation(src.getAggregation().stream() + .map(VersionConvertor_10_30::convertAggregationMode) + .collect(Collectors.toList())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) + tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) + tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) + tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) + tgt.setHumanElement(convertString(src.getHumanElement())); + tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); + if (src.hasXpathElement()) + tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) + tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) + tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) + tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) + tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) + ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); + if (src.hasXpathElement()) + tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) + tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) + tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) + tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) + tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) + tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) + tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) + tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) + tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) + tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) + tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) + tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) + tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) + tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) + tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) + tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) + tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) + tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) + tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) + tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) + tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) + tgt.setBounds(convertType(src.getBounds())); + if (src.hasCountElement()) + tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasDurationElement()) + tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) + tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnits()) + tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); + if (src.hasFrequencyElement()) + tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMaxElement()) + tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriodElement()) + tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) + tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnits()) + tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); + tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) + tgt.setBounds(convertType(src.getBounds())); + if (src.hasCountElement()) + tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasDurationElement()) + tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) + tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) + tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequencyElement()) + tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMaxElement()) + tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriodElement()) + tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) + tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) + tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) + tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + break; + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) + tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) + tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) + tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) + tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) + tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeType) + return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateType) + return convertDate((org.hl7.fhir.dstu2.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IdType) + return convertId((org.hl7.fhir.dstu2.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2.model.OidType) + return convertOid((org.hl7.fhir.dstu2.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.StringType) + return convertString((org.hl7.fhir.dstu2.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2.model.TimeType) + return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UriType) + return convertUri((org.hl7.fhir.dstu2.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2.model.Extension) + return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2.model.Coding) + return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2.model.Period) + return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2.model.Age) + return convertAge((org.hl7.fhir.dstu2.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2.model.Count) + return convertCount((org.hl7.fhir.dstu2.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2.model.Distance) + return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Duration) + return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2.model.Money) + return convertMoney((org.hl7.fhir.dstu2.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.dstu2.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2.model.Range) + return convertRange((org.hl7.fhir.dstu2.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2.model.Ratio) + return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2.model.Reference) + return convertReference((org.hl7.fhir.dstu2.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2.model.Signature) + return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2.model.Address) + return convertAddress((org.hl7.fhir.dstu2.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu2.model.ElementDefinition) src, new ArrayList()); + if (src instanceof org.hl7.fhir.dstu2.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2.model.Meta) + return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2.model.Timing) + return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeType) + return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateType) + return convertDate((org.hl7.fhir.dstu3.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IdType) + return convertId((org.hl7.fhir.dstu3.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu3.model.InstantType) + return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu3.model.OidType) + return convertOid((org.hl7.fhir.dstu3.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.StringType) + return convertString((org.hl7.fhir.dstu3.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu3.model.TimeType) + return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UuidType) + return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UriType) + return convertUri((org.hl7.fhir.dstu3.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu3.model.Extension) + return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu3.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu3.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu3.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coding) + return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu3.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu3.model.Period) + return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); + if (src instanceof org.hl7.fhir.dstu3.model.Age) + return convertAge((org.hl7.fhir.dstu3.model.Age) src); + if (src instanceof org.hl7.fhir.dstu3.model.Count) + return convertCount((org.hl7.fhir.dstu3.model.Count) src); + if (src instanceof org.hl7.fhir.dstu3.model.Distance) + return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Duration) + return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu3.model.Money) + return convertMoney((org.hl7.fhir.dstu3.model.Money) src); + if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Range) + return convertRange((org.hl7.fhir.dstu3.model.Range) src); + if (src instanceof org.hl7.fhir.dstu3.model.Ratio) + return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu3.model.Reference) + return convertReference((org.hl7.fhir.dstu3.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu3.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu3.model.Signature) + return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu3.model.Address) + return convertAddress((org.hl7.fhir.dstu3.model.Address) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu3.model.Meta) + return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu3.model.Timing) + return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu3.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu3.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu3.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + tgt.setMeta(convertMeta(src.getMeta())); + tgt.setImplicitRules(src.getImplicitRules()); + tgt.setLanguage(src.getLanguage()); + } + + public static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2.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()); + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + break; + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + tgt.setValue(convertSearchParamType(src.getValue())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType src) throws FHIRException { + switch (src) { case NUMBER: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER; case DATE: @@ -2709,740 +2649,741 @@ public class VersionConvertor_10_30 { return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI; default: return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL; - } + } + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + break; + } + return tgt; + } + + static public class SourceElementComponentWrapper { + + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; } - static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; + public String source; + + public String target; + + public org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent comp; + } + + public static org.hl7.fhir.dstu3.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.dstu3.model.UsageContext result = new org.hl7.fhir.dstu3.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + break; } + return tgt; + } - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent comp; + static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + break; } + return tgt; + } - public static org.hl7.fhir.dstu3.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.dstu3.model.UsageContext result = new org.hl7.fhir.dstu3.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; + static public org.hl7.fhir.dstu3.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CURRENT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT); + break; + case SUPERSEDED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); + break; + case ENTEREDINERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL); + break; } + return tgt; + } - static public org.hl7.fhir.dstu3.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CURRENT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.CURRENT); + break; + case SUPERSEDED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); + break; + case ENTEREDINERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.NULL); + break; } + return tgt; + } - static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; + static public boolean hasConcept(org.hl7.fhir.dstu3.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.dstu3.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) + return true; } + return false; + } - static public org.hl7.fhir.dstu3.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CURRENT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT); - break; - case SUPERSEDED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); - break; - case ENTEREDINERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL); - break; - } - return tgt; + static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) + return true; } + return false; + } - static public org.hl7.fhir.dstu2.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CURRENT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.CURRENT); - break; - case SUPERSEDED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); - break; - case ENTEREDINERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.NULL); - break; - } - return tgt; - } + public static org.hl7.fhir.dstu3.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); + copyElement(src, tgt); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) + tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) + tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) + tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + if (src.hasRoute()) + tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) + tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose()) + tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) + tgt.setRate(convertType(src.getRate())); + if (src.hasMaxDosePerPeriod()) + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } - static public boolean hasConcept(org.hl7.fhir.dstu3.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.dstu3.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } + public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); + copyElement(src, tgt); + if (src.hasTextElement()) + tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) + tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) + tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) + tgt.setSite(convertType(src.getSite())); + if (src.hasRoute()) + tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) + tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose()) + tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) + tgt.setRate(convertType(src.getRate())); + if (src.hasMaxDosePerPeriod()) + tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } - static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; + static public org.hl7.fhir.dstu3.model.Enumeration convertActionList(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcessRequest.ActionListEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CANCEL: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.CANCEL); + break; + case POLL: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.POLL); + break; + case REPROCESS: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.REPROCESS); + break; + case STATUS: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.STATUS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL); + break; } + return tgt; + } - public static org.hl7.fhir.dstu3.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertActionList(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ProcessRequest.ActionListEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case CANCEL: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.CANCEL); + break; + case POLL: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.POLL); + break; + case REPROCESS: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.REPROCESS); + break; + case STATUS: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.STATUS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.NULL); + break; } + return tgt; + } - public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertType(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } + public static org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent(); + copyElement(src, tgt); + if (src.hasSequenceLinkIdElement()) + tgt.setSequenceLinkIdElement(convertInteger(src.getSequenceLinkIdElement())); + return tgt; + } - static public org.hl7.fhir.dstu3.model.Enumeration convertActionList(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcessRequest.ActionListEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CANCEL: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.CANCEL); - break; - case POLL: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.POLL); - break; - case REPROCESS: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.REPROCESS); - break; - case STATUS: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.STATUS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL); - break; - } - return tgt; - } + public static org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent(); + copyElement(src, tgt); + if (src.hasSequenceLinkIdElement()) + tgt.setSequenceLinkIdElement(convertInteger(src.getSequenceLinkIdElement())); + return tgt; + } - static public org.hl7.fhir.dstu2.model.Enumeration convertActionList(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ProcessRequest.ActionListEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case CANCEL: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.CANCEL); - break; - case POLL: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.POLL); - break; - case REPROCESS: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.REPROCESS); - break; - case STATUS: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.STATUS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.NULL); - break; - } - return tgt; + static public org.hl7.fhir.dstu3.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL); + break; } + return tgt; + } - public static org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent(); - copyElement(src, tgt); - if (src.hasSequenceLinkIdElement()) - tgt.setSequenceLinkIdElement(convertInteger(src.getSequenceLinkIdElement())); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + break; } + return tgt; + } - public static org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent(); - copyElement(src, tgt); - if (src.hasSequenceLinkIdElement()) - tgt.setSequenceLinkIdElement(convertInteger(src.getSequenceLinkIdElement())); - return tgt; + static public org.hl7.fhir.dstu3.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case REQUESTED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ACTIVE); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case FAILED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL); + break; } + return tgt; + } - static public org.hl7.fhir.dstu3.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL); - break; - } - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_30.copyElement(src, tgt); + switch (src.getValue()) { + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + break; } + return tgt; + } - static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); - break; - } - return tgt; - } + public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.dstu3.model.CodeSystem src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); + copyElement(src, tgt); + if (src.hasUrlElement()) + tgt.setSystemElement(convertUri(src.getUrlElement())); + if (src.hasVersionElement()) + tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCaseSensitiveElement()) + tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); + for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); + return tgt; + } - static public org.hl7.fhir.dstu3.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case REQUESTED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ACTIVE); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case FAILED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.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; + } - static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_30.copyElement(src, tgt); - switch(src.getValue()) { - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); + copyElement(src, tgt); + tgt.setUse(convertCoding(src.getUse())); + tgt.setLanguage(src.getLanguage()); + tgt.setValue(src.getValue()); + return tgt; + } - public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.dstu3.model.CodeSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setSystemElement(convertUri(src.getUrlElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCaseSensitiveElement()) - tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); - for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); - return tgt; - } + static public 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 static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.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 static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.dstu2.model.Parameters) + return Parameters10_30.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2.model.Account) + return Account10_30.convertAccount((org.hl7.fhir.dstu2.model.Account) src); + if (src instanceof org.hl7.fhir.dstu2.model.Appointment) + return Appointment10_30.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) + return AppointmentResponse10_30.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) + return AuditEvent10_30.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu2.model.Basic) + return Basic10_30.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu2.model.Binary) + return Binary10_30.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu2.model.Bundle) + return Bundle10_30.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) + return CarePlan10_30.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu2.model.ClinicalImpression) + return ClinicalImpression10_30.convertClinicalImpression((org.hl7.fhir.dstu2.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.dstu2.model.Communication) + return Communication10_30.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) + return CommunicationRequest10_30.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.Composition) + return Composition10_30.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) + return ConceptMap10_30.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2.model.Condition) + return Condition10_30.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Conformance) + return Conformance10_30.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Contract) + return Contract10_30.convertContract((org.hl7.fhir.dstu2.model.Contract) src); + if (src instanceof org.hl7.fhir.dstu2.model.DataElement) + return DataElement10_30.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) + return DetectedIssue10_30.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu2.model.Device) + return Device10_30.convertDevice((org.hl7.fhir.dstu2.model.Device) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceComponent) + return DeviceComponent10_30.convertDeviceComponent((org.hl7.fhir.dstu2.model.DeviceComponent) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) + return DeviceMetric10_30.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) + return DeviceUseStatement10_30.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) + return DiagnosticReport10_30.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu2.model.DocumentManifest) + return DocumentManifest10_30.convertDocumentManifest((org.hl7.fhir.dstu2.model.DocumentManifest) src); + if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) + return DocumentReference10_30.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu2.model.Encounter) + return Encounter10_30.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) + return EnrollmentRequest10_30.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) + return EnrollmentResponse10_30.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) + return EpisodeOfCare10_30.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) + return FamilyMemberHistory10_30.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu2.model.Flag) + return Flag10_30.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu2.model.Group) + return Group10_30.convertGroup((org.hl7.fhir.dstu2.model.Group) src); + if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) + return HealthcareService10_30.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu2.model.ImagingStudy) + return ImagingStudy10_30.convertImagingStudy((org.hl7.fhir.dstu2.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.dstu2.model.Immunization) + return Immunization10_30.convertImmunization((org.hl7.fhir.dstu2.model.Immunization) src); + if (src instanceof org.hl7.fhir.dstu2.model.ImmunizationRecommendation) + return ImmunizationRecommendation10_30.convertImmunizationRecommendation((org.hl7.fhir.dstu2.model.ImmunizationRecommendation) src); + if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) + return ImplementationGuide10_30.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2.model.List_) + return List10_30.convertList((org.hl7.fhir.dstu2.model.List_) src); + if (src instanceof org.hl7.fhir.dstu2.model.Location) + return Location10_30.convertLocation((org.hl7.fhir.dstu2.model.Location) src); + if (src instanceof org.hl7.fhir.dstu2.model.Media) + return Media10_30.convertMedia((org.hl7.fhir.dstu2.model.Media) src); + if (src instanceof org.hl7.fhir.dstu2.model.Medication) + return Medication10_30.convertMedication((org.hl7.fhir.dstu2.model.Medication) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) + return MedicationDispense10_30.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) + return MedicationStatement10_30.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) + return MessageHeader10_30.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) + return NamingSystem10_30.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2.model.Observation) + return Observation10_30.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) + return OperationDefinition10_30.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) + return OperationOutcome10_30.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2.model.Organization) + return Organization10_30.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu2.model.Patient) + return Patient10_30.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu2.model.Person) + return Person10_30.convertPerson((org.hl7.fhir.dstu2.model.Person) src); + if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) + return Practitioner10_30.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu2.model.Procedure) + return Procedure10_30.convertProcedure((org.hl7.fhir.dstu2.model.Procedure) src); + if (src instanceof org.hl7.fhir.dstu2.model.ProcedureRequest) + return ProcedureRequest10_30.convertProcedureRequest((org.hl7.fhir.dstu2.model.ProcedureRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.Provenance) + return Provenance10_30.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) + return Questionnaire10_30.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) + return QuestionnaireResponse10_30.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.ReferralRequest) + return ReferralRequest10_30.convertReferralRequest((org.hl7.fhir.dstu2.model.ReferralRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.RelatedPerson) + return RelatedPerson10_30.convertRelatedPerson((org.hl7.fhir.dstu2.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) + return RiskAssessment10_30.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu2.model.Schedule) + return Schedule10_30.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) + return SearchParameter10_30.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2.model.Slot) + return Slot10_30.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) + return StructureDefinition10_30.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Subscription) + return Subscription10_30.convertSubscription((org.hl7.fhir.dstu2.model.Subscription) src); + if (src instanceof org.hl7.fhir.dstu2.model.Substance) + return Substance10_30.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) + return SupplyDelivery10_30.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) + return SupplyRequest10_30.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.TestScript) + return TestScript10_30.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) + return ValueSet10_30.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } - public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); - copyElement(src, tgt); - tgt.setUse(convertCoding(src.getUse())); - tgt.setLanguage(src.getLanguage()); - tgt.setValue(src.getValue()); - return tgt; - } + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { + if (src == null || src.isEmpty()) + return null; + if (src instanceof org.hl7.fhir.dstu3.model.Parameters) + return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu3.model.Appointment) + return Appointment10_30.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) + return AppointmentResponse10_30.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) + return AuditEvent10_30.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu3.model.Basic) + return Basic10_30.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu3.model.Binary) + return Binary10_30.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu3.model.Bundle) + return Bundle10_30.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src, advisor); + if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) + return CarePlan10_30.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) + return ClinicalImpression10_30.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.dstu3.model.Communication) + return Communication10_30.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu3.model.CommunicationRequest) + return CommunicationRequest10_30.convertCommunicationRequest((org.hl7.fhir.dstu3.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.Composition) + return Composition10_30.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) + return ConceptMap10_30.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.Condition) + return Condition10_30.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) + return Conformance10_30.convertConformance((org.hl7.fhir.dstu3.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.Contract) + return Contract10_30.convertContract((org.hl7.fhir.dstu3.model.Contract) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataElement) + return DataElement10_30.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) + return DetectedIssue10_30.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu3.model.Device) + return Device10_30.convertDevice((org.hl7.fhir.dstu3.model.Device) src); + if (src instanceof org.hl7.fhir.dstu3.model.DeviceComponent) + return DeviceComponent10_30.convertDeviceComponent((org.hl7.fhir.dstu3.model.DeviceComponent) src); + if (src instanceof org.hl7.fhir.dstu3.model.DeviceMetric) + return DeviceMetric10_30.convertDeviceMetric((org.hl7.fhir.dstu3.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) + return DeviceUseStatement10_30.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) + return DiagnosticReport10_30.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu3.model.DocumentManifest) + return DocumentManifest10_30.convertDocumentManifest((org.hl7.fhir.dstu3.model.DocumentManifest) src); + if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) + return DocumentReference10_30.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu3.model.Encounter) + return Encounter10_30.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu3.model.EnrollmentRequest) + return EnrollmentRequest10_30.convertEnrollmentRequest((org.hl7.fhir.dstu3.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.EnrollmentResponse) + return EnrollmentResponse10_30.convertEnrollmentResponse((org.hl7.fhir.dstu3.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) + return EpisodeOfCare10_30.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) + return FamilyMemberHistory10_30.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu3.model.Flag) + return Flag10_30.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu3.model.Group) + return Group10_30.convertGroup((org.hl7.fhir.dstu3.model.Group) src); + if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) + return HealthcareService10_30.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) + return ImagingStudy10_30.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.dstu3.model.Immunization) + return Immunization10_30.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImmunizationRecommendation) + return ImmunizationRecommendation10_30.convertImmunizationRecommendation((org.hl7.fhir.dstu3.model.ImmunizationRecommendation) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) + return ImplementationGuide10_30.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu3.model.ListResource) + return List10_30.convertList((org.hl7.fhir.dstu3.model.ListResource) src); + if (src instanceof org.hl7.fhir.dstu3.model.Location) + return Location10_30.convertLocation((org.hl7.fhir.dstu3.model.Location) src); + if (src instanceof org.hl7.fhir.dstu3.model.Media) + return Media10_30.convertMedia((org.hl7.fhir.dstu3.model.Media) src); + if (src instanceof org.hl7.fhir.dstu3.model.Medication) + return Medication10_30.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) + return MedicationDispense10_30.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) + return MedicationStatement10_30.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) + return MessageHeader10_30.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) + return NamingSystem10_30.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.Observation) + return Observation10_30.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) + return OperationDefinition10_30.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) + return OperationOutcome10_30.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu3.model.Organization) + return Organization10_30.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu3.model.Patient) + return Patient10_30.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu3.model.Person) + return Person10_30.convertPerson((org.hl7.fhir.dstu3.model.Person) src); + if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) + return Practitioner10_30.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu3.model.Procedure) + return Procedure10_30.convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src); + if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest) + return ProcedureRequest10_30.convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.Provenance) + return Provenance10_30.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) + return Questionnaire10_30.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) + return QuestionnaireResponse10_30.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.ReferralRequest) + return ReferralRequest10_30.convertReferralRequest((org.hl7.fhir.dstu3.model.ReferralRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) + return RelatedPerson10_30.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) + return RiskAssessment10_30.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu3.model.Schedule) + return Schedule10_30.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) + return SearchParameter10_30.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu3.model.Slot) + return Slot10_30.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu3.model.Specimen) + return Specimen10_30.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) + return StructureDefinition10_30.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Subscription) + return Subscription10_30.convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src); + if (src instanceof org.hl7.fhir.dstu3.model.Substance) + return Substance10_30.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) + return SupplyDelivery10_30.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu3.model.SupplyRequest) + return SupplyRequest10_30.convertSupplyRequest((org.hl7.fhir.dstu3.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestScript) + return TestScript10_30.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) + return ValueSet10_30.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } - static public 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 static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "ClinicalImpression", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "Contract", "DataElement", "DetectedIssue", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentManifest", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "ListResource", "Location", "Media", "Medication", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Procedure", "ProcedureRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); + } - public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Parameters) - return Parameters10_30.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2.model.Account) - return Account10_30.convertAccount((org.hl7.fhir.dstu2.model.Account) src); - if (src instanceof org.hl7.fhir.dstu2.model.Appointment) - return Appointment10_30.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) - return AppointmentResponse10_30.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) - return AuditEvent10_30.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu2.model.Basic) - return Basic10_30.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu2.model.Binary) - return Binary10_30.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu2.model.Bundle) - return Bundle10_30.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) - return CarePlan10_30.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu2.model.ClinicalImpression) - return ClinicalImpression10_30.convertClinicalImpression((org.hl7.fhir.dstu2.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.dstu2.model.Communication) - return Communication10_30.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) - return CommunicationRequest10_30.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.Composition) - return Composition10_30.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) - return ConceptMap10_30.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2.model.Condition) - return Condition10_30.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Conformance) - return Conformance10_30.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Contract) - return Contract10_30.convertContract((org.hl7.fhir.dstu2.model.Contract) src); - if (src instanceof org.hl7.fhir.dstu2.model.DataElement) - return DataElement10_30.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) - return DetectedIssue10_30.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu2.model.Device) - return Device10_30.convertDevice((org.hl7.fhir.dstu2.model.Device) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceComponent) - return DeviceComponent10_30.convertDeviceComponent((org.hl7.fhir.dstu2.model.DeviceComponent) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) - return DeviceMetric10_30.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) - return DeviceUseStatement10_30.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) - return DiagnosticReport10_30.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu2.model.DocumentManifest) - return DocumentManifest10_30.convertDocumentManifest((org.hl7.fhir.dstu2.model.DocumentManifest) src); - if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) - return DocumentReference10_30.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu2.model.Encounter) - return Encounter10_30.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) - return EnrollmentRequest10_30.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) - return EnrollmentResponse10_30.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) - return EpisodeOfCare10_30.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) - return FamilyMemberHistory10_30.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu2.model.Flag) - return Flag10_30.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu2.model.Group) - return Group10_30.convertGroup((org.hl7.fhir.dstu2.model.Group) src); - if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) - return HealthcareService10_30.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu2.model.ImagingStudy) - return ImagingStudy10_30.convertImagingStudy((org.hl7.fhir.dstu2.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.dstu2.model.Immunization) - return Immunization10_30.convertImmunization((org.hl7.fhir.dstu2.model.Immunization) src); - if (src instanceof org.hl7.fhir.dstu2.model.ImmunizationRecommendation) - return ImmunizationRecommendation10_30.convertImmunizationRecommendation((org.hl7.fhir.dstu2.model.ImmunizationRecommendation) src); - if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) - return ImplementationGuide10_30.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2.model.List_) - return List10_30.convertList((org.hl7.fhir.dstu2.model.List_) src); - if (src instanceof org.hl7.fhir.dstu2.model.Location) - return Location10_30.convertLocation((org.hl7.fhir.dstu2.model.Location) src); - if (src instanceof org.hl7.fhir.dstu2.model.Media) - return Media10_30.convertMedia((org.hl7.fhir.dstu2.model.Media) src); - if (src instanceof org.hl7.fhir.dstu2.model.Medication) - return Medication10_30.convertMedication((org.hl7.fhir.dstu2.model.Medication) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) - return MedicationDispense10_30.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) - return MedicationStatement10_30.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) - return MessageHeader10_30.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) - return NamingSystem10_30.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2.model.Observation) - return Observation10_30.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) - return OperationDefinition10_30.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) - return OperationOutcome10_30.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2.model.Organization) - return Organization10_30.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu2.model.Patient) - return Patient10_30.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu2.model.Person) - return Person10_30.convertPerson((org.hl7.fhir.dstu2.model.Person) src); - if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) - return Practitioner10_30.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu2.model.Procedure) - return Procedure10_30.convertProcedure((org.hl7.fhir.dstu2.model.Procedure) src); - if (src instanceof org.hl7.fhir.dstu2.model.ProcedureRequest) - return ProcedureRequest10_30.convertProcedureRequest((org.hl7.fhir.dstu2.model.ProcedureRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.Provenance) - return Provenance10_30.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) - return Questionnaire10_30.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) - return QuestionnaireResponse10_30.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.ReferralRequest) - return ReferralRequest10_30.convertReferralRequest((org.hl7.fhir.dstu2.model.ReferralRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.RelatedPerson) - return RelatedPerson10_30.convertRelatedPerson((org.hl7.fhir.dstu2.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) - return RiskAssessment10_30.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu2.model.Schedule) - return Schedule10_30.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) - return SearchParameter10_30.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2.model.Slot) - return Slot10_30.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) - return StructureDefinition10_30.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Subscription) - return Subscription10_30.convertSubscription((org.hl7.fhir.dstu2.model.Subscription) src); - if (src instanceof org.hl7.fhir.dstu2.model.Substance) - return Substance10_30.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) - return SupplyDelivery10_30.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) - return SupplyRequest10_30.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.TestScript) - return TestScript10_30.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) - return ValueSet10_30.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } + public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { + return convertResource(src, null); + } - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Parameters) - return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu3.model.Appointment) - return Appointment10_30.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) - return AppointmentResponse10_30.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) - return AuditEvent10_30.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu3.model.Basic) - return Basic10_30.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu3.model.Binary) - return Binary10_30.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu3.model.Bundle) - return Bundle10_30.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src, advisor); - if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) - return CarePlan10_30.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) - return ClinicalImpression10_30.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.dstu3.model.Communication) - return Communication10_30.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu3.model.CommunicationRequest) - return CommunicationRequest10_30.convertCommunicationRequest((org.hl7.fhir.dstu3.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.Composition) - return Composition10_30.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) - return ConceptMap10_30.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.Condition) - return Condition10_30.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) - return Conformance10_30.convertConformance((org.hl7.fhir.dstu3.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.Contract) - return Contract10_30.convertContract((org.hl7.fhir.dstu3.model.Contract) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataElement) - return DataElement10_30.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) - return DetectedIssue10_30.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu3.model.Device) - return Device10_30.convertDevice((org.hl7.fhir.dstu3.model.Device) src); - if (src instanceof org.hl7.fhir.dstu3.model.DeviceComponent) - return DeviceComponent10_30.convertDeviceComponent((org.hl7.fhir.dstu3.model.DeviceComponent) src); - if (src instanceof org.hl7.fhir.dstu3.model.DeviceMetric) - return DeviceMetric10_30.convertDeviceMetric((org.hl7.fhir.dstu3.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) - return DeviceUseStatement10_30.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) - return DiagnosticReport10_30.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu3.model.DocumentManifest) - return DocumentManifest10_30.convertDocumentManifest((org.hl7.fhir.dstu3.model.DocumentManifest) src); - if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) - return DocumentReference10_30.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu3.model.Encounter) - return Encounter10_30.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu3.model.EnrollmentRequest) - return EnrollmentRequest10_30.convertEnrollmentRequest((org.hl7.fhir.dstu3.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.EnrollmentResponse) - return EnrollmentResponse10_30.convertEnrollmentResponse((org.hl7.fhir.dstu3.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) - return EpisodeOfCare10_30.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) - return FamilyMemberHistory10_30.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu3.model.Flag) - return Flag10_30.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu3.model.Group) - return Group10_30.convertGroup((org.hl7.fhir.dstu3.model.Group) src); - if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) - return HealthcareService10_30.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) - return ImagingStudy10_30.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.dstu3.model.Immunization) - return Immunization10_30.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImmunizationRecommendation) - return ImmunizationRecommendation10_30.convertImmunizationRecommendation((org.hl7.fhir.dstu3.model.ImmunizationRecommendation) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) - return ImplementationGuide10_30.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu3.model.ListResource) - return List10_30.convertList((org.hl7.fhir.dstu3.model.ListResource) src); - if (src instanceof org.hl7.fhir.dstu3.model.Location) - return Location10_30.convertLocation((org.hl7.fhir.dstu3.model.Location) src); - if (src instanceof org.hl7.fhir.dstu3.model.Media) - return Media10_30.convertMedia((org.hl7.fhir.dstu3.model.Media) src); - if (src instanceof org.hl7.fhir.dstu3.model.Medication) - return Medication10_30.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) - return MedicationDispense10_30.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) - return MedicationStatement10_30.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) - return MessageHeader10_30.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) - return NamingSystem10_30.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.Observation) - return Observation10_30.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) - return OperationDefinition10_30.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) - return OperationOutcome10_30.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu3.model.Organization) - return Organization10_30.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu3.model.Patient) - return Patient10_30.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu3.model.Person) - return Person10_30.convertPerson((org.hl7.fhir.dstu3.model.Person) src); - if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) - return Practitioner10_30.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu3.model.Procedure) - return Procedure10_30.convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src); - if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest) - return ProcedureRequest10_30.convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.Provenance) - return Provenance10_30.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) - return Questionnaire10_30.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) - return QuestionnaireResponse10_30.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.ReferralRequest) - return ReferralRequest10_30.convertReferralRequest((org.hl7.fhir.dstu3.model.ReferralRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) - return RelatedPerson10_30.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) - return RiskAssessment10_30.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu3.model.Schedule) - return Schedule10_30.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) - return SearchParameter10_30.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu3.model.Slot) - return Slot10_30.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu3.model.Specimen) - return Specimen10_30.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) - return StructureDefinition10_30.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Subscription) - return Subscription10_30.convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src); - if (src instanceof org.hl7.fhir.dstu3.model.Substance) - return Substance10_30.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) - return SupplyDelivery10_30.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu3.model.SupplyRequest) - return SupplyRequest10_30.convertSupplyRequest((org.hl7.fhir.dstu3.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestScript) - return TestScript10_30.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) - return ValueSet10_30.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "ClinicalImpression", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "Contract", "DataElement", "DetectedIssue", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentManifest", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "ListResource", "Location", "Media", "Medication", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Procedure", "ProcedureRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); - } - - public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { - return convertResource(src, null); - } - - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { - return convertResource(src, null); - } + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { + return convertResource(src, null); + } } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index 3cd708bce..a4922239b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -170,241 +170,241 @@ public class VersionConvertor_10_40 { } public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue()); + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2.model.BooleanType tgt = new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()); + org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue()); + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateTimeType tgt = new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue()); + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DecimalType tgt = new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()); + org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue()); + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IdType tgt = new org.hl7.fhir.dstu2.model.IdType(src.getValue()); + org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValue()); + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValue()) : new org.hl7.fhir.r4.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2.model.InstantType tgt = new org.hl7.fhir.dstu2.model.InstantType(src.getValue()); + org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue()); + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IntegerType tgt = new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()); + org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue()); + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.MarkdownType tgt = new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()); + org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue()); + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.OidType tgt = new org.hl7.fhir.dstu2.model.OidType(src.getValue()); + org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.PositiveIntType tgt = new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()); + org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue()); + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = new org.hl7.fhir.dstu2.model.StringType(src.getValue()); + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue()); + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.TimeType tgt = new org.hl7.fhir.dstu2.model.TimeType(src.getValue()); + org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UriType tgt = new org.hl7.fhir.dstu2.model.UriType(src.getValue()); + org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue()); + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UuidType tgt = new org.hl7.fhir.dstu2.model.UuidType(src.getValue()); + org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java index 972e5873c..a9ffd31bb 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java @@ -179,241 +179,241 @@ public class VersionConvertor_10_50 { } public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(src.getValue()); + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2.model.BooleanType tgt = new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()); + org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(src.getValue()); + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(src.getValue()); + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = new org.hl7.fhir.dstu2.model.CodeType(src.getValue()); + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateTimeType tgt = new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType(src.getValue()); + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DecimalType tgt = new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()); + org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType(src.getValue()); + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IdType tgt = new org.hl7.fhir.dstu2.model.IdType(src.getValue()); + org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(src.getValue()); + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2.model.InstantType tgt = new org.hl7.fhir.dstu2.model.InstantType(src.getValue()); + org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(src.getValue()); + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IntegerType tgt = new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()); + org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(src.getValue()); + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.MarkdownType tgt = new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()); + org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = new org.hl7.fhir.r5.model.OidType(src.getValue()); + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.OidType tgt = new org.hl7.fhir.dstu2.model.OidType(src.getValue()); + org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.PositiveIntType tgt = new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()); + org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(src.getValue()); + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = new org.hl7.fhir.dstu2.model.StringType(src.getValue()); + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = new org.hl7.fhir.r5.model.TimeType(src.getValue()); + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.TimeType tgt = new org.hl7.fhir.dstu2.model.TimeType(src.getValue()); + org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(src.getValue()); + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UriType tgt = new org.hl7.fhir.dstu2.model.UriType(src.getValue()); + org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = new org.hl7.fhir.r5.model.UuidType(src.getValue()); + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UuidType tgt = new org.hl7.fhir.dstu2.model.UuidType(src.getValue()); + org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java index 3e7c38022..412cadfc3 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java @@ -79,8 +79,7 @@ import java.util.stream.Collectors; public class VersionConvertor_14_30 { static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && (!(e.getUrl().equals(VersionConvertorConstants.PROFILE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION)))) { tgt.addExtension(convertExtension(e)); @@ -89,8 +88,7 @@ public class VersionConvertor_14_30 { } static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { tgt.addExtension(convertExtension(e)); @@ -114,272 +112,238 @@ public class VersionConvertor_14_30 { public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); + if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java index 413a731dd..601f90728 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java @@ -202,217 +202,217 @@ public class VersionConvertor_30_40 { } public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue()); + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()); + org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue()); + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue()); + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue()); + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()); + org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue()); + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(src.getValue()); + org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()); + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue()); + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()); + org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue()); + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()); + org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue()); + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(src.getValue()); + org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()); + org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue()); + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue()); + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue()); + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(src.getValue()); + org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(src.getValue()); + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue()); + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(src.getValue()); + org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java index 8151527c0..417489293 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java @@ -203,145 +203,145 @@ public class VersionConvertor_30_50 { } public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(src.getValue()); + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()); + org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(src.getValue()); + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue()); + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.CodeType convertStringToCode(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(src.getValue()); + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.StringType convertCodeToString(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue()); + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.CodeType convertStringToCode(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue()); + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.StringType convertCodeToString(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(src.getValue()); + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType(src.getValue()); + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()); + org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType(src.getValue()); + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(src.getValue()); + org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()); + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()); + org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(src.getValue()); + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()); + org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); copyElement(src, tgt); return tgt; } @@ -353,121 +353,121 @@ public class VersionConvertor_30_50 { } public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(src.getValue()); + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()); + org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = new org.hl7.fhir.r5.model.OidType(src.getValue()); + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(src.getValue()); + org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()); + org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(src.getValue()); + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue()); + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(src.getValue()); + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.StringType convertMarkdownToString(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(src.getValue()); + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = new org.hl7.fhir.r5.model.TimeType(src.getValue()); + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(src.getValue()); + org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(src.getValue()); + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(src.getValue()); + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(src.getValue()); + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(src.getValue()); + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = new org.hl7.fhir.r5.model.UuidType(src.getValue()); + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(src.getValue()); + org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java index 7a7ac771e..8c58b003f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java @@ -70,8 +70,7 @@ public class VersionConvertor_40_50 { } protected static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { tgt.addExtension(convertExtension(e)); @@ -80,8 +79,7 @@ public class VersionConvertor_40_50 { } protected static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { tgt.addExtension(convertExtension(e)); @@ -90,16 +88,14 @@ public class VersionConvertor_40_50 { } protected static void copyEnumeration(org.hl7.fhir.r4.model.Enumeration src, org.hl7.fhir.r5.model.Enumeration tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { tgt.addExtension(convertExtension(e)); } } protected static void copyEnumeration(org.hl7.fhir.r5.model.Enumeration src, org.hl7.fhir.r4.model.Enumeration tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); + if (src.hasId()) tgt.setId(src.getId()); for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { tgt.addExtension(convertExtension(e)); } @@ -138,241 +134,241 @@ public class VersionConvertor_40_50 { } public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()); + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(src.getValue()); + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(src.getValue()); + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.CanonicalType convertCanonical(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.r5.model.CanonicalType tgt = new org.hl7.fhir.r5.model.CanonicalType(src.getValue()); + org.hl7.fhir.r5.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r5.model.CanonicalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.CanonicalType convertCanonical(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.r4.model.CanonicalType tgt = new org.hl7.fhir.r4.model.CanonicalType(src.getValue()); + org.hl7.fhir.r4.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r4.model.CanonicalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(src.getValue()); + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(src.getValue()); + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(src.getValue()); + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValue()) : new org.hl7.fhir.r5.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(src.getValue()); + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValue()) : new org.hl7.fhir.r4.model.DateType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(src.getValue()); + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValue()) : new org.hl7.fhir.r5.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(src.getValue()); + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValue()) : new org.hl7.fhir.r4.model.DateTimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType(src.getValue()); + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(src.getValue()); + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType(src.getValue()); + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(src.getValue()); + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(src.getValue()); + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(src.getValue()); + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValue()) : new org.hl7.fhir.r4.model.InstantType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(src.getValue()); + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.Integer64Type convertUnsignedIntToInteger64(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.Integer64Type tgt = new org.hl7.fhir.r5.model.Integer64Type(Long.valueOf(src.getValue())); + org.hl7.fhir.r5.model.Integer64Type tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Integer64Type(Long.valueOf(src.getValue())) : new org.hl7.fhir.r5.model.Integer64Type(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UnsignedIntType convertInteger64ToUnsignedInt(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(Math.toIntExact(src.getValue())); + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(Math.toIntExact(src.getValue())) : new org.hl7.fhir.r4.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(src.getValue()); + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(src.getValue()); + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(src.getValue()); + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = new org.hl7.fhir.r5.model.OidType(src.getValue()); + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(src.getValue()); + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()); + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(src.getValue()); + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(src.getValue()); + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = new org.hl7.fhir.r5.model.TimeType(src.getValue()); + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(src.getValue()); + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()); + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(src.getValue()); + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(src.getValue()); + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UrlType convertUrl(org.hl7.fhir.r4.model.UrlType src) throws FHIRException { - org.hl7.fhir.r5.model.UrlType tgt = new org.hl7.fhir.r5.model.UrlType(src.getValue()); + org.hl7.fhir.r5.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UrlType(src.getValue()) : new org.hl7.fhir.r5.model.UrlType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UrlType convertUrl(org.hl7.fhir.r5.model.UrlType src) throws FHIRException { - org.hl7.fhir.r4.model.UrlType tgt = new org.hl7.fhir.r4.model.UrlType(src.getValue()); + org.hl7.fhir.r4.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UrlType(src.getValue()) : new org.hl7.fhir.r4.model.UrlType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = new org.hl7.fhir.r5.model.UuidType(src.getValue()); + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); copyElement(src, tgt); return tgt; } public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(src.getValue()); + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); copyElement(src, tgt); return tgt; } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java new file mode 100644 index 000000000..1b1accf9a --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_30Test.java @@ -0,0 +1,84 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.dstu2.model.BooleanType; +import org.hl7.fhir.dstu2.model.CodeType; +import org.hl7.fhir.dstu2.model.DateType; +import org.hl7.fhir.dstu2.model.DateTimeType; +import org.hl7.fhir.dstu2.model.DecimalType; +import org.hl7.fhir.dstu2.model.InstantType; +import org.hl7.fhir.dstu2.model.PositiveIntType; +import org.hl7.fhir.dstu2.model.UnsignedIntType; +import org.hl7.fhir.dstu2.model.IntegerType; +import org.hl7.fhir.dstu2.model.MarkdownType; +import org.hl7.fhir.dstu2.model.OidType; +import org.hl7.fhir.dstu2.model.StringType; +import org.hl7.fhir.dstu2.model.TimeType; +import org.hl7.fhir.dstu2.model.UuidType; +import org.hl7.fhir.dstu2.model.PrimitiveType; +import org.hl7.fhir.dstu2.model.Base64BinaryType; +import org.hl7.fhir.dstu2.model.UriType; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType10_30Test { + + @ParameterizedTest(name = "Testing dstu2 -> dstu3 conversion of null value {0}.") + @MethodSource("dstu2PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.dstu3.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing dstu3 -> dstu2 conversion of null value {0}.") + @MethodSource("Dstu3PrimitiveTypes") + public void testNullValueDstu3Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu3.model.StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.dstu2.model.PrimitiveType) VersionConvertor_10_30.convertType(obj)).getValue()); + } + + public static Stream dstu2PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream Dstu3PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.dstu3.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.CodeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.CodeType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.DateType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DateType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.InstantType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.InstantType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.OidType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.OidType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.StringType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.StringType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.TimeType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.TimeType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.UuidType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UuidType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.dstu3.model.UriType.class.getSimpleName(), new org.hl7.fhir.dstu3.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java new file mode 100644 index 000000000..d6c04a959 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_40Test.java @@ -0,0 +1,67 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.dstu2.model.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType10_40Test { + + @ParameterizedTest(name = "Testing dstu2 -> r4 conversion of null value {0}.") + @MethodSource("dstu2PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing r4 -> dstu2 conversion of null value {0}.") + @MethodSource("r4PrimitiveTypes") + public void testNullValueR4Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r4.model.StringType("A value")); + Assertions.assertNull(((PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue()); + } + + public static Stream dstu2PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream r4PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.r4.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r4.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.r4.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r4.model.CodeType()), + Arguments.arguments(org.hl7.fhir.r4.model.DateType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateType()), + Arguments.arguments(org.hl7.fhir.r4.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.r4.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r4.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.r4.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r4.model.InstantType()), + Arguments.arguments(org.hl7.fhir.r4.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.r4.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.r4.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r4.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.r4.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r4.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.r4.model.OidType.class.getSimpleName(), new org.hl7.fhir.r4.model.OidType()), + Arguments.arguments(org.hl7.fhir.r4.model.StringType.class.getSimpleName(), new org.hl7.fhir.r4.model.StringType()), + Arguments.arguments(org.hl7.fhir.r4.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.TimeType()), + Arguments.arguments(org.hl7.fhir.r4.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r4.model.UuidType()), + Arguments.arguments(org.hl7.fhir.r4.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r4.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.r4.model.UriType.class.getSimpleName(), new org.hl7.fhir.r4.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java new file mode 100644 index 000000000..aba2d717f --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType10_50Test.java @@ -0,0 +1,67 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.dstu2.model.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType10_50Test { + + @ParameterizedTest(name = "Testing dstu2 -> r5 conversion of null value {0}.") + @MethodSource("dstu2PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_10_40.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing r5 -> dstu2 conversion of null value {0}.") + @MethodSource("r5PrimitiveTypes") + public void testNullValueR5Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value")); + Assertions.assertNull(((PrimitiveType) VersionConvertor_10_50.convertType(obj)).getValue()); + } + + public static Stream dstu2PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream r5PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()), + Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()), + Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()), + Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()), + Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java new file mode 100644 index 000000000..58bb89d35 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_40Test.java @@ -0,0 +1,67 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.dstu3.model.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType30_40Test { + + @ParameterizedTest(name = "Testing dstu3 -> r4 conversion of null value {0}.") + @MethodSource("dstu3PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.r4.model.PrimitiveType) VersionConvertor_30_40.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing r4 -> dstu3 conversion of null value {0}.") + @MethodSource("r4PrimitiveTypes") + public void testNullValueR4Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r4.model.StringType("A value")); + Assertions.assertNull(((PrimitiveType) VersionConvertor_30_40.convertType(obj)).getValue()); + } + + public static Stream dstu3PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream r4PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.r4.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r4.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.r4.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r4.model.CodeType()), + Arguments.arguments(org.hl7.fhir.r4.model.DateType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateType()), + Arguments.arguments(org.hl7.fhir.r4.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.r4.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r4.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.r4.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r4.model.InstantType()), + Arguments.arguments(org.hl7.fhir.r4.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.r4.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r4.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.r4.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r4.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.r4.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r4.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.r4.model.OidType.class.getSimpleName(), new org.hl7.fhir.r4.model.OidType()), + Arguments.arguments(org.hl7.fhir.r4.model.StringType.class.getSimpleName(), new org.hl7.fhir.r4.model.StringType()), + Arguments.arguments(org.hl7.fhir.r4.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r4.model.TimeType()), + Arguments.arguments(org.hl7.fhir.r4.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r4.model.UuidType()), + Arguments.arguments(org.hl7.fhir.r4.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r4.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.r4.model.UriType.class.getSimpleName(), new org.hl7.fhir.r4.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java new file mode 100644 index 000000000..385a46d10 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType30_50Test.java @@ -0,0 +1,67 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.dstu3.model.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType30_50Test { + + @ParameterizedTest(name = "Testing dstu3 -> r5 conversion of null value {0}.") + @MethodSource("dstu3PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.r5.model.PrimitiveType) VersionConvertor_30_50.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing r5 -> dstu3 conversion of null value {0}.") + @MethodSource("r5PrimitiveTypes") + public void testNullValueR5Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value")); + Assertions.assertNull(((PrimitiveType) VersionConvertor_30_50.convertType(obj)).getValue()); + } + + public static Stream dstu3PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream r5PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()), + Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()), + Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()), + Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()), + Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java new file mode 100644 index 000000000..53e8a1767 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertorPrimitiveType40_50Test.java @@ -0,0 +1,67 @@ +package org.hl7.fhir.convertors; + +import org.hl7.fhir.r4.model.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +public class VersionConvertorPrimitiveType40_50Test { + + @ParameterizedTest(name = "Testing r4 -> r5 conversion of null value {0}.") + @MethodSource("r4PrimitiveTypes") + public void testNullValueDstu2Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new StringType("A value")); + Assertions.assertNull(((org.hl7.fhir.r5.model.PrimitiveType) VersionConvertor_40_50.convertType(obj)).getValue()); + } + + @ParameterizedTest(name = "Testing r5 -> r4 conversion of null value {0}.") + @MethodSource("r5PrimitiveTypes") + public void testNullValueR5Primitive(String classname, T obj) { + obj.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.r5.model.StringType("A value")); + Assertions.assertNull(((PrimitiveType) VersionConvertor_40_50.convertType(obj)).getValue()); + } + + public static Stream r4PrimitiveTypes() { + return Stream.of( + Arguments.arguments(BooleanType.class.getSimpleName(), new BooleanType()), + Arguments.arguments(CodeType.class.getSimpleName(), new CodeType()), + Arguments.arguments(DateType.class.getSimpleName(), new DateType()), + Arguments.arguments(DateTimeType.class.getSimpleName(), new DateTimeType()), + Arguments.arguments(DecimalType.class.getSimpleName(), new DecimalType()), + Arguments.arguments(InstantType.class.getSimpleName(), new InstantType()), + Arguments.arguments(PositiveIntType.class.getSimpleName(), new PositiveIntType()), + Arguments.arguments(UnsignedIntType.class.getSimpleName(), new UnsignedIntType()), + Arguments.arguments(IntegerType.class.getSimpleName(), new IntegerType()), + Arguments.arguments(MarkdownType.class.getSimpleName(), new MarkdownType()), + Arguments.arguments(OidType.class.getSimpleName(), new OidType()), + Arguments.arguments(StringType.class.getSimpleName(), new StringType()), + Arguments.arguments(TimeType.class.getSimpleName(), new TimeType()), + Arguments.arguments(UuidType.class.getSimpleName(), new UuidType()), + Arguments.arguments(Base64BinaryType.class.getSimpleName(), new Base64BinaryType()), + Arguments.arguments(UriType.class.getSimpleName(), new UriType())); + } + + public static Stream r5PrimitiveTypes() { + return Stream.of( + Arguments.arguments(org.hl7.fhir.r5.model.BooleanType.class.getSimpleName(), new org.hl7.fhir.r5.model.BooleanType()), + Arguments.arguments(org.hl7.fhir.r5.model.CodeType.class.getSimpleName(), new org.hl7.fhir.r5.model.CodeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateType()), + Arguments.arguments(org.hl7.fhir.r5.model.DateTimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.DateTimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.DecimalType.class.getSimpleName(), new org.hl7.fhir.r5.model.DecimalType()), + Arguments.arguments(org.hl7.fhir.r5.model.InstantType.class.getSimpleName(), new org.hl7.fhir.r5.model.InstantType()), + Arguments.arguments(org.hl7.fhir.r5.model.PositiveIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.PositiveIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.UnsignedIntType.class.getSimpleName(), new org.hl7.fhir.r5.model.UnsignedIntType()), + Arguments.arguments(org.hl7.fhir.r5.model.IntegerType.class.getSimpleName(), new org.hl7.fhir.r5.model.IntegerType()), + Arguments.arguments(org.hl7.fhir.r5.model.MarkdownType.class.getSimpleName(), new org.hl7.fhir.r5.model.MarkdownType()), + Arguments.arguments(org.hl7.fhir.r5.model.OidType.class.getSimpleName(), new org.hl7.fhir.r5.model.OidType()), + Arguments.arguments(org.hl7.fhir.r5.model.StringType.class.getSimpleName(), new org.hl7.fhir.r5.model.StringType()), + Arguments.arguments(org.hl7.fhir.r5.model.TimeType.class.getSimpleName(), new org.hl7.fhir.r5.model.TimeType()), + Arguments.arguments(org.hl7.fhir.r5.model.UuidType.class.getSimpleName(), new org.hl7.fhir.r5.model.UuidType()), + Arguments.arguments(org.hl7.fhir.r5.model.Base64BinaryType.class.getSimpleName(), new org.hl7.fhir.r5.model.Base64BinaryType()), + Arguments.arguments(org.hl7.fhir.r5.model.UriType.class.getSimpleName(), new org.hl7.fhir.r5.model.UriType())); + } +} + diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java index ab6e543dd..f16b5a3c8 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/VersionConvertor_10_30Test.java @@ -1,18 +1,18 @@ package org.hl7.fhir.convertors; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; public class VersionConvertor_10_30Test { @Test + @DisplayName("Test 10_30 UnsignedIntType preserves value on conversion.") public void testConvertUnsignedInt() { - org.hl7.fhir.dstu3.model.UnsignedIntType output; output = (org.hl7.fhir.dstu3.model.UnsignedIntType)VersionConvertor_10_30.convertType(new org.hl7.fhir.dstu2.model.UnsignedIntType(33)); - assertEquals(33, output.getValue().intValue()); - + Assertions.assertEquals(33, output.getValue().intValue()); } } + diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index f04c9d29f..fc926c2ba 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml @@ -95,7 +95,13 @@ Saxon-HE test + + org.junit.jupiter + junit-jupiter + RELEASE + test + - + diff --git a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/model/Base64BinaryType.java b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/model/Base64BinaryType.java index 12fa68eb9..60500850a 100644 --- a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/model/Base64BinaryType.java +++ b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/model/Base64BinaryType.java @@ -49,6 +49,7 @@ package org.hl7.fhir.dstu2.model; */ +import ca.uhn.fhir.parser.DataFormatException; import org.apache.commons.codec.binary.Base64; import ca.uhn.fhir.model.api.annotation.DatatypeDef; @@ -74,11 +75,17 @@ public class Base64BinaryType extends PrimitiveType { public Base64BinaryType(String theValue) { super(); + // Null values still result in non-null instance being created + if (theValue != null) checkValidBase64(theValue); setValueAsString(theValue); } protected byte[] parse(String theValue) { - return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + if (theValue != null) { + return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + } else { + return null; + } } protected String encode(byte[] theValue) { @@ -96,4 +103,17 @@ public class Base64BinaryType extends PrimitiveType { public String fhirType() { return "base64Binary"; } + + /** + * Checks if the passed in String is a valid {@link Base64} encoded String. Will throw a {@link DataFormatException} if not + * formatted correctly. + * + * @param toCheck {@link String} to check if valid {@link Base64} + * @throws DataFormatException + */ + public void checkValidBase64(String toCheck) throws DataFormatException { + if (!Base64.isBase64(toCheck.getBytes())) { + throw new DataFormatException(""); + } + } } diff --git a/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/model/Base64BinaryTypeTest.java b/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/model/Base64BinaryTypeTest.java new file mode 100644 index 000000000..f92ed0c22 --- /dev/null +++ b/org.hl7.fhir.dstu2/src/test/java/org/hl7/fhir/dstu2/model/Base64BinaryTypeTest.java @@ -0,0 +1,38 @@ +package org.hl7.fhir.dstu2.model; + +import ca.uhn.fhir.parser.DataFormatException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Base64BinaryTypeTest { + + @Test + @DisplayName("Passing a non Base64 encoded String to constructor causes exception.") + public void testNonBase64String() { + String nonBase64 = "Picard was the best starship captain."; + assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64)); + } + + @Test + @DisplayName("Null String value creates non-null instance with null value.") + public void testNullInstance() throws DataFormatException { + String v = null; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNull(b64.getValue()); + Assertions.assertNull(b64.getValueAsString()); + } + + @Test + @DisplayName("Valid Base64 String creates non-null instance with non-null values.") + public void testValid() { + String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNotNull(b64.getValue()); + Assertions.assertEquals(v, b64.asStringValue()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index acbdba752..bbd0f3034 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml @@ -109,7 +109,13 @@ Saxon-HE test + + org.junit.jupiter + junit-jupiter + RELEASE + test + - + diff --git a/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/model/Base64BinaryType.java b/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/model/Base64BinaryType.java index f75be514c..9241aed7a 100644 --- a/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/model/Base64BinaryType.java +++ b/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/model/Base64BinaryType.java @@ -49,6 +49,7 @@ package org.hl7.fhir.dstu2016may.model; */ +import ca.uhn.fhir.parser.DataFormatException; import org.apache.commons.codec.binary.Base64; import ca.uhn.fhir.model.api.annotation.DatatypeDef; @@ -75,11 +76,17 @@ public class Base64BinaryType extends PrimitiveType { public Base64BinaryType(String theValue) { super(); + // Null values still result in non-null instance being created + if (theValue != null) checkValidBase64(theValue); setValueAsString(theValue); } protected byte[] parse(String theValue) { - return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + if (theValue != null) { + return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + } else { + return null; + } } protected String encode(byte[] theValue) { @@ -97,4 +104,17 @@ public class Base64BinaryType extends PrimitiveType { public String fhirType() { return "base64Binary"; } + + /** + * Checks if the passed in String is a valid {@link Base64} encoded String. Will throw a {@link DataFormatException} if not + * formatted correctly. + * + * @param toCheck {@link String} to check if valid {@link Base64} + * @throws DataFormatException + */ + public void checkValidBase64(String toCheck) throws DataFormatException { + if (!Base64.isBase64(toCheck.getBytes())) { + throw new DataFormatException(""); + } + } } diff --git a/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/model/Base64BinaryTypeTest.java b/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/model/Base64BinaryTypeTest.java new file mode 100644 index 000000000..1487a2f47 --- /dev/null +++ b/org.hl7.fhir.dstu2016may/src/test/java/org/hl7/fhir/dstu2016may/model/Base64BinaryTypeTest.java @@ -0,0 +1,38 @@ +package org.hl7.fhir.dstu2016may.model; + +import ca.uhn.fhir.parser.DataFormatException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Base64BinaryTypeTest { + + @Test + @DisplayName("Passing a non Base64 encoded String to constructor causes exception.") + public void testNonBase64String() { + String nonBase64 = "Picard was the best starship captain."; + assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64)); + } + + @Test + @DisplayName("Null String value creates non-null instance with null value.") + public void testNullInstance() throws DataFormatException { + String v = null; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNull(b64.getValue()); + Assertions.assertNull(b64.getValueAsString()); + } + + @Test + @DisplayName("Valid Base64 String creates non-null instance with non-null values.") + public void testValid() { + String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNotNull(b64.getValue()); + Assertions.assertEquals(v, b64.asStringValue()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index dd14b47e7..7efe0d1c4 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml @@ -95,6 +95,12 @@ Saxon-HE test + + org.junit.jupiter + junit-jupiter + RELEASE + test + diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Base64BinaryType.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Base64BinaryType.java index 7e62a955b..a640bdb07 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Base64BinaryType.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Base64BinaryType.java @@ -51,6 +51,7 @@ package org.hl7.fhir.dstu3.model; import ca.uhn.fhir.model.api.IElement; import ca.uhn.fhir.model.api.annotation.DatatypeDef; +import ca.uhn.fhir.parser.DataFormatException; import org.apache.commons.codec.binary.Base64; import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IPrimitiveType; @@ -83,11 +84,17 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv public Base64BinaryType(String theValue) { super(); + // Null values still result in non-null instance being created + if (theValue != null) checkValidBase64(theValue); setValueAsString(theValue); } protected byte[] parse(String theValue) { - return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + if (theValue != null) { + return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + } else { + return null; + } } protected String encode(byte[] theValue) { @@ -128,6 +135,7 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv @Override public void setValueAsString(String theValue) throws IllegalArgumentException { + fromStringValue(theValue); setValue(parse(theValue)); } @@ -153,5 +161,16 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv return ca.uhn.fhir.util.ElementUtil.isEmpty(id, extension) && !hasValue(); } - + /** + * Checks if the passed in String is a valid {@link Base64} encoded String. Will throw a {@link DataFormatException} if not + * formatted correctly. + * + * @param toCheck {@link String} to check if valid {@link Base64} + * @throws DataFormatException + */ + public void checkValidBase64(String toCheck) throws DataFormatException { + if (!Base64.isBase64(toCheck.getBytes())) { + throw new DataFormatException(""); + } + } } diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Element.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Element.java index 143982e56..4bb033fc0 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Element.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/Element.java @@ -52,6 +52,7 @@ package org.hl7.fhir.dstu3.model; // Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseElement; diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/model/Base64BinaryTypeTest.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/model/Base64BinaryTypeTest.java new file mode 100644 index 000000000..68a8687c4 --- /dev/null +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/model/Base64BinaryTypeTest.java @@ -0,0 +1,38 @@ +package org.hl7.fhir.dstu3.model; + +import ca.uhn.fhir.parser.DataFormatException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Base64BinaryTypeTest { + + @Test + @DisplayName("Passing a non Base64 encoded String to constructor causes exception.") + public void testNonBase64String() { + String nonBase64 = "Picard was the best starship captain."; + assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64)); + } + + @Test + @DisplayName("Null String value creates non-null instance with null value.") + public void testNullInstance() throws DataFormatException { + String v = null; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNull(b64.getValue()); + Assertions.assertNull(b64.getValueAsString()); + } + + @Test + @DisplayName("Valid Base64 String creates non-null instance with non-null values.") + public void testValid() { + String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNotNull(b64.getValue()); + Assertions.assertEquals(v, b64.asStringValue()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 22af04ec4..3d5594906 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml @@ -101,6 +101,12 @@ Saxon-HE test + + org.junit.jupiter + junit-jupiter + RELEASE + test + diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base64BinaryType.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base64BinaryType.java index 6721f1649..c3c0321ad 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base64BinaryType.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base64BinaryType.java @@ -50,6 +50,7 @@ package org.hl7.fhir.r4.model; import ca.uhn.fhir.model.api.IElement; +import ca.uhn.fhir.parser.DataFormatException; import org.apache.commons.codec.binary.Base64; import ca.uhn.fhir.model.api.annotation.DatatypeDef; @@ -84,11 +85,17 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv public Base64BinaryType(String theValue) { super(); + // Null values still result in non-null instance being created + if (theValue != null) checkValidBase64(theValue); setValueAsString(theValue); } protected byte[] parse(String theValue) { - return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + if (theValue != null) { + return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + } else { + return null; + } } protected String encode(byte[] theValue) { @@ -129,6 +136,7 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv @Override public void setValueAsString(String theValue) throws IllegalArgumentException { + fromStringValue(theValue); setValue(parse(theValue)); } @@ -154,4 +162,16 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv return ca.uhn.fhir.util.ElementUtil.isEmpty(id, extension) && !hasValue(); } + /** + * Checks if the passed in String is a valid {@link Base64} encoded String. Will throw a {@link DataFormatException} if not + * formatted correctly. + * + * @param toCheck {@link String} to check if valid {@link Base64} + * @throws DataFormatException + */ + public void checkValidBase64(String toCheck) throws DataFormatException { + if (!Base64.isBase64(toCheck.getBytes())) { + throw new DataFormatException(""); + } + } } diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/model/Base64BinaryTypeTest.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/model/Base64BinaryTypeTest.java new file mode 100644 index 000000000..d00ef03ee --- /dev/null +++ b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/model/Base64BinaryTypeTest.java @@ -0,0 +1,38 @@ +package org.hl7.fhir.r4.model; + +import ca.uhn.fhir.parser.DataFormatException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Base64BinaryTypeTest { + + @Test + @DisplayName("Passing a non Base64 encoded String to constructor causes exception.") + public void testNonBase64String() { + String nonBase64 = "Picard was the best starship captain."; + assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64)); + } + + @Test + @DisplayName("Null String value creates non-null instance with null value.") + public void testNullInstance() throws DataFormatException { + String v = null; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNull(b64.getValue()); + Assertions.assertNull(b64.getValueAsString()); + } + + @Test + @DisplayName("Valid Base64 String creates non-null instance with non-null values.") + public void testValid() { + String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNotNull(b64.getValue()); + Assertions.assertEquals(v, b64.asStringValue()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 702c2616b..640d2eabc 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/CapabilityStatementUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/CapabilityStatementUtilities.java index 2720ebde4..38ebe39c5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/CapabilityStatementUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/CapabilityStatementUtilities.java @@ -627,7 +627,7 @@ public class CapabilityStatementUtilities { return cc.getText(); if (cc.hasCoding()) return gen(cc.getCoding().get(0)); - return "??"; + return "?gen-cc?"; } private String gen(Coding coding) { @@ -635,7 +635,7 @@ public class CapabilityStatementUtilities { return coding.getDisplay(); if (coding.hasCode()) return coding.getCode(); - return "???"; + return "?gen-c?"; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileComparer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileComparer.java index b76567e3e..5e01a69a7 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileComparer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileComparer.java @@ -37,6 +37,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -114,90 +115,17 @@ public class ProfileComparer implements ProfileKnowledgeProvider { this.context = context; this.keygen = keygen; this.folder = folder; - if (!new File(Utilities.path(folder, "conparison-zip-marker.bin")).exists()) { - String f = Utilities.path(folder, "comparison.zip"); - download("http://www.fhir.org/archive/comparison.zip", f); - unzip(f, folder); + for (Entry e : context.getBinaries().entrySet()) { + TextFile.bytesToFile(e.getValue(), Utilities.path(folder, e.getKey())); } } - private void download(String address, String filename) throws IOException { -// System.out.print("Download "+address+" to "+filename); - URL url = new URL(address); - URLConnection c = url.openConnection(); - InputStream s = c.getInputStream(); - FileOutputStream f = new FileOutputStream(filename); - transfer(s, f, 1024); - f.close(); -// System.out.println(" ... "+new File(filename).length()+" bytes"); - } - - - public static void transfer(InputStream in, OutputStream out, int buffer) throws IOException { - byte[] read = new byte[buffer]; // Your buffer size. - while (0 < (buffer = in.read(read))) - out.write(read, 0, buffer); - } - - /** - * Size of the buffer to read/write data - */ - private static final int BUFFER_SIZE = 4096; - /** - * Extracts a zip file specified by the zipFilePath to a directory specified by - * destDirectory (will be created if does not exists) - * @param zipFilePath - * @param destDirectory - * @throws IOException - */ - public void unzip(String zipFilePath, String destDirectory) throws IOException { - File destDir = new File(destDirectory); - if (!destDir.exists()) { - destDir.mkdir(); - } - ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath)); - ZipEntry entry = zipIn.getNextEntry(); - // iterates over entries in the zip file - while (entry != null) { - String filePath = destDirectory + File.separator + entry.getName(); - if (!entry.isDirectory()) { - // if the entry is a file, extracts it - extractFile(zipIn, filePath); - } else { - // if the entry is a directory, make the directory - File dir = new File(filePath); - dir.mkdir(); - } - zipIn.closeEntry(); - entry = zipIn.getNextEntry(); - } - zipIn.close(); - } - /** - * Extracts a zip entry (file entry) - * @param zipIn - * @param filePath - * @throws IOException - */ - private void extractFile(ZipInputStream zipIn, String filePath) throws IOException { - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath)); - byte[] bytesIn = new byte[BUFFER_SIZE]; - int read = 0; - while ((read = zipIn.read(bytesIn)) != -1) { - bos.write(bytesIn, 0, read); - } - bos.close(); - } - - public ProfileComparer(IWorkerContext context, String folder) throws IOException { super(); this.context = context; this.folder = folder; - if (!new File(Utilities.path(folder, "conparison-zip-marker.bin")).exists()) { - String f = Utilities.path(folder, "comparison.zip"); - download("https://www.fhir.org/archive/comparison.zip", f); - unzip(f, folder); + for (Entry e : context.getBinaries().entrySet()) { + TextFile.bytesToFile(e.getValue(), Utilities.path(folder, e.getKey())); } } @@ -364,6 +292,8 @@ public class ProfileComparer implements ProfileKnowledgeProvider { private List comparisons = new ArrayList(); private String id; private String title; + private String leftPrefix; + private String rightPrefix; private String leftLink; private String leftName; private String rightLink; @@ -846,22 +776,33 @@ public class ProfileComparer implements ProfileKnowledgeProvider { try { le = context.expandVS(lvs, true, false); re = context.expandVS(rvs, true, false); - if (!closed(le.getValueset()) || !closed(re.getValueset())) - throw new DefinitionException("unclosed value sets are not handled yet"); - cvs = intersectByExpansion(path, le.getValueset(), re.getValueset()); - if (!cvs.getCompose().hasInclude()) { - outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value sets "+lvs.getUrl()+" and "+rvs.getUrl()+" do not intersect", ValidationMessage.IssueSeverity.ERROR)); - status(subset, ProfileUtilities.STATUS_ERROR); - return false; + if (le.getError() != null) { + outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value set "+lvs.getUrl()+" could not be expanded", ValidationMessage.IssueSeverity.ERROR)); + } else if (re.getError() != null) { + outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value set "+rvs.getUrl()+" could not be expanded", ValidationMessage.IssueSeverity.ERROR)); + } else if (!closed(le.getValueset())) { + outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value set "+lvs.getUrl()+" is not closed, so can't be compased", ValidationMessage.IssueSeverity.ERROR)); + } else if (!closed(re.getValueset())) { + outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value set "+rvs.getUrl()+" is not closed, so can't be compased", ValidationMessage.IssueSeverity.ERROR)); + } else { + cvs = intersectByExpansion(path, le.getValueset(), re.getValueset()); + if (!cvs.getCompose().hasInclude()) { + outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "The value sets "+lvs.getUrl()+" and "+rvs.getUrl()+" do not intersect", ValidationMessage.IssueSeverity.ERROR)); + status(subset, ProfileUtilities.STATUS_ERROR); + return false; + } } } catch (Exception e){ outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "Unable to expand or process value sets "+lvs.getUrl()+" and "+rvs.getUrl()+": "+e.getMessage(), ValidationMessage.IssueSeverity.ERROR)); status(subset, ProfileUtilities.STATUS_ERROR); + e.printStackTrace(); return false; } } - subBinding.setValueSet("#"+addValueSet(cvs)); - superBinding.setValueSet("#"+addValueSet(unite(superset, outcome, path, lvs, rvs))); + if (cvs != null) { + subBinding.setValueSet("#"+addValueSet(cvs)); + superBinding.setValueSet("#"+addValueSet(unite(superset, outcome, path, lvs, rvs))); + } } } return false; @@ -1407,11 +1348,30 @@ public class ProfileComparer implements ProfileKnowledgeProvider { this.rightName = rightName; } - private String genPCLink(String leftName, String leftLink) { - if (leftLink == null) - return leftName; - else - return ""+Utilities.escapeXml(leftName)+""; + public String getLeftPrefix() { + return leftPrefix; + } + + public void setLeftPrefix(String leftPrefix) { + this.leftPrefix = leftPrefix; + } + + public String getRightPrefix() { + return rightPrefix; + } + + public void setRightPrefix(String rightPrefix) { + this.rightPrefix = rightPrefix; + } + + private String genPCLink(String name, String link, String prefix) { + if (link == null) { + return name; + } else if (!Utilities.isAbsoluteUrl(link) && !Utilities.noString(prefix)) { + return ""+Utilities.escapeXml(name)+""; + } else { + return ""+Utilities.escapeXml(name)+""; + } } private String genValueSets(String base) throws IOException { @@ -1462,8 +1422,8 @@ public class ProfileComparer implements ProfileKnowledgeProvider { for (ProfileComparison cmp : getComparisons()) { b.append(""); - b.append(" "+Utilities.escapeXml(cmp.getLeft().getName())+""); - b.append(" "+Utilities.escapeXml(cmp.getRight().getName())+""); + b.append(" "+Utilities.escapeXml(cmp.getLeft().getName())+""); + b.append(" "+Utilities.escapeXml(cmp.getRight().getName())+""); b.append(" Click Here"); b.append(" "+cmp.getErrorCount()+""); b.append(" "+cmp.getWarningCount()+""); @@ -1476,6 +1436,10 @@ public class ProfileComparer implements ProfileKnowledgeProvider { } + private String fixLink(String path, String pfx) { + return (pfx == null || Utilities.isAbsoluteUrl(path)) ? path : Utilities.pathURL(pfx, path); + } + private String genCmpMessages(ProfileComparison cmp) { StringBuilder b = new StringBuilder(); b.append("\r\n"); @@ -1515,7 +1479,7 @@ public class ProfileComparer implements ProfileKnowledgeProvider { private String genCompModel(StructureDefinition sd, String name, String base, String prefix, String dest) throws FHIRException, IOException { if (sd == null) return "

No "+name+" could be generated

\r\n"; - return new XhtmlComposer(XhtmlComposer.HTML).compose(new ProfileUtilities(context, null, this).generateTable("??", sd, false, dest, false, base, true, prefix, prefix, false, false, null, true)); + return new XhtmlComposer(XhtmlComposer.HTML).compose(new ProfileUtilities(context, null, this).generateTable("?gen-cm?", sd, false, dest, false, base, true, prefix, prefix, false, false, null, true)); } @@ -1527,8 +1491,8 @@ public class ProfileComparer implements ProfileKnowledgeProvider { // first page we produce is simply the index Map vars = new HashMap(); vars.put("title", getTitle()); - vars.put("left", genPCLink(getLeftName(), getLeftLink())); - vars.put("right", genPCLink(getRightName(), getRightLink())); + vars.put("left", genPCLink(getLeftName(), getLeftLink(), getLeftPrefix())); + vars.put("right", genPCLink(getRightName(), getRightLink(), getRightPrefix())); vars.put("table", genPCTable()); vars.put("valuesets", genValueSets(folder+"/"+getId()+"-vs")); producePage(summaryTemplate(), Utilities.path(folder, getId()+".html"), vars); @@ -1537,8 +1501,8 @@ public class ProfileComparer implements ProfileKnowledgeProvider { for (ProfileComparison cmp : getComparisons()) { vars.clear(); vars.put("title", getTitle()); - vars.put("left", genPCLink(getLeftName(), getLeftLink())); - vars.put("right", genPCLink(getRightName(), getRightLink())); + vars.put("left", genPCLink(getLeftName(), getLeftLink(), getLeftPrefix())); + vars.put("right", genPCLink(getRightName(), getRightLink(), getRightPrefix())); vars.put("messages", genCmpMessages(cmp)); vars.put("subset", genCompModel(cmp.getSubset(), "intersection", getId()+"."+cmp.getId(), "", folder)); vars.put("superset", genCompModel(cmp.getSuperset(), "union", getId()+"."+cmp.getId(), "", folder)); @@ -1560,7 +1524,7 @@ public class ProfileComparer implements ProfileKnowledgeProvider { String s1 = src.substring(0, i1); String s2 = src.substring(i1 + 2, i2).trim(); String s3 = src.substring(i2+2); - String v = vars.containsKey(s2) ? vars.get(s2) : "???"; + String v = vars.containsKey(s2) ? vars.get(s2) : "?pp??"; src = s1+v+s3; } TextFile.stringToFile(src, path); @@ -1644,7 +1608,7 @@ public class ProfileComparer implements ProfileKnowledgeProvider { @Override public String getLinkForProfile(StructureDefinition profile, String url) { StructureDefinition sd = context.fetchResource(StructureDefinition.class, url); - return sd == null ? null : sd.getUserString("path"); + return sd == null ? null : sd.getUserString("path")+"|"+sd.present(); } @Override diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index a977faefc..2b03846d1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -87,10 +87,13 @@ import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.NarrativeGenerator; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.TranslatingUtilities; +import org.hl7.fhir.r5.utils.XVerExtensionManager; +import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus; import org.hl7.fhir.r5.utils.formats.CSVWriter; import org.hl7.fhir.r5.utils.formats.XLSXWriter; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; @@ -265,6 +268,7 @@ public class ProfileUtilities extends TranslatingUtilities { private boolean newSlicingProcessing; private String defWebRoot; private boolean autoFixSliceNames; + private XVerExtensionManager xver; public ProfileUtilities(IWorkerContext context, List messages, ProfileKnowledgeProvider pkp) { super(); @@ -617,6 +621,11 @@ public class ProfileUtilities extends TranslatingUtilities { for (TypeRefComponent t : ed.getType()) { for (UriType u : t.getProfile()) { StructureDefinition sd = context.fetchResource(StructureDefinition.class, u.getValue()); + if (sd == null) { + if (xver != null && xver.matchingUrl(u.getValue()) && xver.status(u.getValue()) == XVerExtensionStatus.Valid) { + sd = xver.makeDefinition(u.getValue()); + } + } if (sd == null) { if (messages != null) { messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), "The type of profile "+u.getValue()+" cannot be checked as the profile is not known", IssueSeverity.WARNING)); @@ -876,6 +885,16 @@ public class ProfileUtilities extends TranslatingUtilities { if (diffMatches.get(0).hasType() && diffMatches.get(0).getType().size() == 1 && diffMatches.get(0).getType().get(0).hasProfile() && !"Reference".equals(diffMatches.get(0).getType().get(0).getWorkingCode())) { CanonicalType p = diffMatches.get(0).getType().get(0).getProfile().get(0); StructureDefinition sd = context.fetchResource(StructureDefinition.class, p.getValue()); + if (sd == null && xver != null && xver.matchingUrl(p.getValue())) { + switch (xver.status(p.getValue())) { + case BadVersion: throw new FHIRException("Reference to invalid version in extension url "+p.getValue()); + case Invalid: throw new FHIRException("Reference to invalid extension "+p.getValue()); + case Unknown: throw new FHIRException("Reference to unknown extension "+p.getValue()); + case Valid: + sd = xver.makeDefinition(p.getValue()); + generateSnapshot(context.fetchTypeDefinition("Extension"), sd, sd.getUrl(), webUrl, sd.getName()); + } + } if (sd != null) { checkNotGenerating(sd, "an extension definition"); if (!sd.hasSnapshot()) { @@ -2440,7 +2459,7 @@ public class ProfileUtilities extends TranslatingUtilities { messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.BUSINESSRULE, pn+"."+base.getPath(), "Binding "+base.getBinding().getValueSet()+" could not be expanded", ValidationMessage.IssueSeverity.WARNING)); else if (expDerived.getValueset() == null) messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.BUSINESSRULE, pn+"."+derived.getPath(), "Binding "+derived.getBinding().getValueSet()+" could not be expanded", ValidationMessage.IssueSeverity.WARNING)); - else if (ToolingExtensions.hasExtension(expBase.getValueset().getExpansion(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly")) + else if (ToolingExtensions.hasExtension(expBase.getValueset().getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY)) messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.BUSINESSRULE, pn+"."+derived.getPath(), "Unable to check if "+derived.getBinding().getValueSet()+" is a proper subset of " +base.getBinding().getValueSet()+" - base value set is too large to check", ValidationMessage.IssueSeverity.WARNING)); else if (!isSubset(expBase.getValueset(), expDerived.getValueset())) messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.BUSINESSRULE, pn+"."+derived.getPath(), "Binding "+derived.getBinding().getValueSet()+" is not a subset of binding "+base.getBinding().getValueSet(), ValidationMessage.IssueSeverity.ERROR)); @@ -3366,7 +3385,7 @@ public class ProfileUtilities extends TranslatingUtilities { extDefn = locateExtension(StructureDefinition.class, eurl); if (extDefn == null) { genCardinality(gen, element, row, hasDef, used, null); - row.getCells().add(gen.new Cell(null, null, "?? "+element.getType().get(0).getProfile(), null, null)); + row.getCells().add(gen.new Cell(null, null, "?gen-e1? "+element.getType().get(0).getProfile(), null, null)); generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot); } else { String name = urltail(eurl); @@ -3556,7 +3575,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (first) first = false; else typeCell.addPiece(gen.new Piece(null, " | ", null)); StructureDefinition psd = context.fetchResource(StructureDefinition.class, pt.getValue()); if (psd == null) - typeCell.addPiece(gen.new Piece(null, "??", null)); + typeCell.addPiece(gen.new Piece(null, "?gen-e2?", null)); else typeCell.addPiece(gen.new Piece(psd.getUserString("path"), psd.getName(), psd.present())); @@ -3914,7 +3933,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (ref != null) { ref = ref.substring(0, ref.indexOf(".html"))+"-definitions.html#"; } else { - ref = "??"; + ref = "?gen-fv?"; } StructureDefinition sd = context.fetchTypeDefinition(value.fhirType()); @@ -4236,7 +4255,7 @@ public class ProfileUtilities extends TranslatingUtilities { case OPEN : return translate("sd.table", "Open"); case OPENATEND : return translate("sd.table", "Open At End"); default: - return "??"; + return "?gen-sr?"; } } @@ -5449,7 +5468,7 @@ public class ProfileUtilities extends TranslatingUtilities { private String summarizeCoding(Coding value) { String uri = value.getSystem(); - String system = NarrativeGenerator.describeSystem(uri); + String system = TerminologyRenderer.describeSystem(uri); if (Utilities.isURL(system)) { if (system.equals("http://cap.org/protocols")) system = "CAP Code"; @@ -5662,6 +5681,15 @@ public class ProfileUtilities extends TranslatingUtilities { return base; } + public XVerExtensionManager getXver() { + return xver; + } + + public ProfileUtilities setXver(XVerExtensionManager xver) { + this.xver = xver; + return this; + } + diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 27c49bae9..86208d186 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -81,6 +81,7 @@ import org.hl7.fhir.r5.model.TerminologyCapabilities.TerminologyCapabilitiesCode import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent; +import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; @@ -265,9 +266,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte structures.see(sd, packageInfo); } else if (r instanceof ValueSet) valueSets.see((ValueSet) m, packageInfo); - else if (r instanceof CodeSystem) + else if (r instanceof CodeSystem) { + CodeSystemUtilities.crossLinkCodeSystem((CodeSystem) r); codeSystems.see((CodeSystem) m, packageInfo); - else if (r instanceof ImplementationGuide) + } else if (r instanceof ImplementationGuide) guides.see((ImplementationGuide) m, packageInfo); else if (r instanceof CapabilityStatement) capstmts.see((CapabilityStatement) m, packageInfo); @@ -569,7 +571,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte private boolean hasTooCostlyExpansion(ValueSet valueset) { - return valueset != null && valueset.hasExpansion() && ToolingExtensions.hasExtension(valueset.getExpansion(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"); + return valueset != null && valueset.hasExpansion() && ToolingExtensions.hasExtension(valueset.getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY); } // --- validate code ------------------------------------------------------------------------------- diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index 4c0bcf156..27f4d8c79 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r5.context; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.EnumSet; /*- @@ -41,6 +44,7 @@ import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.ConceptMap; import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent; +import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.Parameters; import org.hl7.fhir.r5.model.Resource; @@ -53,6 +57,7 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.INarrativeGenerator; import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.utilities.TranslationServices; +import org.hl7.fhir.utilities.cache.NpmPackage; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; @@ -105,6 +110,13 @@ public interface IWorkerContext { } } + public interface IContextResourceLoader { + Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException; + + String[] getTypes(); + } + + /** * Get the versions of the definitions loaded in context * @return @@ -618,5 +630,9 @@ public interface IWorkerContext { public String getLinkForUrl(String corePath, String s); public Map getBinaries(); + void loadFromPackage(NpmPackage pi, IContextResourceLoader loader, String[] types) throws FileNotFoundException, IOException, FHIRException; + + public boolean hasPackage(String id, String ver); + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index 5e4c3d6f8..dd3674c10 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -90,12 +90,6 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon } - public interface IContextResourceLoader { - Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException; - - String[] getTypes(); - } - public interface IValidatorFactory { IResourceValidator makeValidator(IWorkerContext ctxts) throws FHIRException; } @@ -106,6 +100,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon private IValidatorFactory validatorFactory; private boolean ignoreProfileErrors; private boolean progress; + private List loadedPackages = new ArrayList(); public SimpleWorkerContext() throws FileNotFoundException, IOException, FHIRException { super(); @@ -324,6 +319,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon if (progress) { System.out.println("Load Package "+pi.name()+"#"+pi.version()); } + loadedPackages.add(pi.id()+"#"+pi.version()); for (String s : pi.listResources(loader.getTypes())) { try { loadDefinitionItem(s, pi.load("package", s), loader, filter, new PackageVersion(pi.id(), pi.version())); @@ -339,10 +335,12 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon } } + @Override public void loadFromPackage(NpmPackage pi, IContextResourceLoader loader, String... types) throws FileNotFoundException, IOException, FHIRException { if (progress) { System.out.println("Load Package "+pi.name()+"#"+pi.version()); } + loadedPackages.add(pi.id()+"#"+pi.version()); if (types.length == 0) types = new String[] { "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem" }; for (String s : pi.listResources(types)) { @@ -699,6 +697,11 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon this.progress = progress; } + @Override + public boolean hasPackage(String id, String ver) { + return loadedPackages.contains(id+"#"+ver); + } + diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java index c044f589c..5c92b4ce4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java @@ -103,6 +103,7 @@ public class TerminologyCache { private Object lock; private String folder; private Map caches = new HashMap(); + private static boolean noCaching; // use lock from the context public TerminologyCache(Object lock, String folder) throws FileNotFoundException, IOException, FHIRException { @@ -245,6 +246,9 @@ public class TerminologyCache { } public void store(CacheToken cacheToken, boolean persistent, NamedCache nc, CacheEntry e) { + if (noCaching) { + return; + } boolean n = nc.map.containsKey(cacheToken.key); nc.map.put(cacheToken.key, e); if (persistent) { @@ -426,7 +430,6 @@ public class TerminologyCache { return code.getSystem()+"#"+code.getCode()+": \""+code.getDisplay()+"\""; } - public String summary(CodeableConcept code) { StringBuilder b = new StringBuilder(); b.append("{"); @@ -440,5 +443,14 @@ public class TerminologyCache { b.append("\""); return b.toString(); } + + public static boolean isNoCaching() { + return noCaching; + } + + public static void setNoCaching(boolean noCaching) { + TerminologyCache.noCaching = noCaching; + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index e80c53c23..3c3be99f3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -678,12 +678,12 @@ public class XmlParser extends ParserBase { return header.substring(i+9, i+12); } } - return "??"; + return "?xml-p1?"; } catch (Exception e) { // suppress this error logError(0, 0, "XML", IssueType.INVALID, e.getMessage(), IssueSeverity.ERROR); } - return "??"; + return "?xml-p2?"; } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java index ca1164dbf..15d841321 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java @@ -54,6 +54,7 @@ package org.hl7.fhir.r5.formats; +import ca.uhn.fhir.parser.DataFormatException; import org.hl7.fhir.r5.model.*; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlNode; @@ -160,8 +161,7 @@ public class JsonParser extends JsonParserBase { } protected Base64BinaryType parseBase64Binary(String v) throws IOException, FHIRFormatError { - Base64BinaryType res = new Base64BinaryType(v); - return res; + return new Base64BinaryType(v); } protected UnsignedIntType parseUnsignedInt(String v) throws IOException, FHIRFormatError { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Base64BinaryType.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Base64BinaryType.java index 23bf557eb..3810d370b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Base64BinaryType.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Base64BinaryType.java @@ -51,8 +51,8 @@ package org.hl7.fhir.r5.model; import ca.uhn.fhir.model.api.IElement; import ca.uhn.fhir.model.api.annotation.DatatypeDef; +import ca.uhn.fhir.parser.DataFormatException; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IPrimitiveType; @@ -84,11 +84,17 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv public Base64BinaryType(String theValue) { super(); + // Null values still result in non-null instance being created + if (theValue != null) checkValidBase64(theValue); setValueAsString(theValue); } protected byte[] parse(String theValue) { - return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + if (theValue != null) { + return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8)); + } else { + return null; + } } protected String encode(byte[] theValue) { @@ -129,6 +135,7 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv @Override public void setValueAsString(String theValue) throws IllegalArgumentException { + fromStringValue(theValue); setValue(parse(theValue)); } @@ -158,4 +165,17 @@ public class Base64BinaryType extends PrimitiveType implements IPrimitiv public String primitiveValue() { return encode(myValue); } + + /** + * Checks if the passed in String is a valid {@link Base64} encoded String. Will throw a {@link DataFormatException} if not + * formatted correctly. + * + * @param toCheck {@link String} to check if valid {@link Base64} + * @throws DataFormatException + */ + public void checkValidBase64(String toCheck) throws DataFormatException { + if (!Base64.isBase64(toCheck.getBytes())) { + throw new DataFormatException(""); + } + } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/CodeableConcept.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/CodeableConcept.java index 5734e8dfa..a4a385cb8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/CodeableConcept.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/CodeableConcept.java @@ -351,6 +351,10 @@ public class CodeableConcept extends DataType implements ICompositeType { } return false; } + + public boolean hasCoding(Coding coding) { + return hasCoding(coding.getSystem(), coding.getCode()); + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java index 2bfcbcc17..c5a802ee4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java @@ -217,7 +217,7 @@ public class ExpressionNode { case ConvertsToDateTime : return "convertsToDateTime"; case ConvertsToTime : return "isTime"; case ConformsTo : return "conformsTo"; - default: return "??"; + default: return "?custom?"; } } } @@ -309,7 +309,7 @@ public class ExpressionNode { case In : return "in"; case Contains : return "contains"; case MemberOf : return "memberOf"; - default: return "??"; + default: return "?custom?"; } } } @@ -534,7 +534,7 @@ public class ExpressionNode { case Constant: return uniqueId+": "+constant; case Group: return uniqueId+": (Group)"; } - return "??"; + return "?exp-kind?"; } private void write(StringBuilder b) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemRenderer.java new file mode 100644 index 000000000..f56ef5456 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemRenderer.java @@ -0,0 +1,511 @@ +package org.hl7.fhir.r5.terminologies; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hl7.fhir.exceptions.DefinitionException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.ConceptMap; +import org.hl7.fhir.r5.model.Enumeration; +import org.hl7.fhir.r5.model.Extension; +import org.hl7.fhir.r5.model.CodeSystem.CodeSystemContentMode; +import org.hl7.fhir.r5.model.CodeSystem.CodeSystemFilterComponent; +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent; +import org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent; +import org.hl7.fhir.r5.model.CodeSystem.PropertyComponent; +import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent; +import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent; +import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.CodeSystemNavigator; +import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; + +public class CodeSystemRenderer extends TerminologyRenderer { + + + private List codeSystemPropList = new ArrayList<>(); + + /** + * + * @param mode - whether we are rendering for a resource directly, or for an IG + * @param context - common services (terminology server, code system cache etc) + * @param markdown - markdown processing engine of the correct sort for the version applicable + * @param prefix - the path to the base FHIR specification + * @param lang - the language to use (null for the default) + */ + public CodeSystemRenderer(TerminologyRendererMode mode, IWorkerContext context, MarkDownProcessor markdown, String prefix, String lang) { + super(mode, context, markdown, prefix, lang); + } + + public List getCodeSystemPropList() { + return codeSystemPropList; + } + + public boolean generate(XhtmlNode x, CodeSystem cs, boolean header) throws FHIRFormatError, DefinitionException, IOException { + boolean hasExtensions = false; + + if (header) { + XhtmlNode h = x.h2(); + h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName()); + addMarkdown(x, cs.getDescription()); + if (cs.hasCopyright()) + generateCopyright(x, cs); + } + + generateProperties(x, cs); + generateFilters(x, cs); + List maps = new ArrayList(); + hasExtensions = generateCodeSystemContent(x, cs, hasExtensions, maps); + + return hasExtensions; + } + + private void generateFilters(XhtmlNode x, CodeSystem cs) { + if (cs.hasFilter()) { + x.para().b().tx(context.translator().translate("xhtml-gen-cs", "Filters", lang)); + XhtmlNode tbl = x.table("grid"); + XhtmlNode tr = tbl.tr(); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Description", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "operator", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Value", lang)); + for (CodeSystemFilterComponent f : cs.getFilter()) { + tr = tbl.tr(); + tr.td().tx(f.getCode()); + tr.td().tx(f.getDescription()); + XhtmlNode td = tr.td(); + for (Enumeration t : f.getOperator()) + td.tx(t.asStringValue()+" "); + tr.td().tx(f.getValue()); + } + } + } + + private void generateProperties(XhtmlNode x, CodeSystem cs) { + if (cs.hasProperty()) { + boolean hasRendered = false; + for (PropertyComponent p : cs.getProperty()) { + hasRendered = hasRendered || !p.getCode().equals(ToolingExtensions.getPresentation(p, p.getCodeElement())); + } + + x.para().b().tx(context.translator().translate("xhtml-gen-cs", "Properties", lang)); + XhtmlNode tbl = x.table("grid"); + XhtmlNode tr = tbl.tr(); + if (hasRendered) { + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Name", lang)); + } + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "URL", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Description", lang)); + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Type", lang)); + for (PropertyComponent p : cs.getProperty()) { + tr = tbl.tr(); + if (hasRendered) { + tr.td().tx(ToolingExtensions.getPresentation(p, p.getCodeElement())); + } + tr.td().tx(p.getCode()); + tr.td().tx(p.getUri()); + tr.td().tx(p.getDescription()); + tr.td().tx(p.hasType() ? p.getType().toCode() : ""); + } + } + } + + private boolean generateCodeSystemContent(XhtmlNode x, CodeSystem cs, boolean hasExtensions, List maps) throws FHIRFormatError, DefinitionException, IOException { + XhtmlNode p = x.para(); + if (cs.getContent() == CodeSystemContentMode.COMPLETE) + p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines the following codes", cs.getUrl())+":"); + else if (cs.getContent() == CodeSystemContentMode.EXAMPLE) + p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, of which the following are some examples", cs.getUrl())+":"); + else if (cs.getContent() == CodeSystemContentMode.FRAGMENT ) + p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, of which the following are a subset", cs.getUrl())+":"); + else if (cs.getContent() == CodeSystemContentMode.NOTPRESENT ) { + p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, but they are not represented here", cs.getUrl())); + return false; + } + XhtmlNode t = x.table( "codes"); + boolean commentS = false; + boolean deprecated = false; + boolean display = false; + boolean hierarchy = false; + boolean version = false; + List properties = new ArrayList<>(); + for (PropertyComponent cp : cs.getProperty()) { + if (showPropertyInTable(cp)) { + boolean exists = false; + for (ConceptDefinitionComponent c : cs.getConcept()) { + exists = exists || conceptsHaveProperty(c, cp); + } + if (exists) { + properties.add(cp); + } + } + } + for (ConceptDefinitionComponent c : cs.getConcept()) { + commentS = commentS || conceptsHaveComments(c); + deprecated = deprecated || conceptsHaveDeprecated(cs, c); + display = display || conceptsHaveDisplay(c); + version = version || conceptsHaveVersion(c); + hierarchy = hierarchy || c.hasConcept(); + } + CodeSystemNavigator csNav = new CodeSystemNavigator(cs); + hierarchy = hierarchy || csNav.isRestructure(); + + List langs = new ArrayList<>(); + addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, true, commentS, version, deprecated, properties), maps); + for (ConceptDefinitionComponent c : csNav.getConcepts(null)) { + hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs) || hasExtensions; + } + if (langs.size() > 0) { + Collections.sort(langs); + x.para().b().tx("Additional Language Displays"); + t = x.table( "codes"); + XhtmlNode tr = t.tr(); + tr.td().b().tx("Code"); + for (String lang : langs) + tr.td().b().addText(describeLang(lang)); + for (ConceptDefinitionComponent c : cs.getConcept()) { + addLanguageRow(c, t, langs); + } + } + return hasExtensions; + } + + private boolean conceptsHaveProperty(ConceptDefinitionComponent c, PropertyComponent cp) { + if (CodeSystemUtilities.hasProperty(c, cp.getCode())) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) + if (conceptsHaveProperty(g, cp)) + return true; + return false; + + } + + private boolean showPropertyInTable(PropertyComponent cp) { + if (cp.hasCode()) { + if (cp.hasExtension(ToolingExtensions.EXT_RENDERED_VALUE)) { + return true; + } + if (cp.getCodeElement().hasExtension(ToolingExtensions.EXT_RENDERED_VALUE)) { + return true; + } + String uri = cp.getUri(); + String code = null; + if (Utilities.noString(uri)){ + return false; + } + if (uri.contains("#")) { + code = uri.substring(uri.indexOf("#")+1); + uri = uri.substring(0, uri.indexOf("#")); + } + if (Utilities.existsInList(uri, "http://hl7.org/fhir/concept-properties") || codeSystemPropList.contains(uri)) { + return true; + }; + CodeSystem cs = context.fetchCodeSystem(uri); + if (cs == null) { + return false; + } + return CodeSystemUtilities.hasCode(cs, code); + } + return false; + } + + + private int countConcepts(List list) { + int count = list.size(); + for (ConceptDefinitionComponent c : list) + if (c.hasConcept()) + count = count + countConcepts(c.getConcept()); + return count; + } + + private boolean conceptsHaveComments(ConceptDefinitionComponent c) { + if (ToolingExtensions.hasCSComment(c)) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) + if (conceptsHaveComments(g)) + return true; + return false; + } + + private boolean conceptsHaveDisplay(ConceptDefinitionComponent c) { + if (c.hasDisplay()) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) + if (conceptsHaveDisplay(g)) + return true; + return false; + } + + private boolean conceptsHaveVersion(ConceptDefinitionComponent c) { + if (c.hasUserData("cs.version.notes")) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) + if (conceptsHaveVersion(g)) + return true; + return false; + } + + private boolean conceptsHaveDeprecated(CodeSystem cs, ConceptDefinitionComponent c) { + if (CodeSystemUtilities.isDeprecated(cs, c)) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) + if (conceptsHaveDeprecated(cs, g)) + return true; + return false; + } + + + + private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean comment, boolean version, boolean deprecated, List maps, String system, CodeSystem cs, List properties, CodeSystemNavigator csNav, List langs) throws FHIRFormatError, DefinitionException, IOException { + boolean hasExtensions = false; + XhtmlNode tr = t.tr(); + XhtmlNode td = tr.td(); + if (hasHierarchy) { + td.addText(Integer.toString(level+1)); + td = tr.td(); + String s = Utilities.padLeft("", '\u00A0', level*2); + td.addText(s); + } + td.attribute("style", "white-space:nowrap").addText(c.getCode()); + XhtmlNode a; + if (c.hasCodeElement()) { + td.an(cs.getId()+"-" + Utilities.nmtokenize(c.getCode())); + } + + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { + if (cd.hasLanguage() && !langs.contains(cd.getLanguage())) { + langs.add(cd.getLanguage()); + } + + } + + if (hasDisplay) { + td = tr.td(); + renderDisplayName(c, cs, td); + } + td = tr.td(); + if (c != null && + c.hasDefinitionElement()) { + if (lang == null) { + if (hasMarkdownInDefinitions(cs)) + addMarkdown(td, c.getDefinition()); + else + td.addText(c.getDefinition()); + } else if (lang.equals("*")) { + boolean sl = false; + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) + sl = true; + td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDefinition()); + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) { + td.br(); + td.addText(cd.getLanguage()+": "+cd.getValue()); + } + } + } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { + td.addText(c.getDefinition()); + } else { + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(lang)) { + td.addText(cd.getValue()); + } + } + } + } + if (deprecated) { + td = tr.td(); + Boolean b = CodeSystemUtilities.isDeprecated(cs, c); + if (b != null && b) { + smartAddText(td, context.translator().translate("xhtml-gen-cs", "Deprecated", lang)); + hasExtensions = true; + if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) { + Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue(); + td.tx(" (replaced by "); + String url = getCodingReference(cc, system); + if (url != null) { + td.ah(url).addText(cc.getCode()); + td.tx(": "+cc.getDisplay()+")"); + } else + td.addText(cc.getCode()+" '"+cc.getDisplay()+"' in "+cc.getSystem()+")"); + } + } + } + if (comment) { + td = tr.td(); + Extension ext = c.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT); + if (ext != null) { + hasExtensions = true; + String bc = ext.hasValue() ? ext.getValue().primitiveValue() : null; + Map translations = ToolingExtensions.getLanguageTranslations(ext.getValue()); + + if (lang == null) { + if (bc != null) + td.addText(bc); + } else if (lang.equals("*")) { + boolean sl = false; + for (String l : translations.keySet()) + if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) + sl = true; + if (bc != null) { + td.addText((sl ? cs.getLanguage("en")+": " : "")+bc); + } + for (String l : translations.keySet()) { + if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) { + if (!td.getChildNodes().isEmpty()) + td.br(); + td.addText(l+": "+translations.get(l)); + } + } + } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { + if (bc != null) + td.addText(bc); + } else { + if (bc != null) + translations.put(cs.getLanguage("en"), bc); + for (String l : translations.keySet()) { + if (l.equals(lang)) { + td.addText(translations.get(l)); + } + } + } + } + } + if (version) { + td = tr.td(); + if (c.hasUserData("cs.version.notes")) + td.addText(c.getUserString("cs.version.notes")); + } + if (properties != null) { + for (PropertyComponent pc : properties) { + td = tr.td(); + boolean first = true; + ConceptPropertyComponent pcv = CodeSystemUtilities.getProperty(c, pc.getCode()); + if (pcv != null && pcv.hasValue()) { + if (first) first = false; else td.addText(", "); + if (pcv.hasValueCoding()) { + td.addText(pcv.getValueCoding().getCode()); + } else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrl(pcv.getValue().primitiveValue())) { + td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue()); + } else { + td.addText(pcv.getValue().primitiveValue()); + } + } + } + } + + for (UsedConceptMap m : maps) { + td = tr.td(); + List mappings = findMappingsForCode(c.getCode(), m.getMap()); + boolean first = true; + for (TargetElementComponentWrapper mapping : mappings) { + if (!first) + td.br(); + first = false; + XhtmlNode span = td.span(null, mapping.comp.hasRelationship() ? mapping.comp.getRelationship().toCode() : ""); + span.addText(getCharForRelationship(mapping.comp)); + a = td.ah(prefix+m.getLink()+"#"+makeAnchor(mapping.group.getTarget(), mapping.comp.getCode())); + a.addText(mapping.comp.getCode()); + if (!Utilities.noString(mapping.comp.getComment())) + td.i().tx("("+mapping.comp.getComment()+")"); + } + } + List ocl = csNav.getOtherChildren(c); + for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) { + hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, comment, version, deprecated, maps, system, cs, properties, csNav, langs) || hasExtensions; + } + for (ConceptDefinitionComponent cc : ocl) { + tr = t.tr(); + td = tr.td(); + td.addText(Integer.toString(level+2)); + td = tr.td(); + String s = Utilities.padLeft("", '\u00A0', (level+1)*2); + td.addText(s); + td.attribute("style", "white-space:nowrap"); + a = td.ah("#"+cs.getId()+"-" + Utilities.nmtokenize(cc.getCode())); + a.addText(cc.getCode()); + if (hasDisplay) { + td = tr.td(); + renderDisplayName(cc, cs, td); + } + int w = 1 + (deprecated ? 1 : 0) + (comment ? 1 : 0) + (version ? 1 : 0) + maps.size(); + if (properties != null) { + w = w + properties.size(); + } + td = tr.td().colspan(Integer.toString(w)); + } + return hasExtensions; + } + + private boolean hasMarkdownInDefinitions(CodeSystem cs) { + return ToolingExtensions.readBoolExtension(cs, "http://hl7.org/fhir/StructureDefinition/codesystem-use-markdown"); + } + + + public void renderDisplayName(ConceptDefinitionComponent c, CodeSystem cs, XhtmlNode td) { + if (c.hasDisplayElement()) { + if (lang == null) { + td.addText(c.getDisplay()); + } else if (lang.equals("*")) { + boolean sl = false; + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && !c.getDisplay().equalsIgnoreCase(cd.getValue())) + sl = true; + td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDisplay()); + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && !c.getDisplay().equalsIgnoreCase(cd.getValue())) { + td.br(); + td.addText(cd.getLanguage()+": "+cd.getValue()); + } + } + } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { + td.addText(c.getDisplay()); + } else { + for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { + if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && cd.getLanguage().equals(lang)) { + td.addText(cd.getValue()); + } + } + } + } + } + + private String getCodingReference(Coding cc, String system) { + if (cc.getSystem().equals(system)) + return "#"+cc.getCode(); + if (cc.getSystem().equals("http://snomed.info/sct")) + return "http://snomed.info/sct/"+cc.getCode(); + if (cc.getSystem().equals("http://loinc.org")) + return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return null; + } + + + private void addLanguageRow(ConceptDefinitionComponent c, XhtmlNode t, List langs) { + XhtmlNode tr = t.tr(); + tr.td().addText(c.getCode()); + for (String lang : langs) { + ConceptDefinitionDesignationComponent d = null; + for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) { + if (designation.hasLanguage()) { + if (lang.equals(designation.getLanguage())) + d = designation; + } + } + tr.td().addText(d == null ? "" : d.getValue()); + } + } + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java index 7db44a8bb..8b28ef2e0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java @@ -49,6 +49,8 @@ import org.hl7.fhir.utilities.Utilities; public class CodeSystemUtilities { + public static final String USER_DATA_CROSS_LINK = "cs.utils.cross.link"; + public static class CodeSystemNavigator { private CodeSystem cs; @@ -289,7 +291,7 @@ public class CodeSystemUtilities { return null; } - private static ConceptDefinitionComponent findCode(List list, String code) { + public static ConceptDefinitionComponent findCode(List list, String code) { for (ConceptDefinitionComponent c : list) { if (c.getCode().equals(code)) return c; @@ -344,6 +346,17 @@ public class CodeSystemUtilities { return p; return null; } + + public static List getPropertyValues(ConceptDefinitionComponent concept, String code) { + List res = new ArrayList<>(); + for (ConceptPropertyComponent p : concept.getProperty()) { + if (p.getCode().equals(code)) { + res.add(p); + } + } + return res; + } + // see http://hl7.org/fhir/R4/codesystem.html#hierachy // returns additional parents not in the heirarchy @@ -416,4 +429,40 @@ public class CodeSystemUtilities { return null; } + public static void crossLinkCodeSystem(CodeSystem cs) { + String parent = getPropertyByUrl(cs, "http://hl7.org/fhir/concept-properties#parent"); + if ((parent != null)) { + crossLinkConcepts(cs.getConcept(), cs.getConcept(), parent); + } + } + + private static String getPropertyByUrl(CodeSystem cs, String url) { + for (PropertyComponent pc : cs.getProperty()) { + if (url.equals(pc.getUri())) { + return pc.getCode(); + } + } + return null; + } + + private static void crossLinkConcepts(List root, List focus, String parent) { + for (ConceptDefinitionComponent def : focus) { + List pcl = getPropertyValues(def, parent); + for (ConceptPropertyComponent pc : pcl) { + String code = pc.getValue().primitiveValue(); + ConceptDefinitionComponent tgt = findCode(root, code); + if (!tgt.hasUserData(USER_DATA_CROSS_LINK)) { + tgt.setUserData(USER_DATA_CROSS_LINK, new ArrayList<>()); + } + @SuppressWarnings("unchecked") + List children = (List) tgt.getUserData(USER_DATA_CROSS_LINK); + children.add(def); + } + if (def.hasConcept()) { + crossLinkConcepts(root, def.getConcept(), parent); + } + } + + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ConceptMapRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ConceptMapRenderer.java new file mode 100644 index 000000000..f6e9bb043 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ConceptMapRenderer.java @@ -0,0 +1,396 @@ +package org.hl7.fhir.r5.terminologies; + +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import org.hl7.fhir.exceptions.DefinitionException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.ConceptMap; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.ContactPoint; +import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent; +import org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent; +import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent; +import org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship; +import org.hl7.fhir.r5.model.Narrative.NarrativeStatus; +import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.r5.utils.NarrativeGenerator.ResourceContext; +import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.xhtml.NodeType; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; + +public class ConceptMapRenderer extends TerminologyRenderer { + + /** + * + * @param mode - whether we are rendering for a resource directly, or for an IG + * @param context - common services (terminology server, code system cache etc) + * @param markdown - markdown processing engine of the correct sort for the version applicable + * @param prefix - the path to the base FHIR specification + * @param lang - the language to use (null for the default) + */ + public ConceptMapRenderer(TerminologyRendererMode mode, IWorkerContext context, MarkDownProcessor markdown, String prefix, String lang) { + super(mode, context, markdown, prefix, lang); + } + + public boolean generate(ResourceContext rcontext, ConceptMap cm, XhtmlNode x) throws FHIRFormatError, DefinitionException, IOException { + x.h2().addText(cm.getName()+" ("+cm.getUrl()+")"); + + XhtmlNode p = x.para(); + p.tx("Mapping from "); + if (cm.hasSource()) + AddVsRef(rcontext, cm.getSource().primitiveValue(), p); + else + p.tx("(not specified)"); + p.tx(" to "); + if (cm.hasTarget()) + AddVsRef(rcontext, cm.getTarget().primitiveValue(), p); + else + p.tx("(not specified)"); + + p = x.para(); + if (cm.getExperimental()) + p.addText(Utilities.capitalize(cm.getStatus().toString())+" (not intended for production usage). "); + else + p.addText(Utilities.capitalize(cm.getStatus().toString())+". "); + p.tx("Published on "+(cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "?ngen-10?")+" by "+cm.getPublisher()); + if (!cm.getContact().isEmpty()) { + p.tx(" ("); + boolean firsti = true; + for (ContactDetail ci : cm.getContact()) { + if (firsti) + firsti = false; + else + p.tx(", "); + if (ci.hasName()) + p.addText(ci.getName()+": "); + boolean first = true; + for (ContactPoint c : ci.getTelecom()) { + if (first) + first = false; + else + p.tx(", "); + addTelecom(p, c); + } + } + p.tx(")"); + } + p.tx(". "); + p.addText(cm.getCopyright()); + if (!Utilities.noString(cm.getDescription())) + addMarkdown(x, cm.getDescription()); + + x.br(); + + CodeSystem cs = context.fetchCodeSystem("http://hl7.org/fhir/concept-map-relationship"); + if (cs == null) + cs = context.fetchCodeSystem("http://hl7.org/fhir/concept-map-equivalence"); + String eqpath = cs == null ? null : cs.getUserString("path"); + + for (ConceptMapGroupComponent grp : cm.getGroup()) { + String src = grp.getSource(); + boolean comment = false; + boolean ok = true; + Map> sources = new HashMap>(); + Map> targets = new HashMap>(); + sources.put("code", new HashSet()); + targets.put("code", new HashSet()); + SourceElementComponent cc = grp.getElement().get(0); + String dst = grp.getTarget(); + sources.get("code").add(grp.getSource()); + targets.get("code").add(grp.getTarget()); + for (SourceElementComponent ccl : grp.getElement()) { + ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty(); + for (TargetElementComponent ccm : ccl.getTarget()) { + comment = comment || !Utilities.noString(ccm.getComment()); + for (OtherElementComponent d : ccm.getDependsOn()) { + if (!sources.containsKey(d.getProperty())) + sources.put(d.getProperty(), new HashSet()); + sources.get(d.getProperty()).add(d.getSystem()); + } + for (OtherElementComponent d : ccm.getProduct()) { + if (!targets.containsKey(d.getProperty())) + targets.put(d.getProperty(), new HashSet()); + targets.get(d.getProperty()).add(d.getSystem()); + } + } + } + + String display; + if (ok) { + // simple + XhtmlNode tbl = x.table( "grid"); + XhtmlNode tr = tbl.tr(); + tr.td().b().tx("Source Code"); + tr.td().b().tx("Relationship"); + tr.td().b().tx("Destination Code"); + if (comment) + tr.td().b().tx("Comment"); + for (SourceElementComponent ccl : grp.getElement()) { + tr = tbl.tr(); + XhtmlNode td = tr.td(); + td.addText(ccl.getCode()); + display = getDisplayForConcept(grp.getSource(), ccl.getCode()); + if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display)) + td.tx(" ("+display+")"); + TargetElementComponent ccm = ccl.getTarget().get(0); + if (!ccm.hasRelationship()) + tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")"); + else { + if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { + String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE); + tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code)); + } else { + tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode())); + } + } + td = tr.td(); + td.addText(ccm.getCode()); + display = getDisplayForConcept(grp.getTarget(), ccm.getCode()); + if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display)) + td.tx(" ("+display+")"); + if (comment) + tr.td().addText(ccm.getComment()); + addUnmapped(tbl, grp); + } + } else { + XhtmlNode tbl = x.table( "grid"); + XhtmlNode tr = tbl.tr(); + XhtmlNode td; + tr.td().colspan(Integer.toString(1+sources.size())).b().tx("Source Concept Details"); + tr.td().b().tx("Relationship"); + tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Destination Concept Details"); + if (comment) { + tr.td().b().tx("Comment"); + } + tr = tbl.tr(); + if (sources.get("code").size() == 1) { + String url = sources.get("code").iterator().next(); + renderCSDetailsLink(tr, url, true); + } else + tr.td().b().tx("Code"); + for (String s : sources.keySet()) { + if (!s.equals("code")) { + if (sources.get(s).size() == 1) { + String url = sources.get(s).iterator().next(); + renderCSDetailsLink(tr, url, false); + } else + tr.td().b().addText(getDescForConcept(s)); + } + } + tr.td(); + if (targets.get("code").size() == 1) { + String url = targets.get("code").iterator().next(); + renderCSDetailsLink(tr, url, true); + } else + tr.td().b().tx("Code"); + for (String s : targets.keySet()) { + if (!s.equals("code")) { + if (targets.get(s).size() == 1) { + String url = targets.get(s).iterator().next(); + renderCSDetailsLink(tr, url, false); + } else + tr.td().b().addText(getDescForConcept(s)); + } + } + if (comment) + tr.td(); + + for (int si = 0; si < grp.getElement().size(); si++) { + SourceElementComponent ccl = grp.getElement().get(si); + boolean slast = si == grp.getElement().size()-1; + boolean first = true; + if (ccl.hasNoMap() && ccl.getNoMap()) { + tr = tbl.tr(); + td = tr.td().style("border-right-width: 0px"); + if (!first) + td.style("border-top-style: none"); + else + td.style("border-bottom-style: none"); + if (sources.get("code").size() == 1) + td.addText(ccl.getCode()); + else + td.addText(grp.getSource()+" / "+ccl.getCode()); + display = getDisplayForConcept(grp.getSource(), ccl.getCode()); + tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); + tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)"); + + } else { + for (int ti = 0; ti < ccl.getTarget().size(); ti++) { + TargetElementComponent ccm = ccl.getTarget().get(ti); + boolean last = ti == ccl.getTarget().size()-1; + tr = tbl.tr(); + td = tr.td().style("border-right-width: 0px"); + if (!first && !last) + td.style("border-top-style: none; border-bottom-style: none"); + else if (!first) + td.style("border-top-style: none"); + else if (!last) + td.style("border-bottom-style: none"); + if (first) { + if (sources.get("code").size() == 1) + td.addText(ccl.getCode()); + else + td.addText(grp.getSource()+" / "+ccl.getCode()); + display = getDisplayForConcept(grp.getSource(), ccl.getCode()); + tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); + } + for (String s : sources.keySet()) { + if (!s.equals("code")) { + td = tr.td(); + if (first) { + td.addText(getValue(ccm.getDependsOn(), s, sources.get(s).size() != 1)); + display = getDisplay(ccm.getDependsOn(), s); + if (display != null) + td.tx(" ("+display+")"); + } + } + } + first = false; + if (!ccm.hasRelationship()) + tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")"); + else { + if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { + String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE); + tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code)); + } else { + tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode())); + } + } + td = tr.td().style("border-right-width: 0px"); + if (targets.get("code").size() == 1) + td.addText(ccm.getCode()); + else + td.addText(grp.getTarget()+" / "+ccm.getCode()); + display = getDisplayForConcept(grp.getTarget(), ccm.getCode()); + tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); + + for (String s : targets.keySet()) { + if (!s.equals("code")) { + td = tr.td(); + td.addText(getValue(ccm.getProduct(), s, targets.get(s).size() != 1)); + display = getDisplay(ccm.getProduct(), s); + if (display != null) + td.tx(" ("+display+")"); + } + } + if (comment) + tr.td().addText(ccm.getComment()); + } + } + addUnmapped(tbl, grp); + } + } + } + return true; + } + + private boolean isSameCodeAndDisplay(String code, String display) { + String c = code.replace(" ", "").replace("-", "").toLowerCase(); + String d = display.replace(" ", "").replace("-", "").toLowerCase(); + return c.equals(d); + } + + + private String presentRelationshipCode(String code) { + if ("related-to".equals(code)) { + return "is related to"; + } else if ("equivalent".equals(code)) { + return "is equivalent to"; + } else if ("broader".equals(code)) { + return "maps to wider concept"; + } else if ("narrower".equals(code)) { + return "maps to narrower concept"; + } else if ("not-related-to".equals(code)) { + return "is not related to"; + } else { + return code; + } + } + + private String presentEquivalenceCode(String code) { + if ("relatedto".equals(code)) { + return "is related to"; + } else if ("equivalent".equals(code)) { + return "is equivalent to"; + } else if ("equal".equals(code)) { + return "is equal to"; + } else if ("wider".equals(code)) { + return "maps to wider concept"; + } else if ("subsumes".equals(code)) { + return "is subsumed by"; + } else if ("narrower".equals(code)) { + return "maps to narrower concept"; + } else if ("specializes".equals(code)) { + return "has specialization"; + } else if ("inexact".equals(code)) { + return "maps loosely to"; + } else if ("unmatched".equals(code)) { + return "has no match"; + } else if ("disjoint".equals(code)) { + return "is not related to"; + } else { + return code; + } + } + + public void renderCSDetailsLink(XhtmlNode tr, String url, boolean span2) { + CodeSystem cs; + XhtmlNode td; + cs = context.fetchCodeSystem(url); + td = tr.td(); + if (span2) { + td.colspan("2"); + } + td.b().tx("Code"); + td.tx(" from "); + if (cs == null) + td.tx(url); + else + td.ah(cs.getUserString("path")).attribute("title", url).tx(cs.present()); + } + + private void addUnmapped(XhtmlNode tbl, ConceptMapGroupComponent grp) { + if (grp.hasUnmapped()) { +// throw new Error("not done yet"); + } + + } + + private String getDescForConcept(String s) { + if (s.startsWith("http://hl7.org/fhir/v2/element/")) + return "v2 "+s.substring("http://hl7.org/fhir/v2/element/".length()); + return s; + } + + + + private String getValue(List list, String s, boolean withSystem) { + for (OtherElementComponent c : list) { + if (s.equals(c.getProperty())) + if (withSystem) + return c.getSystem()+" / "+c.getValue(); + else + return c.getValue(); + } + return null; + } + + private String getDisplay(List list, String s) { + for (OtherElementComponent c : list) { + if (s.equals(c.getProperty())) + return getDisplayForConcept(c.getSystem(), c.getValue()); + } + return null; + } + + + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/SpecialCodeSystem.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/SpecialCodeSystem.java new file mode 100644 index 000000000..553416a7f --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/SpecialCodeSystem.java @@ -0,0 +1,10 @@ +package org.hl7.fhir.r5.terminologies; + +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.r5.model.Coding; + +public abstract class SpecialCodeSystem { + + public abstract ConceptDefinitionComponent findConcept(Coding code); + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyRenderer.java new file mode 100644 index 000000000..12e30c8d7 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyRenderer.java @@ -0,0 +1,495 @@ +package org.hl7.fhir.r5.terminologies; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.hl7.fhir.exceptions.DefinitionException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.exceptions.TerminologyServiceException; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult; +import org.hl7.fhir.r5.model.CanonicalResource; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.ConceptMap; +import org.hl7.fhir.r5.model.ContactPoint; +import org.hl7.fhir.r5.model.Questionnaire; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.StructureDefinition; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.r5.model.CodeSystem.PropertyComponent; +import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent; +import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent; +import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem; +import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent; +import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent; +import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.r5.utils.NarrativeGenerator.ResourceContext; +import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; +import org.hl7.fhir.utilities.validation.ValidationOptions; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; +import org.hl7.fhir.utilities.xhtml.XhtmlParser; + +public class TerminologyRenderer { + + public enum TerminologyRendererMode { + RESOURCE, IG + } + + protected class TargetElementComponentWrapper { + protected ConceptMapGroupComponent group; + protected TargetElementComponent comp; + protected TargetElementComponentWrapper(ConceptMapGroupComponent group, TargetElementComponent comp) { + super(); + this.group = group; + this.comp = comp; + } + + } + + public class UsedConceptMap { + + private ConceptMapRenderInstructions details; + private String link; + private ConceptMap map; + public UsedConceptMap(ConceptMapRenderInstructions details, String link, ConceptMap map) { + super(); + this.details = details; + this.link = link; + this.map = map; + } + public ConceptMapRenderInstructions getDetails() { + return details; + } + public ConceptMap getMap() { + return map; + } + public String getLink() { + return link; + } + } + + public class ConceptMapRenderInstructions { + private String name; + private String url; + private boolean doDescription; + public ConceptMapRenderInstructions(String name, String url, boolean doDescription) { + super(); + this.name = name; + this.url = url; + this.doDescription = doDescription; + } + public String getName() { + return name; + } + public String getUrl() { + return url; + } + public boolean isDoDescription() { + return doDescription; + } + + } + + protected TerminologyRendererMode mode; + protected IWorkerContext context; + protected MarkDownProcessor markdown; + protected String lang; + protected String prefix; + protected int headerLevelContext; + protected ValidationOptions terminologyServiceOptions = new ValidationOptions(); + protected boolean noSlowLookup; + + /** + * + * @param mode - whether we are rendering for a resource directly, or for an IG + * @param context - common services (terminology server, code system cache etc) + * @param markdown - markdown processing engine of the correct sort for the version applicable + * @param prefix - the path to the base FHIR specification + * @param lang - the language to use (null for the default) + */ + public TerminologyRenderer(TerminologyRendererMode mode, IWorkerContext context, MarkDownProcessor markdown, String prefix, String lang) { + super(); + this.mode = mode; + this.context = context; + this.markdown = markdown; + this.lang = lang; + this.prefix = prefix; + } + + public TerminologyRendererMode getMode() { + return mode; + } + + public int getHeaderLevelContext() { + return headerLevelContext; + } + + public void setHeaderLevelContext(int headerLevelContext) { + this.headerLevelContext = headerLevelContext; + } + + public ValidationOptions getTerminologyServiceOptions() { + return terminologyServiceOptions; + } + + public void setTerminologyServiceOptions(ValidationOptions terminologyServiceOptions) { + this.terminologyServiceOptions = terminologyServiceOptions; + } + + + + public boolean isNoSlowLookup() { + return noSlowLookup; + } + + public void setNoSlowLookup(boolean noSlowLookup) { + this.noSlowLookup = noSlowLookup; + } + + protected void addMarkdown(XhtmlNode x, String text) throws FHIRFormatError, IOException, DefinitionException { + if (text != null) { + // 1. custom FHIR extensions + while (text.contains("[[[")) { + String left = text.substring(0, text.indexOf("[[[")); + String link = text.substring(text.indexOf("[[[")+3, text.indexOf("]]]")); + String right = text.substring(text.indexOf("]]]")+3); + String url = link; + String[] parts = link.split("\\#"); + StructureDefinition p = context.fetchResource(StructureDefinition.class, parts[0]); + if (p == null) + p = context.fetchTypeDefinition(parts[0]); + if (p == null) + p = context.fetchResource(StructureDefinition.class, link); + if (p != null) { + url = p.getUserString("path"); + if (url == null) + url = p.getUserString("filename"); + } else + throw new DefinitionException("Unable to resolve markdown link "+link); + + text = left+"["+link+"]("+url+")"+right; + } + + // 2. markdown + String s = markdown.process(Utilities.escapeXml(text), "narrative generator"); + XhtmlParser p = new XhtmlParser(); + XhtmlNode m; + try { + m = p.parse("
"+s+"
", "div"); + } catch (org.hl7.fhir.exceptions.FHIRFormatError e) { + throw new FHIRFormatError(e.getMessage(), e); + } + x.getChildNodes().addAll(m.getChildNodes()); + } + } + + protected void generateCopyright(XhtmlNode x, CanonicalResource cs) { + XhtmlNode p = x.para(); + p.b().tx(context.translator().translate("xhtml-gen-cs", "Copyright Statement:", lang)); + smartAddText(p, " " + cs.getCopyright()); + } + + protected void smartAddText(XhtmlNode p, String text) { + if (text == null) + return; + + String[] lines = text.split("\\r\\n"); + for (int i = 0; i < lines.length; i++) { + if (i > 0) + p.br(); + p.addText(lines[i]); + } + } + + protected void addMapHeaders(XhtmlNode tr, List maps) throws FHIRFormatError, DefinitionException, IOException { + for (UsedConceptMap m : maps) { + XhtmlNode td = tr.td(); + XhtmlNode b = td.b(); + XhtmlNode a = b.ah(prefix+m.getLink()); + a.addText(m.getDetails().getName()); + if (m.getDetails().isDoDescription() && m.getMap().hasDescription()) + addMarkdown(td, m.getMap().getDescription()); + } + } + + protected String getHeader() { + int i = 3; + while (i <= headerLevelContext) + i++; + if (i > 6) + i = 6; + return "h"+Integer.toString(i); + } + + public static String describeSystem(String system) { + if (system == null) + return "[not stated]"; + if (system.equals("http://loinc.org")) + return "LOINC"; + if (system.startsWith("http://snomed.info")) + return "SNOMED CT"; + if (system.equals("http://www.nlm.nih.gov/research/umls/rxnorm")) + return "RxNorm"; + if (system.equals("http://hl7.org/fhir/sid/icd-9")) + return "ICD-9"; + if (system.equals("http://dicom.nema.org/resources/ontology/DCM")) + return "DICOM"; + if (system.equals("http://unitsofmeasure.org")) + return "UCUM"; + + return system; + } + + + protected String makeAnchor(String codeSystem, String code) { + String s = codeSystem+'-'+code; + StringBuilder b = new StringBuilder(); + for (char c : s.toCharArray()) { + if (Character.isAlphabetic(c) || Character.isDigit(c) || c == '.') + b.append(c); + else + b.append('-'); + } + return b.toString(); + } + + protected List findMappingsForCode(String code, ConceptMap map) { + List mappings = new ArrayList(); + + for (ConceptMapGroupComponent g : map.getGroup()) { + for (SourceElementComponent c : g.getElement()) { + if (c.getCode().equals(code)) + for (TargetElementComponent cc : c.getTarget()) + mappings.add(new TargetElementComponentWrapper(g, cc)); + } + } + return mappings; + } + + + + protected String getCharForRelationship(TargetElementComponent mapping) { + if (!mapping.hasRelationship()) + return ""; + switch (mapping.getRelationship()) { + case EQUIVALENT : return "~"; + case BROADER : return "<"; + case NARROWER : return ">"; + case NOTRELATEDTO : return "!="; + default: return "?"; + } + } + + protected void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) { + String ref = null; + boolean addHtml = true; + if (cs != null) { + ref = (String) cs.getUserData("external.url"); + if (Utilities.noString(ref)) + ref = (String) cs.getUserData("filename"); + else + addHtml = false; + if (Utilities.noString(ref)) + ref = (String) cs.getUserData("path"); + } + String spec = getSpecialReference(inc.getSystem()); + if (spec != null) { + XhtmlNode a = li.ah(spec); + a.code(inc.getSystem()); + } else if (cs != null && ref != null) { + if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/")) + ref = ref.substring(20)+"/index.html"; + else if (addHtml && !ref.contains(".html")) + ref = ref + ".html"; + XhtmlNode a = li.ah(prefix+ref.replace("\\", "/")); + a.code(inc.getSystem()); + } else { + li.code(inc.getSystem()); + } + } + + + private String getSpecialReference(String system) { + if ("http://snomed.info/sct".equals(system)) + return "http://www.snomed.org/"; + if (Utilities.existsInList(system, "http://loinc.org", "http://unitsofmeasure.org", "http://www.nlm.nih.gov/research/umls/rxnorm", "http://ncimeta.nci.nih.gov", "http://fdasis.nlm.nih.gov", + "http://www.radlex.org", "http://www.whocc.no/atc", "http://dicom.nema.org/resources/ontology/DCM", "http://www.genenames.org", "http://www.ensembl.org", "http://www.ncbi.nlm.nih.gov/nuccore", + "http://www.ncbi.nlm.nih.gov/clinvar", "http://sequenceontology.org", "http://www.hgvs.org/mutnomen", "http://www.ncbi.nlm.nih.gov/projects/SNP", "http://cancer.sanger.ac.uk/cancergenome/projects/cosmic", + "http://www.lrg-sequence.org", "http://www.omim.org", "http://www.ncbi.nlm.nih.gov/pubmed", "http://www.pharmgkb.org", "http://clinicaltrials.gov", "http://www.ebi.ac.uk/ipd/imgt/hla/")) + return system; + + return null; + } + + protected XhtmlNode addTableHeaderRowStandard(XhtmlNode t, boolean hasHierarchy, boolean hasDisplay, boolean definitions, boolean comments, boolean version, boolean deprecated, List properties) { + XhtmlNode tr = t.tr(); + if (hasHierarchy) + tr.td().b().tx("Lvl"); + tr.td().attribute("style", "white-space:nowrap").b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); + if (hasDisplay) + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Display", lang)); + if (definitions) + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Definition", lang)); + if (deprecated) + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Deprecated", lang)); + if (comments) + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Comments", lang)); + if (version) + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Version", lang)); + if (properties != null) { + for (PropertyComponent pc : properties) { + String display = ToolingExtensions.getPresentation(pc, pc.getCodeElement()); + if (display == null || display.equals(pc.getCode()) && pc.hasUri()) { + display = getDisplayForProperty(pc.getUri()); + if (display == null) { + display = pc.getCode(); + } + } + tr.td().b().tx(context.translator().translate("xhtml-gen-cs", display, lang)); + } + } + return tr; + } + + + protected String getDisplayForProperty(String uri) { + if (Utilities.noString(uri)){ + return null; + } + String code = null; + if (uri.contains("#")) { + code = uri.substring(uri.indexOf("#")+1); + uri = uri.substring(0, uri.indexOf("#")); + } + CodeSystem cs = context.fetchCodeSystem(uri); + if (cs == null) { + return null; + } + ConceptDefinitionComponent cc = CodeSystemUtilities.getCode(cs, code); + return cc == null ? null : cc.getDisplay(); + } + + + protected void AddVsRef(ResourceContext rcontext, String value, XhtmlNode li) { + Resource res = null; + if (rcontext != null) { + BundleEntryComponent be = rcontext.resolve(value); + if (be != null) { + res = be.getResource(); + } + } + if (res != null && !(res instanceof CanonicalResource)) { + li.addText(value); + return; + } + CanonicalResource vs = (CanonicalResource) res; + if (vs == null) + vs = context.fetchResource(ValueSet.class, value); + if (vs == null) + vs = context.fetchResource(StructureDefinition.class, value); + // if (vs == null) + // vs = context.fetchResource(DataElement.class, value); + if (vs == null) + vs = context.fetchResource(Questionnaire.class, value); + if (vs != null) { + String ref = (String) vs.getUserData("path"); + + ref = adjustForPath(ref); + XhtmlNode a = li.ah(ref == null ? "?ngen-11?" : ref.replace("\\", "/")); + a.addText(value); + } else { + CodeSystem cs = context.fetchCodeSystem(value); + if (cs != null) { + String ref = (String) cs.getUserData("path"); + ref = adjustForPath(ref); + XhtmlNode a = li.ah(ref == null ? "?ngen-12?" : ref.replace("\\", "/")); + a.addText(value); + } else if (value.equals("http://snomed.info/sct") || value.equals("http://snomed.info/id")) { + XhtmlNode a = li.ah(value); + a.tx("SNOMED-CT"); + } + else { + if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us")) + System.out.println("Unable to resolve value set "+value); + li.addText(value); + } + } + } + + private String adjustForPath(String ref) { + if (prefix == null) + return ref; + else + return prefix+ref; + } + + + protected void addTelecom(XhtmlNode p, ContactPoint c) { + if (c.getSystem() == ContactPointSystem.PHONE) { + p.tx("Phone: "+c.getValue()); + } else if (c.getSystem() == ContactPointSystem.FAX) { + p.tx("Fax: "+c.getValue()); + } else if (c.getSystem() == ContactPointSystem.EMAIL) { + p.ah( "mailto:"+c.getValue()).addText(c.getValue()); + } else if (c.getSystem() == ContactPointSystem.URL) { + if (c.getValue().length() > 30) + p.ah(c.getValue()).addText(c.getValue().substring(0, 30)+"..."); + else + p.ah(c.getValue()).addText(c.getValue()); + } + } + + + protected String getDisplayForConcept(String system, String value) { + if (value == null || system == null) + return null; + ValidationResult cl = context.validateCode(terminologyServiceOptions, system, value, null); + return cl == null ? null : cl.getDisplay(); + } + + + + protected String describeLang(String lang) { + ValueSet v = context.fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages"); + if (v != null) { + ConceptReferenceComponent l = null; + for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) { + if (cc.getCode().equals(lang)) + l = cc; + } + if (l == null) { + if (lang.contains("-")) + lang = lang.substring(0, lang.indexOf("-")); + for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) { + if (cc.getCode().equals(lang) || cc.getCode().startsWith(lang+"-")) + l = cc; + } + } + if (l != null) { + if (lang.contains("-")) + lang = lang.substring(0, lang.indexOf("-")); + String en = l.getDisplay(); + String nativelang = null; + for (ConceptReferenceDesignationComponent cd : l.getDesignation()) { + if (cd.getLanguage().equals(lang)) + nativelang = cd.getValue(); + } + if (nativelang == null) + return en+" ("+lang+")"; + else + return nativelang+" ("+en+", "+lang+")"; + } + } + return lang; + } +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/URICodeSystem.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/URICodeSystem.java new file mode 100644 index 000000000..56bbc9ee8 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/URICodeSystem.java @@ -0,0 +1,18 @@ +package org.hl7.fhir.r5.terminologies; + +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.utilities.Utilities; + +public class URICodeSystem extends SpecialCodeSystem { + + @Override + public ConceptDefinitionComponent findConcept(Coding code) { + if (Utilities.isAbsoluteUrl(code.getCode())) { + return new ConceptDefinitionComponent(code.getCode()); + } else { + return null; + } + } + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index a16f87af6..92da0ba48 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -112,10 +112,17 @@ public class ValueSetCheckerSimple implements ValueSetChecker { if (system == null && !code.hasDisplay()) { // dealing with just a plain code (enum) system = systemForCodeInValueSet(code.getCode()); } - if (!code.hasSystem()) + if (!code.hasSystem()) { + if (options.isGuessSystem() && system == null && Utilities.isAbsoluteUrl(code.getCode())) { + system = "urn:ietf:rfc:3986"; // this arises when using URIs bound to value sets + } code.setSystem(system); + } inExpansion = checkExpansion(code); CodeSystem cs = context.fetchCodeSystem(system); + if (cs == null) { + cs = findSpecialCodeSystem(system); + } if (cs == null) { warningMessage = "Unable to resolve system "+system+" - system is not specified or implicit"; if (!inExpansion) @@ -123,7 +130,7 @@ public class ValueSetCheckerSimple implements ValueSetChecker { } if (cs!=null && cs.getContent() != CodeSystemContentMode.COMPLETE) { warningMessage = "Unable to resolve system "+system+" - system is not complete"; - if (!inExpansion) + if (!inExpansion && cs.getContent() != CodeSystemContentMode.FRAGMENT) // we're going to give it a go if it's a fragment throw new FHIRException(warningMessage); } @@ -147,6 +154,17 @@ public class ValueSetCheckerSimple implements ValueSetChecker { return res; } + private CodeSystem findSpecialCodeSystem(String system) { + if ("urn:ietf:rfc:3986".equals(system)) { + CodeSystem cs = new CodeSystem(); + cs.setUrl(system); + cs.setUserData("tx.cs.special", new URICodeSystem()); + cs.setContent(CodeSystemContentMode.COMPLETE); + return cs; + } + return null; + } + boolean checkExpansion(Coding code) { if (valueset==null || !valueset.hasExpansion()) return false; @@ -164,9 +182,14 @@ public class ValueSetCheckerSimple implements ValueSetChecker { } private ValidationResult validateCode(Coding code, CodeSystem cs) { - ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code.getCode()); - if (cc == null) - return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_, gen(code), cs.getUrl())); + ConceptDefinitionComponent cc = cs.hasUserData("tx.cs.special") ? ((SpecialCodeSystem) cs.getUserData("tx.cs.special")).findConcept(code) : findCodeInConcept(cs.getConcept(), code.getCode()); + if (cc == null) { + if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { + return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_FRAGMENT, gen(code), cs.getUrl())); + } else { + return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_, gen(code), cs.getUrl())); + } + } if (code.getDisplay() == null) return new ValidationResult(cc); CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java index 48f1f5ad7..aa62f6367 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java @@ -101,6 +101,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { private Map map = new HashMap(); private IWorkerContext context; private boolean canBeHeirarchy = true; + private boolean includeAbstract = true; private Set excludeKeys = new HashSet(); private Set excludeSystems = new HashSet(); private ValueSet focus; @@ -116,7 +117,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { public void setMaxExpansionSize(int theMaxExpansionSize) { maxExpansionSize = theMaxExpansionSize; } - + private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List designations, Parameters expParams, boolean isAbstract, boolean inactive, List filters) { if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code)) @@ -213,13 +214,25 @@ public class ValueSetExpanderSimple implements ValueSetExpander { ValueSetExpansionContainsComponent np = null; boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def); - if (canBeHeirarchy || !abs) + if (includeAbstract || !abs) np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters); - for (ConceptDefinitionComponent c : def.getConcept()) + for (ConceptDefinitionComponent c : def.getConcept()) { addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion); + } + if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { + List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); + for (ConceptDefinitionComponent c : children) + addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion); + } } else { - for (ConceptDefinitionComponent c : def.getConcept()) + for (ConceptDefinitionComponent c : def.getConcept()) { addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion); + } + if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { + List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); + for (ConceptDefinitionComponent c : children) + addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion); + } } } @@ -328,7 +341,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { } } else { for (ValueSetExpansionContainsComponent c : codes) { - if (map.containsKey(key(c)) && !c.getAbstract()) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them + if (map.containsKey(key(c)) && (includeAbstract || !c.getAbstract())) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them focus.getExpansion().getContains().add(c); c.getContains().clear(); // make sure any heirarchy is wiped } @@ -349,19 +362,6 @@ public class ValueSetExpanderSimple implements ValueSetExpander { return res; } - private void addToHeirarchy(List target, List source) { - for (ValueSetExpansionContainsComponent s : source) { - target.add(s); - } - } - - private String getCodeDisplay(CodeSystem cs, String code) throws TerminologyServiceException { - ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), code); - if (def == null) - throw new TerminologyServiceException("Unable to find code '" + code + "' in code system " + cs.getUrl()); - return def.getDisplay(); - } - private ConceptDefinitionComponent getConceptForCode(List clist, String code) { for (ConceptDefinitionComponent c : clist) { if (code.equals(c.getCode())) @@ -380,6 +380,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { for (ConceptSetComponent inc : compose.getExclude()) excludeCodes(inc, exp.getParameter(), ctxt); canBeHeirarchy = !expParams.getParameterBool("excludeNested") && excludeKeys.isEmpty() && excludeSystems.isEmpty(); + includeAbstract = !expParams.getParameterBool("excludeNotForUI"); boolean first = true; for (ConceptSetComponent inc : compose.getInclude()) { if (first == true) @@ -404,9 +405,9 @@ public class ValueSetExpanderSimple implements ValueSetExpander { if (!existsInParams(exp.getParameter(), "version", new UriType(vs.getUrl() + "|" + vs.getVersion()))) exp.getParameter().add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion()))); for (Extension ex : vso.getValueset().getExpansion().getExtension()) { - if (ex.getUrl().equals("http://hl7.org/fhir/StructureDefinition/valueset-toocostly")) { + if (ex.getUrl().equals(ToolingExtensions.EXT_EXP_TOOCOSTLY)) { if (ex.getValue() instanceof BooleanType) { - exp.getExtension().add(new Extension("http://hl7.org/fhir/StructureDefinition/valueset-toocostly").setValue(new UriType(value))); + exp.getExtension().add(new Extension(ToolingExtensions.EXT_EXP_TOOCOSTLY).setValue(new UriType(value))); } else { exp.getExtension().add(ex); } @@ -444,7 +445,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { copyImportContains(base.getExpansion().getContains(), null, expParams, imports); } else { CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); - if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE)) { + if ((cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) { doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions); } else { doInternalIncludeCodes(inc, exp, expParams, imports, cs); @@ -469,7 +470,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { } } for (Extension ex : vs.getExpansion().getExtension()) { - if (Utilities.existsInList(ex.getUrl(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly", "http://hl7.org/fhir/StructureDefinition/valueset-unclosed")) { + if (Utilities.existsInList(ex.getUrl(), ToolingExtensions.EXT_EXP_TOOCOSTLY, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed")) { if (!hasExtension(extensions, ex.getUrl())) { extensions.add(ex); } @@ -489,16 +490,15 @@ public class ValueSetExpanderSimple implements ValueSetExpander { return false; } - public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, - CodeSystem cs) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { + public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, CodeSystem cs) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { if (cs == null) { if (context.isNoTerminologyServer()) - throw new NoTerminologyServiceException("unable to find code system " + inc.getSystem().toString()); + throw new NoTerminologyServiceException("Unable to find code system " + inc.getSystem().toString()); else - throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString()); + throw new TerminologyServiceException("Unable to find code system " + inc.getSystem().toString()); } cs.checkNoModifiers("Code System", "expanding"); - if (cs.getContent() != CodeSystemContentMode.COMPLETE) + if (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT) throw new TerminologyServiceException("Code system " + inc.getSystem().toString() + " is incomplete"); if (cs.hasVersion()) if (!existsInParams(exp.getParameter(), "version", new UriType(cs.getUrl() + "|" + cs.getVersion()))) @@ -509,14 +509,27 @@ public class ValueSetExpanderSimple implements ValueSetExpander { for (ConceptDefinitionComponent def : cs.getConcept()) { addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null); } + if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { + addFragmentWarning(exp, cs); + } } if (!inc.getConcept().isEmpty()) { canBeHeirarchy = false; for (ConceptReferenceComponent c : inc.getConcept()) { c.checkNoModifiers("Code in Code System", "expanding"); - addCode(inc.getSystem(), c.getCode(), Utilities.noString(c.getDisplay()) ? getCodeDisplay(cs, c.getCode()) : c.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, - CodeSystemUtilities.isInactive(cs, c.getCode()), imports); + ConceptDefinitionComponent def = CodeSystemUtilities.findCode(cs.getConcept(), c.getCode()); + Boolean inactive = false; // default is true if we're a fragment and + if (def == null) { + if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { + addFragmentWarning(exp, cs); + } else { + throw new TerminologyServiceException("Unable to find code '" + c.getCode() + "' in code system " + cs.getUrl()); + } + } else { + inactive = CodeSystemUtilities.isInactive(cs, def); + } + addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports); } } if (inc.getFilter().size() > 1) { @@ -524,6 +537,9 @@ public class ValueSetExpanderSimple implements ValueSetExpander { throw new TerminologyServiceException("Multiple filters not handled yet"); // need to and them, and this isn't done yet. But this shouldn't arise in non loinc and snomed value sets } if (inc.getFilter().size() == 1) { + if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { + addFragmentWarning(exp, cs); + } ConceptSetFilterComponent fc = inc.getFilter().get(0); if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISA) { // special: all codes in the target code system under the value @@ -546,6 +562,12 @@ public class ValueSetExpanderSimple implements ValueSetExpander { throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent c : def.getConcept()) addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null); + if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { + List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); + for (ConceptDefinitionComponent c : children) + addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null); + } + } else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) { // gg; note: wtf is this: if the filter is display=v, look up the code 'v', and see if it's diplsay is 'v'? canBeHeirarchy = false; @@ -563,6 +585,15 @@ public class ValueSetExpanderSimple implements ValueSetExpander { } } + private void addFragmentWarning(ValueSetExpansionComponent exp, CodeSystem cs) { + for (Extension ex : cs.getExtensionsByUrl(ToolingExtensions.EXT_EXP_FRAGMENT)) { + if (ex.getValue().primitiveValue().equals(cs.getUrl())) { + return; + } + } + exp.addExtension(new Extension(ToolingExtensions.EXT_EXP_FRAGMENT).setValue(new UriType(cs.getUrl()))); + } + private List convertDesignations(List list) { List res = new ArrayList(); for (ConceptReferenceDesignationComponent t : list) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetRenderer.java new file mode 100644 index 000000000..44f587573 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetRenderer.java @@ -0,0 +1,996 @@ +package org.hl7.fhir.r5.terminologies; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.hl7.fhir.exceptions.DefinitionException; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.exceptions.TerminologyServiceException; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult; +import org.hl7.fhir.r5.model.BooleanType; +import org.hl7.fhir.r5.model.CanonicalResource; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.ConceptMap; +import org.hl7.fhir.r5.model.DataType; +import org.hl7.fhir.r5.model.Extension; +import org.hl7.fhir.r5.model.ExtensionHelper; +import org.hl7.fhir.r5.model.PrimitiveType; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.UriType; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent; +import org.hl7.fhir.r5.model.Enumerations.FilterOperator; +import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent; +import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent; +import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; +import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer.ConceptMapRenderInstructions; +import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.r5.utils.NarrativeGenerator.ResourceContext; +import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.xhtml.NodeType; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +public class ValueSetRenderer extends TerminologyRenderer { + + private static final String ABSTRACT_CODE_HINT = "This code is not selectable ('Abstract')"; + + private String tooCostlyNoteEmpty; + private String tooCostlyNoteNotEmpty; + private String tooCostlyNoteEmptyDependent; + private String tooCostlyNoteNotEmptyDependent; + private List renderingMaps = new ArrayList(); + + /** + * + * @param mode - whether we are rendering for a resource directly, or for an IG + * @param context - common services (terminology server, code system cache etc) + * @param markdown - markdown processing engine of the correct sort for the version applicable + * @param prefix - the path to the base FHIR specification + * @param lang - the language to use (null for the default) + */ + public ValueSetRenderer(TerminologyRendererMode mode, IWorkerContext context, MarkDownProcessor markdown, String prefix, String lang) { + super(mode, context, markdown, prefix, lang); + renderingMaps.add(new ConceptMapRenderInstructions("Canonical Status", "http://hl7.org/fhir/ValueSet/resource-status", false)); + } + + public String getTooCostlyNoteEmpty() { + return tooCostlyNoteEmpty; + } + + public void setTooCostlyNoteEmpty(String tooCostlyNoteEmpty) { + this.tooCostlyNoteEmpty = tooCostlyNoteEmpty; + } + + public String getTooCostlyNoteNotEmpty() { + return tooCostlyNoteNotEmpty; + } + + public void setTooCostlyNoteNotEmpty(String tooCostlyNoteNotEmpty) { + this.tooCostlyNoteNotEmpty = tooCostlyNoteNotEmpty; + } + + public String getTooCostlyNoteEmptyDependent() { + return tooCostlyNoteEmptyDependent; + } + + public void setTooCostlyNoteEmptyDependent(String tooCostlyNoteEmptyDependent) { + this.tooCostlyNoteEmptyDependent = tooCostlyNoteEmptyDependent; + } + + public String getTooCostlyNoteNotEmptyDependent() { + return tooCostlyNoteNotEmptyDependent; + } + + public void setTooCostlyNoteNotEmptyDependent(String tooCostlyNoteNotEmptyDependent) { + this.tooCostlyNoteNotEmptyDependent = tooCostlyNoteNotEmptyDependent; + } + + public boolean render(ResourceContext rcontext, XhtmlNode x, ValueSet vs, ValueSet src, boolean header) throws FHIRFormatError, DefinitionException, IOException { + List maps = findReleventMaps(vs); + + boolean hasExtensions; + if (vs.hasExpansion()) { + // for now, we just accept an expansion if there is one + hasExtensions = generateExpansion(x, vs, src, header, maps); + } else { + hasExtensions = generateComposition(rcontext, x, vs, header, maps); + } + return hasExtensions; + } + + private List findReleventMaps(ValueSet vs) throws FHIRException { + List res = new ArrayList(); + for (CanonicalResource md : context.allConformanceResources()) { + if (md instanceof ConceptMap) { + ConceptMap cm = (ConceptMap) md; + if (isSource(vs, cm.getSource())) { + ConceptMapRenderInstructions re = findByTarget(cm.getTarget()); + if (re != null) { + ValueSet vst = cm.hasTarget() ? context.fetchResource(ValueSet.class, cm.hasTargetCanonicalType() ? cm.getTargetCanonicalType().getValue() : cm.getTargetUriType().asStringValue()) : null; + res.add(new UsedConceptMap(re, vst == null ? cm.getUserString("path") : vst.getUserString("path"), cm)); + } + } + } + } + return res; +// Map mymaps = new HashMap(); +// for (ConceptMap a : context.findMapsForSource(vs.getUrl())) { +// String url = ""; +// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference()); +// if (vsr != null) +// url = (String) vsr.getUserData("filename"); +// mymaps.put(a, url); +// } +// Map mymaps = new HashMap(); +// for (ConceptMap a : context.findMapsForSource(cs.getValueSet())) { +// String url = ""; +// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference()); +// if (vsr != null) +// url = (String) vsr.getUserData("filename"); +// mymaps.put(a, url); +// } + // also, look in the contained resources for a concept map +// for (Resource r : cs.getContained()) { +// if (r instanceof ConceptMap) { +// ConceptMap cm = (ConceptMap) r; +// if (((Reference) cm.getSource()).getReference().equals(cs.getValueSet())) { +// String url = ""; +// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) cm.getTarget()).getReference()); +// if (vsr != null) +// url = (String) vsr.getUserData("filename"); +// mymaps.put(cm, url); +// } +// } +// } + } + + private boolean isSource(ValueSet vs, DataType source) { + return vs.hasUrl() && source != null && vs.getUrl().equals(source.primitiveValue()); + } + + private boolean generateExpansion(XhtmlNode x, ValueSet vs, ValueSet src, boolean header, List maps) throws FHIRFormatError, DefinitionException, IOException { + boolean hasExtensions = false; + List langs = new ArrayList(); + + + if (header) { + XhtmlNode h = x.addTag(getHeader()); + h.tx("Value Set Contents"); + if (IsNotFixedExpansion(vs)) + addMarkdown(x, vs.getDescription()); + if (vs.hasCopyright()) + generateCopyright(x, vs); + } + if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY)) { + List exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_TOOCOSTLY); + boolean other = false; + for (Extension ex : exl) { + if (ex.getValue() instanceof BooleanType) { + x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? tooCostlyNoteEmpty : tooCostlyNoteNotEmpty ); + } else if (!other) { + x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? tooCostlyNoteEmptyDependent : tooCostlyNoteNotEmptyDependent ); + other = true; + } + } + } else { + Integer count = countMembership(vs); + if (count == null) + x.para().tx("This value set does not contain a fixed number of concepts"); + else + x.para().tx("This value set contains "+count.toString()+" concepts"); + } + if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_FRAGMENT)) { + XhtmlNode div = x.div().style("border: maroon 1px solid; background-color: #FFCCCC; padding: 8px"); + List exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_FRAGMENT); + if (exl.size() > 1) { + div.para().addText("Warning: this expansion is generated from fragments of the following code systems, and may be missing codes, or include codes that are not valid:"); + XhtmlNode ul = div.ul(); + for (Extension ex : exl) { + addCSRef(ul.li(), ex.getValue().primitiveValue()); + } + } else { + XhtmlNode p = div.para(); + p.addText("Warning: this expansion is generated from a fragment of the code system "); + addCSRef(p, exl.get(0).getValue().primitiveValue()); + p.addText(" and may be missing codes, or include codes that are not valid"); + } + } + + generateVersionNotice(x, vs.getExpansion()); + + CodeSystem allCS = null; + boolean doLevel = false; + for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { + if (cc.hasContains()) { + doLevel = true; + break; + } + } + + boolean doSystem = true; // checkDoSystem(vs, src); + boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains()); + if (doSystem && allFromOneSystem(vs)) { + doSystem = false; + XhtmlNode p = x.para(); + p.tx("All codes from system "); + allCS = context.fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem()); + String ref = null; + if (allCS != null) + ref = getCsRef(allCS); + if (ref == null) + p.code(vs.getExpansion().getContains().get(0).getSystem()); + else + p.ah(prefix+ref).code(vs.getExpansion().getContains().get(0).getSystem()); + } + XhtmlNode t = x.table( "codes"); + XhtmlNode tr = t.tr(); + if (doLevel) + tr.td().b().tx("Lvl"); + tr.td().attribute("style", "white-space:nowrap").b().tx("Code"); + if (doSystem) + tr.td().b().tx("System"); + tr.td().b().tx("Display"); + if (doDefinition) + tr.td().b().tx("Definition"); + + addMapHeaders(tr, maps); + for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { + addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs); + } + + // now, build observed languages + + if (langs.size() > 0) { + Collections.sort(langs); + x.para().b().tx("Additional Language Displays"); + t = x.table( "codes"); + tr = t.tr(); + tr.td().b().tx("Code"); + for (String lang : langs) + tr.td().b().addText(describeLang(lang)); + for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { + addLanguageRow(c, t, langs); + } + } + + return hasExtensions; + } + + private boolean checkDoSystem(ValueSet vs, ValueSet src) { + if (src != null) + vs = src; + return vs.hasCompose(); + } + + private boolean IsNotFixedExpansion(ValueSet vs) { + if (vs.hasCompose()) + return false; + + + // it's not fixed if it has any includes that are not version fixed + for (ConceptSetComponent cc : vs.getCompose().getInclude()) { + if (cc.hasValueSet()) + return true; + if (!cc.hasVersion()) + return true; + } + return false; + } + + + + + private ConceptMapRenderInstructions findByTarget(DataType source) { + if (source == null) { + return null; + } + String src = source.primitiveValue(); + if (src != null) + for (ConceptMapRenderInstructions t : renderingMaps) { + if (src.equals(t.getUrl())) + return t; + } + return null; + } + + + private Integer countMembership(ValueSet vs) { + int count = 0; + if (vs.hasExpansion()) + count = count + conceptCount(vs.getExpansion().getContains()); + else { + if (vs.hasCompose()) { + if (vs.getCompose().hasExclude()) { + try { + ValueSetExpansionOutcome vse = context.expandVS(vs, true, false); + count = 0; + count += conceptCount(vse.getValueset().getExpansion().getContains()); + return count; + } catch (Exception e) { + return null; + } + } + for (ConceptSetComponent inc : vs.getCompose().getInclude()) { + if (inc.hasFilter()) + return null; + if (!inc.hasConcept()) + return null; + count = count + inc.getConcept().size(); + } + } + } + return count; + } + + private int conceptCount(List list) { + int count = 0; + for (ValueSetExpansionContainsComponent c : list) { + if (!c.getAbstract()) + count++; + count = count + conceptCount(c.getContains()); + } + return count; + } + + private void addCSRef(XhtmlNode x, String url) { + CodeSystem cs = context.fetchCodeSystem(url); + if (cs == null) { + x.code(url); + } else if (cs.hasUserData("path")) { + x.ah(cs.getUserString("path")).tx(cs.present()); + } else { + x.code(url); + x.tx(" ("+cs.present()+")"); + } + } + + @SuppressWarnings("rawtypes") + private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) { + Multimap versions = HashMultimap.create(); + for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { + if (p.getName().equals("version")) { + String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|"); + if (parts.length == 2) + versions.put(parts[0], parts[1]); + } + } + if (versions.size() > 0) { + XhtmlNode div = null; + XhtmlNode ul = null; + boolean first = true; + for (String s : versions.keySet()) { + if (versions.size() == 1 && versions.get(s).size() == 1) { + for (String v : versions.get(s)) { // though there'll only be one + XhtmlNode p = x.para().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px"); + p.tx("Expansion based on "); + expRef(p, s, v); + } + } else { + for (String v : versions.get(s)) { + if (first) { + div = x.div().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px"); + div.para().tx("Expansion based on: "); + ul = div.ul(); + first = false; + } + expRef(ul.li(), s, v); + } + } + } + } + } + + private void expRef(XhtmlNode x, String u, String v) { + // TODO Auto-generated method stub + if (u.equals("http://snomed.info/sct")) { + String[] parts = v.split("\\/"); + if (parts.length >= 5) { + String m = describeModule(parts[4]); + if (parts.length == 7) { + x.tx("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + } else { + x.tx("SNOMED CT "+m+" edition"); + } + } else { + x.tx(describeSystem(u)+" version "+v); + } + } else if (u.equals("http://loinc.org")) { + String vd = describeLoincVer(v); + if (vd != null) { + x.tx("Loinc v"+v+" ("+vd+")"); + } else { + x.tx("Loinc v"+v); + } + } else { + CanonicalResource cr = (CanonicalResource) context.fetchResource(Resource.class, u+"|"+v); + if (cr != null) { + if (cr.hasUserData("path")) { + x.ah(cr.getUserString("path")).tx(cr.present()+" v"+v+" ("+cr.fhirType()+")"); + } else { + x.tx(describeSystem(u)+" v"+v+" ("+cr.fhirType()+")"); + } + } else { + x.tx(describeSystem(u)+" version "+v); + } + } + } + + private String describeLoincVer(String v) { + if ("2.67".equals(v)) return "Dec 2019"; + if ("2.66".equals(v)) return "Jun 2019"; + if ("2.65".equals(v)) return "Dec 2018"; + if ("2.64".equals(v)) return "Jun 2018"; + if ("2.63".equals(v)) return "Dec 2017"; + if ("2.61".equals(v)) return "Jun 2017"; + if ("2.59".equals(v)) return "Feb 2017"; + if ("2.58".equals(v)) return "Dec 2016"; + if ("2.56".equals(v)) return "Jun 2016"; + if ("2.54".equals(v)) return "Dec 2015"; + if ("2.52".equals(v)) return "Jun 2015"; + if ("2.50".equals(v)) return "Dec 2014"; + if ("2.48".equals(v)) return "Jun 2014"; + if ("2.46".equals(v)) return "Dec 2013"; + if ("2.44".equals(v)) return "Jun 2013"; + if ("2.42".equals(v)) return "Dec 2012"; + if ("2.40".equals(v)) return "Jun 2012"; + if ("2.38".equals(v)) return "Dec 2011"; + if ("2.36".equals(v)) return "Jun 2011"; + if ("2.34".equals(v)) return "Dec 2010"; + if ("2.32".equals(v)) return "Jun 2010"; + if ("2.30".equals(v)) return "Feb 2010"; + if ("2.29".equals(v)) return "Dec 2009"; + if ("2.27".equals(v)) return "Jul 2009"; + if ("2.26".equals(v)) return "Jan 2009"; + if ("2.24".equals(v)) return "Jul 2008"; + if ("2.22".equals(v)) return "Dec 2007"; + if ("2.21".equals(v)) return "Jun 2007"; + if ("2.19".equals(v)) return "Dec 2006"; + if ("2.17".equals(v)) return "Jun 2006"; + if ("2.16".equals(v)) return "Dec 2005"; + if ("2.15".equals(v)) return "Jun 2005"; + if ("2.14".equals(v)) return "Dec 2004"; + if ("2.13".equals(v)) return "Aug 2004"; + if ("2.12".equals(v)) return "Feb 2004"; + if ("2.10".equals(v)) return "Oct 2003"; + if ("2.09".equals(v)) return "May 2003"; + if ("2.08 ".equals(v)) return "Sep 2002"; + if ("2.07".equals(v)) return "Aug 2002"; + if ("2.05".equals(v)) return "Feb 2002"; + if ("2.04".equals(v)) return "Jan 2002"; + if ("2.03".equals(v)) return "Jul 2001"; + if ("2.02".equals(v)) return "May 2001"; + if ("2.01".equals(v)) return "Jan 2001"; + if ("2.00".equals(v)) return "Jan 2001"; + if ("1.0n".equals(v)) return "Feb 2000"; + if ("1.0ma".equals(v)) return "Aug 1999"; + if ("1.0m".equals(v)) return "Jul 1999"; + if ("1.0l".equals(v)) return "Jan 1998"; + if ("1.0ja".equals(v)) return "Oct 1997"; + + return null; + } + + private String formatSCTDate(String ds) { + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + Date date; + try { + date = format.parse(ds); + } catch (ParseException e) { + return ds; + } + return new SimpleDateFormat("dd-MMM yyyy").format(date); + } + + private String describeModule(String module) { + if ("900000000000207008".equals(module)) + return "International"; + if ("731000124108".equals(module)) + return "United States"; + if ("32506021000036107".equals(module)) + return "Australian"; + if ("449081005".equals(module)) + return "Spanish"; + if ("554471000005108".equals(module)) + return "Danish"; + if ("11000146104".equals(module)) + return "Dutch"; + if ("45991000052106".equals(module)) + return "Swedish"; + if ("999000041000000102".equals(module)) + return "United Kingdon"; + return module; + } + + private boolean hasVersionParameter(ValueSetExpansionComponent expansion) { + for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { + if (p.getName().equals("version")) + return true; + } + return false; + } + + private void addLanguageRow(ValueSetExpansionContainsComponent c, XhtmlNode t, List langs) { + XhtmlNode tr = t.tr(); + tr.td().addText(c.getCode()); + for (String lang : langs) { + String d = null; + for (Extension ext : c.getExtension()) { + if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) { + String l = ToolingExtensions.readStringExtension(ext, "lang"); + if (lang.equals(l)) + d = ToolingExtensions.readStringExtension(ext, "content"); + } + } + tr.td().addText(d == null ? "" : d); + } + for (ValueSetExpansionContainsComponent cc : c.getContains()) { + addLanguageRow(cc, t, langs); + } + } + + + private boolean checkDoDefinition(List contains) { + for (ValueSetExpansionContainsComponent c : contains) { + CodeSystem cs = context.fetchCodeSystem(c.getSystem()); + if (cs != null) + return true; + if (checkDoDefinition(c.getContains())) + return true; + } + return false; + } + + + private boolean allFromOneSystem(ValueSet vs) { + if (vs.getExpansion().getContains().isEmpty()) + return false; + String system = vs.getExpansion().getContains().get(0).getSystem(); + for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { + if (!checkSystemMatches(system, cc)) + return false; + } + return true; + } + + private String getCsRef(String system) { + CodeSystem cs = context.fetchCodeSystem(system); + return getCsRef(cs); + } + + private String getCsRef(T cs) { + String ref = (String) cs.getUserData("filename"); + if (ref == null) + ref = (String) cs.getUserData("path"); + if (ref == null) + return "?ngen-14?.html"; + if (!ref.contains(".html")) + ref = ref + ".html"; + return ref.replace("\\", "/"); + } + + private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doLevel, boolean doSystem, boolean doDefinition, List maps, CodeSystem allCS, List langs) { + XhtmlNode tr = t.tr(); + XhtmlNode td = tr.td(); + + String tgt = makeAnchor(c.getSystem(), c.getCode()); + td.an(tgt); + + if (doLevel) { + td.addText(Integer.toString(i)); + td = tr.td(); + } + String s = Utilities.padLeft("", '\u00A0', i*2); + td.attribute("style", "white-space:nowrap").addText(s); + addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td); + if (doSystem) { + td = tr.td(); + td.addText(c.getSystem()); + } + td = tr.td(); + if (c.hasDisplayElement()) + td.addText(c.getDisplay()); + + if (doDefinition) { + CodeSystem cs = allCS; + if (cs == null) + cs = context.fetchCodeSystem(c.getSystem()); + td = tr.td(); + if (cs != null) + td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode())); + } + for (UsedConceptMap m : maps) { + td = tr.td(); + List mappings = findMappingsForCode(c.getCode(), m.getMap()); + boolean first = true; + for (TargetElementComponentWrapper mapping : mappings) { + if (!first) + td.br(); + first = false; + XhtmlNode span = td.span(null, mapping.comp.getRelationship().toString()); + span.addText(getCharForRelationship(mapping.comp)); + addRefToCode(td, mapping.group.getTarget(), m.getLink(), mapping.comp.getCode()); + if (!Utilities.noString(mapping.comp.getComment())) + td.i().tx("("+mapping.comp.getComment()+")"); + } + } + for (Extension ext : c.getExtension()) { + if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) { + String lang = ToolingExtensions.readStringExtension(ext, "lang"); + if (!Utilities.noString(lang) && !langs.contains(lang)) + langs.add(lang); + } + } + for (ValueSetExpansionContainsComponent cc : c.getContains()) { + addExpansionRowToTable(t, cc, i+1, doLevel, doSystem, doDefinition, maps, allCS, langs); + } + } + + + + + + private boolean checkSystemMatches(String system, ValueSetExpansionContainsComponent cc) { + if (!system.equals(cc.getSystem())) + return false; + for (ValueSetExpansionContainsComponent cc1 : cc.getContains()) { + if (!checkSystemMatches(system, cc1)) + return false; + } + return true; + } + + private void addCodeToTable(boolean isAbstract, String system, String code, String display, XhtmlNode td) { + CodeSystem e = context.fetchCodeSystem(system); + if (e == null || e.getContent() != org.hl7.fhir.r5.model.CodeSystem.CodeSystemContentMode.COMPLETE) { + if (isAbstract) + td.i().setAttribute("title", ABSTRACT_CODE_HINT).addText(code); + else if ("http://snomed.info/sct".equals(system)) { + td.ah(sctLink(code)).addText(code); + } else if ("http://loinc.org".equals(system)) { + td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); + } else + td.addText(code); + } else { + String href = prefix+getCsRef(e); + if (href.contains("#")) + href = href + "-"+Utilities.nmtokenize(code); + else + href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(code); + if (isAbstract) + td.ah(href).setAttribute("title", ABSTRACT_CODE_HINT).i().addText(code); + else + td.ah(href).addText(code); + } + } + + + public String sctLink(String code) { +// if (snomedEdition != null) +// http://browser.ihtsdotools.org/?perspective=full&conceptId1=428041000124106&edition=us-edition&release=v20180301&server=https://prod-browser-exten.ihtsdotools.org/api/snomed&langRefset=900000000000509007 + return "http://browser.ihtsdotools.org/?perspective=full&conceptId1="+code; + } + + private void addRefToCode(XhtmlNode td, String target, String vslink, String code) { + CodeSystem cs = context.fetchCodeSystem(target); + String cslink = getCsRef(cs); + XhtmlNode a = null; + if (cslink != null) + a = td.ah(prefix+cslink+"#"+cs.getId()+"-"+code); + else + a = td.ah(prefix+vslink+"#"+code); + a.addText(code); + } + + private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header, List maps) throws FHIRException, IOException { + boolean hasExtensions = false; + List langs = new ArrayList(); + + if (header) { + XhtmlNode h = x.h2(); + h.addText(vs.present()); + addMarkdown(x, vs.getDescription()); + if (vs.hasCopyrightElement()) + generateCopyright(x, vs); + } + XhtmlNode ul = x.ul(); + if (vs.getCompose().getInclude().size() == 1 && vs.getCompose().getExclude().size() == 0) { + hasExtensions = genInclude(rcontext, ul, vs.getCompose().getInclude().get(0), "Include", langs, maps) || hasExtensions; + } else { + XhtmlNode p = x.para(); + p.tx("This value set includes codes based on the following rules:"); + + XhtmlNode li; + for (ConceptSetComponent inc : vs.getCompose().getInclude()) { + hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions; + } + for (ConceptSetComponent exc : vs.getCompose().getExclude()) { + hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions; + } + } + + // now, build observed languages + + if (langs.size() > 0) { + Collections.sort(langs); + x.para().b().tx("Additional Language Displays"); + XhtmlNode t = x.table( "codes"); + XhtmlNode tr = t.tr(); + tr.td().b().tx("Code"); + for (String lang : langs) + tr.td().b().addText(describeLang(lang)); + for (ConceptSetComponent c : vs.getCompose().getInclude()) { + for (ConceptReferenceComponent cc : c.getConcept()) { + addLanguageRow(cc, t, langs); + } + } + } + + return hasExtensions; + } + + private boolean genInclude(ResourceContext rcontext, XhtmlNode ul, ConceptSetComponent inc, String type, List langs, List maps) throws FHIRException, IOException { + boolean hasExtensions = false; + XhtmlNode li; + li = ul.li(); + CodeSystem e = context.fetchCodeSystem(inc.getSystem()); + + if (inc.hasSystem()) { + if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) { + li.addText(type+" all codes defined in "); + addCsRef(inc, li, e); + } else { + if (inc.getConcept().size() > 0) { + li.addText(type+" these codes as defined in "); + addCsRef(inc, li, e); + if (inc.hasVersion()) { + li.addText(" version "); + li.code(inc.getVersion()); + } + + XhtmlNode t = li.table("none"); + boolean hasComments = false; + boolean hasDefinition = false; + for (ConceptReferenceComponent c : inc.getConcept()) { + hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT); + hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION); + } + if (hasComments || hasDefinition) + hasExtensions = true; + addMapHeaders(addTableHeaderRowStandard(t, false, true, hasDefinition, hasComments, false, false, null), maps); + for (ConceptReferenceComponent c : inc.getConcept()) { + XhtmlNode tr = t.tr(); + XhtmlNode td = tr.td(); + ConceptDefinitionComponent cc = getConceptForCode(e, c.getCode(), inc); + addCodeToTable(false, inc.getSystem(), c.getCode(), c.hasDisplay()? c.getDisplay() : cc != null ? cc.getDisplay() : "", td); + + td = tr.td(); + if (!Utilities.noString(c.getDisplay())) + td.addText(c.getDisplay()); + else if (cc != null && !Utilities.noString(cc.getDisplay())) + td.addText(cc.getDisplay()); + + td = tr.td(); + if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION)) + smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION)); + else if (cc != null && !Utilities.noString(cc.getDefinition())) + smartAddText(td, cc.getDefinition()); + + if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) { + smartAddText(tr.td(), "Note: "+ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT)); + } + for (ConceptReferenceDesignationComponent cd : c.getDesignation()) { + if (cd.hasLanguage() && !langs.contains(cd.getLanguage())) + langs.add(cd.getLanguage()); + } + } + } + if (inc.getFilter().size() > 0) { + li.addText(type+" codes from "); + addCsRef(inc, li, e); + li.tx(" where "); + for (int i = 0; i < inc.getFilter().size(); i++) { + ConceptSetFilterComponent f = inc.getFilter().get(i); + if (i > 0) { + if (i == inc.getFilter().size()-1) { + li.tx(" and "); + } else { + li.tx(", "); + } + } + if (f.getOp() == FilterOperator.EXISTS) { + if (f.getValue().equals("true")) { + li.tx(f.getProperty()+" exists"); + } else { + li.tx(f.getProperty()+" doesn't exist"); + } + } else { + li.tx(f.getProperty()+" "+describe(f.getOp())+" "); + if (e != null && codeExistsInValueSet(e, f.getValue())) { + String href = prefix+getCsRef(e); + if (href.contains("#")) + href = href + "-"+Utilities.nmtokenize(f.getValue()); + else + href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(f.getValue()); + li.ah(href).addText(f.getValue()); + } else if ("concept".equals(f.getProperty()) && inc.hasSystem()) { + li.addText(f.getValue()); + ValidationResult vr = context.validateCode(terminologyServiceOptions, inc.getSystem(), f.getValue(), null); + if (vr.isOk()) { + li.tx(" ("+vr.getDisplay()+")"); + } + } + else + li.addText(f.getValue()); + String disp = ToolingExtensions.getDisplayHint(f); + if (disp != null) + li.tx(" ("+disp+")"); + } + } + } + } + if (inc.hasValueSet()) { + li.tx(", where the codes are contained in "); + boolean first = true; + for (UriType vs : inc.getValueSet()) { + if (first) + first = false; + else + li.tx(", "); + AddVsRef(rcontext, vs.asStringValue(), li); + } + } + } else { + li.tx("Import all the codes that are contained in "); + boolean first = true; + for (UriType vs : inc.getValueSet()) { + if (first) + first = false; + else + li.tx(", "); + AddVsRef(rcontext, vs.asStringValue(), li); + } + } + return hasExtensions; + } + + + private ConceptDefinitionComponent getConceptForCode(CodeSystem e, String code, ConceptSetComponent inc) { + if (code == null) { + return null; + } + // first, look in the code systems + if (e == null) + e = context.fetchCodeSystem(inc.getSystem()); + if (e != null) { + ConceptDefinitionComponent v = getConceptForCode(e.getConcept(), code); + if (v != null) + return v; + } + + if (noSlowLookup) + return null; + + if (!context.hasCache()) { + ValueSetExpansionComponent vse; + try { + ValueSetExpansionOutcome vso = context.expandVS(inc, false); + ValueSet valueset = vso.getValueset(); + if (valueset == null) + throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError()); + vse = valueset.getExpansion(); + + } catch (TerminologyServiceException e1) { + return null; + } + if (vse != null) { + ConceptDefinitionComponent v = getConceptForCodeFromExpansion(vse.getContains(), code); + if (v != null) + return v; + } + } + + return context.validateCode(terminologyServiceOptions, inc.getSystem(), code, null).asConceptDefinition(); + } + + private ConceptDefinitionComponent getConceptForCode(List list, String code) { + for (ConceptDefinitionComponent c : list) { + if (code.equals(c.getCode())) + return c; + ConceptDefinitionComponent v = getConceptForCode(c.getConcept(), code); + if (v != null) + return v; + } + return null; + } + + private ConceptDefinitionComponent getConceptForCodeFromExpansion(List list, String code) { + for (ValueSetExpansionContainsComponent c : list) { + if (code.equals(c.getCode())) { + ConceptDefinitionComponent res = new ConceptDefinitionComponent(); + res.setCode(c.getCode()); + res.setDisplay(c.getDisplay()); + return res; + } + ConceptDefinitionComponent v = getConceptForCodeFromExpansion(c.getContains(), code); + if (v != null) + return v; + } + return null; + } + + + private boolean codeExistsInValueSet(CodeSystem cs, String code) { + for (ConceptDefinitionComponent c : cs.getConcept()) { + if (inConcept(code, c)) + return true; + } + return false; + } + + + private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List langs) { + XhtmlNode tr = t.tr(); + tr.td().addText(c.getCode()); + for (String lang : langs) { + String d = null; + for (ConceptReferenceDesignationComponent cd : c.getDesignation()) { + String l = cd.getLanguage(); + if (lang.equals(l)) + d = cd.getValue(); + } + tr.td().addText(d == null ? "" : d); + } + } + + + private String describe(FilterOperator op) { + if (op == null) + return " null "; + switch (op) { + case EQUAL: return " = "; + case ISA: return " is-a "; + case ISNOTA: return " is-not-a "; + case REGEX: return " matches (by regex) "; + case NULL: return " ?ngen-13? "; + case IN: return " in "; + case NOTIN: return " not in "; + case DESCENDENTOF: return " descends from "; + case EXISTS: return " exists "; + case GENERALIZES: return " generalizes "; + } + return null; + } + + + + + + private boolean inConcept(String code, ConceptDefinitionComponent c) { + if (c.hasCodeElement() && c.getCode().equals(code)) + return true; + for (ConceptDefinitionComponent g : c.getConcept()) { + if (inConcept(code, g)) + return true; + } + return false; + } + + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index 2e2afe214..a179880f3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -536,17 +536,17 @@ public class FHIRPathEngine { * evaluate a path and return the matching elements * * @param base - the object against which the path is being evaluated - * @param ExpressionNode - the parsed ExpressionNode statement to use + * @param expressionNode - the parsed ExpressionNode statement to use * @return * @throws FHIRException * @ */ - public List evaluate(Object appContext, Base focusResource, Base rootResource, Base base, ExpressionNode ExpressionNode) throws FHIRException { + public List evaluate(Object appContext, Base focusResource, Base rootResource, Base base, ExpressionNode expressionNode) throws FHIRException { List list = new ArrayList(); if (base != null) list.add(base); log = new StringBuilder(); - return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list, ExpressionNode, true); + return execute(new ExecutionContext(appContext, focusResource, rootResource, base, null, base), list, expressionNode, true); } /** diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java index d3386f7ee..d0e7d6701 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java @@ -33,12 +33,12 @@ Copyright (c) 2011+, HL7, Inc 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 + * 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, + * 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 + * 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. @@ -53,12 +53,14 @@ Copyright (c) 2011+, HL7, Inc ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + */ import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; +import com.google.common.collect.Multimap; +import com.google.common.collect.HashMultimap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -180,11 +182,18 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; +import org.hl7.fhir.r5.terminologies.CodeSystemRenderer; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.CodeSystemNavigator; +import org.hl7.fhir.r5.terminologies.ConceptMapRenderer; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer.ConceptMapRenderInstructions; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer.TerminologyRendererMode; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.terminologies.ValueSetRenderer; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument; +import org.hl7.fhir.r5.utils.NarrativeGenerator.ResourceContext; import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.MarkDownProcessor; @@ -211,57 +220,13 @@ public class NarrativeGenerator implements INarrativeGenerator { Base parseType(String xml, String type) throws FHIRFormatError, IOException, FHIRException ; } - public class ConceptMapRenderInstructions { - private String name; - private String url; - private boolean doDescription; - public ConceptMapRenderInstructions(String name, String url, boolean doDescription) { - super(); - this.name = name; - this.url = url; - this.doDescription = doDescription; - } - public String getName() { - return name; - } - public String getUrl() { - return url; - } - public boolean isDoDescription() { - return doDescription; - } - - } - - public class UsedConceptMap { - - private ConceptMapRenderInstructions details; - private String link; - private ConceptMap map; - public UsedConceptMap(ConceptMapRenderInstructions details, String link, ConceptMap map) { - super(); - this.details = details; - this.link = link; - this.map = map; - } - public ConceptMapRenderInstructions getDetails() { - return details; - } - public ConceptMap getMap() { - return map; - } - public String getLink() { - return link; - } - } - public static class ResourceContext { Bundle bundleResource; org.hl7.fhir.r5.elementmodel.Element bundleElement; - + DomainResource resourceResource; org.hl7.fhir.r5.elementmodel.Element resourceElement; - + public ResourceContext(Bundle bundle, DomainResource dr) { super(); this.bundleResource = bundle; @@ -300,7 +265,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } return null; } - + public org.hl7.fhir.r5.elementmodel.Element resolveElement(String value) { if (value.startsWith("#")) { if (resourceElement != null) { @@ -324,8 +289,6 @@ public class NarrativeGenerator implements INarrativeGenerator { } } - private static final String ABSTRACT_CODE_HINT = "This code is not selectable ('Abstract')"; - public interface IReferenceResolver { ResourceWithReference resolve(String url); } @@ -340,7 +303,7 @@ public class NarrativeGenerator implements INarrativeGenerator { private ITypeParser parser; // when generating for an element model private ILiquidTemplateProvider templateProvider; private IEvaluationContext services; - + public boolean generate(Bundle b, boolean evenIfAlreadyHasNarrative, Set outputTracker) throws EOperationOutcome, FHIRException, IOException { boolean res = false; this.bundle = b; @@ -360,15 +323,15 @@ public class NarrativeGenerator implements INarrativeGenerator { public boolean generate(DomainResource r, Set outputTracker) throws EOperationOutcome, FHIRException, IOException { return generate(null, r, outputTracker); } - + public boolean generate(ResourceContext rcontext, DomainResource r, Set outputTracker) throws EOperationOutcome, FHIRException, IOException { if (rcontext == null) rcontext = new ResourceContext(null, r); - + if (templateProvider != null) { String liquidTemplate = templateProvider.findTemplate(rcontext, r); if (liquidTemplate != null) { - return generateByLiquid(rcontext, r, liquidTemplate, outputTracker); + return generateByLiquid(rcontext, r, liquidTemplate, outputTracker); } } if (r instanceof ConceptMap) { @@ -447,7 +410,7 @@ public class NarrativeGenerator implements INarrativeGenerator { public List children(String name) throws UnsupportedEncodingException, FHIRException, IOException; public List children(); } - + private interface ResourceWrapper extends WrapperBase { public List getContained(); public String getId(); @@ -500,7 +463,7 @@ public class NarrativeGenerator implements INarrativeGenerator { return null; } } - + private class BaseWrapperElement extends WrapperBaseImpl implements BaseWrapper { private Element element; private String type; @@ -521,12 +484,12 @@ public class NarrativeGenerator implements INarrativeGenerator { if (type == null || type.equals("Resource") || type.equals("BackboneElement") || type.equals("Element")) return null; - String xml; - try { - xml = new XmlGenerator().generate(element); - } catch (org.hl7.fhir.exceptions.FHIRException e) { - throw new FHIRException(e.getMessage(), e); - } + String xml; + try { + xml = new XmlGenerator().generate(element); + } catch (org.hl7.fhir.exceptions.FHIRException e) { + throw new FHIRException(e.getMessage(), e); + } return parseType(xml, type); } @@ -775,7 +738,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } else if (wrapped.hasChild("name") && wrapped.getChildValue("name") != null) { x.tx(wrapped.getChildValue("name")); } else { - x.tx("??"); + x.tx("?ngen-1?"); } } } @@ -887,12 +850,12 @@ public class NarrativeGenerator implements INarrativeGenerator { if (div == null) return null; try { - return new XhtmlParser().parse(new XmlGenerator().generate(div), "div"); - } catch (org.hl7.fhir.exceptions.FHIRFormatError e) { - throw new FHIRFormatError(e.getMessage(), e); - } catch (org.hl7.fhir.exceptions.FHIRException e) { - throw new FHIRException(e.getMessage(), e); - } + return new XhtmlParser().parse(new XmlGenerator().generate(div), "div"); + } catch (org.hl7.fhir.exceptions.FHIRFormatError e) { + throw new FHIRFormatError(e.getMessage(), e); + } catch (org.hl7.fhir.exceptions.FHIRException e) { + throw new FHIRException(e.getMessage(), e); + } } @Override @@ -984,7 +947,7 @@ public class NarrativeGenerator implements INarrativeGenerator { throw new Error("Access single value, but value count is "+getValues().size()); return getValues().get(0); } - + public String toString() { return "#."+wrapped.toString(); } @@ -1074,8 +1037,8 @@ public class NarrativeGenerator implements INarrativeGenerator { public List children() { List list = new ArrayList(); if (wrapped.children() != null) { - for (Property c : wrapped.children()) - list.add(new PropertyWrapperDirect(c)); + for (Property c : wrapped.children()) + list.add(new PropertyWrapperDirect(c)); } return list; } @@ -1120,7 +1083,6 @@ public class NarrativeGenerator implements INarrativeGenerator { private String tooCostlyNoteNotEmptyDependent; private IReferenceResolver resolver; private int headerLevelContext; - private List renderingMaps = new ArrayList(); private boolean pretty; private boolean canonicalUrlsAsLinks; private ValidationOptions terminologyServiceOptions = new ValidationOptions(); @@ -1136,7 +1098,7 @@ public class NarrativeGenerator implements INarrativeGenerator { this.basePath = basePath; init(); } - + public NarrativeGenerator setLiquidServices(ILiquidTemplateProvider templateProvider, IEvaluationContext services) { this.templateProvider = templateProvider; this.services = services; @@ -1162,12 +1124,8 @@ public class NarrativeGenerator implements INarrativeGenerator { private void init() { profileUtilities = new ProfileUtilities(context, null, null); - renderingMaps.add(new ConceptMapRenderInstructions("Canonical Status", "http://hl7.org/fhir/ValueSet/resource-status", false)); } - public List getRenderingMaps() { - return renderingMaps; - } public int getHeaderLevelContext() { return headerLevelContext; @@ -1232,12 +1190,12 @@ public class NarrativeGenerator implements INarrativeGenerator { public String generate(org.hl7.fhir.r5.elementmodel.Element er, boolean showCodeDetails, ITypeParser parser) throws IOException, FHIRException, EOperationOutcome { return generate(null, er, showCodeDetails, parser); } - + public String generate(ResourceContext rcontext, org.hl7.fhir.r5.elementmodel.Element er, boolean showCodeDetails, ITypeParser parser) throws IOException, FHIRException, EOperationOutcome { if (rcontext == null) rcontext = new ResourceContext(null, er); this.parser = parser; - + ResourceWrapperMetaElement resw = new ResourceWrapperMetaElement(er); XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); if ("List".equals(resw.getName())) { @@ -1308,7 +1266,7 @@ public class NarrativeGenerator implements INarrativeGenerator { Map displayHints = readDisplayHints(child); if (!exemptFromRendering(child)) { List grandChildren = getChildrenForPath(allElements, path+"."+p.getName()); - filterGrandChildren(grandChildren, path+"."+p.getName(), p); + filterGrandChildren(grandChildren, path+"."+p.getName(), p); if (p.getValues().size() > 0 && child != null) { if (isPrimitive(child)) { XhtmlNode para = x.para(); @@ -1373,18 +1331,18 @@ public class NarrativeGenerator implements INarrativeGenerator { } private void filterGrandChildren(List grandChildren, String string, PropertyWrapper prop) { - List toRemove = new ArrayList(); - toRemove.addAll(grandChildren); - for (BaseWrapper b : prop.getValues()) { - List list = new ArrayList(); - for (ElementDefinition ed : toRemove) { - PropertyWrapper p = b.getChildByName(tail(ed.getPath())); - if (p != null && p.hasValues()) - list.add(ed); - } - toRemove.removeAll(list); - } - grandChildren.removeAll(toRemove); + List toRemove = new ArrayList(); + toRemove.addAll(grandChildren); + for (BaseWrapper b : prop.getValues()) { + List list = new ArrayList(); + for (ElementDefinition ed : toRemove) { + PropertyWrapper p = b.getChildByName(tail(ed.getPath())); + if (p != null && p.hasValues()) + list.add(ed); + } + toRemove.removeAll(list); + } + grandChildren.removeAll(toRemove); } private List splitExtensions(StructureDefinition profile, List children) throws UnsupportedEncodingException, IOException, FHIRException { @@ -1445,7 +1403,7 @@ public class NarrativeGenerator implements INarrativeGenerator { private boolean isDefault(Map displayHints, PrimitiveType primitiveType) { String v = primitiveType.asStringValue(); if (!Utilities.noString(v) && displayHints.containsKey("default") && v.equals(displayHints.get("default"))) - return true; + return true; return false; } @@ -1519,7 +1477,7 @@ public class NarrativeGenerator implements INarrativeGenerator { if (e.getType().size() == 1 && isBase(e.getType().get(0).getWorkingCode())) return false; return true; -// return !e.getType().isEmpty() + // return !e.getType().isEmpty() } private boolean isBase(String code) { @@ -1561,7 +1519,7 @@ public class NarrativeGenerator implements INarrativeGenerator { x.addText(((org.hl7.fhir.r5.model.DateType) e).toHumanDisplay()); else if (e instanceof Enumeration) { Object ev = ((Enumeration) e).getValue(); - x.addText(ev == null ? "" : ev.toString()); // todo: look up a display name if there is one + x.addText(ev == null ? "" : ev.toString()); // todo: look up a display name if there is one } else if (e instanceof BooleanType) x.addText(((BooleanType) e).getValue().toString()); else if (e instanceof CodeableConcept) { @@ -1607,7 +1565,7 @@ public class NarrativeGenerator implements INarrativeGenerator { ResourceWithReference tr = null; if (r.hasReferenceElement()) { tr = resolveReference(res, r.getReference(), rc); - + if (!r.getReference().startsWith("#")) { if (tr != null && tr.getReference() != null) c = x.ah(tr.getReference()); @@ -1654,7 +1612,7 @@ public class NarrativeGenerator implements INarrativeGenerator { name = name.substring(0, name.length() - 3); if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints, ((PrimitiveType) e))) - return false; + return false; if (e instanceof StringType) { x.addText(name+": "+((StringType) e).getValue()); @@ -1675,7 +1633,7 @@ public class NarrativeGenerator implements INarrativeGenerator { x.addText(name+": "+((InstantType) e).toHumanDisplay()); return true; } else if (e instanceof Extension) { -// x.tx("Extensions: todo"); + // x.tx("Extensions: todo"); return false; } else if (e instanceof org.hl7.fhir.r5.model.DateType) { x.addText(name+": "+((org.hl7.fhir.r5.model.DateType) e).toHumanDisplay()); @@ -1686,7 +1644,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } else if (e instanceof BooleanType) { if (((BooleanType) e).getValue()) { x.addText(name); - return true; + return true; } } else if (e instanceof CodeableConcept) { renderCodeableConcept((CodeableConcept) e, x, showCodeDetails); @@ -1732,7 +1690,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } else if (e instanceof Period) { Period p = (Period) e; x.addText(name+": "); - x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay()); + x.addText(!p.hasStart() ? "?ngen-2?" : p.getStartElement().toHumanDisplay()); x.tx(" --> "); x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay()); return true; @@ -1742,9 +1700,9 @@ public class NarrativeGenerator implements INarrativeGenerator { x.addText(r.getDisplay()); else if (r.hasReferenceElement()) { ResourceWithReference tr = resolveReference(res, r.getReference(), rc); - x.addText(tr == null ? r.getReference() : "????"); // getDisplayForReference(tr.getReference())); + x.addText(tr == null ? r.getReference() : "?ngen-3"); // getDisplayForReference(tr.getReference())); } else - x.tx("??"); + x.tx("?ngen-4?"); return true; } else if (e instanceof Narrative) { return false; @@ -1792,7 +1750,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } public static String displayPeriod(Period p) { - String s = !p.hasStart() ? "??" : p.getStartElement().toHumanDisplay(); + String s = !p.hasStart() ? "?ngen-5?" : p.getStartElement().toHumanDisplay(); s = s + " --> "; return s + (!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay()); } @@ -1860,7 +1818,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } return null; } - + if (rc!=null) { BundleEntryComponent bundleResource = rc.resolve(url); if (bundleResource != null) { @@ -1931,19 +1889,19 @@ public class NarrativeGenerator implements INarrativeGenerator { first = false; } else sp.tx("; "); - sp.tx("{"+describeSystem(c.getSystem())+" code '"+c.getCode()+"' = '"+lookupCode(c.getSystem(), c.getCode())+(c.hasDisplay() ? "', given as '"+c.getDisplay()+"'}" : "")); + sp.tx("{"+TerminologyRenderer.describeSystem(c.getSystem())+" code '"+c.getCode()+"' = '"+lookupCode(c.getSystem(), c.getCode())+(c.hasDisplay() ? "', given as '"+c.getDisplay()+"'}" : "")); } sp.tx(")"); } else { - CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); - for (Coding c : cc.getCoding()) { - if (c.hasCodeElement() && c.hasSystemElement()) { - b.append("{"+c.getSystem()+" "+c.getCode()+"}"); + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (Coding c : cc.getCoding()) { + if (c.hasCodeElement() && c.hasSystemElement()) { + b.append("{"+c.getSystem()+" "+c.getCode()+"}"); + } } - } - x.span(null, "Codes: "+b.toString()).addText(s); + x.span(null, "Codes: "+b.toString()).addText(s); } } @@ -1983,7 +1941,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } return b.toString(); } - + public String describeCoding(Coding c, boolean showCodeDetails) { String s = ""; if (c.hasDisplayElement()) @@ -1995,7 +1953,7 @@ public class NarrativeGenerator implements INarrativeGenerator { s = c.getCode(); if (showCodeDetails) { - return s+" (Details: "+describeSystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getCode())+"', stated as '"+c.getDisplay()+"')"; + return s+" (Details: "+TerminologyRenderer.describeSystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getCode())+"', stated as '"+c.getDisplay()+"')"; } else return ""+Utilities.escapeXml(s)+""; } @@ -2011,35 +1969,16 @@ public class NarrativeGenerator implements INarrativeGenerator { s = c.getCode(); if (showCodeDetails) { - x.addText(s+" (Details: "+describeSystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getCode())+"', stated as '"+c.getDisplay()+"')"); + x.addText(s+" (Details: "+TerminologyRenderer.describeSystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getCode())+"', stated as '"+c.getDisplay()+"')"); } else x.span(null, "{"+c.getSystem()+" "+c.getCode()+"}").addText(s); } - public static String describeSystem(String system) { - if (system == null) - return "[not stated]"; - if (system.equals("http://loinc.org")) - return "LOINC"; - if (system.startsWith("http://snomed.info")) - return "SNOMED CT"; - if (system.equals("http://www.nlm.nih.gov/research/umls/rxnorm")) - return "RxNorm"; - if (system.equals("http://hl7.org/fhir/sid/icd-9")) - return "ICD-9"; - if (system.equals("http://dicom.nema.org/resources/ontology/DCM")) - return "DICOM"; - if (system.equals("http://unitsofmeasure.org")) - return "UCUM"; - - return system; - } - private String lookupCode(String system, String code) { ValidationResult t = context.validateCode(terminologyServiceOptions , system, code, null); if (t != null && t.getDisplay() != null) - return t.getDisplay(); + return t.getDisplay(); else return code; @@ -2103,7 +2042,7 @@ public class NarrativeGenerator implements INarrativeGenerator { else if (q.hasCode()) x.tx(" "+q.getCode()); if (showCodeDetails && q.hasCode()) { - x.span("background: LightGoldenRodYellow", null).tx(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')"); + x.span("background: LightGoldenRodYellow", null).tx(" (Details: "+TerminologyRenderer.describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')"); } } @@ -2218,9 +2157,9 @@ public class NarrativeGenerator implements INarrativeGenerator { private String displayQuantity(Quantity q) { StringBuilder s = new StringBuilder(); - s.append("(system = '").append(describeSystem(q.getSystem())) - .append("' code ").append(q.getCode()) - .append(" = '").append(lookupCode(q.getSystem(), q.getCode())).append("')"); + s.append("(system = '").append(TerminologyRenderer.describeSystem(q.getSystem())) + .append("' code ").append(q.getCode()) + .append(" = '").append(lookupCode(q.getSystem(), q.getCode())).append("')"); return s.toString(); } @@ -2228,7 +2167,7 @@ public class NarrativeGenerator implements INarrativeGenerator { private String displayTiming(Timing s) throws FHIRException { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (s.hasCode()) - b.append("Code: "+displayCodeableConcept(s.getCode())); + b.append("Code: "+displayCodeableConcept(s.getCode())); if (s.getEvent().size() > 0) { CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder(); @@ -2265,10 +2204,10 @@ public class NarrativeGenerator implements INarrativeGenerator { st = st + "-"+Integer.toString(rep.getFrequency()); } if (rep.hasPeriod()) { - st = st + " per "+rep.getPeriod().toPlainString(); - if (rep.hasPeriodMax()) - st = st + "-"+rep.getPeriodMax().toPlainString(); - st = st + " "+displayTimeUnits(rep.getPeriodUnit()); + st = st + " per "+rep.getPeriod().toPlainString(); + if (rep.hasPeriodMax()) + st = st + "-"+rep.getPeriodMax().toPlainString(); + st = st + " "+displayTimeUnits(rep.getPeriodUnit()); } b.append("Do "+st); } @@ -2294,13 +2233,13 @@ public class NarrativeGenerator implements INarrativeGenerator { case PCM: return "after breakfast"; case PCV: return "after dinner"; case WAKE: return "after waking"; - default: return "??"; + default: return "?ngen-6?"; } } private String displayTimeUnits(UnitsOfTime units) { - if (units == null) - return "??"; + if (units == null) + return "?ngen-7?"; switch (units) { case A: return "years"; case D: return "days"; @@ -2309,7 +2248,7 @@ public class NarrativeGenerator implements INarrativeGenerator { case MO: return "months"; case S: return "seconds"; case WK: return "weeks"; - default: return "??"; + default: return "?ngen-8?"; } } @@ -2389,15 +2328,15 @@ public class NarrativeGenerator implements INarrativeGenerator { } private String displayIdentifier(Identifier ii) { - String s = Utilities.noString(ii.getValue()) ? "??" : ii.getValue(); + String s = Utilities.noString(ii.getValue()) ? "?ngen-9?" : ii.getValue(); if (ii.hasType()) { - if (ii.getType().hasText()) - s = ii.getType().getText()+" = "+s; - else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay()) - s = ii.getType().getCoding().get(0).getDisplay()+" = "+s; - else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode()) - s = lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getCode())+" = "+s; + if (ii.getType().hasText()) + s = ii.getType().getText()+" = "+s; + else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay()) + s = ii.getType().getCoding().get(0).getDisplay()+" = "+s; + else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode()) + s = lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getCode())+" = "+s; } if (ii.hasUse()) @@ -2409,15 +2348,15 @@ public class NarrativeGenerator implements INarrativeGenerator { // do we need to do a name reference substitution? for (ElementDefinition e : elements) { if (e.getPath().equals(path) && e.hasContentReference()) { - String ref = e.getContentReference(); - ElementDefinition t = null; - // now, resolve the name + String ref = e.getContentReference(); + ElementDefinition t = null; + // now, resolve the name for (ElementDefinition e1 : elements) { - if (ref.equals("#"+e1.getId())) - t = e1; + if (ref.equals("#"+e1.getId())) + t = e1; } if (t == null) - throw new DefinitionException("Unable to resolve content reference "+ref+" trying to resolve "+path); + throw new DefinitionException("Unable to resolve content reference "+ref+" trying to resolve "+path); path = t.getPath(); break; } @@ -2434,329 +2373,12 @@ public class NarrativeGenerator implements INarrativeGenerator { public boolean generate(ResourceContext rcontext, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException { XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); - x.h2().addText(cm.getName()+" ("+cm.getUrl()+")"); - - XhtmlNode p = x.para(); - p.tx("Mapping from "); - if (cm.hasSource()) - AddVsRef(rcontext, cm.getSource().primitiveValue(), p); - else - p.tx("(not specified)"); - p.tx(" to "); - if (cm.hasTarget()) - AddVsRef(rcontext, cm.getTarget().primitiveValue(), p); - else - p.tx("(not specified)"); - - p = x.para(); - if (cm.getExperimental()) - p.addText(Utilities.capitalize(cm.getStatus().toString())+" (not intended for production usage). "); - else - p.addText(Utilities.capitalize(cm.getStatus().toString())+". "); - p.tx("Published on "+(cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "??")+" by "+cm.getPublisher()); - if (!cm.getContact().isEmpty()) { - p.tx(" ("); - boolean firsti = true; - for (ContactDetail ci : cm.getContact()) { - if (firsti) - firsti = false; - else - p.tx(", "); - if (ci.hasName()) - p.addText(ci.getName()+": "); - boolean first = true; - for (ContactPoint c : ci.getTelecom()) { - if (first) - first = false; - else - p.tx(", "); - addTelecom(p, c); - } - } - p.tx(")"); - } - p.tx(". "); - p.addText(cm.getCopyright()); - if (!Utilities.noString(cm.getDescription())) - addMarkdown(x, cm.getDescription()); - - x.br(); - - CodeSystem cs = context.fetchCodeSystem("http://hl7.org/fhir/concept-map-relationship"); - if (cs == null) - cs = context.fetchCodeSystem("http://hl7.org/fhir/concept-map-equivalence"); - String eqpath = cs == null ? null : cs.getUserString("path"); - - for (ConceptMapGroupComponent grp : cm.getGroup()) { - String src = grp.getSource(); - boolean comment = false; - boolean ok = true; - Map> sources = new HashMap>(); - Map> targets = new HashMap>(); - sources.put("code", new HashSet()); - targets.put("code", new HashSet()); - SourceElementComponent cc = grp.getElement().get(0); - String dst = grp.getTarget(); - sources.get("code").add(grp.getSource()); - targets.get("code").add(grp.getTarget()); - for (SourceElementComponent ccl : grp.getElement()) { - ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty(); - for (TargetElementComponent ccm : ccl.getTarget()) { - comment = comment || !Utilities.noString(ccm.getComment()); - for (OtherElementComponent d : ccm.getDependsOn()) { - if (!sources.containsKey(d.getProperty())) - sources.put(d.getProperty(), new HashSet()); - sources.get(d.getProperty()).add(d.getSystem()); - } - for (OtherElementComponent d : ccm.getProduct()) { - if (!targets.containsKey(d.getProperty())) - targets.put(d.getProperty(), new HashSet()); - targets.get(d.getProperty()).add(d.getSystem()); - } - } - } - - String display; - if (ok) { - // simple - XhtmlNode tbl = x.table( "grid"); - XhtmlNode tr = tbl.tr(); - tr.td().b().tx("Source Code"); - tr.td().b().tx("Relationship"); - tr.td().b().tx("Destination Code"); - if (comment) - tr.td().b().tx("Comment"); - for (SourceElementComponent ccl : grp.getElement()) { - tr = tbl.tr(); - XhtmlNode td = tr.td(); - td.addText(ccl.getCode()); - display = getDisplayForConcept(grp.getSource(), ccl.getCode()); - if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display)) - td.tx(" ("+display+")"); - TargetElementComponent ccm = ccl.getTarget().get(0); - if (!ccm.hasRelationship()) - tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")"); - else { - if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { - String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE); - tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code)); - } else { - tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode())); - } - } - td = tr.td(); - td.addText(ccm.getCode()); - display = getDisplayForConcept(grp.getTarget(), ccm.getCode()); - if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display)) - td.tx(" ("+display+")"); - if (comment) - tr.td().addText(ccm.getComment()); - addUnmapped(tbl, grp); - } - } else { - XhtmlNode tbl = x.table( "grid"); - XhtmlNode tr = tbl.tr(); - XhtmlNode td; - tr.td().colspan(Integer.toString(1+sources.size())).b().tx("Source Concept Details"); - tr.td().b().tx("Relationship"); - tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Destination Concept Details"); - if (comment) { - tr.td().b().tx("Comment"); - } - tr = tbl.tr(); - if (sources.get("code").size() == 1) { - String url = sources.get("code").iterator().next(); - renderCSDetailsLink(tr, url, true); - } else - tr.td().b().tx("Code"); - for (String s : sources.keySet()) { - if (!s.equals("code")) { - if (sources.get(s).size() == 1) { - String url = sources.get(s).iterator().next(); - renderCSDetailsLink(tr, url, false); - } else - tr.td().b().addText(getDescForConcept(s)); - } - } - tr.td(); - if (targets.get("code").size() == 1) { - String url = targets.get("code").iterator().next(); - renderCSDetailsLink(tr, url, true); - } else - tr.td().b().tx("Code"); - for (String s : targets.keySet()) { - if (!s.equals("code")) { - if (targets.get(s).size() == 1) { - String url = targets.get(s).iterator().next(); - renderCSDetailsLink(tr, url, false); - } else - tr.td().b().addText(getDescForConcept(s)); - } - } - if (comment) - tr.td(); - - for (int si = 0; si < grp.getElement().size(); si++) { - SourceElementComponent ccl = grp.getElement().get(si); - boolean slast = si == grp.getElement().size()-1; - boolean first = true; - if (ccl.hasNoMap() && ccl.getNoMap()) { - tr = tbl.tr(); - td = tr.td().style("border-right-width: 0px"); - if (!first) - td.style("border-top-style: none"); - else - td.style("border-bottom-style: none"); - if (sources.get("code").size() == 1) - td.addText(ccl.getCode()); - else - td.addText(grp.getSource()+" / "+ccl.getCode()); - display = getDisplayForConcept(grp.getSource(), ccl.getCode()); - tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); - tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)"); - - } else { - for (int ti = 0; ti < ccl.getTarget().size(); ti++) { - TargetElementComponent ccm = ccl.getTarget().get(ti); - boolean last = ti == ccl.getTarget().size()-1; - tr = tbl.tr(); - td = tr.td().style("border-right-width: 0px"); - if (!first && !last) - td.style("border-top-style: none; border-bottom-style: none"); - else if (!first) - td.style("border-top-style: none"); - else if (!last) - td.style("border-bottom-style: none"); - if (first) { - if (sources.get("code").size() == 1) - td.addText(ccl.getCode()); - else - td.addText(grp.getSource()+" / "+ccl.getCode()); - display = getDisplayForConcept(grp.getSource(), ccl.getCode()); - tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); - } - for (String s : sources.keySet()) { - if (!s.equals("code")) { - td = tr.td(); - if (first) { - td.addText(getValue(ccm.getDependsOn(), s, sources.get(s).size() != 1)); - display = getDisplay(ccm.getDependsOn(), s); - if (display != null) - td.tx(" ("+display+")"); - } - } - } - first = false; - if (!ccm.hasRelationship()) - tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")"); - else { - if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { - String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE); - tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code)); - } else { - tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode())); - } - } - td = tr.td().style("border-right-width: 0px"); - if (targets.get("code").size() == 1) - td.addText(ccm.getCode()); - else - td.addText(grp.getTarget()+" / "+ccm.getCode()); - display = getDisplayForConcept(grp.getTarget(), ccm.getCode()); - tr.td().style("border-left-width: 0px").tx(display == null ? "" : display); - - for (String s : targets.keySet()) { - if (!s.equals("code")) { - td = tr.td(); - td.addText(getValue(ccm.getProduct(), s, targets.get(s).size() != 1)); - display = getDisplay(ccm.getProduct(), s); - if (display != null) - td.tx(" ("+display+")"); - } - } - if (comment) - tr.td().addText(ccm.getComment()); - } - } - addUnmapped(tbl, grp); - } - } - } - + ConceptMapRenderer renderer = new ConceptMapRenderer(TerminologyRendererMode.RESOURCE, context, markdown, prefix, null); + boolean res = renderer.generate(rcontext, cm, x); inject(cm, x, NarrativeStatus.GENERATED); - return true; + return res; } - private void addUnmapped(XhtmlNode tbl, ConceptMapGroupComponent grp) { - if (grp.hasUnmapped()) { -// throw new Error("not done yet"); - } - - } - - private String presentRelationshipCode(String code) { - if ("related-to".equals(code)) { - return "is related to"; - } else if ("equivalent".equals(code)) { - return "is equivalent to"; - } else if ("broader".equals(code)) { - return "maps to wider concept"; - } else if ("narrower".equals(code)) { - return "maps to narrower concept"; - } else if ("not-related-to".equals(code)) { - return "is not related to"; - } else { - return code; - } - } - - private String presentEquivalenceCode(String code) { - if ("relatedto".equals(code)) { - return "is related to"; - } else if ("equivalent".equals(code)) { - return "is equivalent to"; - } else if ("equal".equals(code)) { - return "is equal to"; - } else if ("wider".equals(code)) { - return "maps to wider concept"; - } else if ("subsumes".equals(code)) { - return "is subsumed by"; - } else if ("narrower".equals(code)) { - return "maps to narrower concept"; - } else if ("specializes".equals(code)) { - return "has specialization"; - } else if ("inexact".equals(code)) { - return "maps loosely to"; - } else if ("unmatched".equals(code)) { - return "has no match"; - } else if ("disjoint".equals(code)) { - return "is not related to"; - } else { - return code; - } - } - - public void renderCSDetailsLink(XhtmlNode tr, String url, boolean span2) { - CodeSystem cs; - XhtmlNode td; - cs = context.fetchCodeSystem(url); - td = tr.td(); - if (span2) { - td.colspan("2"); - } - td.b().tx("Code"); - td.tx(" from "); - if (cs == null) - td.tx(url); - else - td.ah(cs.getUserString("path")).attribute("title", url).tx(cs.present()); - } - - private boolean isSameCodeAndDisplay(String code, String display) { - String c = code.replace(" ", "").replace("-", "").toLowerCase(); - String d = display.replace(" ", "").replace("-", "").toLowerCase(); - return c.equals(d); - } private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) { if (!x.hasAttribute("xmlns")) @@ -2862,55 +2484,6 @@ public class NarrativeGenerator implements INarrativeGenerator { div.setXhtml(x); } - private String getDisplay(List list, String s) { - for (OtherElementComponent c : list) { - if (s.equals(c.getProperty())) - return getDisplayForConcept(c.getSystem(), c.getValue()); - } - return null; - } - - private String getDisplayForConcept(String system, String value) { - if (value == null || system == null) - return null; - ValidationResult cl = context.validateCode(terminologyServiceOptions, system, value, null); - return cl == null ? null : cl.getDisplay(); - } - - - - private String getDescForConcept(String s) { - if (s.startsWith("http://hl7.org/fhir/v2/element/")) - return "v2 "+s.substring("http://hl7.org/fhir/v2/element/".length()); - return s; - } - - private String getValue(List list, String s, boolean withSystem) { - for (OtherElementComponent c : list) { - if (s.equals(c.getProperty())) - if (withSystem) - return c.getSystem()+" / "+c.getValue(); - else - return c.getValue(); - } - return null; - } - - private void addTelecom(XhtmlNode p, ContactPoint c) { - if (c.getSystem() == ContactPointSystem.PHONE) { - p.tx("Phone: "+c.getValue()); - } else if (c.getSystem() == ContactPointSystem.FAX) { - p.tx("Fax: "+c.getValue()); - } else if (c.getSystem() == ContactPointSystem.EMAIL) { - p.ah( "mailto:"+c.getValue()).addText(c.getValue()); - } else if (c.getSystem() == ContactPointSystem.URL) { - if (c.getValue().length() > 30) - p.ah(c.getValue()).addText(c.getValue().substring(0, 30)+"..."); - else - p.ah(c.getValue()).addText(c.getValue()); - } - } - /** * This generate is optimised for the FHIR build process itself in as much as it * generates hyperlinks in the narrative that are only going to be correct for @@ -2925,213 +2498,15 @@ public class NarrativeGenerator implements INarrativeGenerator { */ public boolean generate(ResourceContext rcontext, CodeSystem cs, boolean header, String lang) throws FHIRFormatError, DefinitionException, IOException { XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); - boolean hasExtensions = false; - hasExtensions = generateDefinition(x, cs, header, lang); + CodeSystemRenderer renderer = new CodeSystemRenderer(TerminologyRendererMode.RESOURCE, context, markdown, prefix, lang); + renderer.getCodeSystemPropList().addAll(getCodeSystemPropList()); + renderer.setHeaderLevelContext(headerLevelContext); + renderer.setTerminologyServiceOptions(terminologyServiceOptions); + boolean hasExtensions = renderer.generate(x, cs, header); inject(cs, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED); return true; } - private boolean generateDefinition(XhtmlNode x, CodeSystem cs, boolean header, String lang) throws FHIRFormatError, DefinitionException, IOException { - boolean hasExtensions = false; - - if (header) { - XhtmlNode h = x.h2(); - h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName()); - addMarkdown(x, cs.getDescription()); - if (cs.hasCopyright()) - generateCopyright(x, cs, lang); - } - - generateProperties(x, cs, lang); - generateFilters(x, cs, lang); - List maps = new ArrayList(); - hasExtensions = generateCodeSystemContent(x, cs, hasExtensions, maps, lang); - - return hasExtensions; - } - - private void generateFilters(XhtmlNode x, CodeSystem cs, String lang) { - if (cs.hasFilter()) { - x.para().b().tx(context.translator().translate("xhtml-gen-cs", "Filters", lang)); - XhtmlNode tbl = x.table("grid"); - XhtmlNode tr = tbl.tr(); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Description", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "operator", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Value", lang)); - for (CodeSystemFilterComponent f : cs.getFilter()) { - tr = tbl.tr(); - tr.td().tx(f.getCode()); - tr.td().tx(f.getDescription()); - XhtmlNode td = tr.td(); - for (Enumeration t : f.getOperator()) - td.tx(t.asStringValue()+" "); - tr.td().tx(f.getValue()); - } - } - } - - private void generateProperties(XhtmlNode x, CodeSystem cs, String lang) { - if (cs.hasProperty()) { - boolean hasRendered = false; - for (PropertyComponent p : cs.getProperty()) { - hasRendered = hasRendered || !p.getCode().equals(ToolingExtensions.getPresentation(p, p.getCodeElement())); - } - - x.para().b().tx(context.translator().translate("xhtml-gen-cs", "Properties", lang)); - XhtmlNode tbl = x.table("grid"); - XhtmlNode tr = tbl.tr(); - if (hasRendered) { - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Name", lang)); - } - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "URL", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Description", lang)); - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Type", lang)); - for (PropertyComponent p : cs.getProperty()) { - tr = tbl.tr(); - if (hasRendered) { - tr.td().tx(ToolingExtensions.getPresentation(p, p.getCodeElement())); - } - tr.td().tx(p.getCode()); - tr.td().tx(p.getUri()); - tr.td().tx(p.getDescription()); - tr.td().tx(p.hasType() ? p.getType().toCode() : ""); - } - } - } - - private boolean generateCodeSystemContent(XhtmlNode x, CodeSystem cs, boolean hasExtensions, List maps, String lang) throws FHIRFormatError, DefinitionException, IOException { - XhtmlNode p = x.para(); - if (cs.getContent() == CodeSystemContentMode.COMPLETE) - p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines the following codes", cs.getUrl())+":"); - else if (cs.getContent() == CodeSystemContentMode.EXAMPLE) - p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, of which the following are some examples", cs.getUrl())+":"); - else if (cs.getContent() == CodeSystemContentMode.FRAGMENT ) - p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, of which the following are a subset", cs.getUrl())+":"); - else if (cs.getContent() == CodeSystemContentMode.NOTPRESENT ) { - p.tx(context.translator().translateAndFormat("xhtml-gen-cs", lang, "This code system %s defines many codes, but they are not represented here", cs.getUrl())); - return false; - } - XhtmlNode t = x.table( "codes"); - boolean commentS = false; - boolean deprecated = false; - boolean display = false; - boolean hierarchy = false; - boolean version = false; - List properties = new ArrayList(); - for (PropertyComponent cp : cs.getProperty()) { - if (showPropertyInTable(cp)) { - boolean exists = false; - for (ConceptDefinitionComponent c : cs.getConcept()) { - exists = exists || conceptsHaveProperty(c, cp); - } - if (exists) { - properties.add(cp); - } - } - } - for (ConceptDefinitionComponent c : cs.getConcept()) { - commentS = commentS || conceptsHaveComments(c); - deprecated = deprecated || conceptsHaveDeprecated(cs, c); - display = display || conceptsHaveDisplay(c); - version = version || conceptsHaveVersion(c); - hierarchy = hierarchy || c.hasConcept(); - } - CodeSystemNavigator csNav = new CodeSystemNavigator(cs); - hierarchy = hierarchy || csNav.isRestructure(); - - addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, true, commentS, version, deprecated, lang, properties), maps); - for (ConceptDefinitionComponent c : csNav.getConcepts(null)) { - hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, commentS, version, deprecated, maps, cs.getUrl(), cs, lang, properties, csNav) || hasExtensions; - } -// if (langs.size() > 0) { -// Collections.sort(langs); -// x.para().b().tx("Additional Language Displays"); -// t = x.table( "codes"); -// XhtmlNode tr = t.tr(); -// tr.td().b().tx("Code"); -// for (String lang : langs) -// tr.td().b().addText(describeLang(lang)); -// for (ConceptDefinitionComponent c : cs.getConcept()) { -// addLanguageRow(c, t, langs); -// } -// } - return hasExtensions; - } - - private boolean conceptsHaveProperty(ConceptDefinitionComponent c, PropertyComponent cp) { - if (CodeSystemUtilities.hasProperty(c, cp.getCode())) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) - if (conceptsHaveProperty(g, cp)) - return true; - return false; - - } - - private boolean showPropertyInTable(PropertyComponent cp) { - if (cp.hasCode()) { - if (cp.hasExtension(ToolingExtensions.EXT_RENDERED_VALUE)) { - return true; - } - if (cp.getCodeElement().hasExtension(ToolingExtensions.EXT_RENDERED_VALUE)) { - return true; - } - String uri = cp.getUri(); - String code = null; - if (Utilities.noString(uri)){ - return false; - } - if (uri.contains("#")) { - code = uri.substring(uri.indexOf("#")+1); - uri = uri.substring(0, uri.indexOf("#")); - } - if (Utilities.existsInList(uri, "http://hl7.org/fhir/concept-properties") || codeSystemPropList.contains(uri)) { - return true; - }; - CodeSystem cs = context.fetchCodeSystem(uri); - if (cs == null) { - return false; - } - return CodeSystemUtilities.hasCode(cs, code); - } - return false; - } - - private String getDisplayForProperty(String uri) { - if (Utilities.noString(uri)){ - return null; - } - String code = null; - if (uri.contains("#")) { - code = uri.substring(uri.indexOf("#")+1); - uri = uri.substring(0, uri.indexOf("#")); - } - CodeSystem cs = context.fetchCodeSystem(uri); - if (cs == null) { - return null; - } - ConceptDefinitionComponent cc = CodeSystemUtilities.getCode(cs, code); - return cc == null ? null : cc.getDisplay(); - } - - - private int countConcepts(List list) { - int count = list.size(); - for (ConceptDefinitionComponent c : list) - if (c.hasConcept()) - count = count + countConcepts(c.getConcept()); - return count; - } - - private void generateCopyright(XhtmlNode x, CodeSystem cs, String lang) { - XhtmlNode p = x.para(); - p.b().tx(context.translator().translate("xhtml-gen-cs", "Copyright Statement:", lang)); - smartAddText(p, " " + cs.getCopyright()); - } - - /** * This generate is optimised for the FHIR build process itself in as much as it * generates hyperlinks in the narrative that are only going to be correct for @@ -3149,1374 +2524,39 @@ public class NarrativeGenerator implements INarrativeGenerator { } public void generate(ResourceContext rcontext, ValueSet vs, ValueSet src, boolean header) throws FHIRException, IOException { - List maps = findReleventMaps(vs); - XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); - boolean hasExtensions; - if (vs.hasExpansion()) { - // for now, we just accept an expansion if there is one - hasExtensions = generateExpansion(x, vs, src, header, maps); - } else { - hasExtensions = generateComposition(rcontext, x, vs, header, maps); - } + ValueSetRenderer renderer = new ValueSetRenderer(TerminologyRendererMode.RESOURCE, context, markdown, prefix, null); + renderer.setTooCostlyNoteEmpty(tooCostlyNoteEmpty); + renderer.setTooCostlyNoteNotEmpty(tooCostlyNoteNotEmpty); + renderer.setTooCostlyNoteEmptyDependent(tooCostlyNoteEmptyDependent); + renderer.setTooCostlyNoteNotEmptyDependent(tooCostlyNoteNotEmptyDependent); + renderer.setNoSlowLookup(noSlowLookup); + renderer.setHeaderLevelContext(headerLevelContext); + renderer.setTerminologyServiceOptions(terminologyServiceOptions); + + boolean hasExtensions = renderer.render(rcontext, x, vs, src, header); inject(vs, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED); } - private List findReleventMaps(ValueSet vs) throws FHIRException { - List res = new ArrayList(); - for (CanonicalResource md : context.allConformanceResources()) { - if (md instanceof ConceptMap) { - ConceptMap cm = (ConceptMap) md; - if (isSource(vs, cm.getSource())) { - ConceptMapRenderInstructions re = findByTarget(cm.getTarget()); - if (re != null) { - ValueSet vst = cm.hasTarget() ? context.fetchResource(ValueSet.class, cm.hasTargetCanonicalType() ? cm.getTargetCanonicalType().getValue() : cm.getTargetUriType().asStringValue()) : null; - res.add(new UsedConceptMap(re, vst == null ? cm.getUserString("path") : vst.getUserString("path"), cm)); - } - } - } - } - return res; -// Map mymaps = new HashMap(); -// for (ConceptMap a : context.findMapsForSource(vs.getUrl())) { -// String url = ""; -// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference()); -// if (vsr != null) -// url = (String) vsr.getUserData("filename"); -// mymaps.put(a, url); -// } -// Map mymaps = new HashMap(); -// for (ConceptMap a : context.findMapsForSource(cs.getValueSet())) { -// String url = ""; -// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference()); -// if (vsr != null) -// url = (String) vsr.getUserData("filename"); -// mymaps.put(a, url); -// } - // also, look in the contained resources for a concept map -// for (Resource r : cs.getContained()) { -// if (r instanceof ConceptMap) { -// ConceptMap cm = (ConceptMap) r; -// if (((Reference) cm.getSource()).getReference().equals(cs.getValueSet())) { -// String url = ""; -// ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) cm.getTarget()).getReference()); -// if (vsr != null) -// url = (String) vsr.getUserData("filename"); -// mymaps.put(cm, url); -// } -// } -// } - } - private ConceptMapRenderInstructions findByTarget(DataType source) { - if (source == null) { - return null; - } - String src = source.primitiveValue(); - if (src != null) - for (ConceptMapRenderInstructions t : renderingMaps) { - if (src.equals(t.url)) - return t; - } - return null; - } - private boolean isSource(ValueSet vs, DataType source) { - return vs.hasUrl() && source != null && vs.getUrl().equals(source.primitiveValue()); - } - private Integer countMembership(ValueSet vs) { - int count = 0; - if (vs.hasExpansion()) - count = count + conceptCount(vs.getExpansion().getContains()); - else { - if (vs.hasCompose()) { - if (vs.getCompose().hasExclude()) { - try { - ValueSetExpansionOutcome vse = context.expandVS(vs, true, false); - count = 0; - count += conceptCount(vse.getValueset().getExpansion().getContains()); - return count; - } catch (Exception e) { - return null; - } - } - for (ConceptSetComponent inc : vs.getCompose().getInclude()) { - if (inc.hasFilter()) - return null; - if (!inc.hasConcept()) - return null; - count = count + inc.getConcept().size(); - } - } - } - return count; - } - private int conceptCount(List list) { - int count = 0; - for (ValueSetExpansionContainsComponent c : list) { - if (!c.getAbstract()) - count++; - count = count + conceptCount(c.getContains()); - } - return count; - } + // private void scanLangs(ConceptDefinitionComponent c, List langs) { + // for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) { + // if (designation.hasLanguage()) { + // String lang = designation.getLanguage(); + // if (langs != null && !langs.contains(lang) && c.hasDisplay() && !c.getDisplay().equalsIgnoreCase(designation.getValue())) + // langs.add(lang); + // } + // } + // for (ConceptDefinitionComponent g : c.getConcept()) + // scanLangs(g, langs); + // } - private boolean generateExpansion(XhtmlNode x, ValueSet vs, ValueSet src, boolean header, List maps) throws FHIRFormatError, DefinitionException, IOException { - boolean hasExtensions = false; - List langs = new ArrayList(); - if (header) { - XhtmlNode h = x.addTag(getHeader()); - h.tx("Value Set Contents"); - if (IsNotFixedExpansion(vs)) - addMarkdown(x, vs.getDescription()); - if (vs.hasCopyright()) - generateCopyright(x, vs); - } - if (ToolingExtensions.hasExtension(vs.getExpansion(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly")) { - List exl = vs.getExpansion().getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/valueset-toocostly"); - boolean other = false; - for (Extension ex : exl) { - if (ex.getValue() instanceof BooleanType) { - x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? tooCostlyNoteEmpty : tooCostlyNoteNotEmpty ); - } else if (!other) { - x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? tooCostlyNoteEmptyDependent : tooCostlyNoteNotEmptyDependent ); - other = true; - } - } - } else { - Integer count = countMembership(vs); - if (count == null) - x.para().tx("This value set does not contain a fixed number of concepts"); - else - x.para().tx("This value set contains "+count.toString()+" concepts"); - } - generateVersionNotice(x, vs.getExpansion()); - - CodeSystem allCS = null; - boolean doLevel = false; - for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { - if (cc.hasContains()) { - doLevel = true; - break; - } - } - - boolean doSystem = true; // checkDoSystem(vs, src); - boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains()); - if (doSystem && allFromOneSystem(vs)) { - doSystem = false; - XhtmlNode p = x.para(); - p.tx("All codes from system "); - allCS = context.fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem()); - String ref = null; - if (allCS != null) - ref = getCsRef(allCS); - if (ref == null) - p.code(vs.getExpansion().getContains().get(0).getSystem()); - else - p.ah(prefix+ref).code(vs.getExpansion().getContains().get(0).getSystem()); - } - XhtmlNode t = x.table( "codes"); - XhtmlNode tr = t.tr(); - if (doLevel) - tr.td().b().tx("Lvl"); - tr.td().attribute("style", "white-space:nowrap").b().tx("Code"); - if (doSystem) - tr.td().b().tx("System"); - tr.td().b().tx("Display"); - if (doDefinition) - tr.td().b().tx("Definition"); - - addMapHeaders(tr, maps); - for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { - addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs); - } - - // now, build observed languages - - if (langs.size() > 0) { - Collections.sort(langs); - x.para().b().tx("Additional Language Displays"); - t = x.table( "codes"); - tr = t.tr(); - tr.td().b().tx("Code"); - for (String lang : langs) - tr.td().b().addText(describeLang(lang)); - for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { - addLanguageRow(c, t, langs); - } - } - - return hasExtensions; - } - - @SuppressWarnings("rawtypes") - private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) { - Map versions = new HashMap(); - for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { - if (p.getName().equals("version")) { - String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|"); - if (parts.length == 2) - versions.put(parts[0], parts[1]); - } - } - if (versions.size() > 1) { - XhtmlNode div = x.div().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px"); - div.para().tx("Expansion based on: "); - XhtmlNode ul = div.ul(); - for (String s : versions.keySet()) { // though there'll only be one - expRef(ul.li(), s, versions.get(s)); - } - } else if (versions.size() == 1) { - XhtmlNode p = x.para().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px"); - p.tx("Expansion based on "); - for (String s : versions.keySet()) { // though there'll only be one - expRef(p, s, versions.get(s)); - } - } - } - - private void expRef(XhtmlNode x, String u, String v) { - // TODO Auto-generated method stub - if (u.equals("http://snomed.info/sct")) { - String[] parts = v.split("\\/"); - if (parts.length >= 5) { - String m = describeModule(parts[4]); - if (parts.length == 7) { - x.tx("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); - } else { - x.tx("SNOMED CT "+m+" edition"); - } - } else { - x.tx(describeSystem(u)+" version "+v); - } - } else if (u.equals("http://loinc.org")) { - String vd = describeLoincVer(v); - if (vd != null) { - x.tx("Loinc v"+v+" ("+vd+")"); - } else { - x.tx("Loinc v"+v); - } - } else { - CanonicalResource cr = (CanonicalResource) context.fetchResource(Resource.class, u+"|"+v); - if (cr != null) { - if (cr.hasUserData("path")) { - x.ah(cr.getUserString("path")).tx(cr.present()+" v"+v+" ("+cr.fhirType()+")"); - } else { - x.tx(describeSystem(u)+" v"+v+" ("+cr.fhirType()+")"); - } - } else { - x.tx(describeSystem(u)+" version "+v); - } - } - } - - private String describeLoincVer(String v) { - if ("2.67".equals(v)) return "Dec 2019"; - if ("2.66".equals(v)) return "Jun 2019"; - if ("2.65".equals(v)) return "Dec 2018"; - if ("2.64".equals(v)) return "Jun 2018"; - if ("2.63".equals(v)) return "Dec 2017"; - if ("2.61".equals(v)) return "Jun 2017"; - if ("2.59".equals(v)) return "Feb 2017"; - if ("2.58".equals(v)) return "Dec 2016"; - if ("2.56".equals(v)) return "Jun 2016"; - if ("2.54".equals(v)) return "Dec 2015"; - if ("2.52".equals(v)) return "Jun 2015"; - if ("2.50".equals(v)) return "Dec 2014"; - if ("2.48".equals(v)) return "Jun 2014"; - if ("2.46".equals(v)) return "Dec 2013"; - if ("2.44".equals(v)) return "Jun 2013"; - if ("2.42".equals(v)) return "Dec 2012"; - if ("2.40".equals(v)) return "Jun 2012"; - if ("2.38".equals(v)) return "Dec 2011"; - if ("2.36".equals(v)) return "Jun 2011"; - if ("2.34".equals(v)) return "Dec 2010"; - if ("2.32".equals(v)) return "Jun 2010"; - if ("2.30".equals(v)) return "Feb 2010"; - if ("2.29".equals(v)) return "Dec 2009"; - if ("2.27".equals(v)) return "Jul 2009"; - if ("2.26".equals(v)) return "Jan 2009"; - if ("2.24".equals(v)) return "Jul 2008"; - if ("2.22".equals(v)) return "Dec 2007"; - if ("2.21".equals(v)) return "Jun 2007"; - if ("2.19".equals(v)) return "Dec 2006"; - if ("2.17".equals(v)) return "Jun 2006"; - if ("2.16".equals(v)) return "Dec 2005"; - if ("2.15".equals(v)) return "Jun 2005"; - if ("2.14".equals(v)) return "Dec 2004"; - if ("2.13".equals(v)) return "Aug 2004"; - if ("2.12".equals(v)) return "Feb 2004"; - if ("2.10".equals(v)) return "Oct 2003"; - if ("2.09".equals(v)) return "May 2003"; - if ("2.08 ".equals(v)) return "Sep 2002"; - if ("2.07".equals(v)) return "Aug 2002"; - if ("2.05".equals(v)) return "Feb 2002"; - if ("2.04".equals(v)) return "Jan 2002"; - if ("2.03".equals(v)) return "Jul 2001"; - if ("2.02".equals(v)) return "May 2001"; - if ("2.01".equals(v)) return "Jan 2001"; - if ("2.00".equals(v)) return "Jan 2001"; - if ("1.0n".equals(v)) return "Feb 2000"; - if ("1.0ma".equals(v)) return "Aug 1999"; - if ("1.0m".equals(v)) return "Jul 1999"; - if ("1.0l".equals(v)) return "Jan 1998"; - if ("1.0ja".equals(v)) return "Oct 1997"; - - return null; - } - - private String formatSCTDate(String ds) { - SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); - Date date; - try { - date = format.parse(ds); - } catch (ParseException e) { - return ds; - } - return new SimpleDateFormat("dd-MMM yyyy").format(date); - } - - private String describeModule(String module) { - if ("900000000000207008".equals(module)) - return "International"; - if ("731000124108".equals(module)) - return "United States"; - if ("32506021000036107".equals(module)) - return "Australian"; - if ("449081005".equals(module)) - return "Spanish"; - if ("554471000005108".equals(module)) - return "Danish"; - if ("11000146104".equals(module)) - return "Dutch"; - if ("45991000052106".equals(module)) - return "Swedish"; - if ("999000041000000102".equals(module)) - return "United Kingdon"; - return module; - } - - private boolean hasVersionParameter(ValueSetExpansionComponent expansion) { - for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { - if (p.getName().equals("version")) - return true; - } - return false; - } - - private void addLanguageRow(ValueSetExpansionContainsComponent c, XhtmlNode t, List langs) { - XhtmlNode tr = t.tr(); - tr.td().addText(c.getCode()); - for (String lang : langs) { - String d = null; - for (Extension ext : c.getExtension()) { - if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) { - String l = ToolingExtensions.readStringExtension(ext, "lang"); - if (lang.equals(l)) - d = ToolingExtensions.readStringExtension(ext, "content"); - } - } - tr.td().addText(d == null ? "" : d); - } - for (ValueSetExpansionContainsComponent cc : c.getContains()) { - addLanguageRow(cc, t, langs); - } - } - - - private String describeLang(String lang) { - ValueSet v = context.fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages"); - if (v != null) { - ConceptReferenceComponent l = null; - for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) { - if (cc.getCode().equals(lang)) - l = cc; - } - if (l == null) { - if (lang.contains("-")) - lang = lang.substring(0, lang.indexOf("-")); - for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) { - if (cc.getCode().equals(lang) || cc.getCode().startsWith(lang+"-")) - l = cc; - } - } - if (l != null) { - if (lang.contains("-")) - lang = lang.substring(0, lang.indexOf("-")); - String en = l.getDisplay(); - String nativelang = null; - for (ConceptReferenceDesignationComponent cd : l.getDesignation()) { - if (cd.getLanguage().equals(lang)) - nativelang = cd.getValue(); - } - if (nativelang == null) - return en+" ("+lang+")"; - else - return nativelang+" ("+en+", "+lang+")"; - } - } - return lang; - } - - - private boolean checkDoDefinition(List contains) { - for (ValueSetExpansionContainsComponent c : contains) { - CodeSystem cs = context.fetchCodeSystem(c.getSystem()); - if (cs != null) - return true; - if (checkDoDefinition(c.getContains())) - return true; - } - return false; - } - - - private boolean allFromOneSystem(ValueSet vs) { - if (vs.getExpansion().getContains().isEmpty()) - return false; - String system = vs.getExpansion().getContains().get(0).getSystem(); - for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { - if (!checkSystemMatches(system, cc)) - return false; - } - return true; - } - - - private boolean checkSystemMatches(String system, ValueSetExpansionContainsComponent cc) { - if (!system.equals(cc.getSystem())) - return false; - for (ValueSetExpansionContainsComponent cc1 : cc.getContains()) { - if (!checkSystemMatches(system, cc1)) - return false; - } - return true; - } - - - private boolean checkDoSystem(ValueSet vs, ValueSet src) { - if (src != null) - vs = src; - return vs.hasCompose(); - } - - private boolean IsNotFixedExpansion(ValueSet vs) { - if (vs.hasCompose()) - return false; - - - // it's not fixed if it has any includes that are not version fixed - for (ConceptSetComponent cc : vs.getCompose().getInclude()) { - if (cc.hasValueSet()) - return true; - if (!cc.hasVersion()) - return true; - } - return false; - } - - - private void addLanguageRow(ConceptDefinitionComponent c, XhtmlNode t, List langs) { - XhtmlNode tr = t.tr(); - tr.td().addText(c.getCode()); - for (String lang : langs) { - ConceptDefinitionDesignationComponent d = null; - for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) { - if (designation.hasLanguage()) { - if (lang.equals(designation.getLanguage())) - d = designation; - } - } - tr.td().addText(d == null ? "" : d.getValue()); - } - } - -// private void scanLangs(ConceptDefinitionComponent c, List langs) { -// for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) { -// if (designation.hasLanguage()) { -// String lang = designation.getLanguage(); -// if (langs != null && !langs.contains(lang) && c.hasDisplay() && !c.getDisplay().equalsIgnoreCase(designation.getValue())) -// langs.add(lang); -// } -// } -// for (ConceptDefinitionComponent g : c.getConcept()) -// scanLangs(g, langs); -// } - - private void addMapHeaders(XhtmlNode tr, List maps) throws FHIRFormatError, DefinitionException, IOException { - for (UsedConceptMap m : maps) { - XhtmlNode td = tr.td(); - XhtmlNode b = td.b(); - XhtmlNode a = b.ah(prefix+m.getLink()); - a.addText(m.getDetails().getName()); - if (m.getDetails().isDoDescription() && m.getMap().hasDescription()) - addMarkdown(td, m.getMap().getDescription()); - } - } - - private void smartAddText(XhtmlNode p, String text) { - if (text == null) - return; - - String[] lines = text.split("\\r\\n"); - for (int i = 0; i < lines.length; i++) { - if (i > 0) - p.br(); - p.addText(lines[i]); - } - } - - private boolean conceptsHaveComments(ConceptDefinitionComponent c) { - if (ToolingExtensions.hasCSComment(c)) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) - if (conceptsHaveComments(g)) - return true; - return false; - } - - private boolean conceptsHaveDisplay(ConceptDefinitionComponent c) { - if (c.hasDisplay()) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) - if (conceptsHaveDisplay(g)) - return true; - return false; - } - - private boolean conceptsHaveVersion(ConceptDefinitionComponent c) { - if (c.hasUserData("cs.version.notes")) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) - if (conceptsHaveVersion(g)) - return true; - return false; - } - - private boolean conceptsHaveDeprecated(CodeSystem cs, ConceptDefinitionComponent c) { - if (CodeSystemUtilities.isDeprecated(cs, c)) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) - if (conceptsHaveDeprecated(cs, g)) - return true; - return false; - } - - private void generateCopyright(XhtmlNode x, ValueSet vs) throws FHIRFormatError, DefinitionException, IOException { - XhtmlNode p = x.para(); - p.b().tx("Copyright Statement:"); - addMarkdown(x, vs.getCopyright()); - } - - private XhtmlNode addTableHeaderRowStandard(XhtmlNode t, boolean hasHierarchy, boolean hasDisplay, boolean definitions, boolean comments, boolean version, boolean deprecated, String lang, List properties) { - XhtmlNode tr = t.tr(); - if (hasHierarchy) - tr.td().b().tx("Lvl"); - tr.td().attribute("style", "white-space:nowrap").b().tx(context.translator().translate("xhtml-gen-cs", "Code", lang)); - if (hasDisplay) - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Display", lang)); - if (definitions) - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Definition", lang)); - if (deprecated) - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Deprecated", lang)); - if (comments) - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Comments", lang)); - if (version) - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Version", lang)); - if (properties != null) { - for (PropertyComponent pc : properties) { - String display = ToolingExtensions.getPresentation(pc, pc.getCodeElement()); - if (display == null || display.equals(pc.getCode()) && pc.hasUri()) { - display = getDisplayForProperty(pc.getUri()); - if (display == null) { - display = pc.getCode(); - } - } - tr.td().b().tx(context.translator().translate("xhtml-gen-cs", display, lang)); - } - } - return tr; - } - - private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doLevel, boolean doSystem, boolean doDefinition, List maps, CodeSystem allCS, List langs) { - XhtmlNode tr = t.tr(); - XhtmlNode td = tr.td(); - - String tgt = makeAnchor(c.getSystem(), c.getCode()); - td.an(tgt); - - if (doLevel) { - td.addText(Integer.toString(i)); - td = tr.td(); - } - String s = Utilities.padLeft("", '\u00A0', i*2); - td.attribute("style", "white-space:nowrap").addText(s); - addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td); - if (doSystem) { - td = tr.td(); - td.addText(c.getSystem()); - } - td = tr.td(); - if (c.hasDisplayElement()) - td.addText(c.getDisplay()); - - if (doDefinition) { - CodeSystem cs = allCS; - if (cs == null) - cs = context.fetchCodeSystem(c.getSystem()); - td = tr.td(); - if (cs != null) - td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode())); - } - for (UsedConceptMap m : maps) { - td = tr.td(); - List mappings = findMappingsForCode(c.getCode(), m.getMap()); - boolean first = true; - for (TargetElementComponentWrapper mapping : mappings) { - if (!first) - td.br(); - first = false; - XhtmlNode span = td.span(null, mapping.comp.getRelationship().toString()); - span.addText(getCharForRelationship(mapping.comp)); - addRefToCode(td, mapping.group.getTarget(), m.getLink(), mapping.comp.getCode()); - if (!Utilities.noString(mapping.comp.getComment())) - td.i().tx("("+mapping.comp.getComment()+")"); - } - } - for (Extension ext : c.getExtension()) { - if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) { - String lang = ToolingExtensions.readStringExtension(ext, "lang"); - if (!Utilities.noString(lang) && !langs.contains(lang)) - langs.add(lang); - } - } - for (ValueSetExpansionContainsComponent cc : c.getContains()) { - addExpansionRowToTable(t, cc, i+1, doLevel, doSystem, doDefinition, maps, allCS, langs); - } - } - - private void addCodeToTable(boolean isAbstract, String system, String code, String display, XhtmlNode td) { - CodeSystem e = context.fetchCodeSystem(system); - if (e == null || e.getContent() != org.hl7.fhir.r5.model.CodeSystem.CodeSystemContentMode.COMPLETE) { - if (isAbstract) - td.i().setAttribute("title", ABSTRACT_CODE_HINT).addText(code); - else if ("http://snomed.info/sct".equals(system)) { - td.ah(sctLink(code)).addText(code); - } else if ("http://loinc.org".equals(system)) { - td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); - } else - td.addText(code); - } else { - String href = prefix+getCsRef(e); - if (href.contains("#")) - href = href + "-"+Utilities.nmtokenize(code); - else - href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(code); - if (isAbstract) - td.ah(href).setAttribute("title", ABSTRACT_CODE_HINT).i().addText(code); - else - td.ah(href).addText(code); - } - } - - public String sctLink(String code) { -// if (snomedEdition != null) -// http://browser.ihtsdotools.org/?perspective=full&conceptId1=428041000124106&edition=us-edition&release=v20180301&server=https://prod-browser-exten.ihtsdotools.org/api/snomed&langRefset=900000000000509007 - return "http://browser.ihtsdotools.org/?perspective=full&conceptId1="+code; - } - - private class TargetElementComponentWrapper { - private ConceptMapGroupComponent group; - private TargetElementComponent comp; - public TargetElementComponentWrapper(ConceptMapGroupComponent group, TargetElementComponent comp) { - super(); - this.group = group; - this.comp = comp; - } - - } - - private String langDisplay(String l, boolean isShort) { - ValueSet vs = context.fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages"); - for (ConceptReferenceComponent vc : vs.getCompose().getInclude().get(0).getConcept()) { - if (vc.getCode().equals(l)) { - for (ConceptReferenceDesignationComponent cd : vc.getDesignation()) { - if (cd.getLanguage().equals(l)) - return cd.getValue()+(isShort ? "" : " ("+vc.getDisplay()+")"); - } - return vc.getDisplay(); - } - } - return "??Lang"; - } - - private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean comment, boolean version, boolean deprecated, List maps, String system, CodeSystem cs, String lang, List properties, CodeSystemNavigator csNav) throws FHIRFormatError, DefinitionException, IOException { - boolean hasExtensions = false; - XhtmlNode tr = t.tr(); - XhtmlNode td = tr.td(); - if (hasHierarchy) { - td.addText(Integer.toString(level+1)); - td = tr.td(); - String s = Utilities.padLeft("", '\u00A0', level*2); - td.addText(s); - } - td.attribute("style", "white-space:nowrap").addText(c.getCode()); - XhtmlNode a; - if (c.hasCodeElement()) { - td.an(cs.getId()+"-" + Utilities.nmtokenize(c.getCode())); - } - - if (hasDisplay) { - td = tr.td(); - renderDisplayName(c, cs, lang, td); - } - td = tr.td(); - if (c != null && - c.hasDefinitionElement()) { - if (lang == null) { - if (hasMarkdownInDefinitions(cs)) - addMarkdown(td, c.getDefinition()); - else - td.addText(c.getDefinition()); - } else if (lang.equals("*")) { - boolean sl = false; - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) - sl = true; - td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDefinition()); - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) { - td.br(); - td.addText(cd.getLanguage()+": "+cd.getValue()); - } - } - } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { - td.addText(c.getDefinition()); - } else { - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(lang)) { - td.addText(cd.getValue()); - } - } - } - } - if (deprecated) { - td = tr.td(); - Boolean b = CodeSystemUtilities.isDeprecated(cs, c); - if (b != null && b) { - smartAddText(td, context.translator().translate("xhtml-gen-cs", "Deprecated", lang)); - hasExtensions = true; - if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) { - Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue(); - td.tx(" (replaced by "); - String url = getCodingReference(cc, system); - if (url != null) { - td.ah(url).addText(cc.getCode()); - td.tx(": "+cc.getDisplay()+")"); - } else - td.addText(cc.getCode()+" '"+cc.getDisplay()+"' in "+cc.getSystem()+")"); - } - } - } - if (comment) { - td = tr.td(); - Extension ext = c.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT); - if (ext != null) { - hasExtensions = true; - String bc = ext.hasValue() ? ext.getValue().primitiveValue() : null; - Map translations = ToolingExtensions.getLanguageTranslations(ext.getValue()); - - if (lang == null) { - if (bc != null) - td.addText(bc); - } else if (lang.equals("*")) { - boolean sl = false; - for (String l : translations.keySet()) - if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) - sl = true; - if (bc != null) { - td.addText((sl ? cs.getLanguage("en")+": " : "")+bc); - } - for (String l : translations.keySet()) { - if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) { - if (!td.getChildNodes().isEmpty()) - td.br(); - td.addText(l+": "+translations.get(l)); - } - } - } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { - if (bc != null) - td.addText(bc); - } else { - if (bc != null) - translations.put(cs.getLanguage("en"), bc); - for (String l : translations.keySet()) { - if (l.equals(lang)) { - td.addText(translations.get(l)); - } - } - } - } - } - if (version) { - td = tr.td(); - if (c.hasUserData("cs.version.notes")) - td.addText(c.getUserString("cs.version.notes")); - } - if (properties != null) { - for (PropertyComponent pc : properties) { - td = tr.td(); - boolean first = true; - ConceptPropertyComponent pcv = CodeSystemUtilities.getProperty(c, pc.getCode()); - if (pcv != null && pcv.hasValue()) { - if (first) first = false; else td.addText(", "); - if (pcv.hasValueCoding()) { - td.addText(pcv.getValueCoding().getCode()); - } else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrl(pcv.getValue().primitiveValue())) { - td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue()); - } else { - td.addText(pcv.getValue().primitiveValue()); - } - } - } - } - - for (UsedConceptMap m : maps) { - td = tr.td(); - List mappings = findMappingsForCode(c.getCode(), m.getMap()); - boolean first = true; - for (TargetElementComponentWrapper mapping : mappings) { - if (!first) - td.br(); - first = false; - XhtmlNode span = td.span(null, mapping.comp.hasRelationship() ? mapping.comp.getRelationship().toCode() : ""); - span.addText(getCharForRelationship(mapping.comp)); - a = td.ah(prefix+m.getLink()+"#"+makeAnchor(mapping.group.getTarget(), mapping.comp.getCode())); - a.addText(mapping.comp.getCode()); - if (!Utilities.noString(mapping.comp.getComment())) - td.i().tx("("+mapping.comp.getComment()+")"); - } - } - List ocl = csNav.getOtherChildren(c); - for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) { - hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, comment, version, deprecated, maps, system, cs, lang, properties, csNav) || hasExtensions; - } - for (ConceptDefinitionComponent cc : ocl) { - tr = t.tr(); - td = tr.td(); - td.addText(Integer.toString(level+2)); - td = tr.td(); - String s = Utilities.padLeft("", '\u00A0', (level+1)*2); - td.addText(s); - td.attribute("style", "white-space:nowrap"); - a = td.ah("#"+cs.getId()+"-" + Utilities.nmtokenize(cc.getCode())); - a.addText(cc.getCode()); - if (hasDisplay) { - td = tr.td(); - renderDisplayName(cc, cs, lang, td); - } - int w = 1 + (deprecated ? 1 : 0) + (comment ? 1 : 0) + (version ? 1 : 0) + maps.size(); - if (properties != null) { - w = w + properties.size(); - } - td = tr.td().colspan(Integer.toString(w)); - } - return hasExtensions; - } - - public void renderDisplayName(ConceptDefinitionComponent c, CodeSystem cs, String lang, XhtmlNode td) { - if (c.hasDisplayElement()) { - if (lang == null) { - td.addText(c.getDisplay()); - } else if (lang.equals("*")) { - boolean sl = false; - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && !c.getDisplay().equalsIgnoreCase(cd.getValue())) - sl = true; - td.addText((sl ? cs.getLanguage("en")+": " : "")+c.getDisplay()); - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && !c.getDisplay().equalsIgnoreCase(cd.getValue())) { - td.br(); - td.addText(cd.getLanguage()+": "+cd.getValue()); - } - } - } else if (lang.equals(cs.getLanguage()) || (lang.equals("en") && !cs.hasLanguage())) { - td.addText(c.getDisplay()); - } else { - for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) { - if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "display") && cd.hasLanguage() && cd.getLanguage().equals(lang)) { - td.addText(cd.getValue()); - } - } - } - } - } - - - private boolean hasMarkdownInDefinitions(CodeSystem cs) { - return ToolingExtensions.readBoolExtension(cs, "http://hl7.org/fhir/StructureDefinition/codesystem-use-markdown"); - } - - private String makeAnchor(String codeSystem, String code) { - String s = codeSystem+'-'+code; - StringBuilder b = new StringBuilder(); - for (char c : s.toCharArray()) { - if (Character.isAlphabetic(c) || Character.isDigit(c) || c == '.') - b.append(c); - else - b.append('-'); - } - return b.toString(); - } - - private String getCodingReference(Coding cc, String system) { - if (cc.getSystem().equals(system)) - return "#"+cc.getCode(); - if (cc.getSystem().equals("http://snomed.info/sct")) - return "http://snomed.info/sct/"+cc.getCode(); - if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; - return null; - } - - private String getCharForRelationship(TargetElementComponent mapping) { - if (!mapping.hasRelationship()) - return ""; - switch (mapping.getRelationship()) { - case EQUIVALENT : return "~"; - case BROADER : return "<"; - case NARROWER : return ">"; - case NOTRELATEDTO : return "!="; - default: return "?"; - } - } - - private List findMappingsForCode(String code, ConceptMap map) { - List mappings = new ArrayList(); - - for (ConceptMapGroupComponent g : map.getGroup()) { - for (SourceElementComponent c : g.getElement()) { - if (c.getCode().equals(code)) - for (TargetElementComponent cc : c.getTarget()) - mappings.add(new TargetElementComponentWrapper(g, cc)); - } - } - return mappings; - } - - private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header, List maps) throws FHIRException, IOException { - boolean hasExtensions = false; - List langs = new ArrayList(); - - if (header) { - XhtmlNode h = x.h2(); - h.addText(vs.present()); - addMarkdown(x, vs.getDescription()); - if (vs.hasCopyrightElement()) - generateCopyright(x, vs); - } - XhtmlNode ul = x.ul(); - if (vs.getCompose().getInclude().size() == 1 && vs.getCompose().getExclude().size() == 0) { - hasExtensions = genInclude(rcontext, ul, vs.getCompose().getInclude().get(0), "Include", langs, maps) || hasExtensions; - } else { - XhtmlNode p = x.para(); - p.tx("This value set includes codes based on the following rules:"); - - XhtmlNode li; - for (ConceptSetComponent inc : vs.getCompose().getInclude()) { - hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions; - } - for (ConceptSetComponent exc : vs.getCompose().getExclude()) { - hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions; - } - } - - // now, build observed languages - - if (langs.size() > 0) { - Collections.sort(langs); - x.para().b().tx("Additional Language Displays"); - XhtmlNode t = x.table( "codes"); - XhtmlNode tr = t.tr(); - tr.td().b().tx("Code"); - for (String lang : langs) - tr.td().b().addText(describeLang(lang)); - for (ConceptSetComponent c : vs.getCompose().getInclude()) { - for (ConceptReferenceComponent cc : c.getConcept()) { - addLanguageRow(cc, t, langs); - } - } - } - - return hasExtensions; - } - - private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List langs) { - XhtmlNode tr = t.tr(); - tr.td().addText(c.getCode()); - for (String lang : langs) { - String d = null; - for (ConceptReferenceDesignationComponent cd : c.getDesignation()) { - String l = cd.getLanguage(); - if (lang.equals(l)) - d = cd.getValue(); - } - tr.td().addText(d == null ? "" : d); - } - } - - private void AddVsRef(ResourceContext rcontext, String value, XhtmlNode li) { - Resource res = null; - if (rcontext != null) { - BundleEntryComponent be = rcontext.resolve(value); - if (be != null) { - res = be.getResource(); - } - } - if (res != null && !(res instanceof CanonicalResource)) { - li.addText(value); - return; - } - CanonicalResource vs = (CanonicalResource) res; - if (vs == null) - vs = context.fetchResource(ValueSet.class, value); - if (vs == null) - vs = context.fetchResource(StructureDefinition.class, value); -// if (vs == null) - // vs = context.fetchResource(DataElement.class, value); - if (vs == null) - vs = context.fetchResource(Questionnaire.class, value); - if (vs != null) { - String ref = (String) vs.getUserData("path"); - - ref = adjustForPath(ref); - XhtmlNode a = li.ah(ref == null ? "??" : ref.replace("\\", "/")); - a.addText(value); - } else { - CodeSystem cs = context.fetchCodeSystem(value); - if (cs != null) { - String ref = (String) cs.getUserData("path"); - ref = adjustForPath(ref); - XhtmlNode a = li.ah(ref == null ? "??" : ref.replace("\\", "/")); - a.addText(value); - } else if (value.equals("http://snomed.info/sct") || value.equals("http://snomed.info/id")) { - XhtmlNode a = li.ah(value); - a.tx("SNOMED-CT"); - } - else { - if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us")) - System.out.println("Unable to resolve value set "+value); - li.addText(value); - } - } - } - - private String adjustForPath(String ref) { - if (prefix == null) - return ref; - else - return prefix+ref; - } - - private boolean genInclude(ResourceContext rcontext, XhtmlNode ul, ConceptSetComponent inc, String type, List langs, List maps) throws FHIRException, IOException { - boolean hasExtensions = false; - XhtmlNode li; - li = ul.li(); - CodeSystem e = context.fetchCodeSystem(inc.getSystem()); - - if (inc.hasSystem()) { - if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) { - li.addText(type+" all codes defined in "); - addCsRef(inc, li, e); - } else { - if (inc.getConcept().size() > 0) { - li.addText(type+" these codes as defined in "); - addCsRef(inc, li, e); - if (inc.hasVersion()) { - li.addText(" version "); - li.code(inc.getVersion()); - } - - XhtmlNode t = li.table("none"); - boolean hasComments = false; - boolean hasDefinition = false; - for (ConceptReferenceComponent c : inc.getConcept()) { - hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT); - hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION); - } - if (hasComments || hasDefinition) - hasExtensions = true; - addMapHeaders(addTableHeaderRowStandard(t, false, true, hasDefinition, hasComments, false, false, null, null), maps); - for (ConceptReferenceComponent c : inc.getConcept()) { - XhtmlNode tr = t.tr(); - XhtmlNode td = tr.td(); - ConceptDefinitionComponent cc = getConceptForCode(e, c.getCode(), inc); - addCodeToTable(false, inc.getSystem(), c.getCode(), c.hasDisplay()? c.getDisplay() : cc != null ? cc.getDisplay() : "", td); - - td = tr.td(); - if (!Utilities.noString(c.getDisplay())) - td.addText(c.getDisplay()); - else if (cc != null && !Utilities.noString(cc.getDisplay())) - td.addText(cc.getDisplay()); - - td = tr.td(); - if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION)) - smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION)); - else if (cc != null && !Utilities.noString(cc.getDefinition())) - smartAddText(td, cc.getDefinition()); - - if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) { - smartAddText(tr.td(), "Note: "+ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT)); - } - for (ConceptReferenceDesignationComponent cd : c.getDesignation()) { - if (cd.hasLanguage() && !langs.contains(cd.getLanguage())) - langs.add(cd.getLanguage()); - } - } - } - if (inc.getFilter().size() > 0) { - li.addText(type+" codes from "); - addCsRef(inc, li, e); - li.tx(" where "); - for (int i = 0; i < inc.getFilter().size(); i++) { - ConceptSetFilterComponent f = inc.getFilter().get(i); - if (i > 0) { - if (i == inc.getFilter().size()-1) { - li.tx(" and "); - } else { - li.tx(", "); - } - } - if (f.getOp() == FilterOperator.EXISTS) { - if (f.getValue().equals("true")) { - li.tx(f.getProperty()+" exists"); - } else { - li.tx(f.getProperty()+" doesn't exist"); - } - } else { - li.tx(f.getProperty()+" "+describe(f.getOp())+" "); - if (e != null && codeExistsInValueSet(e, f.getValue())) { - String href = prefix+getCsRef(e); - if (href.contains("#")) - href = href + "-"+Utilities.nmtokenize(f.getValue()); - else - href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(f.getValue()); - li.ah(href).addText(f.getValue()); - } else if ("concept".equals(f.getProperty()) && inc.hasSystem()) { - li.addText(f.getValue()); - ValidationResult vr = context.validateCode(terminologyServiceOptions, inc.getSystem(), f.getValue(), null); - if (vr.isOk()) { - li.tx(" ("+vr.getDisplay()+")"); - } - } - else - li.addText(f.getValue()); - String disp = ToolingExtensions.getDisplayHint(f); - if (disp != null) - li.tx(" ("+disp+")"); - } - } - } - } - if (inc.hasValueSet()) { - li.tx(", where the codes are contained in "); - boolean first = true; - for (UriType vs : inc.getValueSet()) { - if (first) - first = false; - else - li.tx(", "); - AddVsRef(rcontext, vs.asStringValue(), li); - } - } - } else { - li.tx("Import all the codes that are contained in "); - boolean first = true; - for (UriType vs : inc.getValueSet()) { - if (first) - first = false; - else - li.tx(", "); - AddVsRef(rcontext, vs.asStringValue(), li); - } - } - return hasExtensions; - } - - private String describe(FilterOperator op) { - if (op == null) - return " null "; - switch (op) { - case EQUAL: return " = "; - case ISA: return " is-a "; - case ISNOTA: return " is-not-a "; - case REGEX: return " matches (by regex) "; - case NULL: return " ?? "; - case IN: return " in "; - case NOTIN: return " not in "; - case DESCENDENTOF: return " descends from "; - case EXISTS: return " exists "; - case GENERALIZES: return " generalizes "; - } - return null; - } - - private ConceptDefinitionComponent getConceptForCode(CodeSystem e, String code, ConceptSetComponent inc) { - if (code == null) { - return null; - } - // first, look in the code systems - if (e == null) - e = context.fetchCodeSystem(inc.getSystem()); - if (e != null) { - ConceptDefinitionComponent v = getConceptForCode(e.getConcept(), code); - if (v != null) - return v; - } - - if (noSlowLookup) - return null; - - if (!context.hasCache()) { - ValueSetExpansionComponent vse; - try { - ValueSetExpansionOutcome vso = context.expandVS(inc, false); - ValueSet valueset = vso.getValueset(); - if (valueset == null) - throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError()); - vse = valueset.getExpansion(); - - } catch (TerminologyServiceException e1) { - return null; - } - if (vse != null) { - ConceptDefinitionComponent v = getConceptForCodeFromExpansion(vse.getContains(), code); - if (v != null) - return v; - } - } - - return context.validateCode(terminologyServiceOptions, inc.getSystem(), code, null).asConceptDefinition(); - } - - - - private ConceptDefinitionComponent getConceptForCode(List list, String code) { - for (ConceptDefinitionComponent c : list) { - if (code.equals(c.getCode())) - return c; - ConceptDefinitionComponent v = getConceptForCode(c.getConcept(), code); - if (v != null) - return v; - } - return null; - } - - private ConceptDefinitionComponent getConceptForCodeFromExpansion(List list, String code) { - for (ValueSetExpansionContainsComponent c : list) { - if (code.equals(c.getCode())) { - ConceptDefinitionComponent res = new ConceptDefinitionComponent(); - res.setCode(c.getCode()); - res.setDisplay(c.getDisplay()); - return res; - } - ConceptDefinitionComponent v = getConceptForCodeFromExpansion(c.getContains(), code); - if (v != null) - return v; - } - return null; - } - - private void addRefToCode(XhtmlNode td, String target, String vslink, String code) { - CodeSystem cs = context.fetchCodeSystem(target); - String cslink = getCsRef(cs); - XhtmlNode a = null; - if (cslink != null) - a = td.ah(prefix+cslink+"#"+cs.getId()+"-"+code); - else - a = td.ah(prefix+vslink+"#"+code); - a.addText(code); - } - - private void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) { - String ref = null; - boolean addHtml = true; - if (cs != null) { - ref = (String) cs.getUserData("external.url"); - if (Utilities.noString(ref)) - ref = (String) cs.getUserData("filename"); - else - addHtml = false; - if (Utilities.noString(ref)) - ref = (String) cs.getUserData("path"); - } - String spec = getSpecialReference(inc.getSystem()); - if (spec != null) { - XhtmlNode a = li.ah(spec); - a.code(inc.getSystem()); - } else if (cs != null && ref != null) { - if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/")) - ref = ref.substring(20)+"/index.html"; - else if (addHtml && !ref.contains(".html")) - ref = ref + ".html"; - XhtmlNode a = li.ah(prefix+ref.replace("\\", "/")); - a.code(inc.getSystem()); - } else { - li.code(inc.getSystem()); - } - } - - private String getSpecialReference(String system) { - if ("http://snomed.info/sct".equals(system)) - return "http://www.snomed.org/"; - if (Utilities.existsInList(system, "http://loinc.org", "http://unitsofmeasure.org", "http://www.nlm.nih.gov/research/umls/rxnorm", "http://ncimeta.nci.nih.gov", "http://fdasis.nlm.nih.gov", - "http://www.radlex.org", "http://www.whocc.no/atc", "http://dicom.nema.org/resources/ontology/DCM", "http://www.genenames.org", "http://www.ensembl.org", "http://www.ncbi.nlm.nih.gov/nuccore", - "http://www.ncbi.nlm.nih.gov/clinvar", "http://sequenceontology.org", "http://www.hgvs.org/mutnomen", "http://www.ncbi.nlm.nih.gov/projects/SNP", "http://cancer.sanger.ac.uk/cancergenome/projects/cosmic", - "http://www.lrg-sequence.org", "http://www.omim.org", "http://www.ncbi.nlm.nih.gov/pubmed", "http://www.pharmgkb.org", "http://clinicaltrials.gov", "http://www.ebi.ac.uk/ipd/imgt/hla/")) - return system; - - return null; - } - - private String getCsRef(String system) { - CodeSystem cs = context.fetchCodeSystem(system); - return getCsRef(cs); - } - - private String getCsRef(T cs) { - String ref = (String) cs.getUserData("filename"); - if (ref == null) - ref = (String) cs.getUserData("path"); - if (ref == null) - return "??.html"; - if (!ref.contains(".html")) - ref = ref + ".html"; - return ref.replace("\\", "/"); - } - - private boolean codeExistsInValueSet(CodeSystem cs, String code) { - for (ConceptDefinitionComponent c : cs.getConcept()) { - if (inConcept(code, c)) - return true; - } - return false; - } - - private boolean inConcept(String code, ConceptDefinitionComponent c) { - if (c.hasCodeElement() && c.getCode().equals(code)) - return true; - for (ConceptDefinitionComponent g : c.getConcept()) { - if (inConcept(code, g)) - return true; - } - return false; - } /** * This generate is optimised for the build tool in that it tracks the source extension. @@ -4532,42 +2572,42 @@ public class NarrativeGenerator implements INarrativeGenerator { boolean hasSource = false; boolean success = true; for (OperationOutcomeIssueComponent i : op.getIssue()) { - success = success && i.getSeverity() == IssueSeverity.INFORMATION; - hasSource = hasSource || ExtensionHelper.hasExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE); + success = success && i.getSeverity() == IssueSeverity.INFORMATION; + hasSource = hasSource || ExtensionHelper.hasExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE); } if (success) - x.para().tx("All OK"); + x.para().tx("All OK"); if (op.getIssue().size() > 0) { - XhtmlNode tbl = x.table("grid"); // on the basis that we'll most likely be rendered using the standard fhir css, but it doesn't really matter - XhtmlNode tr = tbl.tr(); - tr.td().b().tx("Severity"); - tr.td().b().tx("Location"); - tr.td().b().tx("Code"); - tr.td().b().tx("Details"); - tr.td().b().tx("Diagnostics"); - if (hasSource) - tr.td().b().tx("Source"); - for (OperationOutcomeIssueComponent i : op.getIssue()) { - tr = tbl.tr(); - tr.td().addText(i.getSeverity().toString()); - XhtmlNode td = tr.td(); - boolean d = false; - for (StringType s : i.getLocation()) { - if (d) - td.tx(", "); - else - d = true; - td.addText(s.getValue()); - } - tr.td().addText(i.getCode().getDisplay()); - tr.td().addText(gen(i.getDetails())); - smartAddText(tr.td(), i.getDiagnostics()); - if (hasSource) { - Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE); - tr.td().addText(ext == null ? "" : gen(ext)); - } - } - } + XhtmlNode tbl = x.table("grid"); // on the basis that we'll most likely be rendered using the standard fhir css, but it doesn't really matter + XhtmlNode tr = tbl.tr(); + tr.td().b().tx("Severity"); + tr.td().b().tx("Location"); + tr.td().b().tx("Code"); + tr.td().b().tx("Details"); + tr.td().b().tx("Diagnostics"); + if (hasSource) + tr.td().b().tx("Source"); + for (OperationOutcomeIssueComponent i : op.getIssue()) { + tr = tbl.tr(); + tr.td().addText(i.getSeverity().toString()); + XhtmlNode td = tr.td(); + boolean d = false; + for (StringType s : i.getLocation()) { + if (d) + td.tx(", "); + else + d = true; + td.addText(s.getValue()); + } + tr.td().addText(i.getCode().getDisplay()); + tr.td().addText(gen(i.getDetails())); + smartAddText(tr.td(), i.getDiagnostics()); + if (hasSource) { + Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE); + tr.td().addText(ext == null ? "" : gen(ext)); + } + } + } inject(op, x, hasSource ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED); return true; } @@ -4584,17 +2624,17 @@ public class NarrativeGenerator implements INarrativeGenerator { return displayRange((Range) type); return null; } - - private String gen(Extension extension) throws DefinitionException { - if (extension.getValue() instanceof CodeType) - return ((CodeType) extension.getValue()).getValue(); - if (extension.getValue() instanceof Coding) - return gen((Coding) extension.getValue()); - throw new DefinitionException("Unhandled type "+extension.getValue().getClass().getName()); + private String gen(Extension extension) throws DefinitionException { + if (extension.getValue() instanceof CodeType) + return ((CodeType) extension.getValue()).getValue(); + if (extension.getValue() instanceof Coding) + return gen((Coding) extension.getValue()); + + throw new DefinitionException("Unhandled type "+extension.getValue().getClass().getName()); } - public String gen(Reference ref) { + public String gen(Reference ref) { if (ref == null) return null; if (ref.hasDisplay()) { @@ -4606,27 +2646,27 @@ public class NarrativeGenerator implements INarrativeGenerator { if (ref.hasIdentifier()) { return displayIdentifier(ref.getIdentifier()); } - return "??"; - } + return "?ngen-15?"; + } - public String gen(CodeableConcept code) { - if (code == null) - return null; - if (code.hasText()) - return code.getText(); - if (code.hasCoding()) - return gen(code.getCoding().get(0)); - return null; - } + public String gen(CodeableConcept code) { + if (code == null) + return null; + if (code.hasText()) + return code.getText(); + if (code.hasCoding()) + return gen(code.getCoding().get(0)); + return null; + } - public String gen(Coding code) { - if (code == null) - return null; - if (code.hasDisplayElement()) - return code.getDisplay(); - if (code.hasCodeElement()) - return code.getCode(); - return null; + public String gen(Coding code) { + if (code == null) + return null; + if (code.hasDisplayElement()) + return code.getDisplay(); + if (code.hasCodeElement()) + return code.getCode(); + return null; } public boolean generate(ResourceContext rcontext, StructureDefinition sd, Set outputTracker) throws EOperationOutcome, FHIRException, IOException { @@ -4708,7 +2748,7 @@ public class NarrativeGenerator implements INarrativeGenerator { inject(list, x, NarrativeStatus.GENERATED); return false; } - + public boolean generateList(XhtmlNode x, ResourceWrapper list) throws EOperationOutcome, FHIRException, IOException { if (list.has("title")) { x.h2().tx(list.get("title").primitiveValue()); @@ -4743,9 +2783,9 @@ public class NarrativeGenerator implements INarrativeGenerator { if (list.has("orderedBy")) { td.tx("Order: "+genCC(list.get("orderedBy"))); } -// for (Annotation a : list.getNote()) { -// renderAnnotation(a, x); -// } + // for (Annotation a : list.getNote()) { + // renderAnnotation(a, x); + // } boolean flag = false; boolean deleted = false; boolean date = false; @@ -4821,7 +2861,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } else if (disp != null) { x.tx(disp); } else { - x.tx("??"); + x.tx("?ngen-16?"); } } return x; @@ -4869,85 +2909,139 @@ public class NarrativeGenerator implements INarrativeGenerator { addMarkdown(x, opd.getComment()); inject(opd, x, NarrativeStatus.GENERATED); return true; - } + } - private void genOpParam(ResourceContext rcontext, XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException { - XhtmlNode tr; - tr = tbl.tr(); - tr.td().addText(p.getUse().toString()); - tr.td().addText(path+p.getName()); - tr.td().addText(Integer.toString(p.getMin())+".."+p.getMax()); - XhtmlNode td = tr.td(); - StructureDefinition sd = p.getType() != null ? context.fetchTypeDefinition(p.getType().toCode()) : null; - if (sd == null) - td.tx(p.hasType() ? p.getType().toCode() : ""); - else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) { - boolean first = true; - for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) { - if (first) first = false; else td.tx(" | "); - String s = ex.getValue().primitiveValue(); - StructureDefinition sdt = context.fetchTypeDefinition(s); - if (sdt == null) - td.tx(p.hasType() ? p.getType().toCode() : ""); - else - td.ah(sdt.getUserString("path")).tx(s); - } - } else - td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType().toCode() : ""); - if (p.hasSearchType()) { - td.br(); - td.tx("("); - td.ah( corePath == null ? "search.html#"+p.getSearchType().toCode() : Utilities.pathURL(corePath, "search.html#"+p.getSearchType().toCode())).tx(p.getSearchType().toCode()); - td.tx(")"); + private void genOpParam(ResourceContext rcontext, XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException { + XhtmlNode tr; + tr = tbl.tr(); + tr.td().addText(p.getUse().toString()); + tr.td().addText(path+p.getName()); + tr.td().addText(Integer.toString(p.getMin())+".."+p.getMax()); + XhtmlNode td = tr.td(); + StructureDefinition sd = p.getType() != null ? context.fetchTypeDefinition(p.getType().toCode()) : null; + if (sd == null) + td.tx(p.hasType() ? p.getType().toCode() : ""); + else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) { + boolean first = true; + for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) { + if (first) first = false; else td.tx(" | "); + String s = ex.getValue().primitiveValue(); + StructureDefinition sdt = context.fetchTypeDefinition(s); + if (sdt == null) + td.tx(p.hasType() ? p.getType().toCode() : ""); + else + td.ah(sdt.getUserString("path")).tx(s); } - td = tr.td(); - if (p.hasBinding() && p.getBinding().hasValueSet()) { - AddVsRef(rcontext, p.getBinding().getValueSet(), td); - td.tx(" ("+p.getBinding().getStrength().getDisplay()+")"); - } - addMarkdown(tr.td(), p.getDocumentation()); - if (!p.hasType()) { - for (OperationDefinitionParameterComponent pp : p.getPart()) { - genOpParam(rcontext, tbl, path+p.getName()+".", pp); - } + } else + td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType().toCode() : ""); + if (p.hasSearchType()) { + td.br(); + td.tx("("); + td.ah( corePath == null ? "search.html#"+p.getSearchType().toCode() : Utilities.pathURL(corePath, "search.html#"+p.getSearchType().toCode())).tx(p.getSearchType().toCode()); + td.tx(")"); + } + td = tr.td(); + if (p.hasBinding() && p.getBinding().hasValueSet()) { + AddVsRef(rcontext, p.getBinding().getValueSet(), td); + td.tx(" ("+p.getBinding().getStrength().getDisplay()+")"); + } + addMarkdown(tr.td(), p.getDocumentation()); + if (!p.hasType()) { + for (OperationDefinitionParameterComponent pp : p.getPart()) { + genOpParam(rcontext, tbl, path+p.getName()+".", pp); } } + } - private void addMarkdown(XhtmlNode x, String text) throws FHIRFormatError, IOException, DefinitionException { - if (text != null) { - // 1. custom FHIR extensions - while (text.contains("[[[")) { - String left = text.substring(0, text.indexOf("[[[")); - String link = text.substring(text.indexOf("[[[")+3, text.indexOf("]]]")); - String right = text.substring(text.indexOf("]]]")+3); - String url = link; - String[] parts = link.split("\\#"); - StructureDefinition p = context.fetchResource(StructureDefinition.class, parts[0]); - if (p == null) - p = context.fetchTypeDefinition(parts[0]); - if (p == null) - p = context.fetchResource(StructureDefinition.class, link); - if (p != null) { - url = p.getUserString("path"); - if (url == null) - url = p.getUserString("filename"); - } else - throw new DefinitionException("Unable to resolve markdown link "+link); + protected void AddVsRef(ResourceContext rcontext, String value, XhtmlNode li) { + Resource res = null; + if (rcontext != null) { + BundleEntryComponent be = rcontext.resolve(value); + if (be != null) { + res = be.getResource(); + } + } + if (res != null && !(res instanceof CanonicalResource)) { + li.addText(value); + return; + } + CanonicalResource vs = (CanonicalResource) res; + if (vs == null) + vs = context.fetchResource(ValueSet.class, value); + if (vs == null) + vs = context.fetchResource(StructureDefinition.class, value); + // if (vs == null) + // vs = context.fetchResource(DataElement.class, value); + if (vs == null) + vs = context.fetchResource(Questionnaire.class, value); + if (vs != null) { + String ref = (String) vs.getUserData("path"); - text = left+"["+link+"]("+url+")"+right; - } + ref = adjustForPath(ref); + XhtmlNode a = li.ah(ref == null ? "?ngen-11?" : ref.replace("\\", "/")); + a.addText(value); + } else { + CodeSystem cs = context.fetchCodeSystem(value); + if (cs != null) { + String ref = (String) cs.getUserData("path"); + ref = adjustForPath(ref); + XhtmlNode a = li.ah(ref == null ? "?ngen-12?" : ref.replace("\\", "/")); + a.addText(value); + } else if (value.equals("http://snomed.info/sct") || value.equals("http://snomed.info/id")) { + XhtmlNode a = li.ah(value); + a.tx("SNOMED-CT"); + } + else { + if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us")) + System.out.println("Unable to resolve value set "+value); + li.addText(value); + } + } + } + private String adjustForPath(String ref) { + if (prefix == null) + return ref; + else + return prefix+ref; + } - // 2. markdown - String s = markdown.process(Utilities.escapeXml(text), "narrative generator"); - XhtmlParser p = new XhtmlParser(); - XhtmlNode m; - try { - m = p.parse("
"+s+"
", "div"); - } catch (org.hl7.fhir.exceptions.FHIRFormatError e) { - throw new FHIRFormatError(e.getMessage(), e); - } - x.getChildNodes().addAll(m.getChildNodes()); - } + + + private void addMarkdown(XhtmlNode x, String text) throws FHIRFormatError, IOException, DefinitionException { + if (text != null) { + // 1. custom FHIR extensions + while (text.contains("[[[")) { + String left = text.substring(0, text.indexOf("[[[")); + String link = text.substring(text.indexOf("[[[")+3, text.indexOf("]]]")); + String right = text.substring(text.indexOf("]]]")+3); + String url = link; + String[] parts = link.split("\\#"); + StructureDefinition p = context.fetchResource(StructureDefinition.class, parts[0]); + if (p == null) + p = context.fetchTypeDefinition(parts[0]); + if (p == null) + p = context.fetchResource(StructureDefinition.class, link); + if (p != null) { + url = p.getUserString("path"); + if (url == null) + url = p.getUserString("filename"); + } else + throw new DefinitionException("Unable to resolve markdown link "+link); + + text = left+"["+link+"]("+url+")"+right; + } + + // 2. markdown + String s = markdown.process(Utilities.escapeXml(text), "narrative generator"); + XhtmlParser p = new XhtmlParser(); + XhtmlNode m; + try { + m = p.parse("
"+s+"
", "div"); + } catch (org.hl7.fhir.exceptions.FHIRFormatError e) { + throw new FHIRFormatError(e.getMessage(), e); + } + x.getChildNodes().addAll(m.getChildNodes()); + } } public boolean generate(ResourceContext rcontext, CompartmentDefinition cpd) { @@ -5010,7 +3104,7 @@ public class NarrativeGenerator implements INarrativeGenerator { hasHistory = hasHistory || hasOp(r, TypeRestfulInteraction.HISTORYTYPE); hasUpdates = hasUpdates || hasOp(r, TypeRestfulInteraction.HISTORYINSTANCE); } - + t = x.table(null); XhtmlNode tr = t.tr(); tr.th().b().tx("Resource Type"); @@ -5064,7 +3158,7 @@ public class NarrativeGenerator implements INarrativeGenerator { } return false; } - + private String showOp(CapabilityStatementRestResourceComponent r, TypeRestfulInteraction on) { for (ResourceInteractionComponent op : r.getInteraction()) { if (op.getCode() == on) @@ -5112,16 +3206,16 @@ public class NarrativeGenerator implements INarrativeGenerator { node.hr(); if (section.hasTitleElement()) node.addTag("h"+Integer.toString(level)).addText(section.getTitle()); -// else if (section.hasCode()) -// node.addTag("h"+Integer.toString(level)).addText(displayCodeableConcept(section.getCode())); + // else if (section.hasCode()) + // node.addTag("h"+Integer.toString(level)).addText(displayCodeableConcept(section.getCode())); -// if (section.hasText()) { -// node.getChildNodes().add(section.getText().getDiv()); -// } -// -// if (!section.getSection().isEmpty()) { -// renderSections(feed, node.addTag("blockquote"), section.getSection(), level+1); -// } + // if (section.hasText()) { + // node.getChildNodes().add(section.getText().getDiv()); + // } + // + // if (!section.getSection().isEmpty()) { + // renderSections(feed, node.addTag("blockquote"), section.getSection(), level+1); + // } } } @@ -5408,12 +3502,12 @@ public class NarrativeGenerator implements INarrativeGenerator { } private void scanNodesForInternalLinks(Bundle b, List nodes) { - for (XhtmlNode n : nodes) { - if ("a".equals(n.getName()) && n.hasAttribute("href")) { - scanInternalLink(b, n); - } - scanNodesForInternalLinks(b, n.getChildNodes()); - } + for (XhtmlNode n : nodes) { + if ("a".equals(n.getName()) && n.hasAttribute("href")) { + scanInternalLink(b, n); + } + scanNodesForInternalLinks(b, n.getChildNodes()); + } } private void scanInternalLink(Bundle b, XhtmlNode n) { @@ -5592,5 +3686,15 @@ public class NarrativeGenerator implements INarrativeGenerator { throw new Error("Not done yet"); } + private void smartAddText(XhtmlNode p, String text) { + if (text == null) + return; + String[] lines = text.split("\\r\\n"); + for (int i = 0; i < lines.length; i++) { + if (i > 0) + p.br(); + p.addText(lines[i]); + } + } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java index 9d518844d..e3ca6b31a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java @@ -102,6 +102,7 @@ import org.hl7.fhir.r5.model.TypeDetails.ProfiledType; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.terminologies.TerminologyRenderer; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; @@ -2612,7 +2613,7 @@ public class StructureMapUtilities { if (Utilities.noString(code)) throw new FHIRException("Describe Transform, but the code is blank"); Coding c = buildCoding(uri, code); - return NarrativeGenerator.describeSystem(c.getSystem())+"#"+c.getCode()+(c.hasDisplay() ? "("+c.getDisplay()+")" : ""); + return TerminologyRenderer.describeSystem(c.getSystem())+"#"+c.getCode()+(c.hasDisplay() ? "("+c.getDisplay()+")" : ""); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 47057c0d1..a7293f035 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -166,6 +166,8 @@ public class ToolingExtensions { public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type"; public static final String EXT_RENDERED_VALUE = "http://hl7.org/fhir/StructureDefinition/rendered-value"; public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence"; + public static final String EXT_EXP_FRAGMENT = "http://hl7.org/fhir/tools/StructureDefinition/expansion-codesystem-fragment"; + public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"; // specific extension helpers diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java index 6a03e2553..c1416978d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/TypesUtilities.java @@ -39,7 +39,7 @@ public class TypesUtilities { case PRIMITIVE: return "Primitive Type"; case SPECIAL: return "Special Type"; } - return "??"; + return "?tu-class?"; } } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeTest.java new file mode 100644 index 000000000..0a193fca6 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeTest.java @@ -0,0 +1,39 @@ +package org.hl7.fhir.r5.model; + +import ca.uhn.fhir.parser.DataFormatException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Base64BinaryTypeTest { + + @Test + @DisplayName("Passing a non Base64 encoded String to constructor causes exception.") + public void testNonBase64String() { + String nonBase64 = "Picard was the best starship captain."; + assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64)); + } + + @Test + @DisplayName("Null String value creates non-null instance with null value.") + public void testNullInstance() throws DataFormatException { + String v = null; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNull(b64.getValue()); + Assertions.assertNull(b64.getValueAsString()); + } + + @Test + @DisplayName("Valid Base64 String creates non-null instance with non-null values.") + public void testValid() { + String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ="; + Base64BinaryType b64 = new Base64BinaryType(v); + Assertions.assertNotNull(b64); + Assertions.assertNotNull(b64.getValue()); + Assertions.assertEquals(v, b64.asStringValue()); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 7323dcdf4..0c6fe4779 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -5,6 +5,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -22,11 +23,13 @@ import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent; import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus; @@ -43,6 +46,7 @@ import org.hl7.fhir.r5.model.TestScript.TestActionComponent; import org.hl7.fhir.r5.model.TestScript.TestScriptFixtureComponent; import org.hl7.fhir.r5.model.TestScript.TestScriptTestComponent; import org.hl7.fhir.r5.test.SnapShotGenerationTests.TestFetchMode; +import org.hl7.fhir.r5.test.SnapShotGenerationTests.TestLoader; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; @@ -52,8 +56,12 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.r5.utils.NarrativeGenerator; +import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.cache.NpmPackage; +import org.hl7.fhir.utilities.cache.PackageCacheManager; +import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.xml.XMLUtil; @@ -70,6 +78,26 @@ import junit.framework.Assert; @RunWith(Parameterized.class) public class SnapShotGenerationTests { + public class TestLoader implements IContextResourceLoader { + + private String[] types; + + public TestLoader(String[] types) { + this.types = types; + } + + @Override + public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { + return null; + } + + @Override + public String[] getTypes() { + return types; + } + + } + public enum TestFetchMode { INPUT, OUTPUT, @@ -499,6 +527,11 @@ public class SnapShotGenerationTests { pu.setThrowException(false); pu.setDebug(test.isDebug()); pu.setIds(test.getSource(), false); + if (!TestingUtilities.context().hasPackage("hl7.fhir.xver-extensions", "0.0.3")) { + NpmPackage npm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.fhir.xver-extensions", "0.0.3"); + TestingUtilities.context().loadFromPackage(npm, new TestLoader(new String[] {"StructureDefinition"}), new String[] {"StructureDefinition"}); + } + pu.setXver(new XVerExtensionManager(TestingUtilities.context())); if (test.isSort()) { List errors = new ArrayList(); int lastCount = output.getDifferential().getElement().size(); diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index bf0d7f7f5..966343b5f 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index ce1f0045d..5cc2bac48 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -779,7 +779,7 @@ public class PackageCacheManager { } } if (url == null) { - throw new FHIRException("Unable to resolve package id "+id); + throw new FHIRException("Unable to resolve package id "+id+"#"+v); } if (url.contains("/ImplementationGuide/")) { url = url.substring(0, url.indexOf("/ImplementationGuide/")); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java index cfbb58e74..39525e313 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageClient.java @@ -66,7 +66,7 @@ public class PackageClient { } @Override public String toString() { - return id+"#"+(version == null ? "??" : version)+(fhirVersion == null ? "": " ("+canonical+") for FHIR "+fhirVersion)+(url == null ? "" : " @"+url)+(description == null ? "" : " '"+description+"'"); + return id+"#"+(version == null ? "?pc-pi?" : version)+(fhirVersion == null ? "": " ("+canonical+") for FHIR "+fhirVersion)+(url == null ? "" : " @"+url)+(description == null ? "" : " '"+description+"'"); } } @@ -89,15 +89,15 @@ public class PackageClient { } public InputStream fetch(String id, String ver) throws IOException { - return fetchUrl(Utilities.pathURL(address, id, ver)); + return fetchUrl(Utilities.pathURL(address, id, ver), null); } public InputStream fetch(PackageInfo info) throws IOException { - return fetchUrl(Utilities.pathURL(address, info.getId(), info.getVersion())); + return fetchUrl(Utilities.pathURL(address, info.getId(), info.getVersion()), null); } public InputStream fetchNpm(String id, String ver) throws IOException { - return fetchUrl(Utilities.pathURL(address, id, "-", id+"-"+ver+".tgz")); + return fetchUrl(Utilities.pathURL(address, id, "-", id+"-"+ver+".tgz"), null); } public List getVersions(String id) throws IOException { @@ -154,20 +154,23 @@ public class PackageClient { return null; } - private InputStream fetchUrl(String source) throws IOException { + private InputStream fetchUrl(String source, String accept) throws IOException { URL url = new URL(source); URLConnection c = url.openConnection(); + if (accept != null) { + c.setRequestProperty("accept", accept); + } return c.getInputStream(); } private JsonObject fetchJson(String source) throws IOException { - String src = TextFile.streamToString(fetchUrl(source)); + String src = TextFile.streamToString(fetchUrl(source, "application/json")); //System.out.println(src); return (JsonObject) new com.google.gson.JsonParser().parse(src); } private JsonArray fetchJsonArray(String source) throws IOException { - String src = TextFile.streamToString(fetchUrl(source)); + String src = TextFile.streamToString(fetchUrl(source, "application/json")); //System.out.println(src); return (JsonArray) new com.google.gson.JsonParser().parse(src); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java index b4eed7307..51d710ffe 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java @@ -419,6 +419,7 @@ public class I18nConstants { public final static String UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER_USE_PARAMETER_TX_NA_TUN_RUN_WITHOUT_USING_TERMINOLOGY_SERVICES_TO_VALIDATE_LOINC_SNOMED_ICDX_ETC_ERROR__ = "Unable_to_connect_to_terminology_server_Use_parameter_tx_na_tun_run_without_using_terminology_services_to_validate_LOINC_SNOMED_ICDX_etc_Error__"; public final static String DISPLAY_NAME_FOR__SHOULD_BE_ONE_OF__INSTEAD_OF_ = "Display_Name_for__should_be_one_of__instead_of_"; public final static String UNKNOWN_CODE__IN_ = "Unknown_Code__in_"; + public final static String UNKNOWN_CODE__IN_FRAGMENT = "UNKNOWN_CODE__IN_FRAGMENT"; public final static String CODE_FOUND_IN_EXPANSION_HOWEVER_ = "Code_found_in_expansion_however_"; public final static String NONE_OF_THE_PROVIDED_CODES_ARE_IN_THE_VALUE_SET_ = "None_of_the_provided_codes_are_in_the_value_set_"; public final static String CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE = "Coding_has_no_system__cannot_validate"; @@ -502,4 +503,8 @@ public class I18nConstants { //public static final String //public static final String //public static final String + public static final String XHTML_URL_EMPTY = "XHTML_URL_EMPTY"; + public static final String XHTML_URL_INVALID_CHARS = "XHTML_URL_INVALID_CHARS"; + public static final String TERMINOLOGY_TX_SYSTEM_HTTPS = "TERMINOLOGY_TX_SYSTEM_HTTPS"; + public static final String CODESYSTEM_CS_NO_VS_NOTCOMPLETE = "CODESYSTEM_CS_NO_VS_NOTCOMPLETE"; } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 5ef3c3007..eb9d307ee 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -20,10 +20,10 @@ Bundle_MSG_Event_Count = Expected {0} but found {1} event elements Bundle_Document_Date_Missing = A document must have a date {0} Bundle_Document_Date_Missing_html = [(type = 'document') implies (meta.lastUpdated.hasValue())] CapabalityStatement_CS_SP_WrongType = Type mismatch - SearchParameter "{0}" type is {1}, but type here is {2} -CodeSystem_CS_VS_IncludeDetails = CodeSystem {0} has a ''all system'' value set of {1}, but the include has extra details -CodeSystem_CS_VS_Invalid = CodeSystem {0} has a ''all system'' value set of {1}, but doesn''t have a single include -CodeSystem_CS_VS_MisMatch = CodeSystem {0} has a ''all system'' value set of {1}, but it is an expansion -CodeSystem_CS_VS_WrongSystem = CodeSystem {0} has a ''all system'' value set of {1}, but doesn''t have a matching system ({2}) +CodeSystem_CS_VS_IncludeDetails = CodeSystem {0} has an ''all system'' value set of {1}, but the include has extra details +CodeSystem_CS_VS_Invalid = CodeSystem {0} has an ''all system'' value set of {1}, but doesn''t have a single include +CodeSystem_CS_VS_MisMatch = CodeSystem {0} has an ''all system'' value set of {1}, but it is an expansion +CodeSystem_CS_VS_WrongSystem = CodeSystem {0} has an ''all system'' value set of {1}, but doesn''t have a matching system ({2}) Extension_EXT_Context_Wrong = The extension {0} is not allowed to be used at this point (allowed = {1}; this element is [{2}) Extension_EXT_Count_Mismatch = Extensions count mismatch: expected {0} but found {1} Extension_EXT_Count_NotFound = Extension count mismatch: unable to find extension: {0} @@ -419,6 +419,7 @@ Error_parsing_ = Error parsing {0}:{1} Unable_to_connect_to_terminology_server_Use_parameter_tx_na_tun_run_without_using_terminology_services_to_validate_LOINC_SNOMED_ICDX_etc_Error__ = Unable to connect to terminology server. Use parameter ''-tx n/a'' tun run without using terminology services to validate LOINC, SNOMED, ICD-X etc. Error = {0} Display_Name_for__should_be_one_of__instead_of_ = Display Name for {0}#{1} should be one of ''{2}'' instead of ''{3}'' Unknown_Code__in_ = Unknown Code {0} in {1} +UNKNOWN_CODE__IN_FRAGMENT = Unknown Code {0} in {1} - note that the code system is labelled as a fragment, so the code may be valid in some other fragment Code_found_in_expansion_however_ = Code found in expansion, however: {0} None_of_the_provided_codes_are_in_the_value_set_ = None of the provided codes are in the value set {0} Coding_has_no_system__cannot_validate = Coding has no system - cannot validate @@ -436,7 +437,7 @@ documentmsg = (document) xml_attr_value_invalid = The XML Attribute {0} has an illegal character xml_encoding_invalid = The XML encoding is invalid (must be UTF-8) xml_stated_encoding_invalid = The XML encoding stated in the header is invalid (must be "UTF-8" if stated) -XHTML_URL_INVALID = The URL {0} is not valid +XHTML_URL_INVALID = The URL {0} is not valid ({1}) MEASURE_MR_GRP_NO_CODE = Group should have a code that matches the group definition in the measure MEASURE_MR_GRP_UNK_CODE = The code for this group has no match in the measure definition MEASURE_MR_GRP_DUPL_CODE = The code for this group is duplicated with another group @@ -480,4 +481,8 @@ MEASURE_M_CRITERIA_CQL_ERROR = Error in {0}: ''{1}'' MEASURE_M_CRITERIA_CQL_NO_ELM = Error in {0}: No compiled version of CQL found MEASURE_M_CRITERIA_CQL_ELM_NOT_VALID = = Error in {0}: Compiled version of CQL is not valid MEASURE_M_CRITERIA_CQL_NOT_FOUND = The function {1} does not exist in the library {0} - +XHTML_URL_EMPTY = URL is empty +XHTML_URL_INVALID_CHARS = URL contains Invalid Characters ({0}) +TERMINOLOGY_TX_SYSTEM_HTTPS = The system URL ''{0}'' wrongly starts with https: not http: +CODESYSTEM_CS_NO_VS_NOTCOMPLETE = Review the All Codes Value Set - incomplete CodeSystems generally should not have an all codes value set specified + \ No newline at end of file diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 6ca616bfe..5a2a6532d 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index ea27cfbdd..9bf6bac5c 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index cb8406961..0d76dfa8d 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -5,9 +5,9 @@ import org.hl7.fhir.convertors.*; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.conformance.ProfileUtilities; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion; import org.hl7.fhir.r5.context.SimpleWorkerContext; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; @@ -243,6 +243,7 @@ public class ValidationEngine implements IValidatorResourceFetcher { private Set loadedIgs = new HashSet<>(); private IValidatorResourceFetcher fetcher; private boolean assumeValidRestReferences; + private boolean noExtensibleBindingMessages; private Locale locale; private class AsteriskFilter implements FilenameFilter { @@ -1279,6 +1280,7 @@ public class ValidationEngine implements IValidatorResourceFetcher { validator.setNoInvariantChecks(isNoInvariantChecks()); validator.setValidationLanguage(language); validator.setAssumeValidRestReferences(assumeValidRestReferences); + validator.setNoExtensibleWarnings(noExtensibleBindingMessages); validator.getContext().setLocale(locale); validator.setFetcher(this); return validator; @@ -1708,6 +1710,14 @@ public class ValidationEngine implements IValidatorResourceFetcher { this.assumeValidRestReferences = assumeValidRestReferences; } + public boolean isNoExtensibleBindingMessages() { + return noExtensibleBindingMessages; + } + + public void setNoExtensibleBindingMessages(boolean noExtensibleBindingMessages) { + this.noExtensibleBindingMessages = noExtensibleBindingMessages; + } + public byte[] transformVersion(String source, String targetVer, FhirFormat format, Boolean canDoNative) throws FHIRException, IOException, Exception { Content cnt = loadContent(source, "validate"); org.hl7.fhir.r5.elementmodel.Element src = Manager.parse(context, new ByteArrayInputStream(cnt.focus), cnt.cntType); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java index 1e910eae7..951628ffa 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java @@ -25,6 +25,10 @@ public class CliContext { private boolean assumeValidRestReferences = false; @JsonProperty("canDoNative") private boolean canDoNative = false; + @JsonProperty("noInternalCaching") + private boolean noInternalCaching = false; // internal, for when debugging terminology validation + @JsonProperty("noExtensibleBindingMessages") + private boolean noExtensibleBindingMessages = false; @JsonProperty("map") private String map = null; @@ -380,69 +384,26 @@ public class CliContext { return this; } - @Override - public String toString() { - return "CliContext{" + - "map='" + map + '\'' + - ", igs=" + igs + - ", questionnaires=" + questionnaires + - ", txServer='" + txServer + '\'' + - ", doNative=" + doNative + - ", anyExtensionsAllowed=" + anyExtensionsAllowed + - ", hintAboutNonMustSupport=" + hintAboutNonMustSupport + - ", recursive=" + recursive + - ", locale=" + locale + - ", profiles=" + profiles + - ", mode=" + mode + - ", output='" + output + '\'' + - ", canDoNative=" + canDoNative + - ", sources=" + sources + - ", locations=" + locations + - ", sv='" + sv + '\'' + - ", txLog='" + txLog + '\'' + - ", mapLog='" + mapLog + '\'' + - ", lang='" + lang + '\'' + - ", fhirpath='" + fhirpath + '\'' + - ", snomedCT='" + snomedCT + '\'' + - ", targetVer='" + targetVer + '\'' + - ", doDebug=" + doDebug + - ", assumeValidRestReferences=" + assumeValidRestReferences + - '}'; + @JsonProperty("noInternalCaching") + public boolean isNoInternalCaching() { + return noInternalCaching; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - CliContext that = (CliContext) o; - return doNative == that.doNative && - anyExtensionsAllowed == that.anyExtensionsAllowed && - hintAboutNonMustSupport == that.hintAboutNonMustSupport && - recursive == that.recursive && - doDebug == that.doDebug && - assumeValidRestReferences == that.assumeValidRestReferences && - canDoNative == that.canDoNative && - Objects.equals(map, that.map) && - Objects.equals(output, that.output) && - Objects.equals(txServer, that.txServer) && - Objects.equals(sv, that.sv) && - Objects.equals(txLog, that.txLog) && - Objects.equals(mapLog, that.mapLog) && - Objects.equals(lang, that.lang) && - Objects.equals(fhirpath, that.fhirpath) && - Objects.equals(snomedCT, that.snomedCT) && - Objects.equals(targetVer, that.targetVer) && - Objects.equals(igs, that.igs) && - Objects.equals(questionnaires, that.questionnaires) && - Objects.equals(profiles, that.profiles) && - Objects.equals(sources, that.sources) && - mode == that.mode && - Objects.equals(locale, that.locale) && - Objects.equals(locations, that.locations); + @JsonProperty("noInternalCaching") + public CliContext setNoInternalCaching(boolean noInternalCaching) { + this.noInternalCaching = noInternalCaching; + return this; } - @Override - public int hashCode() { - return Objects.hash(doNative, anyExtensionsAllowed, hintAboutNonMustSupport, recursive, doDebug, assumeValidRestReferences, canDoNative, map, output, txServer, sv, txLog, mapLog, lang, fhirpath, snomedCT, targetVer, igs, questionnaires, profiles, sources, mode, locale, locations); + @JsonProperty("noExtensibleBindingMessages") + public boolean isNoExtensibleBindingMessages() { + return noExtensibleBindingMessages; } + + @JsonProperty("noExtensibleBindingMessages") + public CliContext setNoExtensibleBindingMessages(boolean noExtensibleBindingMessages) { + this.noExtensibleBindingMessages = noExtensibleBindingMessages; + return this; + } + } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java index 953a524be..6aacedbb6 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java @@ -1,5 +1,6 @@ package org.hl7.fhir.validation.cli.services; +import org.hl7.fhir.r5.context.TerminologyCache; import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.formats.IParser; import org.hl7.fhir.r5.formats.JsonParser; @@ -180,6 +181,8 @@ public class ValidationService { validator.setLocale(cliContext.getLocale()); validator.setSnomedExtension(cliContext.getSnomedCTCode()); validator.setAssumeValidRestReferences(cliContext.isAssumeValidRestReferences()); + validator.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages()); + TerminologyCache.setNoCaching(cliContext.isNoInternalCaching()); return validator; } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java index f8ae26348..ee465e372 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java @@ -47,6 +47,8 @@ public class Params { public static final String DESTINATION = "-dest"; public static final String LEFT = "-left"; public static final String RIGHT = "-right"; + public static final String NO_INTERNAL_CACHING = "-no-internal-caching"; + public static final String NO_EXTENSIBLE_BINDING_WARNINGS = "-no-extensible-binding-warnings"; /** * Checks the list of passed in params to see if it contains the passed in param. @@ -92,18 +94,19 @@ public class Params { i++; // ignore next parameter } else if (args[i].equals(PROFILE)) { String p = null; - if (i + 1 == args.length) + if (i + 1 == args.length) { throw new Error("Specified -profile without indicating profile source"); - else { + } else { p = args[++i]; - cliContext.addProfile(args[++i]); + cliContext.addProfile(args[i++]); } if (p != null && i + 1 < args.length && args[i + 1].equals("@")) { i++; - if (i + 1 == args.length) + if (i + 1 == args.length) { throw new Error("Specified -profile with @ without indicating profile location"); - else + } else { cliContext.addLocation(p, args[++i]); + } } } else if (args[i].equals(QUESTIONNAIRE)) { if (i + 1 == args.length) @@ -128,6 +131,10 @@ public class Params { } } else if (args[i].equals(STRICT_EXTENSIONS)) { cliContext.setAnyExtensionsAllowed(false); + } else if (args[i].equals(NO_INTERNAL_CACHING)) { + cliContext.setNoInternalCaching(true); + } else if (args[i].equals(NO_EXTENSIBLE_BINDING_WARNINGS)) { + cliContext.setNoExtensibleBindingMessages(true); } else if (args[i].equals(HINT_ABOUT_NON_MUST_SUPPORT)) { cliContext.setHintAboutNonMustSupport(true); } else if (args[i].equals(TO_VERSION)) { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index e0cffc8c5..180a5f5e3 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -139,6 +139,7 @@ import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.TimeTracker; import org.hl7.fhir.validation.instance.EnableWhenEvaluator.QStack; +import org.hl7.fhir.validation.instance.type.CodeSystemValidator; import org.hl7.fhir.validation.instance.type.MeasureValidator; import org.hl7.fhir.validation.instance.type.QuestionnaireValidator; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; @@ -806,7 +807,16 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_SYSTEM_VALUESET, system); // Lloyd: This error used to prohibit checking for downstream issues, but there are some cases where that checking needs to occur. Please talk to me before changing the code back. } - hint(errors, IssueType.UNKNOWN, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_SYSTEM_NOTKNOWN, system); + boolean done = false; + if (system.startsWith("https:") && system.length() > 7) { + String ns = "http:"+system.substring(6); + CodeSystem cs = getCodeSystem(ns); + if (cs != null || Utilities.existsInList(system, "https://loinc.org", "https://unitsofmeasure.org", "https://snomed.info/sct", "https://www.nlm.nih.gov/research/umls/rxnorm")) { + rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_SYSTEM_HTTPS, system); + done = true; + } + } + hint(errors, IssueType.UNKNOWN, element.line(), element.col(), path, done, I18nConstants.TERMINOLOGY_TX_SYSTEM_NOTKNOWN, system); return true; } catch (Exception e) { return true; @@ -1578,7 +1588,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } else if (ctxt.getType() == ExtensionContextType.FHIRPATH) { contexts.append("p:" + ctxt.getExpression()); // The context is all elements that match the FHIRPath query found in the expression. - List res = fpe.evaluate(hostContext, resource, hostContext.getRootResource(), container, fpe.parse(ctxt.getExpression())); + List res = fpe.evaluate(hostContext, resource, hostContext.getRootResource(), resource, fpe.parse(ctxt.getExpression())); if (res.contains(container)) { ok = true; } @@ -1613,6 +1623,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if ("http://hl7.org/fhir/StructureDefinition/regex".equals(extUrl)) { list.get(1).setExpression("ElementDefinition.type"); } + if ("http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version".equals(extUrl)) { + list.get(0).setExpression("Element"); // well, it can't be used anywhere but the list of places it can be used is quite long + } return list; } @@ -2012,28 +2025,35 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat for (XhtmlNode node : list) { if (node.getNodeType() == NodeType.Element) { if ("a".equals(node.getName())) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, isValidUrl(node.getAttribute("href")), I18nConstants.XHTML_URL_INVALID, node.getAttribute("href")); + String msg = checkValidUrl(node.getAttribute("href")); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, msg == null, I18nConstants.XHTML_URL_INVALID, node.getAttribute("href"), msg); } else if ("img".equals(node.getName())) { - rule(errors, IssueType.INVALID, e.line(), e.col(), path, isValidUrl(node.getAttribute("src")), I18nConstants.XHTML_URL_INVALID, node.getAttribute("src")); + String msg = checkValidUrl(node.getAttribute("src")); + rule(errors, IssueType.INVALID, e.line(), e.col(), path, msg == null, I18nConstants.XHTML_URL_INVALID, node.getAttribute("src"), msg); } checkUrls(errors, e, path, node.getChildNodes()); } } } - private boolean isValidUrl(String value) { + private String checkValidUrl(String value) { if (value == null) { - return true; + return null; } - try { - for (char ch : value.toCharArray()) { - if (!(Character.isDigit(ch) || Character.isAlphabetic(ch) || Utilities.existsInList(ch, ';', '?', ':', '@', '&', '=', '+', '$', '.', ',', '/', '%', '-', '_', '~', '#', '[', ']', '!', '\'', '(', ')', '*' ))) { - return false; - } + if (Utilities.noString(value)) { + return context.formatMessage(I18nConstants.XHTML_URL_EMPTY); + } + + Set invalidChars = new HashSet<>(); + for (char ch : value.toCharArray()) { + if (!(Character.isDigit(ch) || Character.isAlphabetic(ch) || Utilities.existsInList(ch, ';', '?', ':', '@', '&', '=', '+', '$', '.', ',', '/', '%', '-', '_', '~', '#', '[', ']', '!', '\'', '(', ')', '*' ))) { + invalidChars.add(ch); } - return true; - } catch (Exception e) { - return false; + } + if (invalidChars.isEmpty()) { + return null; + } else { + return context.formatMessage(I18nConstants.XHTML_URL_INVALID_CHARS, invalidChars.toString()); } } @@ -3459,7 +3479,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } else if (element.getType().equals("CapabilityStatement")) { validateCapabilityStatement(errors, element, stack); } else if (element.getType().equals("CodeSystem")) { - validateCodeSystem(errors, element, stack); + new CodeSystemValidator(context, timeTracker).validateCodeSystem(errors, element, stack); } } @@ -3543,28 +3563,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } } - private void validateCodeSystem(List errors, Element cs, NodeStack stack) { - String url = cs.getNamedChildValue("url"); - String vsu = cs.getNamedChildValue("valueSet"); - if (!Utilities.noString(vsu)) { - ValueSet vs; - try { - vs = context.fetchResourceWithException(ValueSet.class, vsu); - } catch (FHIRException e) { - vs = null; - } - if (vs != null) { - if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.hasCompose() && !vs.hasExpansion(), I18nConstants.CODESYSTEM_CS_VS_MISMATCH, url, vsu)) - if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.getCompose().getInclude().size() == 1, I18nConstants.CODESYSTEM_CS_VS_INVALID, url, vsu)) - if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.getCompose().getInclude().get(0).getSystem().equals(url), I18nConstants.CODESYSTEM_CS_VS_WRONGSYSTEM, url, vsu, vs.getCompose().getInclude().get(0).getSystem())) { - rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !vs.getCompose().getInclude().get(0).hasValueSet() - && !vs.getCompose().getInclude().get(0).hasConcept() && !vs.getCompose().getInclude().get(0).hasFilter(), I18nConstants.CODESYSTEM_CS_VS_INCLUDEDETAILS, url, vsu); - } - } - } // todo... try getting the value set the other way... - } - - private void validateBundle(List errors, Element bundle, NodeStack stack, boolean checkSpecials) { List entries = new ArrayList(); bundle.getNamedChildren(ENTRY, entries); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/CodeSystemValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/CodeSystemValidator.java new file mode 100644 index 000000000..22a7d08df --- /dev/null +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/CodeSystemValidator.java @@ -0,0 +1,51 @@ +package org.hl7.fhir.validation.instance.type; + +import java.util.List; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.elementmodel.Element; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.i18n.I18nConstants; +import org.hl7.fhir.utilities.validation.ValidationMessage; +import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; +import org.hl7.fhir.utilities.validation.ValidationMessage.Source; +import org.hl7.fhir.validation.BaseValidator; +import org.hl7.fhir.validation.TimeTracker; +import org.hl7.fhir.validation.instance.utils.NodeStack; + +public class CodeSystemValidator extends BaseValidator { + + public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker) { + super(context); + source = Source.InstanceValidator; + this.timeTracker = timeTracker; + } + + public void validateCodeSystem(List errors, Element cs, NodeStack stack) { + String url = cs.getNamedChildValue("url"); + String content = cs.getNamedChildValue("content"); + + String vsu = cs.getNamedChildValue("valueSet"); + if (!Utilities.noString(vsu)) { + hint(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), "complete".equals(content), I18nConstants.CODESYSTEM_CS_NO_VS_NOTCOMPLETE); + ValueSet vs; + try { + vs = context.fetchResourceWithException(ValueSet.class, vsu); + } catch (FHIRException e) { + vs = null; + } + if (vs != null) { + if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.hasCompose() && !vs.hasExpansion(), I18nConstants.CODESYSTEM_CS_VS_MISMATCH, url, vsu)) + if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.getCompose().getInclude().size() == 1, I18nConstants.CODESYSTEM_CS_VS_INVALID, url, vsu)) + if (rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), vs.getCompose().getInclude().get(0).getSystem().equals(url), I18nConstants.CODESYSTEM_CS_VS_WRONGSYSTEM, url, vsu, vs.getCompose().getInclude().get(0).getSystem())) { + rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !vs.getCompose().getInclude().get(0).hasValueSet() + && !vs.getCompose().getInclude().get(0).hasConcept() && !vs.getCompose().getInclude().get(0).hasFilter(), I18nConstants.CODESYSTEM_CS_VS_INCLUDEDETAILS, url, vsu); + } + } + } // todo... try getting the value set the other way... + } + + +} diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/MeasureValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/MeasureValidator.java index 9054460c4..81c1ffc57 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/MeasureValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/MeasureValidator.java @@ -116,7 +116,7 @@ public class MeasureValidator extends BaseValidator { String name = cqlRef.substring(0, cqlRef.indexOf(".")); cqlRef = cqlRef.substring(cqlRef.indexOf(".")+1); for (Library l : mctxt.libraries()) { - if (l.getName().equals(name)) { + if (name.equals(l.getName())) { if (rule(errors, IssueType.INVALID, crit.line(), crit.col(), nsc.getLiteralPath(), lib == null, I18nConstants.MEASURE_M_CRITERIA_CQL_LIB_DUPL)) { lib = l; } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/TestingUtilitiesX.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/TestingUtilitiesX.java index 185446742..bfed34ae2 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/TestingUtilitiesX.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/conversion/tests/TestingUtilitiesX.java @@ -42,7 +42,7 @@ import org.hl7.fhir.convertors.R3ToR5Loader; import org.hl7.fhir.convertors.R4ToR5Loader; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext; -import org.hl7.fhir.r5.context.SimpleWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.model.Parameters; import org.hl7.fhir.utilities.CSFile; import org.hl7.fhir.utilities.TextFile; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java index a25485be3..8e2c44e0a 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java @@ -3,10 +3,13 @@ package org.hl7.fhir.validation.tests; import java.io.File; import java.util.UUID; +import org.hl7.fhir.convertors.R5ToR5Loader; import org.hl7.fhir.r5.conformance.ProfileComparer; import org.hl7.fhir.r5.model.FhirPublication; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.utils.KeyGenerator; +import org.hl7.fhir.utilities.cache.PackageCacheManager; +import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.validation.tests.utilities.TestUtilities; @@ -22,7 +25,8 @@ public class ProfileComparisonTests { System.out.println("Compare US Patient Core with AU Patient Base"); ValidationEngine ve = new ValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2"); ve.loadIg("hl7.fhir.us.core#1.0.1", false); - ve.loadIg("hl7.fhir.au.base#dev", false); + ve.loadIg("hl7.fhir.au.base#current", false); + ve.getContext().loadFromPackage(new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.fhir.pubpack", "0.0.4"), new R5ToR5Loader(new String[] {"Binary"}), "Binary"); String left = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"; diff --git a/pom.xml b/pom.xml index 0a87eca61..8cd039b38 100644 --- a/pom.xml +++ b/pom.xml @@ -13,11 +13,12 @@ each other. It is fine to bump the point version of this POM without affecting HAPI FHIR. --> - 4.2.17-SNAPSHOT + 4.2.19-SNAPSHOT 4.2.0 - 1.1.6-SNAPSHOT + 1.1.7-SNAPSHOT + 5.6.2 org.hl7.fhir.core @@ -70,12 +71,23 @@ test + + + org.junit.jupiter + junit-jupiter-api + ${junit_jupiter_version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit_jupiter_version} + test + - - ca.uhn.hapi.fhir hapi-fhir-base diff --git a/release.bat b/release.bat index fc95c073c..46c9f73a6 100644 --- a/release.bat +++ b/release.bat @@ -1,7 +1,7 @@ @echo off -set oldver=4.2.16 -set newver=4.2.17 +set oldver=4.2.18 +set newver=4.2.19 echo .. echo =========================================================================