diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java index b76cd8b3c..797411503 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/advisors/impl/BaseAdvisor_30_50.java @@ -30,6 +30,8 @@ public class BaseAdvisor_30_50 extends BaseAdvisor50 t : src.getConformance()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", new org.hl7.fhir.dstu3.model.CodeType(t.getCode())); + } + if (src.hasRequirement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", MarkDown30_50.convertMarkdown(src.getRequirementElement())); + } + if (src.hasDerivedFrom()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", String30_50.convertString(src.getDerivedFromElement())); + } + for (UrlType ref : src.getSatisfiedBy()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", Uri30_50.convertUrl(ref)); + } + for (UrlType ref : src.getReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", Uri30_50.convertUrl(ref)); + } + for (Reference ref : src.getSource()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source", Reference30_50.convertReference(ref)); + } + } + + + private static void convertRequirementsStatement(Extension src, RequirementsStatementComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key")) { + tgt.setKeyElement(Id30_50.convertId((org.hl7.fhir.dstu3.model.IdType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label")) { + tgt.setLabelElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label").getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance")) { + tgt.addConformance(ConformanceExpectation.fromCode(ext.getValue().primitiveValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement")) { + tgt.setRequirementElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom")) { + tgt.setDerivedFromElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom").getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy")) { + tgt.getSatisfiedBy().add(Uri30_50.convertUrl((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference")) { + tgt.getReference().add(Uri30_50.convertUrl((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source")) { + tgt.getSource().add(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) ext.getValue())); + } + } +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Requirements40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Requirements40_50.java new file mode 100644 index 000000000..5298ee7b7 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Requirements40_50.java @@ -0,0 +1,273 @@ +package org.hl7.fhir.convertors.conv40_50.resources40_50; + +import java.util.stream.Collectors; + +import org.hl7.fhir.convertors.context.ConversionContext40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Annotation40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Id40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Url40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4.model.Extension; +import org.hl7.fhir.r4.model.UriType; +import org.hl7.fhir.r4.utils.ToolingExtensions; +import org.hl7.fhir.r5.model.CanonicalType; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.Enumeration; +import org.hl7.fhir.r5.model.Enumerations.ExampleScenarioActorType; +import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.Requirements.ConformanceExpectation; +import org.hl7.fhir.r5.model.Requirements.RequirementsStatementComponent; +import org.hl7.fhir.r5.model.UrlType; +import org.hl7.fhir.r5.model.UsageContext; + +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*/ +// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 +public class Requirements40_50 { + + public static org.hl7.fhir.r5.model.Requirements convertRequirements(org.hl7.fhir.r4.model.Basic src) throws FHIRException { + if (src == null) + return null; + if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { + throw new FHIRException("Error in logic: this basic resource is not an Requirements"); + } + org.hl7.fhir.r5.model.Requirements tgt = new org.hl7.fhir.r5.model.Requirements(); + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); + + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); + + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url")) { + tgt.setUrlElement(Uri40_50.convertUri((org.hl7.fhir.r4.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version")) { + tgt.setVersionElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name")) { + tgt.setNameElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title")) { + tgt.setTitleElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status")) { + tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status").getValue().primitiveValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental")) { + tgt.setExperimentalElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date")) { + tgt.setDateElement(DateTime40_50.convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher")) { + tgt.setPublisherElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact")) { + tgt.addContact(ContactDetail40_50.convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) ext.getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description")) { + tgt.setPublisherElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext")) { + tgt.addUseContext(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction")) { + tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose")) { + tgt.setPurposeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright")) { + tgt.setCopyrightElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel")) { + tgt.setCopyrightLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom")) { + tgt.getDerivedFrom().add(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor")) { + tgt.getActor().add(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement")) { + convertRequirementsStatement(ext, tgt.addStatement()); + } + return tgt; + } + + + public static org.hl7.fhir.r4.model.Basic convertRequirements(org.hl7.fhir.r5.model.Requirements src) throws FHIRException { + if (src == null) + return null; + org.hl7.fhir.r4.model.Basic tgt = new org.hl7.fhir.r4.model.Basic(); + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); + tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("Requirements"); // note use of R5 type system + + for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); + if (src.hasUrl()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url", Uri40_50.convertUri(src.getUrlElement())); + } + if (src.hasVersion()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version", String40_50.convertString(src.getVersionElement())); + } + if (src.hasName()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name", String40_50.convertString(src.getNameElement())); + } + if (src.hasTitle()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title", String40_50.convertString(src.getTitleElement())); + } + if (src.hasStatus()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status", new org.hl7.fhir.r4.model.CodeType(src.getStatus().toCode())); + } + if (src.hasExperimental()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental", Boolean40_50.convertBoolean(src.getExperimentalElement())); + } + if (src.hasDate()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date", DateTime40_50.convertDateTime(src.getDateElement())); + } + if (src.hasPublisher()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher", String40_50.convertString(src.getPublisherElement())); + } + for (ContactDetail cd : src.getContact()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact", ContactDetail40_50.convertContactDetail(cd)); + } + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement())); + } + for (UsageContext cd : src.getUseContext()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext", UsageContext40_50.convertUsageContext(cd)); + } + for (CodeableConcept cd : src.getJurisdiction()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction", CodeableConcept40_50.convertCodeableConcept(cd)); + } + if (src.hasPurpose()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose", MarkDown40_50.convertMarkdown(src.getPurposeElement())); + } + if (src.hasCopyright()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright", MarkDown40_50.convertMarkdown(src.getCopyrightElement())); + } + if (src.hasCopyrightLabel()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel", String40_50.convertString(src.getCopyrightLabelElement())); + } + for (CanonicalType ref : src.getDerivedFrom()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom", Canonical40_50.convertCanonical(ref)); + } + for (CanonicalType ref : src.getActor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor", Canonical40_50.convertCanonical(ref)); + } + for (RequirementsStatementComponent ref : src.getStatement()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement"); + tgt.addExtension(tgte); + convertRequirementsStatement(ref, tgte); + } + + return tgt; + } + + private static void convertRequirementsStatement(RequirementsStatementComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasKey()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", Id40_50.convertId(src.getKeyElement())); + } + if (src.hasLabel()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", String40_50.convertString(src.getLabelElement())); + } + for (Enumeration t : src.getConformance()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", new org.hl7.fhir.r4.model.CodeType(t.getCode())); + } + if (src.hasRequirement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", MarkDown40_50.convertMarkdown(src.getRequirementElement())); + } + if (src.hasDerivedFrom()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", String40_50.convertString(src.getDerivedFromElement())); + } + for (UrlType ref : src.getSatisfiedBy()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", Url40_50.convertUrl(ref)); + } + for (UrlType ref : src.getReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", Url40_50.convertUrl(ref)); + } + for (Reference ref : src.getSource()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source", Reference40_50.convertReference(ref)); + } + } + + + private static void convertRequirementsStatement(Extension src, RequirementsStatementComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key")) { + tgt.setKeyElement(Id40_50.convertId((org.hl7.fhir.r4.model.IdType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label")) { + tgt.setLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance")) { + tgt.addConformance(ConformanceExpectation.fromCode(ext.getValue().primitiveValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement")) { + tgt.setRequirementElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom")) { + tgt.setDerivedFromElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy")) { + tgt.getSatisfiedBy().add(Url40_50.convertUrl((org.hl7.fhir.r4.model.UrlType) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference")) { + tgt.getReference().add(Url40_50.convertUrl((org.hl7.fhir.r4.model.UrlType) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source")) { + tgt.getSource().add(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) ext.getValue())); + } + } +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java index a999ae1de..426e8b61b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java @@ -53,6 +53,8 @@ public class Resource40_50 { org.hl7.fhir.r4.model.Basic basic = (Basic) src; if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) { return ActorDefinition40_50.convertActorDefinition((org.hl7.fhir.r4.model.Basic) src); + } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { + return Requirements40_50.convertRequirements((org.hl7.fhir.r4.model.Basic) src); } else { return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src); } @@ -468,6 +470,8 @@ public class Resource40_50 { return QuestionnaireResponse40_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) return RelatedPerson40_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r5.model.Requirements) + return Requirements40_50.convertRequirements((org.hl7.fhir.r5.model.Requirements) src); if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) return RiskAssessment40_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); if (src instanceof org.hl7.fhir.r5.model.Schedule) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Requirements43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Requirements43_50.java new file mode 100644 index 000000000..dbc13e213 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Requirements43_50.java @@ -0,0 +1,273 @@ +package org.hl7.fhir.convertors.conv43_50.resources43_50; + +import java.util.stream.Collectors; + +import org.hl7.fhir.convertors.context.ConversionContext43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Annotation43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Canonical43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Id43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Url43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4b.model.Extension; +import org.hl7.fhir.r4b.model.UriType; +import org.hl7.fhir.r4b.utils.ToolingExtensions; +import org.hl7.fhir.r5.model.CanonicalType; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.Enumeration; +import org.hl7.fhir.r5.model.Enumerations.ExampleScenarioActorType; +import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.Requirements.ConformanceExpectation; +import org.hl7.fhir.r5.model.Requirements.RequirementsStatementComponent; +import org.hl7.fhir.r5.model.UrlType; +import org.hl7.fhir.r5.model.UsageContext; + +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*/ +// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 +public class Requirements43_50 { + + public static org.hl7.fhir.r5.model.Requirements convertRequirements(org.hl7.fhir.r4b.model.Basic src) throws FHIRException { + if (src == null) + return null; + if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { + throw new FHIRException("Error in logic: this basic resource is not an Requirements"); + } + org.hl7.fhir.r5.model.Requirements tgt = new org.hl7.fhir.r5.model.Requirements(); + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); + + for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); + + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url")) { + tgt.setUrlElement(Uri43_50.convertUri((org.hl7.fhir.r4b.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version")) { + tgt.setVersionElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name")) { + tgt.setNameElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title")) { + tgt.setTitleElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status")) { + tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status").getValue().primitiveValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental")) { + tgt.setExperimentalElement(Boolean43_50.convertBoolean((org.hl7.fhir.r4b.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date")) { + tgt.setDateElement(DateTime43_50.convertDateTime((org.hl7.fhir.r4b.model.DateTimeType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher")) { + tgt.setPublisherElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact")) { + tgt.addContact(ContactDetail43_50.convertContactDetail((org.hl7.fhir.r4b.model.ContactDetail) ext.getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description")) { + tgt.setPublisherElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext")) { + tgt.addUseContext(UsageContext43_50.convertUsageContext((org.hl7.fhir.r4b.model.UsageContext) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction")) { + tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) ext.getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose")) { + tgt.setPurposeElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright")) { + tgt.setCopyrightElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel")) { + tgt.setCopyrightLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom")) { + tgt.getDerivedFrom().add(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor")) { + tgt.getActor().add(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement")) { + convertRequirementsStatement(ext, tgt.addStatement()); + } + return tgt; + } + + + public static org.hl7.fhir.r4b.model.Basic convertRequirements(org.hl7.fhir.r5.model.Requirements src) throws FHIRException { + if (src == null) + return null; + org.hl7.fhir.r4b.model.Basic tgt = new org.hl7.fhir.r4b.model.Basic(); + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); + tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("Requirements"); // note use of R5 type system + + for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) + tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); + if (src.hasUrl()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url", Uri43_50.convertUri(src.getUrlElement())); + } + if (src.hasVersion()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version", String43_50.convertString(src.getVersionElement())); + } + if (src.hasName()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name", String43_50.convertString(src.getNameElement())); + } + if (src.hasTitle()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title", String43_50.convertString(src.getTitleElement())); + } + if (src.hasStatus()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status", new org.hl7.fhir.r4b.model.CodeType(src.getStatus().toCode())); + } + if (src.hasExperimental()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental", Boolean43_50.convertBoolean(src.getExperimentalElement())); + } + if (src.hasDate()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date", DateTime43_50.convertDateTime(src.getDateElement())); + } + if (src.hasPublisher()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher", String43_50.convertString(src.getPublisherElement())); + } + for (ContactDetail cd : src.getContact()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact", ContactDetail43_50.convertContactDetail(cd)); + } + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description", MarkDown43_50.convertMarkdown(src.getDescriptionElement())); + } + for (UsageContext cd : src.getUseContext()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext", UsageContext43_50.convertUsageContext(cd)); + } + for (CodeableConcept cd : src.getJurisdiction()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction", CodeableConcept43_50.convertCodeableConcept(cd)); + } + if (src.hasPurpose()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose", MarkDown43_50.convertMarkdown(src.getPurposeElement())); + } + if (src.hasCopyright()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright", MarkDown43_50.convertMarkdown(src.getCopyrightElement())); + } + if (src.hasCopyrightLabel()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel", String43_50.convertString(src.getCopyrightLabelElement())); + } + for (CanonicalType ref : src.getDerivedFrom()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom", Canonical43_50.convertCanonical(ref)); + } + for (CanonicalType ref : src.getActor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor", Canonical43_50.convertCanonical(ref)); + } + for (RequirementsStatementComponent ref : src.getStatement()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement"); + tgt.addExtension(tgte); + convertRequirementsStatement(ref, tgte); + } + + return tgt; + } + + private static void convertRequirementsStatement(RequirementsStatementComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasKey()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", Id43_50.convertId(src.getKeyElement())); + } + if (src.hasLabel()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", String43_50.convertString(src.getLabelElement())); + } + for (Enumeration t : src.getConformance()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", new org.hl7.fhir.r4b.model.CodeType(t.getCode())); + } + if (src.hasRequirement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", MarkDown43_50.convertMarkdown(src.getRequirementElement())); + } + if (src.hasDerivedFrom()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", String43_50.convertString(src.getDerivedFromElement())); + } + for (UrlType ref : src.getSatisfiedBy()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", Url43_50.convertUrl(ref)); + } + for (UrlType ref : src.getReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", Url43_50.convertUrl(ref)); + } + for (Reference ref : src.getSource()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source", Reference43_50.convertReference(ref)); + } + } + + + private static void convertRequirementsStatement(Extension src, RequirementsStatementComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key")) { + tgt.setKeyElement(Id43_50.convertId((org.hl7.fhir.r4b.model.IdType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label")) { + tgt.setLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance")) { + tgt.addConformance(ConformanceExpectation.fromCode(ext.getValue().primitiveValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement")) { + tgt.setRequirementElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom")) { + tgt.setDerivedFromElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy")) { + tgt.getSatisfiedBy().add(Url43_50.convertUrl((org.hl7.fhir.r4b.model.UrlType) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference")) { + tgt.getReference().add(Url43_50.convertUrl((org.hl7.fhir.r4b.model.UrlType) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source")) { + tgt.getSource().add(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) ext.getValue())); + } + } +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java index 9a8463b34..335fd9706 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java @@ -55,6 +55,8 @@ public class Resource43_50 { org.hl7.fhir.r4b.model.Basic basic = (org.hl7.fhir.r4b.model.Basic) src; if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) { return ActorDefinition43_50.convertActorDefinition((org.hl7.fhir.r4b.model.Basic) src); + } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { + return Requirements43_50.convertRequirements((org.hl7.fhir.r4b.model.Basic) src); } else { return Basic43_50.convertBasic((org.hl7.fhir.r4b.model.Basic) src); } @@ -460,6 +462,8 @@ public class Resource43_50 { return QuestionnaireResponse43_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) return RelatedPerson43_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r5.model.Requirements) + return Requirements43_50.convertRequirements((org.hl7.fhir.r5.model.Requirements) src); if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) return RiskAssessment43_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); if (src instanceof org.hl7.fhir.r5.model.Schedule) diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/ActorDefinition30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/ActorDefinition30_50Test.java index 5f5735718..86edeafd5 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/ActorDefinition30_50Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/ActorDefinition30_50Test.java @@ -36,52 +36,4 @@ public class ActorDefinition30_50Test { assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); } - -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion.") -// public void testR4_R5() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_base64binary.xml"); -// -// org.hl7.fhir.dstu3.model.AuditEvent r4_actual = (org.hl7.fhir.dstu3.model.AuditEvent) new org.hl7.fhir.dstu3.formats.XmlParser().parse(r4_input); -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_30_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// -// } -// -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion with invalid Base64Binary.") -// public void testR4_R5BadBase64Binary() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_invalid_base64binary.xml"); -// -// org.hl7.fhir.dstu3.model.AuditEvent r4_actual = (org.hl7.fhir.dstu3.model.AuditEvent) new org.hl7.fhir.dstu3.formats.XmlParser().parse(r4_input); -// -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_30_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// System.out.println(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQueryElement().getValueAsString()); -// -// //FIXME we should not be even getting this far. -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// -// } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/Requirements30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/Requirements30_50Test.java new file mode 100644 index 000000000..c1c629b8e --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/Requirements30_50Test.java @@ -0,0 +1,40 @@ +package org.hl7.fhir.convertors.conv30_50; + +import org.apache.commons.codec.binary.Base64; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class Requirements30_50Test { + + + @Test + @DisplayName("Test r5 -> r3 Requirements conversion.") + public void testR5_R4() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/requirements_50_example.json"); + + org.hl7.fhir.r5.model.Requirements r5_actual = (org.hl7.fhir.r5.model.Requirements) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input); + org.hl7.fhir.dstu3.model.Resource r4_conv = VersionConvertorFactory_30_50.convertResource(r5_actual); + + org.hl7.fhir.dstu3.formats.XmlParser r4_parser = new org.hl7.fhir.dstu3.formats.XmlParser(); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + r4_parser.compose(stream, r4_conv); + + org.hl7.fhir.dstu3.model.Resource r4_streamed = (org.hl7.fhir.dstu3.model.Basic) new org.hl7.fhir.dstu3.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); + org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_30_50.convertResource(r4_streamed); + + assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); + } + +} diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/ActorDefinition40_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/ActorDefinition40_50Test.java index 4d3e361c1..313303ca2 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/ActorDefinition40_50Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/ActorDefinition40_50Test.java @@ -36,52 +36,4 @@ public class ActorDefinition40_50Test { assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); } - -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion.") -// public void testR4_R5() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_base64binary.xml"); -// -// org.hl7.fhir.r4.model.AuditEvent r4_actual = (org.hl7.fhir.r4.model.AuditEvent) new org.hl7.fhir.r4.formats.XmlParser().parse(r4_input); -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// -// } -// -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion with invalid Base64Binary.") -// public void testR4_R5BadBase64Binary() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_invalid_base64binary.xml"); -// -// org.hl7.fhir.r4.model.AuditEvent r4_actual = (org.hl7.fhir.r4.model.AuditEvent) new org.hl7.fhir.r4.formats.XmlParser().parse(r4_input); -// -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// System.out.println(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQueryElement().getValueAsString()); -// -// //FIXME we should not be even getting this far. -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// -// } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/Requirements40_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/Requirements40_50Test.java new file mode 100644 index 000000000..136dc299d --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/Requirements40_50Test.java @@ -0,0 +1,40 @@ +package org.hl7.fhir.convertors.conv40_50; + +import org.apache.commons.codec.binary.Base64; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class Requirements40_50Test { + + + @Test + @DisplayName("Test r5 -> r4 Requirements conversion.") + public void testR5_R4() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/requirements_50_example.json"); + + org.hl7.fhir.r5.model.Requirements r5_actual = (org.hl7.fhir.r5.model.Requirements) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input); + org.hl7.fhir.r4.model.Resource r4_conv = VersionConvertorFactory_40_50.convertResource(r5_actual); + + org.hl7.fhir.r4.formats.XmlParser r4_parser = new org.hl7.fhir.r4.formats.XmlParser(); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + r4_parser.compose(stream, r4_conv); + + org.hl7.fhir.r4.model.Resource r4_streamed = (org.hl7.fhir.r4.model.Basic) new org.hl7.fhir.r4.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); + org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_streamed); + + assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); + } + +} diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/ActorDefinition43_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/ActorDefinition43_50Test.java index 6d97d70d6..593a64494 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/ActorDefinition43_50Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/ActorDefinition43_50Test.java @@ -36,51 +36,4 @@ public class ActorDefinition43_50Test { assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); } -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion.") -// public void testR4_R5() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_base64binary.xml"); -// -// org.hl7.fhir.r4b.model.AuditEvent r4_actual = (org.hl7.fhir.r4b.model.AuditEvent) new org.hl7.fhir.r4b.formats.XmlParser().parse(r4_input); -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY); -// -// } -// -// @Test -// @DisplayName("Test r5 -> r4 AuditEvent conversion with invalid Base64Binary.") -// public void testR4_R5BadBase64Binary() throws IOException { -// InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_invalid_base64binary.xml"); -// -// org.hl7.fhir.r4b.model.AuditEvent r4_actual = (org.hl7.fhir.r4b.model.AuditEvent) new org.hl7.fhir.r4b.formats.XmlParser().parse(r4_input); -// -// org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4_actual); -// -// org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser(); -// -// ByteArrayOutputStream stream -// = new ByteArrayOutputStream(); -// -// r5_parser.compose(stream, r5_conv); -// -// org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); -// -// System.out.println(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQueryElement().getValueAsString()); -// -// //FIXME we should not be even getting this far. -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY); -// -// } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/Requirements43_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/Requirements43_50Test.java new file mode 100644 index 000000000..a2f6dbd65 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/Requirements43_50Test.java @@ -0,0 +1,40 @@ +package org.hl7.fhir.convertors.conv43_50; + +import org.apache.commons.codec.binary.Base64; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class Requirements43_50Test { + + + @Test + @DisplayName("Test r5 -> r4 Requirements conversion.") + public void testR5_R4() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/requirements_50_example.json"); + + org.hl7.fhir.r5.model.Requirements r5_actual = (org.hl7.fhir.r5.model.Requirements) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input); + org.hl7.fhir.r4b.model.Resource r4_conv = VersionConvertorFactory_43_50.convertResource(r5_actual); + + org.hl7.fhir.r4b.formats.XmlParser r4_parser = new org.hl7.fhir.r4b.formats.XmlParser(); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + r4_parser.compose(stream, r4_conv); + + org.hl7.fhir.r4b.model.Resource r4_streamed = (org.hl7.fhir.r4b.model.Basic) new org.hl7.fhir.r4b.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); + org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4_streamed); + + assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); + } + +} diff --git a/org.hl7.fhir.convertors/src/test/resources/requirements_50_example.json b/org.hl7.fhir.convertors/src/test/resources/requirements_50_example.json new file mode 100644 index 000000000..cc9a473fd --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/requirements_50_example.json @@ -0,0 +1,52 @@ +{ + "resourceType": "Requirements", + "id": "example1", + "text": { + "status": "generated", + "div": "

Generated Narrative: Requirements

Resource Requirements "example1"

url: http://hl7.org/fhir/Requirements/example1

identifier: id: urn:oid:2.16.840.1.113883.4.642.18.1

name: ExampleRequirements1

title: Example Requirements Set 1

status: active

date: 2021-11-02T14:31:30.239Z

actor: http://hl7.org/fhir/ActorDefinition/server

statement

key: req-1

conformance: SHALL

requirement: The server SHALL support expanding value sets

satisfiedBy: http://hl7.org/fhir/terminology-service.html#expand

source: : Grahame Grieve

statement

key: 46f77dcd-d51e-4738-b61f-22506d0cb0ac

label: requirement-2

conformance: SHALL

requirement: Operations based on the codeSystem resource SHALL have the same result whether or not the relationships are represented explicitly as properties or implicitly using the CodeSystem resource hierarchy

source: : Jose Costa Teixeira

" + }, + "url": "http://hl7.org/fhir/Requirements/example1", + "identifier": [ + { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:2.16.840.1.113883.4.642.18.1" + } + ], + "name": "ExampleRequirements1", + "title": "Example Requirements Set 1", + "status": "active", + "date": "2021-11-02T14:31:30.239Z", + "actor": [ + "http://hl7.org/fhir/ActorDefinition/server" + ], + "statement": [ + { + "key": "req-1", + "conformance": [ + "SHALL" + ], + "requirement": "The server SHALL support expanding value sets", + "satisfiedBy": [ + "http://hl7.org/fhir/terminology-service.html#expand" + ], + "source": [ + { + "display": "Grahame Grieve" + } + ] + }, + { + "key": "46f77dcd-d51e-4738-b61f-22506d0cb0ac", + "label": "requirement-2", + "conformance": [ + "SHALL" + ], + "requirement": "Operations based on the codeSystem resource SHALL have the same result whether or not the relationships are represented explicitly as properties or implicitly using the CodeSystem resource hierarchy", + "source": [ + { + "display": "Jose Costa Teixeira" + } + ] + } + ] +} \ No newline at end of file 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 ea5ff3777..c9810c4db 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 @@ -173,6 +173,23 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE return getExtension().get(0); } + + public Extension getExtensionByUrl(String theUrl) { + org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); + ArrayList retVal = new ArrayList(); + for (Extension next : getExtension()) { + if (theUrl.equals(next.getUrl())) { + retVal.add(next); + } + } + if (retVal.size() == 0) + return null; + else { + org.apache.commons.lang3.Validate.isTrue(retVal.size() == 1, "Url "+theUrl+" must have only one match"); + return retVal.get(0); + } + } + /** * Returns an unmodifiable list containing all extensions on this element which * match the given URL. diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Property.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Property.java index 8011b3f85..7cc8b2e85 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Property.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Property.java @@ -300,7 +300,7 @@ public class Property { } - protected List getChildProperties(String elementName, String statedType) throws FHIRException { + public List getChildProperties(String elementName, String statedType) throws FHIRException { ElementDefinition ed = definition; StructureDefinition sd = structure; SourcedChildDefinitions children = profileUtilities.getChildMap(sd, ed);