Add support for ActorDefinition

This commit is contained in:
Grahame Grieve 2022-10-17 11:43:33 +11:00
parent 82e659c8cc
commit b17735a15b
23 changed files with 1487 additions and 42 deletions

View File

@ -28,6 +28,8 @@ public class BaseAdvisor_30_50 extends BaseAdvisor50<org.hl7.fhir.dstu3.model.Ex
List<String> paths = Arrays.asList(path.split(","));
if ((paths.get(paths.size() - 1).equals("ValueSet")) && (valueSetIgnoredUrls.contains(url))) {
return true;
} else if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.")) {
return true;
} else
return (paths.get(paths.size() - 1).equals("CapabilityStatement")) && (capabilityStatementIgnoredUrls.contains(url));
}

View File

@ -33,6 +33,8 @@ public class BaseAdvisor_40_50 extends BaseAdvisor50<org.hl7.fhir.r4.model.Exten
List<String> paths = Arrays.asList(path.split(","));
if ((paths.get(paths.size() - 1).equals("TestScript")) && (TestScriptIgnoredUrls.contains(url))) {
return true;
} else if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.")) {
return true;
} else
return false;
}

View File

@ -26,6 +26,8 @@ public class BaseAdvisor_43_50 extends BaseAdvisor50<org.hl7.fhir.r4b.model.Exte
List<String> paths = Arrays.asList(path.split(","));
if ((paths.get(paths.size() - 1).equals("TestScript")) && (TestScriptIgnoredUrls.contains(url))) {
return true;
} else if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.")) {
return true;
} else
return false;
}

View File

@ -8,6 +8,7 @@ import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Narrative30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Id30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.ActivityDefinition30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.ActorDefinition30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.AllergyIntolerance30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.Appointment30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.AppointmentResponse30_50;
@ -86,7 +87,10 @@ import org.hl7.fhir.convertors.conv30_50.resources30_50.SupplyDelivery30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.TestReport30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.TestScript30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.ValueSet30_50;
import org.hl7.fhir.convertors.conv40_50.resources40_50.ActorDefinition40_50;
import org.hl7.fhir.convertors.conv40_50.resources40_50.Basic40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.dstu3.model.Basic;
public class Resource30_50 {
@ -124,8 +128,14 @@ public class Resource30_50 {
return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src);
if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent)
return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src);
if (src instanceof org.hl7.fhir.dstu3.model.Basic)
return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src);
if (src instanceof org.hl7.fhir.dstu3.model.Basic) {
org.hl7.fhir.dstu3.model.Basic basic = (Basic) src;
if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
return ActorDefinition30_50.convertActorDefinition((org.hl7.fhir.dstu3.model.Basic) src);
} else {
return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src);
}
}
if (src instanceof org.hl7.fhir.dstu3.model.Binary)
return Binary30_50.convertBinary((org.hl7.fhir.dstu3.model.Binary) src);
if (src instanceof org.hl7.fhir.dstu3.model.BodySite)
@ -280,6 +290,8 @@ public class Resource30_50 {
}
if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition)
return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.ActorDefinition)
return ActorDefinition30_50.convertActorDefinition((org.hl7.fhir.r5.model.ActorDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance)
return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src);
if (src instanceof org.hl7.fhir.r5.model.Appointment)
@ -288,7 +300,8 @@ public class Resource30_50 {
return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src);
if (src instanceof org.hl7.fhir.r5.model.AuditEvent)
return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src);
if (src instanceof org.hl7.fhir.r5.model.Basic) return Basic30_50.convertBasic((org.hl7.fhir.r5.model.Basic) src);
if (src instanceof org.hl7.fhir.r5.model.Basic)
return Basic30_50.convertBasic((org.hl7.fhir.r5.model.Basic) src);
if (src instanceof org.hl7.fhir.r5.model.Binary)
return Binary30_50.convertBinary((org.hl7.fhir.r5.model.Binary) src);
if (src instanceof org.hl7.fhir.r5.model.BodyStructure)

View File

@ -4,6 +4,7 @@ import org.hl7.fhir.convertors.context.ConversionContext30_50;
import org.hl7.fhir.exceptions.FHIRException;
public class Uri30_50 {
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 = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValueAsString()) : new org.hl7.fhir.r5.model.UriType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
@ -16,6 +17,30 @@ public class Uri30_50 {
return tgt;
}
public static org.hl7.fhir.r5.model.UrlType convertUrl(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException {
org.hl7.fhir.r5.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UrlType(src.getValueAsString()) : new org.hl7.fhir.r5.model.UrlType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
return tgt;
}
public static org.hl7.fhir.dstu3.model.UriType convertUrl(org.hl7.fhir.r5.model.UrlType src) throws FHIRException {
org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.UriType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
return tgt;
}
public static org.hl7.fhir.r5.model.CanonicalType convertCanonical(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException {
org.hl7.fhir.r5.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CanonicalType(src.getValueAsString()) : new org.hl7.fhir.r5.model.CanonicalType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
return tgt;
}
public static org.hl7.fhir.dstu3.model.UriType convertCanonical(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException {
org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.UriType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().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 = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);

View File

@ -0,0 +1,207 @@
package org.hl7.fhir.convertors.conv30_50.resources30_50;
import java.util.stream.Collectors;
import org.hl7.fhir.convertors.context.ConversionContext30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.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.Enumerations.ExampleScenarioActorType;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
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 ActorDefinition30_50 {
public static org.hl7.fhir.r5.model.ActorDefinition convertActorDefinition(org.hl7.fhir.dstu3.model.Basic src) throws FHIRException {
if (src == null)
return null;
if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
throw new FHIRException("Error in logic: this basic resource is not an ActorDefinition");
}
org.hl7.fhir.r5.model.ActorDefinition tgt = new org.hl7.fhir.r5.model.ActorDefinition();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url")) {
tgt.setUrlElement(Uri30_50.convertUri((org.hl7.fhir.dstu3.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version")) {
tgt.setVersionElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name")) {
tgt.setNameElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title")) {
tgt.setTitleElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status")) {
tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental")) {
tgt.setExperimentalElement(Boolean30_50.convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date")) {
tgt.setDateElement(DateTime30_50.convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher")) {
tgt.setPublisherElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.contact")) {
tgt.addContact(ContactDetail30_50.convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) ext.getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description")) {
tgt.setPublisherElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.useContext")) {
tgt.addUseContext(UsageContext30_50.convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) ext.getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.jurisdiction")) {
tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) ext.getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose")) {
tgt.setPurposeElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright")) {
tgt.setCopyrightElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel")) {
tgt.setCopyrightLabelElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type")) {
tgt.setType(ExampleScenarioActorType.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation")) {
tgt.setDocumentationElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference")) {
tgt.getReference().add(Uri30_50.convertUrl((org.hl7.fhir.dstu3.model.UriType) ext.getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities")) {
tgt.setCapabilitiesElement(Uri30_50.convertCanonical((org.hl7.fhir.dstu3.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom")) {
tgt.getDerivedFrom().add(Uri30_50.convertCanonical((org.hl7.fhir.dstu3.model.UriType) ext.getValue()));
}
return tgt;
}
public static org.hl7.fhir.dstu3.model.Basic convertActorDefinition(org.hl7.fhir.r5.model.ActorDefinition src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.Basic tgt = new org.hl7.fhir.dstu3.model.Basic();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("ActorDefinition"); // note use of R5 type system
for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
if (src.hasUrl()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url", Uri30_50.convertUri(src.getUrlElement()));
}
if (src.hasVersion()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version", String30_50.convertString(src.getVersionElement()));
}
if (src.hasName()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name", String30_50.convertString(src.getNameElement()));
}
if (src.hasTitle()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title", String30_50.convertString(src.getTitleElement()));
}
if (src.hasStatus()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status", new org.hl7.fhir.dstu3.model.CodeType(src.getStatus().toCode()));
}
if (src.hasExperimental()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental", Boolean30_50.convertBoolean(src.getExperimentalElement()));
}
if (src.hasDate()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date", DateTime30_50.convertDateTime(src.getDateElement()));
}
if (src.hasPublisher()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher", String30_50.convertString(src.getPublisherElement()));
}
for (ContactDetail cd : src.getContact()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.contact", ContactDetail30_50.convertContactDetail(cd));
}
if (src.hasDescription()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description", MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
}
for (UsageContext cd : src.getUseContext()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.useContext", UsageContext30_50.convertUsageContext(cd));
}
for (CodeableConcept cd : src.getJurisdiction()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.jurisdiction", CodeableConcept30_50.convertCodeableConcept(cd));
}
if (src.hasPurpose()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose", MarkDown30_50.convertMarkdown(src.getPurposeElement()));
}
if (src.hasCopyright()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright", MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
}
if (src.hasCopyrightLabel()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel", String30_50.convertString(src.getCopyrightLabelElement()));
}
if (src.hasType()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type", new org.hl7.fhir.dstu3.model.CodeType(src.getType().toCode()));
}
if (src.hasDocumentation()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation", MarkDown30_50.convertMarkdown(src.getDocumentationElement()));
}
for (UrlType ref : src.getReference()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference", Uri30_50.convertUrl(ref));
}
if (src.hasCapabilities()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities", Uri30_50.convertCanonical(src.getCapabilitiesElement()));
}
for (CanonicalType ct : src.getDerivedFrom()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom", Uri30_50.convertCanonical(ct));
}
return tgt;
}
}

View File

@ -0,0 +1,211 @@
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.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.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.Enumerations.ExampleScenarioActorType;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
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 ActorDefinition40_50 {
public static org.hl7.fhir.r5.model.ActorDefinition convertActorDefinition(org.hl7.fhir.r4.model.Basic src) throws FHIRException {
if (src == null)
return null;
if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
throw new FHIRException("Error in logic: this basic resource is not an ActorDefinition");
}
org.hl7.fhir.r5.model.ActorDefinition tgt = new org.hl7.fhir.r5.model.ActorDefinition();
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-ActorDefinition.url")) {
tgt.setUrlElement(Uri40_50.convertUri((org.hl7.fhir.r4.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version")) {
tgt.setVersionElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name")) {
tgt.setNameElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title")) {
tgt.setTitleElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status")) {
tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental")) {
tgt.setExperimentalElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date")) {
tgt.setDateElement(DateTime40_50.convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher")) {
tgt.setPublisherElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher").getValue()));
}
for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.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-ActorDefinition.description")) {
tgt.setPublisherElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description").getValue()));
}
for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.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-ActorDefinition.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-ActorDefinition.purpose")) {
tgt.setPurposeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright")) {
tgt.setCopyrightElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel")) {
tgt.setCopyrightLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type")) {
tgt.setType(ExampleScenarioActorType.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation")) {
tgt.setDocumentationElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation").getValue()));
}
for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference")) {
tgt.getReference().add(Url40_50.convertUrl((org.hl7.fhir.r4.model.UrlType) ext.getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities")) {
tgt.setCapabilitiesElement(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities").getValue()));
}
for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom")) {
tgt.getDerivedFrom().add(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType) ext.getValue()));
}
return tgt;
}
public static org.hl7.fhir.r4.model.Basic convertActorDefinition(org.hl7.fhir.r5.model.ActorDefinition 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("ActorDefinition"); // 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-ActorDefinition.url", Uri40_50.convertUri(src.getUrlElement()));
}
if (src.hasVersion()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version", String40_50.convertString(src.getVersionElement()));
}
if (src.hasName()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name", String40_50.convertString(src.getNameElement()));
}
if (src.hasTitle()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title", String40_50.convertString(src.getTitleElement()));
}
if (src.hasStatus()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status", new org.hl7.fhir.r4.model.CodeType(src.getStatus().toCode()));
}
if (src.hasExperimental()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental", Boolean40_50.convertBoolean(src.getExperimentalElement()));
}
if (src.hasDate()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date", DateTime40_50.convertDateTime(src.getDateElement()));
}
if (src.hasPublisher()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher", String40_50.convertString(src.getPublisherElement()));
}
for (ContactDetail cd : src.getContact()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.contact", ContactDetail40_50.convertContactDetail(cd));
}
if (src.hasDescription()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
}
for (UsageContext cd : src.getUseContext()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.useContext", UsageContext40_50.convertUsageContext(cd));
}
for (CodeableConcept cd : src.getJurisdiction()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.jurisdiction", CodeableConcept40_50.convertCodeableConcept(cd));
}
if (src.hasPurpose()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose", MarkDown40_50.convertMarkdown(src.getPurposeElement()));
}
if (src.hasCopyright()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright", MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
}
if (src.hasCopyrightLabel()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel", String40_50.convertString(src.getCopyrightLabelElement()));
}
if (src.hasType()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type", new org.hl7.fhir.r4.model.CodeType(src.getType().toCode()));
}
if (src.hasDocumentation()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation", MarkDown40_50.convertMarkdown(src.getDocumentationElement()));
}
for (UrlType ref : src.getReference()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference", Url40_50.convertUrl(ref));
}
if (src.hasCapabilities()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities", Canonical40_50.convertCanonical(src.getCapabilitiesElement()));
}
for (CanonicalType ct : src.getDerivedFrom()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom", Canonical40_50.convertCanonical(ct));
}
return tgt;
}
}

View File

@ -9,6 +9,7 @@ import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Extension40
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Meta40_50;
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Narrative40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Basic;
public class Resource40_50 {
@ -48,7 +49,14 @@ public class Resource40_50 {
return AppointmentResponse40_50.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src);
if (src instanceof org.hl7.fhir.r4.model.AuditEvent)
return AuditEvent40_50.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src);
if (src instanceof org.hl7.fhir.r4.model.Basic) return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src);
if (src instanceof org.hl7.fhir.r4.model.Basic) {
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 {
return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src);
}
}
if (src instanceof org.hl7.fhir.r4.model.Binary)
return Binary40_50.convertBinary((org.hl7.fhir.r4.model.Binary) src);
if (src instanceof org.hl7.fhir.r4.model.BiologicallyDerivedProduct)
@ -281,6 +289,8 @@ public class Resource40_50 {
return ActivityDefinition40_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance)
return AllergyIntolerance40_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src);
if (src instanceof org.hl7.fhir.r5.model.ActorDefinition)
return ActorDefinition40_50.convertActorDefinition((org.hl7.fhir.r5.model.ActorDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.Appointment)
return Appointment40_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src);
if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse)

View File

@ -0,0 +1,211 @@
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.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.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.Enumerations.ExampleScenarioActorType;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
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 ActorDefinition43_50 {
public static org.hl7.fhir.r5.model.ActorDefinition convertActorDefinition(org.hl7.fhir.r4b.model.Basic src) throws FHIRException {
if (src == null)
return null;
if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
throw new FHIRException("Error in logic: this basic resource is not an ActorDefinition");
}
org.hl7.fhir.r5.model.ActorDefinition tgt = new org.hl7.fhir.r5.model.ActorDefinition();
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-ActorDefinition.url")) {
tgt.setUrlElement(Uri43_50.convertUri((org.hl7.fhir.r4b.model.UriType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version")) {
tgt.setVersionElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name")) {
tgt.setNameElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title")) {
tgt.setTitleElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status")) {
tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental")) {
tgt.setExperimentalElement(Boolean43_50.convertBoolean((org.hl7.fhir.r4b.model.BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date")) {
tgt.setDateElement(DateTime43_50.convertDateTime((org.hl7.fhir.r4b.model.DateTimeType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher")) {
tgt.setPublisherElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher").getValue()));
}
for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.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-ActorDefinition.description")) {
tgt.setPublisherElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description").getValue()));
}
for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.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-ActorDefinition.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-ActorDefinition.purpose")) {
tgt.setPurposeElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright")) {
tgt.setCopyrightElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel")) {
tgt.setCopyrightLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel").getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type")) {
tgt.setType(ExampleScenarioActorType.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type").getValue().primitiveValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation")) {
tgt.setDocumentationElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation").getValue()));
}
for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference")) {
tgt.getReference().add(Url43_50.convertUrl((org.hl7.fhir.r4b.model.UrlType) ext.getValue()));
}
if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities")) {
tgt.setCapabilitiesElement(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities").getValue()));
}
for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom")) {
tgt.getDerivedFrom().add(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) ext.getValue()));
}
return tgt;
}
public static org.hl7.fhir.r4b.model.Basic convertActorDefinition(org.hl7.fhir.r5.model.ActorDefinition 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("ActorDefinition"); // 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-ActorDefinition.url", Uri43_50.convertUri(src.getUrlElement()));
}
if (src.hasVersion()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version", String43_50.convertString(src.getVersionElement()));
}
if (src.hasName()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name", String43_50.convertString(src.getNameElement()));
}
if (src.hasTitle()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title", String43_50.convertString(src.getTitleElement()));
}
if (src.hasStatus()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status", new org.hl7.fhir.r4b.model.CodeType(src.getStatus().toCode()));
}
if (src.hasExperimental()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental", Boolean43_50.convertBoolean(src.getExperimentalElement()));
}
if (src.hasDate()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date", DateTime43_50.convertDateTime(src.getDateElement()));
}
if (src.hasPublisher()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher", String43_50.convertString(src.getPublisherElement()));
}
for (ContactDetail cd : src.getContact()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.contact", ContactDetail43_50.convertContactDetail(cd));
}
if (src.hasDescription()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description", MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
}
for (UsageContext cd : src.getUseContext()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.useContext", UsageContext43_50.convertUsageContext(cd));
}
for (CodeableConcept cd : src.getJurisdiction()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.jurisdiction", CodeableConcept43_50.convertCodeableConcept(cd));
}
if (src.hasPurpose()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose", MarkDown43_50.convertMarkdown(src.getPurposeElement()));
}
if (src.hasCopyright()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright", MarkDown43_50.convertMarkdown(src.getCopyrightElement()));
}
if (src.hasCopyrightLabel()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel", String43_50.convertString(src.getCopyrightLabelElement()));
}
if (src.hasType()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type", new org.hl7.fhir.r4b.model.CodeType(src.getType().toCode()));
}
if (src.hasDocumentation()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation", MarkDown43_50.convertMarkdown(src.getDocumentationElement()));
}
for (UrlType ref : src.getReference()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference", Url43_50.convertUrl(ref));
}
if (src.hasCapabilities()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities", Canonical43_50.convertCanonical(src.getCapabilitiesElement()));
}
for (CanonicalType ct : src.getDerivedFrom()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom", Canonical43_50.convertCanonical(ct));
}
return tgt;
}
}

View File

@ -2,6 +2,8 @@ package org.hl7.fhir.convertors.conv43_50.resources43_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_50;
import org.hl7.fhir.convertors.context.ConversionContext43_50;
import org.hl7.fhir.convertors.conv40_50.resources40_50.ActorDefinition40_50;
import org.hl7.fhir.convertors.conv40_50.resources40_50.Basic40_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Code43_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.Uri43_50;
@ -9,6 +11,7 @@ import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Extension43
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Meta43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Narrative43_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Basic;
public class Resource43_50 {
@ -48,7 +51,14 @@ public class Resource43_50 {
return AppointmentResponse43_50.convertAppointmentResponse((org.hl7.fhir.r4b.model.AppointmentResponse) src);
if (src instanceof org.hl7.fhir.r4b.model.AuditEvent)
return AuditEvent43_50.convertAuditEvent((org.hl7.fhir.r4b.model.AuditEvent) src);
if (src instanceof org.hl7.fhir.r4b.model.Basic) return Basic43_50.convertBasic((org.hl7.fhir.r4b.model.Basic) src);
if (src instanceof org.hl7.fhir.r4b.model.Basic) {
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 {
return Basic43_50.convertBasic((org.hl7.fhir.r4b.model.Basic) src);
}
}
if (src instanceof org.hl7.fhir.r4b.model.Binary)
return Binary43_50.convertBinary((org.hl7.fhir.r4b.model.Binary) src);
if (src instanceof org.hl7.fhir.r4b.model.BiologicallyDerivedProduct)
@ -269,6 +279,8 @@ public class Resource43_50 {
return Account43_50.convertAccount((org.hl7.fhir.r5.model.Account) src);
if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition)
return ActivityDefinition43_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.ActorDefinition)
return ActorDefinition43_50.convertActorDefinition((org.hl7.fhir.r5.model.ActorDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance)
return AllergyIntolerance43_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src);
if (src instanceof org.hl7.fhir.r5.model.Appointment)

View File

@ -0,0 +1,87 @@
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 ActorDefinition30_50Test {
@Test
@DisplayName("Test r5 -> r4 ActorDefinition conversion.")
public void testR5_R4() throws IOException {
InputStream r5_input = this.getClass().getResourceAsStream("/actordefinition_50_example.json");
org.hl7.fhir.r5.model.ActorDefinition r5_actual = (org.hl7.fhir.r5.model.ActorDefinition) 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");
}
// @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);
//
// }
}

View File

@ -0,0 +1,87 @@
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 ActorDefinition40_50Test {
@Test
@DisplayName("Test r5 -> r4 ActorDefinition conversion.")
public void testR5_R4() throws IOException {
InputStream r5_input = this.getClass().getResourceAsStream("/actordefinition_50_example.json");
org.hl7.fhir.r5.model.ActorDefinition r5_actual = (org.hl7.fhir.r5.model.ActorDefinition) 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");
}
// @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);
//
// }
}

View File

@ -0,0 +1,86 @@
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 ActorDefinition43_50Test {
@Test
@DisplayName("Test r5 -> r4 ActorDefinition conversion.")
public void testR5_R4() throws IOException {
InputStream r5_input = this.getClass().getResourceAsStream("/actordefinition_50_example.json");
org.hl7.fhir.r5.model.ActorDefinition r5_actual = (org.hl7.fhir.r5.model.ActorDefinition) 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");
}
// @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);
//
// }
}

View File

@ -0,0 +1,20 @@
{
"resourceType": "ActorDefinition",
"id": "server",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: ActorDefinition</b><a name=\"server\"> </a></p><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Resource ActorDefinition &quot;server&quot; </p></div><p><b>url</b>: <a href=\"http://hl7.org/fhir/ActorDefinition/server\">http://hl7.org/fhir/ActorDefinition/server</a></p><p><b>identifier</b>: id: urn:oid:2.16.840.1.113883.4.642.27.1</p><p><b>name</b>: ServerActor</p><p><b>title</b>: Server Actor</p><p><b>status</b>: active</p><p><b>date</b>: 2021-11-02T14:31:30.239Z</p><p><b>type</b>: system</p></div>"
},
"url": "http://hl7.org/fhir/ActorDefinition/server",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:oid:2.16.840.1.113883.4.642.27.1"
}
],
"name": "ServerActor",
"title": "Server Actor",
"status": "active",
"date": "2021-11-02T14:31:30.239Z",
"type": "system"
}

View File

@ -423,4 +423,36 @@ public abstract class DomainResource extends Resource implements IBaseHasExtensi
}
public void addExtension(String url, Type value) {
Extension ex = new Extension();
ex.setUrl(url);
ex.setValue(value);
getExtension().add(ex);
}
public boolean hasExtension(String url) {
for (Extension e : getExtension())
if (url.equals(e.getUrl()))
return true;
return false;
}
public Extension getExtensionByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
ArrayList<Extension> retVal = new ArrayList<Extension>();
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);
}
}
}

View File

@ -452,24 +452,24 @@ Modifier extensions SHALL NOT change the meaning of any elements on Resource or
if (url.equals(e.getUrl()))
return true;
return false;
}
public Extension getExtensionByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
ArrayList<Extension> retVal = new ArrayList<Extension>();
for (Extension next : getExtension()) {
if (theUrl.equals(next.getUrl())) {
retVal.add(next);
}
}
public Extension getExtensionByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
ArrayList<Extension> retVal = new ArrayList<Extension>();
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);
}
}
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);
}
}
// end addition

View File

@ -19,7 +19,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -31,18 +31,28 @@ public class R5ExtensionsLoader {
private int count;
private byte[] map;
private NpmPackage pck;
private Map<String, ValueSet> valueSets;
private Map<String, CodeSystem> codeSystems;
private List<StructureDefinition> structures;
private IWorkerContext context;
private PackageVersion pd;
public R5ExtensionsLoader(BasePackageCacheManager pcm) {
public R5ExtensionsLoader(BasePackageCacheManager pcm, IWorkerContext context) {
super();
this.pcm = pcm;
this.context = context;
valueSets = new HashMap<>();
codeSystems = new HashMap<>();
structures = new ArrayList<>();
}
public void loadR5Extensions(IWorkerContext context) throws FHIRException, IOException {
public void load() throws FHIRException, IOException {
pck = pcm.loadPackage("hl7.fhir.r5.core", "current");
pd = new PackageVersion(pck.name(), pck.version(), pck.dateAsDate());
map = pck.hasFile("other", "spec.internals") ? TextFile.streamToBytes(pck.load("other", "spec.internals")) : null;
String[] types = new String[] { "StructureDefinition", "ValueSet", "CodeSystem" };
Map<String, ValueSet> valueSets = new HashMap<>();
Map<String, CodeSystem> codeSystems = new HashMap<>();
List<StructureDefinition> extensions = new ArrayList<>();
JsonParser json = new JsonParser();
for (PackageResourceInformation pri : pck.listIndexedResources(types)) {
CanonicalResource r = (CanonicalResource) json.parse(pck.load(pri));
@ -52,28 +62,40 @@ public class R5ExtensionsLoader {
} else if (r instanceof ValueSet) {
valueSets.put(r.getUrl(), (ValueSet) r);
} else if (r instanceof StructureDefinition) {
extensions.add((StructureDefinition) r);
structures.add((StructureDefinition) r);
}
}
PackageVersion pd = new PackageVersion(pck.name(), pck.version(), pck.dateAsDate());
}
public void loadR5Extensions() throws FHIRException, IOException {
count = 0;
List<String> typeNames = new ContextUtilities(context).getTypeNames();
for (StructureDefinition sd : extensions) {
for (StructureDefinition sd : structures) {
if (sd.getType().equals("Extension") && sd.getDerivation() == TypeDerivationRule.CONSTRAINT &&
!context.hasResource(StructureDefinition.class, sd.getUrl())) {
if (survivesStrippingTypes(sd, context, typeNames)) {
count++;
sd.setUserData("path", Utilities.pathURL(pck.getWebLocation(), "extension-"+sd.getId().toLowerCase()+".html"));
context.cacheResourceFromPackage(sd, pd);
registerTerminologies(sd, context, valueSets, codeSystems, pd);
registerTerminologies(sd);
}
}
}
map = pck.hasFile("other", "spec.internals") ? TextFile.streamToBytes(pck.load("other", "spec.internals")) : null;
}
private void registerTerminologies(StructureDefinition sd, IWorkerContext context, Map<String, ValueSet> valueSets, Map<String, CodeSystem> codeSystems, PackageVersion pd) {
public void loadR5SpecialTypes(List<String> types) throws FHIRException, IOException {
for (StructureDefinition sd : structures) {
if (Utilities.existsInList(sd.getType(), types)) {
count++;
sd.setUserData("path", Utilities.pathURL(pck.getWebLocation(), sd.getId().toLowerCase()+".html"));
context.cacheResourceFromPackage(sd, pd);
registerTerminologies(sd);
}
}
}
private void registerTerminologies(StructureDefinition sd) {
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.hasBinding() && ed.getBinding().hasValueSet()) {
String vs = ed.getBinding().getValueSet();

View File

@ -0,0 +1,414 @@
package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.ActorDefinition;
import org.hl7.fhir.r5.model.Annotation;
import org.hl7.fhir.r5.model.Attachment;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.ContactPoint;
import org.hl7.fhir.r5.model.DataRequirement;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Library;
import org.hl7.fhir.r5.model.ListResource;
import org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent;
import org.hl7.fhir.r5.model.ParameterDefinition;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.RelatedArtifact;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.UrlType;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class ActorDefinitionRenderer extends ResourceRenderer {
private static final int DATA_IMG_SIZE_CUTOFF = 4000;
public ActorDefinitionRenderer(RenderingContext context) {
super(context);
}
public ActorDefinitionRenderer(RenderingContext context, ResourceContext rcontext) {
super(context, rcontext);
}
public boolean render(XhtmlNode x, Resource dr) throws FHIRFormatError, DefinitionException, IOException {
return render(x, (ActorDefinition) dr);
}
public boolean render(XhtmlNode x, ActorDefinition acd) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
tr.td().b().tx("Actor: "+acd.getName());
tr.td().tx(acd.getTitle());
tr.td().tx("Type: " + acd.getType().toCode());
XhtmlNode td = tbl.tr().td().colspan("3");
addMarkdown(td, acd.getDocumentation());
if (acd.hasReference()) {
tbl.tr().td().tx("References:");
td = tr.td().colspan("2");
boolean first = true;
for (UrlType t : acd.getReference()) {
if (first) first = false; else x.br();
render(td, t);
}
}
if (acd.hasCapabilities()) {
tbl.tr().td().tx("Capabilities:");
td = tr.td().colspan("2");
CapabilityStatement cs = context.getWorker().fetchResource(CapabilityStatement.class, acd.getCapabilities());
if (cs != null) {
td.ah(cs.getUserString("path")).tx(cs.present());
} else {
render(td, acd.getCapabilitiesElement());
}
}
if (acd.hasDerivedFrom()) {
tbl.tr().td().tx("Derived from:");
td = tr.td().colspan("2");
boolean first = true;
for (UrlType t : acd.getReference()) {
if (first) first = false; else x.br();
ActorDefinition df = context.getWorker().fetchResource(ActorDefinition.class, t.getValue());
if (df != null) {
td.ah(df.getUserString("path")).tx(df.present());
} else {
render(td, t);
}
}
}
return false;
}
private void renderParameter(XhtmlNode t, BaseWrapper p, boolean doco) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tr = t.tr();
tr.td().tx(p.has("name") ? p.get("name").primitiveValue() : null);
tr.td().tx(p.has("use") ? p.get("use").primitiveValue() : null);
tr.td().tx(p.has("min") ? p.get("min").primitiveValue() : null);
tr.td().tx(p.has("max") ? p.get("max").primitiveValue() : null);
tr.td().tx(p.has("type") ? p.get("type").primitiveValue() : null);
if (doco) {
tr.td().tx(p.has("documentation") ? p.get("documentation").primitiveValue() : null);
}
}
private void renderParameter(XhtmlNode t, ParameterDefinition p, boolean doco) {
XhtmlNode tr = t.tr();
tr.td().tx(p.getName());
tr.td().tx(p.getUse().getDisplay());
tr.td().tx(p.getMin());
tr.td().tx(p.getMax());
tr.td().tx(p.getType().getDisplay());
if (doco) {
tr.td().tx(p.getDocumentation());
}
}
private void renderArtifact(XhtmlNode t, BaseWrapper ra, ResourceWrapper lib, boolean label, boolean display, boolean citation) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tr = t.tr();
tr.td().tx(ra.has("type") ? ra.get("type").primitiveValue() : null);
if (label) {
tr.td().tx(ra.has("label") ? ra.get("label").primitiveValue() : null);
}
if (display) {
tr.td().tx(ra.has("display") ? ra.get("display").primitiveValue() : null);
}
if (citation) {
tr.td().markdown(ra.has("citation") ? ra.get("citation").primitiveValue() : null, "Citation");
}
if (ra.has("resource")) {
renderCanonical(lib, tr.td(), ra.get("resource").primitiveValue());
} else {
tr.td().tx(ra.has("url") ? ra.get("url").primitiveValue() : null);
}
}
private void renderArtifact(XhtmlNode t, RelatedArtifact ra, Resource lib, boolean label, boolean display, boolean citation) throws IOException {
XhtmlNode tr = t.tr();
tr.td().tx(ra.getType().getDisplay());
if (label) {
tr.td().tx(ra.getLabel());
}
if (display) {
tr.td().tx(ra.getDisplay());
}
if (citation) {
tr.td().markdown(ra.getCitation(), "Citation");
}
if (ra.hasResource()) {
renderCanonical(lib, tr.td(), ra.getResource());
} else {
renderAttachment(tr.td(), ra.getDocument(), false, 0, lib.getId());
}
}
private void participantRow(XhtmlNode t, String label, BaseWrapper cd, boolean email, boolean phone, boolean url) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode tr = t.tr();
tr.td().tx(label);
tr.td().tx(cd.get("name") != null ? cd.get("name").primitiveValue() : null);
PropertyWrapper telecoms = cd.getChildByName("telecom");
if (email) {
renderContactPoint(tr.td(), getContactPoint(telecoms, "email"));
}
if (phone) {
renderContactPoint(tr.td(), getContactPoint(telecoms, "phone"));
}
if (url) {
renderContactPoint(tr.td(), getContactPoint(telecoms, "url"));
}
}
private ContactPoint getContactPoint(PropertyWrapper telecoms, String value) throws UnsupportedEncodingException, FHIRException, IOException {
for (BaseWrapper t : telecoms.getValues()) {
if (t.has("system")) {
String system = t.get("system").primitiveValue();
if (value.equals(system)) {
return (ContactPoint) t.getBase();
}
}
}
return null;
}
private void participantRow(XhtmlNode t, String label, ContactDetail cd, boolean email, boolean phone, boolean url) {
XhtmlNode tr = t.tr();
tr.td().tx(label);
tr.td().tx(cd.getName());
if (email) {
renderContactPoint(tr.td(), cd.getEmail());
}
if (phone) {
renderContactPoint(tr.td(), cd.getPhone());
}
if (url) {
renderContactPoint(tr.td(), cd.getUrl());
}
}
public void describe(XhtmlNode x, Library lib) {
x.tx(display(lib));
}
public String display(Library lib) {
return lib.present();
}
@Override
public String display(Resource r) throws UnsupportedEncodingException, IOException {
return ((Library) r).present();
}
@Override
public String display(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
if (r.has("title")) {
return r.children("title").get(0).getBase().primitiveValue();
}
return "??";
}
private void renderAttachment(XhtmlNode x, Attachment att, boolean noShowData, int counter, String baseId) {
boolean ref = !att.hasData() && att.hasUrl();
if (ref) {
XhtmlNode p = x.para();
if (att.hasTitle()) {
p.tx(att.getTitle());
p.tx(": ");
}
p.code().ah(att.getUrl()).tx(att.getUrl());
p.tx(" (");
p.code().tx(att.getContentType());
p.tx(lang(att));
p.tx(")");
} else if (!att.hasData()) {
XhtmlNode p = x.para();
if (att.hasTitle()) {
p.tx(att.getTitle());
p.tx(": ");
}
p.code().tx("No Content");
p.tx(" (");
p.code().tx(att.getContentType());
p.tx(lang(att));
p.tx(")");
} else {
String txt = getText(att);
if (isImage(att.getContentType())) {
XhtmlNode p = x.para();
if (att.hasTitle()) {
p.tx(att.getTitle());
p.tx(": (");
p.code().tx(att.getContentType());
p.tx(lang(att));
p.tx(")");
}
else {
p.code().tx(att.getContentType()+lang(att));
}
if (att.getData().length < ActorDefinitionRenderer.DATA_IMG_SIZE_CUTOFF) {
x.img("data: "+att.getContentType()+">;base64,"+b64(att.getData()), "data");
} else {
String filename = "Library-"+baseId+(counter == 0 ? "" : "-"+Integer.toString(counter))+"."+imgExtension(att.getContentType());
x.img(filename, "data");
}
} else if (txt != null && !noShowData) {
XhtmlNode p = x.para();
if (att.hasTitle()) {
p.tx(att.getTitle());
p.tx(": (");
p.code().tx(att.getContentType());
p.tx(lang(att));
p.tx(")");
}
else {
p.code().tx(att.getContentType()+lang(att));
}
String prismCode = determinePrismCode(att);
if (prismCode != null && !tooBig(txt)) {
x.pre().code().setAttribute("class", "language-"+prismCode).tx(txt);
} else {
x.pre().code().tx(txt);
}
} else {
XhtmlNode p = x.para();
if (att.hasTitle()) {
p.tx(att.getTitle());
p.tx(": ");
}
p.code().tx("Content not shown - (");
p.code().tx(att.getContentType());
p.tx(lang(att));
p.tx(", size = "+Utilities.describeSize(att.getData().length)+")");
}
}
}
private boolean tooBig(String txt) {
return txt.length() > 16384;
}
private String imgExtension(String contentType) {
if (contentType != null && contentType.startsWith("image/")) {
if (contentType.startsWith("image/png")) {
return "png";
}
if (contentType.startsWith("image/jpeg")) {
return "jpg";
}
}
return null;
}
private String b64(byte[] data) {
byte[] encodeBase64 = Base64.encodeBase64(data);
return new String(encodeBase64);
}
private boolean isImage(String contentType) {
return imgExtension(contentType) != null;
}
private String lang(Attachment att) {
if (att.hasLanguage()) {
return ", language = "+describeLang(att.getLanguage());
}
return "";
}
private String getText(Attachment att) {
try {
try {
String src = new String(att.getData(), "UTF-8");
if (checkString(src)) {
return src;
}
} catch (Exception e) {
// ignore
}
try {
String src = new String(att.getData(), "UTF-16");
if (checkString(src)) {
return src;
}
} catch (Exception e) {
// ignore
}
try {
String src = new String(att.getData(), "ASCII");
if (checkString(src)) {
return src;
}
} catch (Exception e) {
// ignore
}
return null;
} catch (Exception e) {
return null;
}
}
public boolean checkString(String src) {
for (char ch : src.toCharArray()) {
if (ch < ' ' && ch != '\r' && ch != '\n' && ch != '\t') {
return false;
}
}
return true;
}
private String determinePrismCode(Attachment att) {
if (att.hasContentType()) {
String ct = att.getContentType();
if (ct.contains(";")) {
ct = ct.substring(0, ct.indexOf(";"));
}
switch (ct) {
case "text/html" : return "html";
case "text/xml" : return "xml";
case "application/xml" : return "xml";
case "text/markdown" : return "markdown";
case "application/js" : return "JavaScript";
case "application/css" : return "css";
case "text/x-csrc" : return "c";
case "text/x-csharp" : return "csharp";
case "text/x-c++src" : return "cpp";
case "application/graphql" : return "graphql";
case "application/x-java" : return "java";
case "application/json" : return "json";
case "text/json" : return "json";
case "application/liquid" : return "liquid";
case "text/x-pascal" : return "pascal";
case "text/x-python" : return "python";
case "text/x-rsrc" : return "r";
case "text/x-ruby" : return "ruby";
case "text/x-sas" : return "sas";
case "text/x-sql" : return "sql";
case "application/typescript" : return "typescript";
case "text/cql" : return "sql"; // not that bad...
}
if (att.getContentType().contains("json+") || att.getContentType().contains("+json")) {
return "json";
}
if (att.getContentType().contains("xml+") || att.getContentType().contains("+xml")) {
return "xml";
}
}
return null;
}
}

View File

@ -85,6 +85,9 @@ public class RendererFactory {
if ("Bundle".equals(resourceName)) {
return new BundleRenderer(context);
}
if ("ActorDefinition".equals(resourceName)) {
return new ActorDefinitionRenderer(context);
}
return new ProfileDrivenRenderer(context);
}
@ -136,7 +139,7 @@ public class RendererFactory {
return Utilities.existsInList(rt,
"CodeSystem", "ValueSet", "ConceptMap",
"CapabilityStatement", "CompartmentDefinition", "ImplementationGuide", "Library", "NamingSystem", "OperationDefinition", "Questionnaire", "SearchParameter", "StructureDefinition");
"CapabilityStatement", "CompartmentDefinition", "ImplementationGuide", "Library", "NamingSystem", "OperationDefinition", "Questionnaire", "SearchParameter", "StructureDefinition", "ActorDefinition");
}
}

View File

@ -571,8 +571,6 @@ public class StructureMapUtilities {
b.append(rtp.getValueDecimalType().asStringValue());
else if (rtp.hasValueIdType())
b.append(rtp.getValueIdType().asStringValue());
else if (rtp.hasValueDecimalType())
b.append(rtp.getValueDecimalType().asStringValue());
else if (rtp.hasValueIntegerType())
b.append(rtp.getValueIntegerType().asStringValue());
else

View File

@ -346,8 +346,9 @@ public class ValidationService {
System.out.println(" - " + validator.getContext().countAllCaches() + " resources (" + tt.milestone() + ")");
igLoader.loadIg(validator.getIgs(), validator.getBinaries(), "hl7.terminology", false);
System.out.print(" Load R5 Extensions");
R5ExtensionsLoader r5e = new R5ExtensionsLoader(validator.getPcm());
r5e.loadR5Extensions(validator.getContext());
R5ExtensionsLoader r5e = new R5ExtensionsLoader(validator.getPcm(), validator.getContext());
r5e.load();
r5e.loadR5Extensions();
System.out.println(" - " + r5e.getCount() + " resources (" + tt.milestone() + ")");
System.out.print(" Terminology server " + cliContext.getTxServer());
String txver = validator.setTerminologyServer(cliContext.getTxServer(), cliContext.getTxLog(), ver);

View File

@ -302,9 +302,9 @@ public class StructureDefinitionValidator extends BaseValidator {
case "Element" :return addCharacteristicsForType(set);
case "Base" :return addCharacteristicsForType(set);
default:
if (!context.getResourceNames().contains(tc)) {
System.out.println("Unhandled data type in addCharacteristics: "+tc);
}
// if (!context.getResourceNames().contains(tc)) {
// System.out.println("Unhandled data type in addCharacteristics: "+tc);
// }
return addCharacteristicsForType(set);
}
}