Merge pull request #962 from hapifhir/gg-202210-psvi

Gg 202210 psvi
This commit is contained in:
Grahame Grieve 2022-10-25 17:04:03 +11:00 committed by GitHub
commit 4bc3c4a93b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
122 changed files with 3688 additions and 1533 deletions

View File

@ -30,6 +30,8 @@ public class BaseAdvisor_30_50 extends BaseAdvisor50<org.hl7.fhir.dstu3.model.Ex
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 if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.")) {
return true;
} else
return (paths.get(paths.size() - 1).equals("CapabilityStatement")) && (capabilityStatementIgnoredUrls.contains(url));
}

View File

@ -35,6 +35,8 @@ public class BaseAdvisor_40_50 extends BaseAdvisor50<org.hl7.fhir.r4.model.Exten
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 if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.")) {
return true;
} else
return false;
}

View File

@ -28,6 +28,8 @@ public class BaseAdvisor_43_50 extends BaseAdvisor50<org.hl7.fhir.r4b.model.Exte
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 if (paths.get(paths.size() - 1).equals("Basic") && url.startsWith("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.")) {
return true;
} else
return false;
}

View File

@ -75,6 +75,7 @@ import org.hl7.fhir.convertors.conv30_50.resources30_50.Provenance30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.Questionnaire30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.QuestionnaireResponse30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.RelatedPerson30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.Requirements30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.RiskAssessment30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.Schedule30_50;
import org.hl7.fhir.convertors.conv30_50.resources30_50.SearchParameter30_50;
@ -87,10 +88,8 @@ 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;
import org.hl7.fhir.exceptions.FHIRException;
public class Resource30_50 {
@ -132,6 +131,8 @@ public class Resource30_50 {
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 if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) {
return Requirements30_50.convertRequirements((org.hl7.fhir.dstu3.model.Basic) src);
} else {
return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src);
}
@ -415,6 +416,8 @@ public class Resource30_50 {
return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src);
if (src instanceof org.hl7.fhir.r5.model.RelatedPerson)
return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src);
if (src instanceof org.hl7.fhir.r5.model.Requirements)
return Requirements30_50.convertRequirements((org.hl7.fhir.r5.model.Requirements) src);
if (src instanceof org.hl7.fhir.r5.model.RiskAssessment)
return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src);
if (src instanceof org.hl7.fhir.r5.model.Schedule)

View File

@ -1,7 +1,5 @@
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;
@ -13,12 +11,8 @@ import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Mark
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;

View File

@ -0,0 +1,263 @@
package org.hl7.fhir.convertors.conv30_50.resources30_50;
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.Reference30_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.Id30_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.dstu3.model.Extension;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.Enumeration;
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 Requirements30_50 {
public static org.hl7.fhir.r5.model.Requirements convertRequirements(org.hl7.fhir.dstu3.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();
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-Requirements.url")) {
tgt.setUrlElement(Uri30_50.convertUri((org.hl7.fhir.dstu3.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(String30_50.convertString((org.hl7.fhir.dstu3.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(String30_50.convertString((org.hl7.fhir.dstu3.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(String30_50.convertString((org.hl7.fhir.dstu3.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(Boolean30_50.convertBoolean((org.hl7.fhir.dstu3.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(DateTime30_50.convertDateTime((org.hl7.fhir.dstu3.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(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.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-Requirements.description")) {
tgt.setPublisherElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.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-Requirements.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-Requirements.purpose")) {
tgt.setPurposeElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.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(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.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(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel").getValue()));
}
for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom")) {
tgt.getDerivedFrom().add(Uri30_50.convertCanonical((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.actor")) {
tgt.getActor().add(Uri30_50.convertCanonical((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")) {
convertRequirementsStatement(ext, tgt.addStatement());
}
return tgt;
}
public static org.hl7.fhir.dstu3.model.Basic convertRequirements(org.hl7.fhir.r5.model.Requirements 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("Requirements"); // 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-Requirements.url", Uri30_50.convertUri(src.getUrlElement()));
}
if (src.hasVersion()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version", String30_50.convertString(src.getVersionElement()));
}
if (src.hasName()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name", String30_50.convertString(src.getNameElement()));
}
if (src.hasTitle()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title", String30_50.convertString(src.getTitleElement()));
}
if (src.hasStatus()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status", new org.hl7.fhir.dstu3.model.CodeType(src.getStatus().toCode()));
}
if (src.hasExperimental()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental", Boolean30_50.convertBoolean(src.getExperimentalElement()));
}
if (src.hasDate()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date", DateTime30_50.convertDateTime(src.getDateElement()));
}
if (src.hasPublisher()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher", String30_50.convertString(src.getPublisherElement()));
}
for (ContactDetail cd : src.getContact()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact", ContactDetail30_50.convertContactDetail(cd));
}
if (src.hasDescription()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description", MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
}
for (UsageContext cd : src.getUseContext()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext", UsageContext30_50.convertUsageContext(cd));
}
for (CodeableConcept cd : src.getJurisdiction()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction", CodeableConcept30_50.convertCodeableConcept(cd));
}
if (src.hasPurpose()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose", MarkDown30_50.convertMarkdown(src.getPurposeElement()));
}
if (src.hasCopyright()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright", MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
}
if (src.hasCopyrightLabel()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel", String30_50.convertString(src.getCopyrightLabelElement()));
}
for (CanonicalType ref : src.getDerivedFrom()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom", Uri30_50.convertCanonical(ref));
}
for (CanonicalType ref : src.getActor()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor", Uri30_50.convertCanonical(ref));
}
for (RequirementsStatementComponent ref : src.getStatement()) {
org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.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) {
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
if (src.hasKey()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", Id30_50.convertId(src.getKeyElement()));
}
if (src.hasLabel()) {
tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", String30_50.convertString(src.getLabelElement()));
}
for (Enumeration<ConformanceExpectation> 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()));
}
}
}

View File

@ -2,8 +2,6 @@ package org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50;
import org.hl7.fhir.convertors.context.ConversionContext40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r5.model.DataType;
public class Canonical40_50 {
public static org.hl7.fhir.r5.model.CanonicalType convertCanonical(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException {

View File

@ -1,9 +1,6 @@
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;
@ -15,14 +12,9 @@ import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown4
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;

View File

@ -0,0 +1,265 @@
package org.hl7.fhir.convertors.conv40_50.resources40_50;
import org.hl7.fhir.convertors.context.ConversionContext40_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.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.Enumeration;
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<ConformanceExpectation> 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()));
}
}
}

View File

@ -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)

View File

@ -1,9 +1,6 @@
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;
@ -15,14 +12,9 @@ import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown4
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;

View File

@ -0,0 +1,265 @@
package org.hl7.fhir.convertors.conv43_50.resources43_50;
import org.hl7.fhir.convertors.context.ConversionContext43_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.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.Enumeration;
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<ConformanceExpectation> 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()));
}
}
}

View File

@ -2,8 +2,6 @@ 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;
@ -11,7 +9,6 @@ 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 {
@ -55,6 +52,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 +459,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)

View File

@ -52,6 +52,7 @@ import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.utils.ToolingExtensions;
public class R5ToR5Loader extends BaseLoaderR5 {
@ -142,10 +143,18 @@ public class R5ToR5Loader extends BaseLoaderR5 {
StructureDefinition sd = (StructureDefinition) r5;
if ("5.0.0-ballot".equals(sd.getVersion()) && "ElementDefinition".equals(sd.getType())) {
for (ElementDefinition ed : sd.getDifferential().getElement()) {
hackR5BallotError(ed);
hackEDR5BallotError(ed);
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
hackR5BallotError(ed);
hackEDR5BallotError(ed);
}
}
if ("5.0.0-ballot".equals(sd.getVersion()) && "Bundle".equals(sd.getType())) {
for (ElementDefinition ed : sd.getDifferential().getElement()) {
hackBundleR5BallotError(ed);
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
hackBundleR5BallotError(ed);
}
}
if ("5.0.0-ballot".equals(sd.getVersion()) && "http://hl7.org/fhir/StructureDefinition/elementdefinition-defaulttype".equals(sd.getUrl())) {
@ -155,7 +164,13 @@ public class R5ToR5Loader extends BaseLoaderR5 {
return r5;
}
private void hackR5BallotError(ElementDefinition ed) {
private void hackBundleR5BallotError(ElementDefinition ed) {
if (ed.getPath().equals("Bundle.link.relation")) {
ToolingExtensions.removeExtension(ed.getBinding(), ToolingExtensions.EXT_BINDING_NAME);
}
}
private void hackEDR5BallotError(ElementDefinition ed) {
if (ed.getPath().equals("ElementDefinition.type.code")) {
ed.getBinding().setStrength(BindingStrength.EXTENSIBLE);
}

View File

@ -8,14 +8,12 @@ import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.utils.ToolingExtensions;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureMap;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion;

View File

@ -1,32 +1,30 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Type10_30;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.hl7.fhir.dstu2.model.Base64BinaryType;
import org.hl7.fhir.dstu2.model.BooleanType;
import org.hl7.fhir.dstu2.model.CodeType;
import org.hl7.fhir.dstu2.model.DateType;
import org.hl7.fhir.dstu2.model.DateTimeType;
import org.hl7.fhir.dstu2.model.DateType;
import org.hl7.fhir.dstu2.model.DecimalType;
import org.hl7.fhir.dstu2.model.InstantType;
import org.hl7.fhir.dstu2.model.PositiveIntType;
import org.hl7.fhir.dstu2.model.UnsignedIntType;
import org.hl7.fhir.dstu2.model.IntegerType;
import org.hl7.fhir.dstu2.model.MarkdownType;
import org.hl7.fhir.dstu2.model.OidType;
import org.hl7.fhir.dstu2.model.PositiveIntType;
import org.hl7.fhir.dstu2.model.PrimitiveType;
import org.hl7.fhir.dstu2.model.StringType;
import org.hl7.fhir.dstu2.model.TimeType;
import org.hl7.fhir.dstu2.model.UuidType;
import org.hl7.fhir.dstu2.model.PrimitiveType;
import org.hl7.fhir.dstu2.model.Base64BinaryType;
import org.hl7.fhir.dstu2.model.UnsignedIntType;
import org.hl7.fhir.dstu2.model.UriType;
import org.hl7.fhir.dstu2.model.UuidType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_30Test {
@ParameterizedTest(name = "Testing dstu2 -> dstu3 conversion of null value {0}.")

View File

@ -1,15 +1,30 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Type10_40;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.dstu2.model.*;
import org.hl7.fhir.dstu2.model.Base64BinaryType;
import org.hl7.fhir.dstu2.model.BooleanType;
import org.hl7.fhir.dstu2.model.CodeType;
import org.hl7.fhir.dstu2.model.DateTimeType;
import org.hl7.fhir.dstu2.model.DateType;
import org.hl7.fhir.dstu2.model.DecimalType;
import org.hl7.fhir.dstu2.model.InstantType;
import org.hl7.fhir.dstu2.model.IntegerType;
import org.hl7.fhir.dstu2.model.MarkdownType;
import org.hl7.fhir.dstu2.model.OidType;
import org.hl7.fhir.dstu2.model.PositiveIntType;
import org.hl7.fhir.dstu2.model.PrimitiveType;
import org.hl7.fhir.dstu2.model.StringType;
import org.hl7.fhir.dstu2.model.TimeType;
import org.hl7.fhir.dstu2.model.UnsignedIntType;
import org.hl7.fhir.dstu2.model.UriType;
import org.hl7.fhir.dstu2.model.UuidType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_40Test {
@ParameterizedTest(name = "Testing dstu2 -> r4 conversion of null value {0}.")

View File

@ -1,8 +1,8 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Type10_40;
import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50;
import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Type10_50;
import java.io.IOException;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.hl7.fhir.dstu2.model.Base64BinaryType;
@ -29,9 +29,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType10_50Test {
private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div>Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"event\" : {\"type\" : {\"system\" : \"http://nema.org/dicom/dicm\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://nema.org/dicom/dicm\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"dateTime\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\"},\"participant\" : [{\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"userId\" : {\"value\" : \"Grahame\"},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}}],\"source\" : {\"site\" : \"Development\",\"identifier\" : {\"value\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://hl7.org/fhir/audit-event-sub-type\",\"code\" : \"1\"}]},\"object\" : [{\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://hl7.org/fhir/identifier-type\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"},\"type\" : {\"system\" : \"http://hl7.org/fhir/object-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://hl7.org/fhir/object-role\",\"code\" : \"4\",\"display\" : \"DomainResource\"},\"lifecycle\" : {\"system\" : \"http://hl7.org/fhir/object-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}";

View File

@ -1,6 +1,7 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Type30_40;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.hl7.fhir.dstu3.model.Base64BinaryType;
import org.hl7.fhir.dstu3.model.BooleanType;
@ -24,8 +25,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType30_40Test {
@ParameterizedTest(name = "Testing dstu3 -> r4 conversion of null value {0}.")

View File

@ -1,7 +1,8 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Type30_50;
import java.io.IOException;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.dstu3.model.Base64BinaryType;
import org.hl7.fhir.dstu3.model.BooleanType;
@ -27,9 +28,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType30_50Test {
private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"userId\" : {\"value\" : \"Grahame\"},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"role\" : [{\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]}],\"userId\" : {\"value\" : \"2.16.840.1.113883.4.2|2.16.840.1.113883.4.2\"},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"identifier\" : {\"value\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://hl7.org/fhir/identifier-type\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"},\"type\" : {\"system\" : \"http://hl7.org/fhir/object-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://hl7.org/fhir/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://hl7.org/fhir/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}";

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.convertors;
import java.io.IOException;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r4.model.Base64BinaryType;
@ -25,9 +28,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.util.stream.Stream;
public class VersionConvertorPrimitiveType40_50Test {
private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/extra-security-role-type\",\"code\" : \"humanuser\",\"display\" : \"human user\"}]},\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"who\" : {\"identifier\" : {\"value\" : \"Grahame\"}},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"type\" : {\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]},\"who\" : {\"identifier\" : {\"system\" : \"urn:oid:2.16.840.1.113883.4.2\",\"value\" : \"2.16.840.1.113883.4.2\"}},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"observer\" : {\"display\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"what\" : {\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/v2-0203\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"}},\"type\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/audit-entity-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}";

View File

@ -1,20 +1,6 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.context.*;
import org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30;
import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40;
import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Canonical10_40;
import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50;
import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50;
import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
import org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50;
import org.hl7.fhir.convertors.factory.*;
import org.hl7.fhir.r4.model.CanonicalType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import static org.mockito.Mockito.mock;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
@ -24,7 +10,35 @@ import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Stream;
import static org.mockito.Mockito.mock;
import org.hl7.fhir.convertors.context.ConversionContext10_30;
import org.hl7.fhir.convertors.context.ConversionContext10_40;
import org.hl7.fhir.convertors.context.ConversionContext10_50;
import org.hl7.fhir.convertors.context.ConversionContext14_50;
import org.hl7.fhir.convertors.context.ConversionContext30_50;
import org.hl7.fhir.convertors.context.ConversionContext40_50;
import org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30;
import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40;
import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Canonical10_40;
import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50;
import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50;
import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
import org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.r4.model.CanonicalType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class VersionConvertorPrimitiveTypeTests {

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.convertors;
import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Type10_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.convertors.advisors;
import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.advisors.support.ExpressionAdvisor40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
@ -10,9 +12,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Expression40Test {
@Test

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.convertors.advisors;
import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.advisors.support.ExpressionAdvisor50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
@ -10,9 +12,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Expression50Test {
@Test

View File

@ -1,5 +1,7 @@
package org.hl7.fhir.convertors.advisors.support;
import javax.annotation.Nonnull;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Uri10_40;
import org.hl7.fhir.dstu2.model.StringType;
@ -7,8 +9,6 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Expression;
import org.hl7.fhir.r4.model.Extension;
import javax.annotation.Nonnull;
public final class ExpressionAdvisor40 extends BaseAdvisor_10_40 {
public boolean useAdvisorForExtension(@Nonnull String path, @Nonnull Extension ext) throws FHIRException {
return ext.hasValue() && ext.getValue() instanceof Expression;

View File

@ -1,13 +1,13 @@
package org.hl7.fhir.convertors.advisors.support;
import javax.annotation.Nonnull;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Uri10_50;
import org.hl7.fhir.dstu2.model.StringType;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Expression;
import javax.annotation.Nonnull;
public class ExpressionAdvisor50 extends BaseAdvisor_10_50 {
public boolean useAdvisorForExtension(@Nonnull String path, @Nonnull org.hl7.fhir.r5.model.Extension ext) {

View File

@ -1,13 +1,13 @@
package org.hl7.fhir.convertors.conv10_30;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class AdministrativeGender10_30Test {
@Test

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_30;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class AllergyIntolerance10_30Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_30;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement10_30Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,13 +1,13 @@
package org.hl7.fhir.convertors.conv10_30;
import java.io.IOException;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
public class Bundle10_30Test {
@Test

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -9,10 +13,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class AllergyIntolerance10_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement10_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,12 +1,12 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
public class Bundle10_40Test {
@Test

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -7,9 +10,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Medication10_40Test {
@Test
@DisplayName("Test 10_40 Medication conversion")

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -9,10 +13,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class MedicationRequest10_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -7,9 +10,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Observation10_40Test {
@Test
@DisplayName("Test 10_40 Observation conversion")

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -7,9 +10,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Procedure10_40Test {
@Test
@DisplayName("Test 10_40 Procedure conversion")

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.convertors.conv10_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
@ -8,9 +11,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class ValueSet10_40Test {
@Test
@DisplayName("Test 10_40 ValueSet conversion")

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv10_50;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement10_50Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,12 +1,12 @@
package org.hl7.fhir.convertors.conv10_50;
import java.io.IOException;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
public class Bundle10_50Test {
@Test

View File

@ -2,10 +2,10 @@ package org.hl7.fhir.convertors.conv30_40;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class AllergyIntolerance30_40Test {
@Test

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv30_40;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement30_40Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,14 +1,14 @@
package org.hl7.fhir.convertors.conv30_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Device30_40Test {
@Test
@DisplayName("Test r4 -> dstu3 device conversion.")

View File

@ -1,16 +1,15 @@
package org.hl7.fhir.convertors.conv30_40;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class Extension30_40Test {
private void convert(String filename) throws FHIRFormatError, IOException {

View File

@ -1,19 +1,15 @@
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 static org.junit.jupiter.api.Assertions.assertTrue;
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;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class ActorDefinition30_50Test {
@ -36,52 +32,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);
//
// }
}

View File

@ -1,5 +1,9 @@
package org.hl7.fhir.convertors.conv30_50;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.junit.jupiter.api.Assertions;
@ -8,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement30_50Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -0,0 +1,36 @@
package org.hl7.fhir.convertors.conv30_50;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
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");
}
}

View File

@ -1,13 +1,13 @@
package org.hl7.fhir.convertors.conv30_50;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
public class StructureDefinition30_50Test {
@Test
@DisplayName("Test r5 -> dstu3 device conversion.")

View File

@ -1,19 +1,15 @@
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 static org.junit.jupiter.api.Assertions.assertTrue;
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;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class ActorDefinition40_50Test {
@ -36,52 +32,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);
//
// }
}

View File

@ -1,17 +1,16 @@
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.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
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 org.apache.commons.codec.binary.Base64;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class AuditEvent40_50Test {

View File

@ -1,8 +1,10 @@
package org.hl7.fhir.convertors.conv40_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -10,10 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
public class BackboneElement40_50Test {
private static Stream<Arguments> filesPaths() {
return Stream.of(

View File

@ -1,15 +1,14 @@
package org.hl7.fhir.convertors.conv40_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.conv40_50.resources40_50.ImplementationGuide40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.junit.jupiter.api.Test;
public class ImplementationGuide40_50Test {

View File

@ -0,0 +1,36 @@
package org.hl7.fhir.convertors.conv40_50;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
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");
}
}

View File

@ -1,19 +1,15 @@
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 static org.junit.jupiter.api.Assertions.assertTrue;
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;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class ActorDefinition43_50Test {
@ -36,51 +32,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);
//
// }
}

View File

@ -0,0 +1,36 @@
package org.hl7.fhir.convertors.conv43_50;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
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");
}
}

View File

@ -0,0 +1,52 @@
{
"resourceType": "Requirements",
"id": "example1",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: Requirements</b><a name=\"example1\"> </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 Requirements &quot;example1&quot; </p></div><p><b>url</b>: <a href=\"http://hl7.org/fhir/Requirements/example1\">http://hl7.org/fhir/Requirements/example1</a></p><p><b>identifier</b>: id: urn:oid:2.16.840.1.113883.4.642.18.1</p><p><b>name</b>: ExampleRequirements1</p><p><b>title</b>: Example Requirements Set 1</p><p><b>status</b>: active</p><p><b>date</b>: 2021-11-02T14:31:30.239Z</p><p><b>actor</b>: <a href=\"http://hl7.org/fhir/ActorDefinition/server\">http://hl7.org/fhir/ActorDefinition/server</a></p><blockquote><p><b>statement</b></p><p><b>key</b>: req-1</p><p><b>conformance</b>: <span title=\" \n\t\t&lt;label value=&quot;requirement-1&quot;/&gt;\n\t\tsince this is commented out, it's simply 'req-1'\n\t\t \">SHALL</span></p><p><b>requirement</b>: The server SHALL support expanding value sets</p><p><b>satisfiedBy</b>: <a href=\"http://hl7.org/fhir/terminology-service.html#expand\">http://hl7.org/fhir/terminology-service.html#expand</a></p><p><b>source</b>: <span>: Grahame Grieve</span></p></blockquote><blockquote><p><b>statement</b></p><p><b>key</b>: 46f77dcd-d51e-4738-b61f-22506d0cb0ac</p><p><b>label</b>: requirement-2</p><p><b>conformance</b>: SHALL</p><p><b>requirement</b>: 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</p><p><b>source</b>: <span>: Jose Costa Teixeira</span></p></blockquote></div>"
},
"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"
}
]
}
]
}

View File

@ -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<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);
}
}
/**
* Returns an unmodifiable list containing all extensions on this element which
* match the given URL.

View File

@ -439,6 +439,7 @@ public class ProfileUtilities extends TranslatingUtilities {
public String url;
}
boolean isDatatype(String typeSimple);
boolean isPrimitiveType(String typeSimple);
boolean isResource(String typeSimple);
boolean hasLinkFor(String typeSimple);
String getLinkFor(String corePath, String typeSimple);
@ -3291,10 +3292,10 @@ public class ProfileUtilities extends TranslatingUtilities {
}
}
if (dest.hasFixed()) {
checkTypeOk(dest, dest.getFixed().fhirType(), srcSD);
checkTypeOk(dest, dest.getFixed().fhirType(), srcSD, "fixed");
}
if (dest.hasPattern()) {
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD);
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD, "pattern");
}
}
@ -3359,7 +3360,7 @@ public class ProfileUtilities extends TranslatingUtilities {
}
public void checkTypeOk(ElementDefinition dest, String ft, StructureDefinition sd) {
public void checkTypeOk(ElementDefinition dest, String ft, StructureDefinition sd, String fieldName) {
boolean ok = false;
Set<String> types = new HashSet<>();
if (dest.getPath().contains(".")) {
@ -3375,7 +3376,7 @@ public class ProfileUtilities extends TranslatingUtilities {
}
if (!ok) {
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.CONFLICT, dest.getId(), "The fixed value has type '"+ft+"' which is not valid (valid "+Utilities.pluralize("type", dest.getType().size())+": "+types.toString()+")", IssueSeverity.ERROR));
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.CONFLICT, dest.getId(), "The "+fieldName+" value has type '"+ft+"' which is not valid (valid "+Utilities.pluralize("type", dest.getType().size())+": "+types.toString()+")", IssueSeverity.ERROR));
}
}

View File

@ -57,6 +57,7 @@ import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
import org.hl7.fhir.r5.context.IWorkerContextManager.IPackageLoadingTracker;
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
import org.hl7.fhir.r5.model.ActorDefinition;
import org.hl7.fhir.r5.model.BooleanType;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.CanonicalResource;
@ -88,6 +89,7 @@ import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.r5.model.PlanDefinition;
import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Requirements;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.SearchParameter;
import org.hl7.fhir.r5.model.StringType;
@ -151,6 +153,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
public Resource getResource() {
return resource != null ? resource : proxy.getResource();
}
public CanonicalResourceProxy getProxy() {
return proxy;
}
public String getUrl() {
if (resource == null) {
@ -219,6 +225,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
private final CanonicalResourceManager<Questionnaire> questionnaires = new CanonicalResourceManager<Questionnaire>(false);
private final CanonicalResourceManager<OperationDefinition> operations = new CanonicalResourceManager<OperationDefinition>(false);
private final CanonicalResourceManager<PlanDefinition> plans = new CanonicalResourceManager<PlanDefinition>(false);
private final CanonicalResourceManager<ActorDefinition> actors = new CanonicalResourceManager<ActorDefinition>(false);
private final CanonicalResourceManager<Requirements> requirements = new CanonicalResourceManager<Requirements>(false);
private final CanonicalResourceManager<NamingSystem> systems = new CanonicalResourceManager<NamingSystem>(false);
private Map<String, NamingSystem> systemUrlMap;
@ -400,6 +408,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
case "NamingSystem":
systems.register(r, packageInfo);
break;
case "Requirements":
requirements.register(r, packageInfo);
break;
case "ActorDefinition":
actors.register(r, packageInfo);
break;
}
}
}
@ -470,6 +484,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} else if (r instanceof NamingSystem) {
systems.see((NamingSystem) m, packageInfo);
systemUrlMap = null;
} else if (r instanceof Requirements) {
requirements.see((Requirements) m, packageInfo);
} else if (r instanceof ActorDefinition) {
actors.see((ActorDefinition) m, packageInfo);
systemUrlMap = null;
}
}
}
@ -1436,20 +1455,16 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (transforms.has(uri)) {
return (T) transforms.get(uri, version);
}
if (actors.has(uri)) {
return (T) transforms.get(uri, version);
}
if (requirements.has(uri)) {
return (T) transforms.get(uri, version);
}
if (questionnaires.has(uri)) {
return (T) questionnaires.get(uri, version);
}
if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
return null;
}
// it might be a special URL.
if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
Resource res = null; // findTxValueSet(uri);
if (res != null) {
return (T) res;
}
}
for (Map<String, ResourceProxy> rt : allResourcesById.values()) {
for (ResourceProxy r : rt.values()) {
if (uri.equals(r.getUrl())) {
@ -1459,6 +1474,17 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
}
}
if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
return null;
}
// it might be a special URL.
// if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
// Resource res = null; // findTxValueSet(uri);
// if (res != null) {
// return (T) res;
// }
// }
return null;
} else if (class_ == ImplementationGuide.class) {
return (T) guides.get(uri, version);
@ -1478,6 +1504,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return (T) codeSystems.get(uri, version);
} else if (class_ == ConceptMap.class) {
return (T) maps.get(uri, version);
} else if (class_ == ActorDefinition.class) {
return (T) actors.get(uri, version);
} else if (class_ == Requirements.class) {
return (T) requirements.get(uri, version);
} else if (class_ == PlanDefinition.class) {
return (T) plans.get(uri, version);
} else if (class_ == OperationDefinition.class) {
@ -1558,6 +1588,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (transforms.has(uri)) {
return transforms.getPackageInfo(uri, version);
}
if (actors.has(uri)) {
return actors.getPackageInfo(uri, version);
}
if (requirements.has(uri)) {
return requirements.getPackageInfo(uri, version);
}
if (questionnaires.has(uri)) {
return questionnaires.getPackageInfo(uri, version);
}
@ -1625,6 +1661,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (transforms.has(uri)) {
return (T) transforms.get(uri, version);
}
if (actors.has(uri)) {
return (T) actors.get(uri, version);
}
if (requirements.has(uri)) {
return (T) requirements.get(uri, version);
}
if (questionnaires.has(uri)) {
return (T) questionnaires.get(uri, version);
}
@ -1647,6 +1689,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return (T) structures.get(uri, version);
} else if ("StructureMap".equals(cls)) {
return (T) transforms.get(uri, version);
} else if ("Requirements".equals(cls)) {
return (T) requirements.get(uri, version);
} else if ("ActorDefinition".equals(cls)) {
return (T) actors.get(uri, version);
} else if ("ValueSet".equals(cls)) {
return (T) valueSets.get(uri, version);
} else if ("CodeSystem".equals(cls)) {
@ -1717,6 +1763,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
res.addAll((List<T>) transforms.getList());
res.addAll((List<T>) questionnaires.getList());
res.addAll((List<T>) systems.getList());
res.addAll((List<T>) actors.getList());
res.addAll((List<T>) requirements.getList());
} else if (class_ == ImplementationGuide.class) {
res.addAll((List<T>) guides.getList());
} else if (class_ == CapabilityStatement.class) {
@ -1735,6 +1783,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
res.addAll((List<T>) codeSystems.getList());
} else if (class_ == NamingSystem.class) {
res.addAll((List<T>) systems.getList());
} else if (class_ == ActorDefinition.class) {
res.addAll((List<T>) actors.getList());
} else if (class_ == Requirements.class) {
res.addAll((List<T>) requirements.getList());
} else if (class_ == ConceptMap.class) {
res.addAll((List<T>) maps.getList());
} else if (class_ == PlanDefinition.class) {
@ -1941,6 +1993,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} else if (fhirType.equals("NamingSystem")) {
systems.drop(id);
systemUrlMap = null;
} else if (fhirType.equals("ActorDefinition")) {
actors.drop(id);
} else if (fhirType.equals("Requirements")) {
requirements.drop(id);
}
}
}
@ -2081,6 +2137,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return transforms.get(url).getUserString("path");
}
if (actors.has(url)) {
return actors.get(url).getUserString("path");
}
if (requirements.has(url)) {
return requirements.get(url).getUserString("path");
}
if (structures.has(url)) {
return structures.get(url).getUserString("path");
}
@ -2176,6 +2240,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
operations.setVersion(version);
plans.setVersion(version);
systems.setVersion(version);
actors.setVersion(version);
requirements.setVersion(version);
}
protected String tail(String url) {
@ -2236,7 +2302,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
public int countAllCaches() {
return codeSystems.size() + valueSets.size() + maps.size() + transforms.size() + structures.size() + measures.size() + libraries.size() +
guides.size() + capstmts.size() + searchParameters.size() + questionnaires.size() + operations.size() + plans.size() + systems.size();
guides.size() + capstmts.size() + searchParameters.size() + questionnaires.size() + operations.size() + plans.size() +
systems.size()+ actors.size()+ requirements.size();
}
public Set<String> getCodeSystemsUsed() {

View File

@ -282,11 +282,17 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
}
@Override
public boolean isDatatype(String type) {
public boolean isPrimitiveType(String type) {
StructureDefinition sd = context.fetchTypeDefinition(type);
return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE;
}
@Override
public boolean isDatatype(String type) {
StructureDefinition sd = context.fetchTypeDefinition(type);
return sd != null && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE) && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION;
}
@Override
public boolean isResource(String t) {
StructureDefinition sd;

View File

@ -55,6 +55,7 @@ import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.TypeConvertor;
import org.hl7.fhir.r5.model.Base.ValidationInfo;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.utilities.ElementDecoration;
@ -75,7 +76,6 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode;
*/
public class Element extends Base {
public enum SpecialElement {
CONTAINED, BUNDLE_ENTRY, BUNDLE_OUTCOME, PARAMETER, LOGICAL;
@ -128,6 +128,7 @@ public class Element extends Base {
private int descendentCount;
private int instanceId;
private boolean isNull;
private Base source;
public Element(String name) {
super();
@ -1140,11 +1141,49 @@ public class Element extends Base {
this.instanceId = instanceId;
}
@Override
public boolean hasValidationInfo() {
return hasSource() ? source.hasValidationInfo() : super.hasValidationInfo();
}
@Override
public List<ValidationInfo> getValidationInfo() {
return hasSource() ? source.getValidationInfo() : super.getValidationInfo();
}
@Override
public ValidationInfo addDefinition(StructureDefinition source, ElementDefinition defn, ValidationMode mode) {
if (this.source != null) {
return this.source.addDefinition(source, defn, mode);
} else {
return super.addDefinition(source, defn, mode);
}
}
public boolean hasSource() {
return source != null;
}
public Base getSource() {
return source;
}
public void setSource(Base source) {
this.source = source;
}
public void printToOutput() {
printToOutput(System.out, "");
}
public void printToOutput(PrintStream stream) {
printToOutput(stream, "");
}
private void printToOutput(PrintStream out, String indent) {
String s = indent+name +(index == -1 ? "" : "["+index+"]") +(special != null ? "$"+special.toHuman(): "")+ (type!= null || explicitType != null ? " : "+type+(explicitType != null ? "/'"+explicitType+"'" : "") : "");
if (isNull) {

View File

@ -300,7 +300,7 @@ public class Property {
}
protected List<Property> getChildProperties(String elementName, String statedType) throws FHIRException {
public List<Property> getChildProperties(String elementName, String statedType) throws FHIRException {
ElementDefinition ed = definition;
StructureDefinition sd = structure;
SourcedChildDefinitions children = profileUtilities.getChildMap(sd, ed);

View File

@ -3,15 +3,36 @@ package org.hl7.fhir.r5.elementmodel;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;
import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element.SpecialElement;
import org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement;
import org.hl7.fhir.r5.elementmodel.ParserBase.ValidationPolicy;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
public class ResourceParser extends ParserBase {
@ -30,5 +51,94 @@ public class ResourceParser extends ParserBase {
throw new NotImplementedException("compose(Element e, OutputStream destination, OutputStyle style, String base)"); // doesns't make sense
}
/**
* It's possible to get an element model from an resource by writing it to a stream, and reading it,
* but this loads it directly, and links to the element model from the resource model
*
* @param resource
* @return
* @throws IOException
*/
public Element parse(Resource resource) {
StructureDefinition sd = context.fetchTypeDefinition(resource.fhirType());
if (sd == null) {
throw new FHIRException("No definition exists for "+resource.fhirType());
}
Property p = new Property(context, sd.getSnapshot().getElement().get(0), sd, new ProfileUtilities(context, null, null));
String path = resource.fhirType();
Element e = new Element(resource.fhirType(), p);
e.setPath(path);
e.setType(resource.fhirType());
parseChildren(path, resource, e);
e.numberChildren();
return e;
}
private void parseChildren(String path, Base src, Element dst) {
dst.setSource(src);
List<Property> properties = dst.getProperty().getChildProperties(dst.getName(), null);
for (org.hl7.fhir.r5.model.Property c : src.children()) {
if (c.hasValues()) {
Property p = getPropertyByName(properties, c.getName());
if (p == null) {
throw new FHIRException("Unable to find property for "+path+"."+c.getName());
}
int i = 0;
for (Base v : c.getValues()) {
String npath = path+"."+c.getName()+(p.isList() ? "["+i+"]" : "");
i++;
String name = c.getName();
if (name.endsWith("[x]")) {
name = name.substring(0, name.length()-3)+Utilities.capitalize(v.fhirType());
}
Element n = new Element(name, p);
dst.getChildren().add(n);
if (v.isPrimitive()) {
if (v.fhirType().equals("xhtml")) {
n.setXhtml(v.getXhtml());
try {
n.setValue(new XhtmlComposer(true).compose(n.getXhtml()));
} catch (Exception e) {
// won't happen here
}
} else {
n.setValue(v.primitiveValue());
}
// if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
// try {
// n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
// } catch (Exception e) {
// logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_XHTML_, e.getMessage()), IssueSeverity.ERROR);
// }
// }
// }
}
n.setPath(npath);
if (p.isResource()) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(v.fhirType(), null));
if (sd == null)
throw new FHIRFormatError(context.formatMessage(I18nConstants.CONTAINED_RESOURCE_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAME_, v.fhirType()));
n.updateProperty(new Property(context, sd.getSnapshot().getElement().get(0), sd), SpecialElement.fromProperty(n.getProperty()), p);
n.setType(v.fhirType());
parseChildren(npath, v, n);
} else {
parseChildren(npath, v, n);
}
}
}
}
}
private Property getPropertyByName(List<Property> properties, String name) {
for (Property p : properties) {
if (p.getName().equals(name)) {
return p;
}
}
return null;
}
}

View File

@ -15,10 +15,87 @@ import ca.uhn.fhir.model.api.IElement;
public abstract class Base implements Serializable, IBase, IElement {
public enum ValidationReason {
Validation, MatchingSlice, Expression
}
public enum ProfileSource {
BaseDefinition, ConfigProfile, MetaProfile, ProfileDependency, FromExpression, GlobalProfile
}
public static class ValidationMode {
private ValidationReason reason;
private ProfileSource source;
public ValidationMode(ValidationReason reason, ProfileSource source) {
super();
this.reason = reason;
this.source = source;
}
public ValidationReason getReason() {
return reason;
}
public ProfileSource getSource() {
return source;
}
public ValidationMode withSource(ProfileSource source) {
ValidationMode res = new ValidationMode(reason, source);
return res;
}
public ValidationMode withReason(ValidationReason reason) {
ValidationMode res = new ValidationMode(reason, source);
return res;
}
}
public class ValidationInfo {
private StructureDefinition structure;
private ElementDefinition definition;
private ValidationReason reason;
private ProfileSource source;
private boolean valid;
public ValidationInfo(StructureDefinition structure, ElementDefinition definition, ValidationMode mode) {
super();
this.structure = structure;
this.definition = definition;
this.reason = mode.reason;
this.source = mode.source;
}
public StructureDefinition getStructure() {
return structure;
}
public ElementDefinition getDefinition() {
return definition;
}
public ValidationReason getReason() {
return reason;
}
public ProfileSource getSource() {
return source;
}
public boolean isValid() {
return valid;
}
public void setValid(boolean valid) {
this.valid = valid;
}
}
/**
* User appended data items - allow users to add extra information to the class
*/
private Map<String, Object> userData;
private transient Map<String, Object> userData;
/**
* Post Validation Definition information
*/
private transient List<ValidationInfo> validationInfo;
/**
* Round tracking xml comments for testing convenience
@ -351,4 +428,33 @@ private Map<String, Object> userData;
return null;
}
public boolean hasValidationInfo() {
return validationInfo != null;
}
/**
* A list of definitions that the validator matched this element to.
* Note that the element doesn't have to conform to these definitions - check whether they're valid
* Some of the definitions will be noted because of slice matching
*
* @return
*/
public List<ValidationInfo> getValidationInfo() {
return validationInfo;
}
public ValidationInfo addDefinition(StructureDefinition structure, ElementDefinition defn, ValidationMode mode) {
if (validationInfo == null) {
validationInfo = new ArrayList<>();
}
for (ValidationInfo t : validationInfo) {
if (t.structure == structure && t.definition == defn && t.reason == mode.reason && t.source == mode.source) {
return t;
}
}
ValidationInfo vi = new ValidationInfo(structure, defn, mode);
this.validationInfo.add(vi);
return vi;
}
}

View File

@ -287,6 +287,7 @@ public class Narrative extends BaseNarrative implements INarrative {
protected void listChildren(List<Property> children) {
super.listChildren(children);
children.add(new Property("status", "code", "The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data.", 0, 1, status));
children.add(new Property("div", "xhtml", "he actual narrative content, a stripped down version of XHTML", 0, 1, new XhtmlType(this)));
}
@Override

View File

@ -2842,6 +2842,15 @@ public class Requirements extends CanonicalResource {
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam VERSION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_VERSION);
public RequirementsStatementComponent findStatement(String key) {
for (RequirementsStatementComponent t : getStatement()) {
if (key.equals(t.getKey())) {
return t;
}
}
return null;
}
}

View File

@ -2,42 +2,21 @@ 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);
}
@ -94,112 +73,7 @@ public class ActorDefinitionRenderer extends ResourceRenderer {
}
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));
}
@ -220,195 +94,5 @@ public class ActorDefinitionRenderer extends ResourceRenderer {
}
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

@ -1,7 +1,6 @@
package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

View File

@ -7,7 +7,6 @@ import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
@ -17,15 +16,12 @@ import org.hl7.fhir.r5.model.Bundle.BundleEntrySearchComponent;
import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.Composition;
import org.hl7.fhir.r5.model.Composition.SectionComponent;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
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;

View File

@ -5,8 +5,7 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
@ -14,11 +13,10 @@ import org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.SystemInteractionComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.SystemRestfulInteraction;
import org.hl7.fhir.r5.model.CapabilityStatement.TypeRestfulInteraction;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.model.Resource;
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.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class CapabilityStatementRenderer extends ResourceRenderer {

View File

@ -16,7 +16,6 @@ import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent;
import org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent;
import org.hl7.fhir.r5.model.CodeSystem.PropertyComponent;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.Resource;

View File

@ -5,13 +5,12 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.CompartmentDefinition;
import org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StringType;
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.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;

View File

@ -16,7 +16,6 @@ import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent;
import org.hl7.fhir.r5.model.ContactDetail;
import org.hl7.fhir.r5.model.ContactPoint;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;

View File

@ -1,27 +1,20 @@
package org.hl7.fhir.r5.renderers;
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoField.YEAR;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.chrono.IsoChronology;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.FormatStyle;
import java.time.format.ResolverStyle;
import java.time.format.SignStyle;
import java.util.Currency;
import java.util.List;
import java.util.TimeZone;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
@ -40,12 +33,12 @@ 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.ContactPoint;
import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem;
import org.hl7.fhir.r5.model.DataRequirement;
import org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent;
import org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent;
import org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent;
import org.hl7.fhir.r5.model.DataRequirement.SortDirection;
import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.DateType;
@ -79,22 +72,17 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.MarkDownProcessor;
import org.hl7.fhir.utilities.MarkDownProcessor.Dialect;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
public class DataRenderer extends Renderer {
// -- 1. context --------------------------------------------------------------

View File

@ -8,11 +8,10 @@ import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DiagnosticReport;
import org.hl7.fhir.r5.model.Resource;
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;

View File

@ -3,10 +3,9 @@ package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class EncounterRenderer extends ResourceRenderer {

View File

@ -5,11 +5,10 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
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.utilities.xhtml.XhtmlNode;

View File

@ -8,18 +8,12 @@ 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.Annotation;
import org.hl7.fhir.r5.model.Attachment;
import org.hl7.fhir.r5.model.Base;
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.renderers.utils.BaseWrappers.BaseWrapper;
@ -27,7 +21,6 @@ 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;

View File

@ -9,11 +9,9 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.LiquidRenderer.LiquidRendererContxt;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
import org.hl7.fhir.r5.utils.EOperationOutcome;

View File

@ -7,7 +7,6 @@ import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.Annotation;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.ListResource;
import org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent;
import org.hl7.fhir.r5.model.Reference;

View File

@ -5,18 +5,14 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.NamingSystem;
import org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
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.terminologies.CodeSystemUtilities;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class NamingSystemRenderer extends ResourceRenderer {

View File

@ -3,11 +3,8 @@ package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.OperationDefinition;
import org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent;

View File

@ -5,7 +5,6 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.ExtensionHelper;
import org.hl7.fhir.r5.model.OperationOutcome;
@ -13,8 +12,8 @@ import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
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.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;

View File

@ -7,18 +7,8 @@ import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.Bundle.BundleEntryRequestComponent;
import org.hl7.fhir.r5.model.Bundle.BundleEntryResponseComponent;
import org.hl7.fhir.r5.model.Bundle.BundleEntrySearchComponent;
import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.Composition;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper;

View File

@ -9,19 +9,15 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.poi.hssf.record.chart.DatRecord;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.Address;
import org.hl7.fhir.r5.model.Attachment;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.ContactPoint;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.DateType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.HumanName;
import org.hl7.fhir.r5.model.HumanName.NameUse;
@ -32,11 +28,10 @@ import org.hl7.fhir.r5.model.Period;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.PatientRenderer.NamedReferance;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
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.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;

View File

@ -14,9 +14,7 @@ import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.context.ContextUtilities;
import org.hl7.fhir.r5.formats.FormatUtilities;
import org.hl7.fhir.r5.model.Address;
import org.hl7.fhir.r5.model.Annotation;
import org.hl7.fhir.r5.model.Attachment;
@ -30,6 +28,7 @@ import org.hl7.fhir.r5.model.Coding;
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.DataType;
import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Dosage;
@ -45,7 +44,6 @@ import org.hl7.fhir.r5.model.Meta;
import org.hl7.fhir.r5.model.Money;
import org.hl7.fhir.r5.model.Narrative;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.Period;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Property;
@ -59,16 +57,14 @@ import org.hl7.fhir.r5.model.SampledData;
import org.hl7.fhir.r5.model.Signature;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.Timing;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.UsageContext;
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.DOMWrappers.BaseWrapperElement;
import org.hl7.fhir.r5.renderers.utils.DOMWrappers.ResourceWrapperElement;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers;
import org.hl7.fhir.r5.renderers.utils.ElementWrappers;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.BaseWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.PropertyWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect;
@ -82,10 +78,7 @@ import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.hl7.fhir.utilities.xml.XMLUtil;
import org.w3c.dom.Element;
public class ProfileDrivenRenderer extends ResourceRenderer {
@ -148,8 +141,62 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
@Override
public String display(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
return "Not done yet";
public String display(ResourceWrapper res) throws UnsupportedEncodingException, IOException {
StructureDefinition profile = getContext().getWorker().fetchTypeDefinition(res.fhirType());
if (profile == null)
return "unknown resource type " +res.fhirType();
else {
boolean firstElement = true;
boolean last = false;
List<PropertyWrapper> children = res.children();
ContextUtilities cu = new ContextUtilities(context.getWorker());
for (PropertyWrapper p : children) {
if (p.getName().equals("title") && cu.isDatatype(p.fhirType()) && p.hasValues()) {
return res.fhirType()+" "+ display((DataType) p.getValues().get(0).getBase());
}
}
for (PropertyWrapper p : children) {
if (p.getName().equals("name") && cu.isDatatype(p.fhirType()) && p.hasValues()) {
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (BaseWrapper v : p.getValues()) {
b.append((display((DataType) v.getBase())));
}
return res.fhirType()+" "+ b.toString();
}
}
for (PropertyWrapper p : children) {
if (p.getName().equals("code") && cu.isDatatype(p.fhirType()) && p.hasValues()) {
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (BaseWrapper v : p.getValues()) {
b.append((display((DataType) v.getBase())));
}
return res.fhirType()+" "+ b.toString();
}
}
for (PropertyWrapper p : children) {
StringBuilder b = new StringBuilder();
if (!ignoreProperty(p) && !p.getElementDefinition().getBase().getPath().startsWith("Resource.")) {
ElementDefinition child = getElementDefinition(profile.getSnapshot().getElement(), res.fhirType()+"."+p.getName(), p);
if (p.getValues().size() > 0 && p.getValues().get(0) != null && child != null && isSimple(child) && includeInSummary(child, p.getValues())) {
if (firstElement)
firstElement = false;
else if (last)
b.append("; ");
boolean first = true;
last = false;
for (BaseWrapper v : p.getValues()) {
if (first)
first = false;
else if (last)
b.append(", ");
b.append((display((DataType) v.getBase())));
}
}
}
return res.fhirType()+" "+ b.toString();
}
return res.fhirType()+" ???";
}
}
//
@ -254,7 +301,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
for (PropertyWrapper p : res.children()) {
if (!ignoreProperty(p) && !p.getElementDefinition().getBase().getPath().startsWith("Resource.")) {
ElementDefinition child = getElementDefinition(profile.getSnapshot().getElement(), path+"."+p.getName(), p);
if (p.getValues().size() > 0 && p.getValues().get(0) != null && child != null && isPrimitive(child) && includeInSummary(child, p.getValues())) {
if (p.getValues().size() > 0 && p.getValues().get(0) != null && child != null && isSimple(child) && includeInSummary(child, p.getValues())) {
if (firstElement)
firstElement = false;
else if (last)
@ -621,7 +668,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
private boolean isPrimitive(ElementDefinition e) {
private boolean isSimple(ElementDefinition e) {
//we can tell if e is a primitive because it has types
if (e.getType().isEmpty()) {
return false;
@ -744,7 +791,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
List<ElementDefinition> grandChildren = getChildrenForPath(profile, allElements, path+"."+p.getName());
filterGrandChildren(grandChildren, path+"."+p.getName(), p);
if (p.getValues().size() > 0) {
if (isPrimitive(child)) {
if (isSimple(child)) {
XhtmlNode para = x.isPara() ? para = x : x.para();
String name = p.getName();
if (name.endsWith("[x]"))
@ -853,7 +900,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
for (ElementDefinition e : grandChildren) {
List<PropertyWrapper> values = getValues(path, p, e);
if (values.size() > 1 || !isPrimitive(e) || !canCollapse(e))
if (values.size() > 1 || !isSimple(e) || !canCollapse(e))
return false;
}
return true;

View File

@ -4,14 +4,13 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class ProvenanceRenderer extends ResourceRenderer {

View File

@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.ContextUtilities;
@ -12,13 +11,9 @@ import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Expression;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent;
@ -26,16 +21,18 @@ import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class QuestionnaireRenderer extends TerminologyRenderer {

View File

@ -2,40 +2,26 @@ package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Expression;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.QuestionnaireResponse;
import org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent;
import org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public class QuestionnaireResponseRenderer extends ResourceRenderer {

View File

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

View File

@ -0,0 +1,241 @@
package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.context.ContextUtilities;
import org.hl7.fhir.r5.model.ActorDefinition;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Library;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Requirements;
import org.hl7.fhir.r5.model.Requirements.ConformanceExpectation;
import org.hl7.fhir.r5.model.Requirements.RequirementsStatementComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.UrlType;
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 RequirementsRenderer extends ResourceRenderer {
public RequirementsRenderer(RenderingContext context) {
super(context);
}
public RequirementsRenderer(RenderingContext context, ResourceContext rcontext) {
super(context, rcontext);
}
public boolean render(XhtmlNode x, Resource dr) throws FHIRFormatError, DefinitionException, IOException {
return render(x, (Requirements) dr);
}
public boolean render(XhtmlNode x, Requirements req) throws FHIRFormatError, DefinitionException, IOException {
if (req.hasActor()) {
if (req.getActor().size() == 1) {
ActorDefinition acd = context.getWorker().fetchResource(ActorDefinition.class, req.getActor().get(0).getValue());
XhtmlNode p = x.para();
p.tx("These requirements apply to the actor ");
if (acd == null) {
p.code(req.getActor().get(0).getValue());
} else {
p.ah(acd.getUserString("path")).tx(acd.present());
}
} else {
x.para().tx("These requirements apply to the following actors:");
XhtmlNode ul = x.ul();
for (CanonicalType a : req.getActor()) {
ActorDefinition acd = context.getWorker().fetchResource(ActorDefinition.class, a.getValue());
if (acd == null) {
ul.li().code(a.getValue());
} else {
ul.li().ah(acd.getUserString("path")).tx(acd.present());
}
}
}
}
if (req.hasDerivedFrom()) {
if (req.getDerivedFrom().size() == 1) {
Requirements reqd = context.getWorker().fetchResource(Requirements.class, req.getDerivedFrom().get(0).getValue());
XhtmlNode p = x.para();
p.tx("These requirements derive from ");
if (reqd == null) {
p.code(req.getDerivedFrom().get(0).getValue());
} else {
p.ah(reqd.getUserString("path")).tx(reqd.present());
}
} else {
x.para().tx("These requirements are derived from the following requirements:");
XhtmlNode ul = x.ul();
for (CanonicalType a : req.getDerivedFrom()) {
Requirements reqd = context.getWorker().fetchResource(Requirements.class, a.getValue());
if (reqd == null) {
ul.li().code(a.getValue());
} else {
ul.li().ah(reqd.getUserString("path")).tx(reqd.present());
}
}
}
}
XhtmlNode tbl = x.table("grid");
for (RequirementsStatementComponent stmt : req.getStatement()) {
XhtmlNode tr = tbl.tr();
String lbl = stmt.hasLabel() ? stmt.getLabel() : stmt.getKey();
XhtmlNode td = tr.td();
td.b().an(stmt.getKey());
td.tx(lbl);
td = tr.td();
boolean first = true;
CodeSystem cs = context.getWorker().fetchCodeSystem("http://hl7.org/fhir/conformance-expectation");
for (Enumeration<ConformanceExpectation> t : stmt.getConformance()) {
if (first) first = false; else td.tx(", ");
if (cs != null) {
td.ah(cs.getUserString("path")+"#conformance-expectation-"+t.asStringValue()).tx(t.asStringValue().toUpperCase());
} else {
td.tx(t.asStringValue().toUpperCase());
}
}
td = tr.td();
addMarkdown(td, stmt.getRequirement());
if (stmt.hasDerivedFrom() || stmt.hasSatisfiedBy() || stmt.hasReference() || stmt.hasSource()) {
td.para().tx("Links:");
XhtmlNode ul = td.ul();
if (stmt.hasDerivedFrom()) {
XhtmlNode li = ul.li();
li.tx("Derived From: ");
String url = stmt.getDerivedFrom();
String key = url.contains("#") ? url.substring(url.indexOf("#")+1) : "";
if (url.contains("#")) { url = url.substring(0, url.indexOf("#")); };
Requirements reqr = context.getWorker().fetchResource(Requirements.class, url);
if (reqr != null) {
RequirementsStatementComponent stmtr = reqr.findStatement(key);
if (stmtr != null) {
li.ah(reqr.getUserString("path")+"#"+key).tx(reqr.present() + " # " +(stmt.hasLabel() ? stmt.getLabel() : stmt.getKey()));
} else {
li.ah(reqr.getUserString("path")+"#"+key).tx(reqr.present()+" # "+key);
}
} else {
li.code(stmt.getDerivedFrom());
}
}
if (stmt.hasSatisfiedBy()) {
XhtmlNode li = ul.li();
li.tx("Satisfied By: ");
first = true;
for (UrlType c : stmt.getSatisfiedBy()) {
if (first) first = false; else li.tx(", ");
String url = c.getValue();
if (url.contains("#")) {
url = url.substring(0, url.indexOf("#"));
}
Resource r = context.getWorker().fetchResource(Resource.class, url);
if (r != null) {
String desc = getResourceDescription(r, null);
li.ah(c.getValue()).tx(desc);
} else {
li.ah(c.getValue()).tx(url);
}
}
}
if (stmt.hasReference()) {
XhtmlNode li = ul.li();
li.tx("References: ");
int i = 0;
for (UrlType c : stmt.getSatisfiedBy()) {
i++;
if (i>1) li.tx(", ");
String url = c.getValue();
if (url.contains("#")) {
url = url.substring(0, url.indexOf("#"));
}
li.ah(c.getValue()).tx(url);
}
}
if (stmt.hasSource()) {
XhtmlNode li = ul.li();
li.tx("Source: ");
first = true;
for (Reference c : stmt.getSource()) {
if (first) first = false; else li.tx(", ");
if (c.hasReference()) {
String url = c.getReference();
if (url.contains("#")) {
url = url.substring(0, url.indexOf("#"));
}
Resource r = context.getWorker().fetchResource(Resource.class, url);
ResourceWithReference t = null;
if (r == null) {
t = context.getResolver().resolve(context, url);
}
if (r != null) {
String desc = getResourceDescription(r, c.getDisplay());
li.ah(c.getReference()).tx(desc);
} else if (t != null) {
String desc = getResourceDescription(t, c.getDisplay());
li.ah(t.getReference()).tx(desc);
} else {
li.ah(c.getReference()).tx(url);
}
} else if (c.hasDisplay()) {
li.tx(c.getDisplay());
} else {
li.tx("??");
}
}
}
}
}
return false;
}
private String getResourceDescription(ResourceWithReference res, String display) throws UnsupportedEncodingException, IOException {
if (!Utilities.noString(display)) {
return display;
}
return RendererFactory.factory(res.getResource(), context).display(res.getResource());
}
private String getResourceDescription(Resource res, String display) throws UnsupportedEncodingException, IOException {
if (!Utilities.noString(display)) {
return display;
}
if (res instanceof CanonicalResource) {
return ((CanonicalResource) res).present();
}
return RendererFactory.factory(res, context).display(res);
}
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 "??";
}
}

View File

@ -3,32 +3,29 @@ package org.hl7.fhir.r5.renderers;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r5.model.CodeableReference;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r5.model.Narrative;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet;
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.DirectWrappers.ResourceWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.ElementWrappers.ResourceWrapperMetaElement;
import org.hl7.fhir.r5.renderers.ResourceRenderer.RendererType;
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;

View File

@ -4,16 +4,10 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Enumerations.AllResourceTypes;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.OperationDefinition;
import org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.SearchParameter;
import org.hl7.fhir.r5.model.SearchParameter.SearchComparator;
@ -24,7 +18,6 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;

View File

@ -5,12 +5,11 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
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.utilities.xhtml.XhtmlNode;

View File

@ -18,7 +18,6 @@ import org.hl7.fhir.r5.model.ConceptMap;
import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent;
import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;

View File

@ -27,7 +27,6 @@ import org.hl7.fhir.r5.model.Enumerations.FilterOperator;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.ExtensionHelper;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;

View File

@ -59,6 +59,10 @@ public class NarrativeGenerationTests {
public boolean isDatatype(String typeSimple) {
throw new NotImplementedException();
}
@Override
public boolean isPrimitiveType(String typeSimple) {
throw new NotImplementedException();
}
@Override
public boolean isResource(String typeSimple) {

View File

@ -0,0 +1,130 @@
package org.hl7.fhir.r5.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.ResourceParser;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Observation;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.test.utils.CompareUtilities;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.utilities.Utilities;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class ResourceToElementTest {
private void runTest(String filename) throws IOException, FileNotFoundException, Exception {
String src = Utilities.path("[tmp]", Utilities.changeFileExt(filename, ".out.xml"));
String dst = Utilities.path("[tmp]", Utilities.changeFileExt(filename, ".in.xml"));
IWorkerContext ctxt = TestingUtilities.getSharedWorkerContext();
ResourceParser p = new ResourceParser(ctxt);
Resource res = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", filename));
Element e = p.parse(res);
new org.hl7.fhir.r5.elementmodel.XmlParser(ctxt).compose(e, new FileOutputStream(src), OutputStyle.PRETTY, null);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dst), res);
String msg = CompareUtilities.checkXMLIsSame(src, dst);
Assertions.assertNull(msg);
}
@Test
public void testObservation() throws Exception {
runTest("observation-example.xml");
}
@Test
public void testPatient() throws Exception {
runTest("patient-example.xml");
}
@Test
public void testPatientGlossy() throws Exception {
runTest("patient-glossy-example.xml");
}
@Test
public void testPatientPeriod() throws Exception {
runTest("patient-example-period.xml");
}
@Test
public void testPatientXds() throws Exception {
runTest("patient-example-xds.xml");
}
@Test
public void testQuestionnaire() throws Exception {
runTest("questionnaire-example.xml");
}
@Test
public void testQuestionnaireLifelines() throws Exception {
runTest("questionnaire-example-f201-lifelines.xml");
}
@Test
public void testValueSet() throws Exception {
runTest("valueset-example-expansion.xml");
}
@Test
public void testParameters() throws Exception {
runTest("parameters-example.xml");
}
@Test
public void testParametersTypes() throws Exception {
runTest("parameters-example-types.xml");
}
@Test
public void testObservation2() throws Exception {
runTest("observation-example-20minute-apgar-score.xml");
}
@Test
public void testDispense() throws Exception {
runTest("medicationdispenseexample8.xml");
}
@Test
public void testDispense2() throws Exception {
runTest("medicationdispense8.xml");
}
@Test
public void testList() throws Exception {
runTest("list-example-long.xml");
}
@Test
public void testCondition() throws Exception {
runTest("condition-example.xml");
}
@Test
public void testCodesystem() throws Exception {
runTest("codesystem-example.xml");
}
}

View File

@ -215,6 +215,13 @@ public class SnapShotGenerationTests {
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
}
@Override
public boolean isPrimitiveType(String name) {
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(name);
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE);
}
@Override
public boolean isResource(String typeSimple) {
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(typeSimple);

Some files were not shown because too many files have changed in this diff Show More