Merge pull request #1454 from hapifhir/2023-10-gg-cda-fixes-2

2023 10 gg cda fixes 2
This commit is contained in:
Grahame Grieve 2023-10-09 14:59:21 +03:00 committed by GitHub
commit a30218177f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 1176 additions and 426 deletions

View File

@ -41,7 +41,7 @@ public class VersionConvertorConstants {
public final static String MODIFIER_REASON_LEGACY = "No Modifier Reason provideed in previous versions of FHIR"; public final static String MODIFIER_REASON_LEGACY = "No Modifier Reason provideed in previous versions of FHIR";
public final static String PROFILE_EXTENSION = "http://hl7.org/fhir/4.0/StructureDefinition/extension-ElementDefinition.type.profile"; public final static String PROFILE_EXTENSION = "http://hl7.org/fhir/4.0/StructureDefinition/extension-ElementDefinition.type.profile";
public final static String IG_CONFORMANCE_MESSAGE_EVENT = "http://hl7.org/fhir/1.0/StructureDefinition/extension-Conformance.messaging.event"; public final static String IG_CONFORMANCE_MESSAGE_EVENT = "http://hl7.org/fhir/1.0/StructureDefinition/extension-Conformance.messaging.event";
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence"; public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.group.element.target.equivalence";
public static final String EXT_ACTUAL_RESOURCE_NAME = "http://hl7.org/fhir/tools/StructureDefinition/original-resource-name"; public static final String EXT_ACTUAL_RESOURCE_NAME = "http://hl7.org/fhir/tools/StructureDefinition/original-resource-name";
public static final String EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL = QuestionnaireRenderer.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL; public static final String EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL = QuestionnaireRenderer.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL;
public static final String EXT_NAMINGSYSTEM_TITLE = "http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.title"; public static final String EXT_NAMINGSYSTEM_TITLE = "http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.title";

View File

@ -148,13 +148,13 @@ public class ConceptMap10_50 {
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException { public static org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent ccm) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu2.model.Enumerations.ConceptMapEquivalenceEnumFactory()); org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu2.model.Enumerations.ConceptMapEquivalenceEnumFactory());
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE); ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)); tgt.setValueAsString(ccm.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
} else { } else {
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
@ -177,12 +177,12 @@ public class ConceptMap10_50 {
return tgt; return tgt;
} }
public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> src) throws FHIRException { public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu2.model.Enumeration<ConceptMapEquivalence> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgtCtxt) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory()); Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString()); ToolingExtensions.setCodeExtensionMod(tgtCtxt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);
@ -283,12 +283,12 @@ public class ConceptMap10_50 {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu2.model.ConceptMap.TargetElementComponent(); org.hl7.fhir.dstu2.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu2.model.ConceptMap.TargetElementComponent();
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
tgt.setCodeSystem(g.getTarget()); tgt.setCodeSystem(g.getTarget());
if (src.hasCodeElement()) if (src.hasCodeElement())
tgt.setCodeElement(Code10_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code10_50.convertCode(src.getCodeElement()));
if (src.hasRelationship()) if (src.hasRelationship())
tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement())); tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement(), src));
if (src.hasCommentElement()) if (src.hasCommentElement())
tgt.setCommentsElement(String10_50.convertString(src.getCommentElement())); tgt.setCommentsElement(String10_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
@ -306,7 +306,7 @@ public class ConceptMap10_50 {
if (src.hasCodeElement()) if (src.hasCodeElement())
tgt.setCodeElement(Code10_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code10_50.convertCode(src.getCodeElement()));
if (src.hasEquivalence()) if (src.hasEquivalence())
tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement())); tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement(), tgt));
if (src.hasCommentsElement()) if (src.hasCommentsElement())
tgt.setCommentElement(String10_50.convertString(src.getCommentsElement())); tgt.setCommentElement(String10_50.convertString(src.getCommentsElement()));
for (org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.dstu2.model.ConceptMap.OtherElementComponent t : src.getDependsOn())

View File

@ -151,13 +151,13 @@ public class ConceptMap14_50 {
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException { public static org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent ccm) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConceptMapEquivalenceEnumFactory()); org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConceptMapEquivalenceEnumFactory());
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE); ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)); tgt.setValueAsString(ccm.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
} else { } else {
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
@ -180,12 +180,12 @@ public class ConceptMap14_50 {
return tgt; return tgt;
} }
public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> src) throws FHIRException { public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu2016may.model.Enumeration<ConceptMapEquivalence> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgtCtxt) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory()); Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString()); ToolingExtensions.setCodeExtensionMod(tgtCtxt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);
@ -293,13 +293,13 @@ public class ConceptMap14_50 {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent(); org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu2016may.model.ConceptMap.TargetElementComponent();
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt); ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
if (g.hasTarget()) if (g.hasTarget())
tgt.setSystem(g.getTarget()); tgt.setSystem(g.getTarget());
if (src.hasCode()) if (src.hasCode())
tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement()));
if (src.hasRelationship()) if (src.hasRelationship())
tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement())); tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement(), src));
if (src.hasComment()) if (src.hasComment())
tgt.setCommentsElement(String14_50.convertString(src.getCommentElement())); tgt.setCommentsElement(String14_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
@ -317,7 +317,7 @@ public class ConceptMap14_50 {
if (src.hasCode()) if (src.hasCode())
tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement()));
if (src.hasEquivalence()) if (src.hasEquivalence())
tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement())); tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement(), tgt));
if (src.hasComments()) if (src.hasComments())
tgt.setCommentElement(String14_50.convertString(src.getCommentsElement())); tgt.setCommentElement(String14_50.convertString(src.getCommentsElement()));
for (org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.dstu2016may.model.ConceptMap.OtherElementComponent t : src.getDependsOn())

View File

@ -247,13 +247,13 @@ public class ConceptMap30_50 {
return tgt; return tgt;
} }
public static org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException { public static org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent ccm) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalenceEnumFactory()); org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalenceEnumFactory());
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE); ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)); tgt.setValueAsString(ccm.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
} else { } else {
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
@ -279,12 +279,12 @@ public class ConceptMap30_50 {
return tgt; return tgt;
} }
public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> src) throws FHIRException { public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgtCtxt) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory()); Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString()); ToolingExtensions.setCodeExtensionMod(tgtCtxt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);
@ -402,7 +402,7 @@ public class ConceptMap30_50 {
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
if (src.hasEquivalence()) if (src.hasEquivalence())
tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement())); tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement(), tgt));
if (src.hasComment()) if (src.hasComment())
tgt.setCommentElement(String30_50.convertString(src.getCommentElement())); tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
@ -416,13 +416,13 @@ public class ConceptMap30_50 {
if (src == null) if (src == null)
return null; return null;
org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent(); org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent();
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
if (src.hasCode()) if (src.hasCode())
tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
if (src.hasRelationship()) if (src.hasRelationship())
tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement())); tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement(), src));
if (src.hasComment()) if (src.hasComment())
tgt.setCommentElement(String30_50.convertString(src.getCommentElement())); tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn())

View File

@ -242,7 +242,7 @@ public class ConceptMap40_50 {
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
if (src.hasEquivalence()) if (src.hasEquivalence())
tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement())); tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement(), tgt));
if (src.hasComment()) if (src.hasComment())
tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); tgt.setCommentElement(String40_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.r4.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
@ -256,13 +256,13 @@ public class ConceptMap40_50 {
if (src == null) if (src == null)
return null; return null;
org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent(); org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent();
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
if (src.hasCode()) if (src.hasCode())
tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
if (src.hasRelationship()) if (src.hasRelationship())
tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement())); tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement(), src));
else else
tgt.setEquivalence(ConceptMapEquivalence.RELATEDTO); tgt.setEquivalence(ConceptMapEquivalence.RELATEDTO);
if (src.hasComment()) if (src.hasComment())
@ -274,13 +274,13 @@ public class ConceptMap40_50 {
return tgt; return tgt;
} }
public static org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException { public static org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent ccm) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalenceEnumFactory()); org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalenceEnumFactory());
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE); ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)); tgt.setValueAsString(ccm.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
} else { } else {
switch (src.getValue()) { switch (src.getValue()) {
case RELATEDTO: case RELATEDTO:
@ -306,12 +306,12 @@ public class ConceptMap40_50 {
return tgt; return tgt;
} }
public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> src) throws FHIRException { public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.r4.model.Enumeration<ConceptMapEquivalence> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgtCtxt) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory()); Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString()); ToolingExtensions.setCodeExtensionMod(tgtCtxt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);

View File

@ -241,7 +241,7 @@ public class ConceptMap43_50 {
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String43_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String43_50.convertString(src.getDisplayElement()));
if (src.hasEquivalence()) if (src.hasEquivalence())
tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement())); tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement(), tgt));
if (src.hasComment()) if (src.hasComment())
tgt.setCommentElement(String43_50.convertString(src.getCommentElement())); tgt.setCommentElement(String43_50.convertString(src.getCommentElement()));
for (org.hl7.fhir.r4b.model.ConceptMap.OtherElementComponent t : src.getDependsOn()) for (org.hl7.fhir.r4b.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
@ -255,13 +255,13 @@ public class ConceptMap43_50 {
if (src == null) if (src == null)
return null; return null;
org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent(); org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent();
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
if (src.hasCode()) if (src.hasCode())
tgt.setCodeElement(Code43_50.convertCode(src.getCodeElement())); tgt.setCodeElement(Code43_50.convertCode(src.getCodeElement()));
if (src.hasDisplay()) if (src.hasDisplay())
tgt.setDisplayElement(String43_50.convertString(src.getDisplayElement())); tgt.setDisplayElement(String43_50.convertString(src.getDisplayElement()));
if (src.hasRelationship()) if (src.hasRelationship())
tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement())); tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement(), src));
else else
tgt.setEquivalence(org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence.RELATEDTO); tgt.setEquivalence(org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence.RELATEDTO);
if (src.hasComment()) if (src.hasComment())
@ -273,13 +273,13 @@ public class ConceptMap43_50 {
return tgt; return tgt;
} }
public static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException { public static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent ccm) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> tgt = new org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence>(new org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalenceEnumFactory()); org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> tgt = new org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence>(new org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalenceEnumFactory());
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE); ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)); tgt.setValueAsString(ccm.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
} else { } else {
switch (src.getValue()) { switch (src.getValue()) {
case RELATEDTO: case RELATEDTO:
@ -305,12 +305,12 @@ public class ConceptMap43_50 {
return tgt; return tgt;
} }
public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> src) throws FHIRException { public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ConceptMap.ConceptMapEquivalence> src, org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgtCtxt) throws FHIRException {
if (src == null || src.isEmpty()) if (src == null || src.isEmpty())
return null; return null;
Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory()); Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString()); ToolingExtensions.setCodeExtensionMod(tgtCtxt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
switch (src.getValue()) { switch (src.getValue()) {
case EQUIVALENT: case EQUIVALENT:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);

View File

@ -107,6 +107,13 @@ public class R5ToR5Loader extends BaseLoaderR5 {
if (patchUrls) { if (patchUrls) {
doPatchUrls(r5); doPatchUrls(r5);
} }
if (r5 instanceof StructureDefinition) {
StructureDefinition sd = (StructureDefinition) r5;
if ("http://hl7.org/fhir/StructureDefinition/Base".equals(sd.getUrl())) {
sd.getSnapshot().getElementFirstRep().getConstraint().clear();
}
}
return r5; return r5;
} }

View File

@ -88,6 +88,8 @@ import org.hl7.fhir.dstu3.model.Type;
import org.hl7.fhir.dstu3.model.UriType; import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.BackboneElement;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source; import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
@ -434,6 +436,29 @@ public class ToolingExtensions {
resource.getExtension().add(new Extension(new UriType(uri)).setValue(new IntegerType(value))); resource.getExtension().add(new Extension(new UriType(uri)).setValue(new IntegerType(value)));
} }
public static void setCodeExtensionMod(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setCodeExtensionMod(BackboneElement resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
// public static String getOID(CodeSystem define) { // public static String getOID(CodeSystem define) {
// return readStringExtension(define, EXT_OID); // return readStringExtension(define, EXT_OID);
// } // }

View File

@ -27,7 +27,7 @@ package org.hl7.fhir.r4.model;
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 // Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
import java.util.ArrayList; import java.util.ArrayList;
@ -35,6 +35,7 @@ import java.util.List;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement; import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef; import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@ -277,7 +278,7 @@ public abstract class BackboneElement extends Element implements IBaseBackboneEl
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension);
} }
// added from java-adornments.txt: // added from java-adornments.txt:
public void checkNoModifiers(String noun, String verb) throws FHIRException { public void checkNoModifiers(String noun, String verb) throws FHIRException {
if (hasModifierExtension()) { if (hasModifierExtension()) {
@ -286,6 +287,119 @@ public abstract class BackboneElement extends Element implements IBaseBackboneEl
} }
// end addition public void addModifierExtension(String url, Type value) {
if (isDisallowExtensions())
throw new Error("Extensions are not allowed in this context");
Extension ex = new Extension();
ex.setUrl(url);
ex.setValue(value);
getModifierExtension().add(ex);
}
@Override
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>();
Extension res = super.getExtensionByUrl(theUrl);
if (res != null) {
retVal.add(res);
}
for (Extension next : getModifierExtension()) {
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);
}
}
@Override
public void removeExtension(String theUrl) {
for (int i = getModifierExtension().size()-1; i >= 0; i--) {
if (theUrl.equals(getExtension().get(i).getUrl()))
getExtension().remove(i);
}
super.removeExtension(theUrl);
}
/**
* Returns an unmodifiable list containing all extensions on this element which
* match the given URL.
*
* @param theUrl The URL. Must not be blank or null.
* @return an unmodifiable list containing all extensions on this element which
* match the given URL
*/
@Override
public List<Extension> getExtensionsByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
ArrayList<Extension> retVal = new ArrayList<Extension>();
retVal.addAll(super.getExtensionsByUrl(theUrl));
for (Extension next : getModifierExtension()) {
if (theUrl.equals(next.getUrl())) {
retVal.add(next);
}
}
return java.util.Collections.unmodifiableList(retVal);
}
public void copyExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) {
super.copyExtensions(src,urls);
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addModifierExtension(e.copy());
}
}
}
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition
} }

View File

@ -27,7 +27,7 @@ package org.hl7.fhir.r4.model;
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
// Generated on Mon, Mar 5, 2018 18:26+1100 for FHIR v3.2.0 // Generated on Mon, Mar 5, 2018 18:26+1100 for FHIR v3.2.0
import java.util.ArrayList; import java.util.ArrayList;
@ -35,6 +35,7 @@ import java.util.List;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement; import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef; import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@ -267,15 +268,65 @@ public abstract class BackboneType extends Type implements IBaseBackboneElement
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension);
} }
// added from java-adornments.txt: // added from java-adornments.txt:
public void checkNoModifiers(String noun, String verb) throws FHIRException { public void checkNoModifiers(String noun, String verb) throws FHIRException {
if (hasModifierExtension()) { if (hasModifierExtension()) {
throw new FHIRException("Found unknown Modifier Exceptions on " + noun + " doing " + verb); throw new FHIRException("Found unknown Modifier Exceptions on " + noun + " doing " + verb);
} }
} }
// end addition public void copyExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) {
super.copyExtensions(src,urls);
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addModifierExtension(e.copy());
}
}
}
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition
} }

View File

@ -27,7 +27,7 @@ package org.hl7.fhir.r4.model;
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 // Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
import java.util.ArrayList; import java.util.ArrayList;
@ -36,6 +36,7 @@ import java.util.List;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseElement; import org.hl7.fhir.instance.model.api.IBaseElement;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
import org.hl7.fhir.utilities.StandardsStatus;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.Child;
@ -393,7 +394,7 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
setId(value); setId(value);
} }
// added from java-adornments.txt: // added from java-adornments.txt:
public void addExtension(String url, Type value) { public void addExtension(String url, Type value) {
if (disallowExtensions) if (disallowExtensions)
throw new Error("Extensions are not allowed in this context"); throw new Error("Extensions are not allowed in this context");
@ -446,6 +447,58 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
return this; return this;
} }
// end addition
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return false;
}
public boolean hasExtension(Extension ext) {
if (hasExtension()) {
for (Extension t : getExtension()) {
if (Base.compareDeep(t, ext, false)) {
return true;
}
}
}
return false;
}
public void copyExtensions(org.hl7.fhir.r4.model.Element src, String... urls) {
for (Extension e : src.getExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addExtension(e.copy());
}
}
}
public void copyNewExtensions(org.hl7.fhir.r4.model.Element src, String... urls) {
for (Extension e : src.getExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
}
// end addition
} }

View File

@ -10,7 +10,7 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.context.SimpleWorkerContext; import org.hl7.fhir.r4.context.SimpleWorkerContext;
import org.hl7.fhir.r4.formats.IParser.OutputStyle; import org.hl7.fhir.r4.formats.IParser.OutputStyle;
import org.hl7.fhir.r4.formats.JsonParser; import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.formats.XmlParser;
import org.hl7.fhir.r4.model.Base; import org.hl7.fhir.r4.model.Base;
import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle;
@ -26,6 +26,8 @@ import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Immunization; import org.hl7.fhir.r4.model.Immunization;
import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Immunization;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Period; import org.hl7.fhir.r4.model.Period;
import org.hl7.fhir.r4.model.Procedure; import org.hl7.fhir.r4.model.Procedure;
@ -118,7 +120,7 @@ public class CmdLineApp {
} else if (p.length > 3 && p[0].equals("tx")) { } else if (p.length > 3 && p[0].equals("tx")) {
tx(p); tx(p);
} else { } else {
tx(p); System.out.println("Command unknown or not understood: "+cmd);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error executing command "+p[0]+": "+e.getMessage()); System.out.println("Error executing command "+p[0]+": "+e.getMessage());
@ -170,7 +172,6 @@ public class CmdLineApp {
} }
private void getImmunizations() throws IOException { private void getImmunizations() throws IOException {
Bundle bnd = client.search("Immunization", "?patient="+currentId); Bundle bnd = client.search("Immunization", "?patient="+currentId);
System.out.println(""+bnd.getTotal()+" Immunizations found. Printing "+bnd.getEntry().size()); System.out.println(""+bnd.getTotal()+" Immunizations found. Printing "+bnd.getEntry().size());

View File

@ -92,6 +92,7 @@ import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.UrlType; import org.hl7.fhir.r4.model.UrlType;
import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4.model.BackboneElement;
import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.StandardsStatus;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -551,6 +552,30 @@ public class ToolingExtensions {
element.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value))); element.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value)));
} }
public static void setCodeExtensionMod(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setCodeExtensionMod(BackboneElement resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setIntegerExtension(DomainResource resource, String uri, int value) { public static void setIntegerExtension(DomainResource resource, String uri, int value) {
Extension ext = getExtension(resource, uri); Extension ext = getExtension(resource, uri);
if (ext != null) if (ext != null)

View File

@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hl7.fhir.r4b.model.Enumerations.*; import org.hl7.fhir.r4b.model.Enumerations.*;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.ICompositeType;
@ -349,6 +350,57 @@ public abstract class BackboneElement extends DataType implements IBaseBackboneE
return java.util.Collections.unmodifiableList(retVal); return java.util.Collections.unmodifiableList(retVal);
} }
public void copyExtensions(org.hl7.fhir.r4b.model.BackboneElement src, String... urls) {
super.copyExtensions(src,urls);
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addModifierExtension(e.copy());
}
}
}
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r4b.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition // end addition
} }

View File

@ -34,6 +34,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hl7.fhir.r4b.model.Enumerations.*; import org.hl7.fhir.r4b.model.Enumerations.*;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.ICompositeType;
@ -288,6 +289,58 @@ public abstract class BackboneType extends DataType implements IBaseBackboneElem
} }
} }
public void copyExtensions(org.hl7.fhir.r4b.model.BackboneElement src, String... urls) {
super.copyExtensions(src,urls);
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addModifierExtension(e.copy());
}
}
}
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r4b.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition // end addition
} }

View File

@ -445,12 +445,15 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
* Note: BackbdoneElements override this to add matching Modifier Extensions too * Note: BackbdoneElements override this to add matching Modifier Extensions too
* *
* @param theUrl The URL. Must not be blank or null. * @param theUrl The URL. Must not be blank or null.
* @return an unmodifiable list containing all extensions on this element which * @return an unmodifiable list containing all extensions on this element which match the given URL
* match the given URL
*/ */
public List<Extension> getExtensionsByUrl(String theUrl) { public List<Extension> getExtensionsByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); if (theUrl == null) {
ArrayList<Extension> retVal = new ArrayList<Extension>(); throw new NullPointerException("theUrl must not be null");
} else if (theUrl.length() == 0) {
throw new IllegalArgumentException("theUrl must not be empty");
}
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getExtension()) { for (Extension next : getExtension()) {
if (theUrl.equals(next.getUrl())) { if (theUrl.equals(next.getUrl())) {
retVal.add(next); retVal.add(next);
@ -459,6 +462,28 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
return java.util.Collections.unmodifiableList(retVal); return java.util.Collections.unmodifiableList(retVal);
} }
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return false;
}
/** /**
* Returns an true if this element has an extension that matchs the given URL. * Returns an true if this element has an extension that matchs the given URL.
* *
@ -467,12 +492,21 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
* @param theUrl The URL. Must not be blank or null. * @param theUrl The URL. Must not be blank or null.
*/ */
public boolean hasExtension(String theUrl) { public boolean hasExtension(String theUrl) {
return !getExtensionsByUrl(theUrl).isEmpty(); if (extension == null || extension.size() == 0) {
return false;
}
for (Extension ext : extension) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return false;
} }
/** /**
* Returns the value as a string if this element has only one extension that * Returns the value as a string if this element has only one extension that matches the given URL, and that can be converted to a string.
* matches the given URL, and that can be converted to a string.
* *
* Note: BackbdoneElements override this to check Modifier Extensions too * Note: BackbdoneElements override this to check Modifier Extensions too
* *
@ -483,12 +517,42 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
if (ext.isEmpty()) if (ext.isEmpty())
return null; return null;
if (ext.size() > 1) if (ext.size() > 1)
throw new FHIRException("Multiple matching extensions found"); throw new FHIRException("Multiple matching extensions found for extension '"+theUrl+"'");
if (!ext.get(0).hasValue())
return null;
if (!ext.get(0).getValue().isPrimitive()) if (!ext.get(0).getValue().isPrimitive())
throw new FHIRException("Extension could not be converted to a string"); throw new FHIRException("Extension '"+theUrl+"' could not be converted to a string");
return ext.get(0).getValue().primitiveValue(); return ext.get(0).getValue().primitiveValue();
} }
public boolean hasExtension(Extension ext) {
if (hasExtension()) {
for (Extension t : getExtension()) {
if (Base.compareDeep(t, ext, false)) {
return true;
}
}
}
return false;
}
public void copyExtensions(org.hl7.fhir.r4b.model.Element src, String... urls) {
for (Extension e : src.getExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addExtension(e.copy());
}
}
}
public void copyNewExtensions(org.hl7.fhir.r4b.model.Element src, String... urls) {
for (Extension e : src.getExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
}
// end addition // end addition
} }

View File

@ -97,6 +97,7 @@ import org.hl7.fhir.r4b.model.UriType;
import org.hl7.fhir.r4b.model.UrlType; import org.hl7.fhir.r4b.model.UrlType;
import org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4b.model.BackboneElement;
import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.StandardsStatus;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -106,8 +107,8 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
public class ToolingExtensions { public class ToolingExtensions {
// validated // validated
// private static final String EXT_OID = "http://hl7.org/fhir/StructureDefinition/valueset-oid"; // private static final String EXT_OID = "http://hl7.org/fhir/StructureDefinition/valueset-oid";
// public static final String EXT_DEPRECATED = "http://hl7.org/fhir/StructureDefinition/codesystem-deprecated"; // public static final String EXT_DEPRECATED = "http://hl7.org/fhir/StructureDefinition/codesystem-deprecated";
public static final String EXT_DEFINITION = "http://hl7.org/fhir/StructureDefinition/valueset-concept-definition"; public static final String EXT_DEFINITION = "http://hl7.org/fhir/StructureDefinition/valueset-concept-definition";
public static final String EXT_CS_COMMENT = "http://hl7.org/fhir/StructureDefinition/codesystem-concept-comments"; public static final String EXT_CS_COMMENT = "http://hl7.org/fhir/StructureDefinition/codesystem-concept-comments";
public static final String EXT_VS_COMMENT = "http://hl7.org/fhir/StructureDefinition/valueset-concept-comments"; public static final String EXT_VS_COMMENT = "http://hl7.org/fhir/StructureDefinition/valueset-concept-comments";
@ -134,12 +135,12 @@ public class ToolingExtensions {
public static final String EXT_MAPPING_PREFIX = "http://hl7.org/fhir/tools/StructureDefinition/logical-mapping-prefix"; public static final String EXT_MAPPING_PREFIX = "http://hl7.org/fhir/tools/StructureDefinition/logical-mapping-prefix";
public static final String EXT_MAPPING_SUFFIX = "http://hl7.org/fhir/tools/StructureDefinition/logical-mapping-suffix"; public static final String EXT_MAPPING_SUFFIX = "http://hl7.org/fhir/tools/StructureDefinition/logical-mapping-suffix";
// public static final String EXT_FLYOVER = "http://hl7.org/fhir/Profile/questionnaire-extensions#flyover"; // public static final String EXT_FLYOVER = "http://hl7.org/fhir/Profile/questionnaire-extensions#flyover";
public static final String EXT_QTYPE = "http://hl7.org/fhir/StructureDefinition/questionnnaire-baseType"; public static final String EXT_QTYPE = "http://hl7.org/fhir/StructureDefinition/questionnnaire-baseType";
// private static final String EXT_QREF = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference"; // private static final String EXT_QREF = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference";
// private static final String EXTENSION_FILTER_ONLY = "http://www.healthintersections.com.au/fhir/Profile/metadata#expandNeedsFilter"; // private static final String EXTENSION_FILTER_ONLY = "http://www.healthintersections.com.au/fhir/Profile/metadata#expandNeedsFilter";
// private static final String EXT_TYPE = "http://www.healthintersections.com.au/fhir/Profile/metadata#type"; // private static final String EXT_TYPE = "http://www.healthintersections.com.au/fhir/Profile/metadata#type";
// private static final String EXT_REFERENCE = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference"; // private static final String EXT_REFERENCE = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference";
private static final String EXT_FHIRTYPE = "http://hl7.org/fhir/StructureDefinition/questionnaire-fhirType"; private static final String EXT_FHIRTYPE = "http://hl7.org/fhir/StructureDefinition/questionnaire-fhirType";
private static final String EXT_ALLOWABLE_UNITS = "http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"; private static final String EXT_ALLOWABLE_UNITS = "http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits";
public static final String EXT_CIMI_REFERENCE = "http://hl7.org/fhir/StructureDefinition/cimi-reference"; public static final String EXT_CIMI_REFERENCE = "http://hl7.org/fhir/StructureDefinition/cimi-reference";
@ -166,8 +167,8 @@ public class ToolingExtensions {
public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv"; public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv";
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle"; public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle";
public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information"; public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information";
// public static final String EXT_IGP_CONTAINED_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/contained-resource-information"; // public static final String EXT_IGP_CONTAINED_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/contained-resource-information";
// public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion"; // public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion";
public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"; public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet";
public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"; public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet";
public static final String EXT_PROFILE_ELEMENT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element"; public static final String EXT_PROFILE_ELEMENT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element";
@ -182,7 +183,7 @@ public class ToolingExtensions {
public static final String EXT_FHIR_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; public static final String EXT_FHIR_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type"; public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type";
public static final String EXT_RENDERED_VALUE = "http://hl7.org/fhir/StructureDefinition/rendered-value"; public static final String EXT_RENDERED_VALUE = "http://hl7.org/fhir/StructureDefinition/rendered-value";
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence"; public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.group.element.target.equivalence";
public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"; public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly";
public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support"; public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support";
public static final String EXT_TRANSLATABLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable"; public static final String EXT_TRANSLATABLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable";
@ -223,15 +224,15 @@ public class ToolingExtensions {
return getExtension(e, url) != null; return getExtension(e, url) != null;
} }
// public static void addStringExtension(DomainResource dr, String url, String content) { // public static void addStringExtension(DomainResource dr, String url, String content) {
// if (!StringUtils.isBlank(content)) { // if (!StringUtils.isBlank(content)) {
// Extension ex = getExtension(dr, url); // Extension ex = getExtension(dr, url);
// if (ex != null) // if (ex != null)
// ex.setValue(new StringType(content)); // ex.setValue(new StringType(content));
// else // else
// dr.getExtension().add(Factory.newExtension(url, new StringType(content), true)); // dr.getExtension().add(Factory.newExtension(url, new StringType(content), true));
// } // }
// } // }
public static void addMarkdownExtension(DomainResource dr, String url, String content) { public static void addMarkdownExtension(DomainResource dr, String url, String content) {
if (!StringUtils.isBlank(content)) { if (!StringUtils.isBlank(content)) {
@ -320,10 +321,10 @@ public class ToolingExtensions {
nc.getExtension().add(Factory.newExtension(EXT_CS_COMMENT, Factory.newString_(comment), true)); nc.getExtension().add(Factory.newExtension(EXT_CS_COMMENT, Factory.newString_(comment), true));
} }
// public static void markDeprecated(Element nc) { // public static void markDeprecated(Element nc) {
// setDeprecated(nc); // setDeprecated(nc);
// } // }
// //
public static void addDefinition(Element nc, String definition) { public static void addDefinition(Element nc, String definition) {
if (!StringUtils.isBlank(definition)) if (!StringUtils.isBlank(definition))
@ -459,18 +460,18 @@ public class ToolingExtensions {
public static String getCSComment(ConceptDefinitionComponent c) { public static String getCSComment(ConceptDefinitionComponent c) {
return readStringExtension(c, EXT_CS_COMMENT); return readStringExtension(c, EXT_CS_COMMENT);
} }
// //
// public static Boolean getDeprecated(Element c) { // public static Boolean getDeprecated(Element c) {
// return readBooleanExtension(c, EXT_DEPRECATED); // return readBooleanExtension(c, EXT_DEPRECATED);
// } // }
public static boolean hasCSComment(ConceptDefinitionComponent c) { public static boolean hasCSComment(ConceptDefinitionComponent c) {
return findStringExtension(c, EXT_CS_COMMENT); return findStringExtension(c, EXT_CS_COMMENT);
} }
// public static boolean hasDeprecated(Element c) { // public static boolean hasDeprecated(Element c) {
// return findBooleanExtension(c, EXT_DEPRECATED); // return findBooleanExtension(c, EXT_DEPRECATED);
// } // }
public static void addFlyOver(QuestionnaireItemComponent item, String text, String linkId) { public static void addFlyOver(QuestionnaireItemComponent item, String text, String linkId) {
if (!StringUtils.isBlank(text)) { if (!StringUtils.isBlank(text)) {
@ -582,6 +583,28 @@ public class ToolingExtensions {
element.getExtension().add(new Extension(uri).setValue(new CodeType(value))); element.getExtension().add(new Extension(uri).setValue(new CodeType(value)));
} }
public static void setCodeExtensionMod(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setCodeExtensionMod(BackboneElement resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setIntegerExtension(DomainResource resource, String uri, int value) { public static void setIntegerExtension(DomainResource resource, String uri, int value) {
Extension ext = getExtension(resource, uri); Extension ext = getExtension(resource, uri);
if (ext != null) if (ext != null)
@ -590,34 +613,34 @@ public class ToolingExtensions {
resource.getExtension().add(new Extension(uri).setValue(new IntegerType(value))); resource.getExtension().add(new Extension(uri).setValue(new IntegerType(value)));
} }
// public static String getOID(CodeSystem define) { // public static String getOID(CodeSystem define) {
// return readStringExtension(define, EXT_OID); // return readStringExtension(define, EXT_OID);
// } // }
// //
// public static String getOID(ValueSet vs) { // public static String getOID(ValueSet vs) {
// return readStringExtension(vs, EXT_OID); // return readStringExtension(vs, EXT_OID);
// } // }
// //
// public static void setOID(CodeSystem define, String oid) throws FHIRFormatError, URISyntaxException { // public static void setOID(CodeSystem define, String oid) throws FHIRFormatError, URISyntaxException {
// if (!oid.startsWith("urn:oid:")) // if (!oid.startsWith("urn:oid:"))
// throw new FHIRFormatError("Error in OID format"); // throw new FHIRFormatError("Error in OID format");
// if (oid.startsWith("urn:oid:urn:oid:")) // if (oid.startsWith("urn:oid:urn:oid:"))
// throw new FHIRFormatError("Error in OID format"); // throw new FHIRFormatError("Error in OID format");
// if (!hasExtension(define, EXT_OID)) // if (!hasExtension(define, EXT_OID))
// define.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false)); // define.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false));
// else if (!oid.equals(readStringExtension(define, EXT_OID))) // else if (!oid.equals(readStringExtension(define, EXT_OID)))
// throw new Error("Attempt to assign multiple OIDs to a code system"); // throw new Error("Attempt to assign multiple OIDs to a code system");
// } // }
// public static void setOID(ValueSet vs, String oid) throws FHIRFormatError, URISyntaxException { // public static void setOID(ValueSet vs, String oid) throws FHIRFormatError, URISyntaxException {
// if (!oid.startsWith("urn:oid:")) // if (!oid.startsWith("urn:oid:"))
// throw new FHIRFormatError("Error in OID format"); // throw new FHIRFormatError("Error in OID format");
// if (oid.startsWith("urn:oid:urn:oid:")) // if (oid.startsWith("urn:oid:urn:oid:"))
// throw new FHIRFormatError("Error in OID format"); // throw new FHIRFormatError("Error in OID format");
// if (!hasExtension(vs, EXT_OID)) // if (!hasExtension(vs, EXT_OID))
// vs.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false)); // vs.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false));
// else if (!oid.equals(readStringExtension(vs, EXT_OID))) // else if (!oid.equals(readStringExtension(vs, EXT_OID)))
// throw new Error("Attempt to assign multiple OIDs to value set "+vs.getName()+" ("+vs.getUrl()+"). Has "+readStringExtension(vs, EXT_OID)+", trying to add "+oid); // throw new Error("Attempt to assign multiple OIDs to value set "+vs.getName()+" ("+vs.getUrl()+"). Has "+readStringExtension(vs, EXT_OID)+", trying to add "+oid);
// } // }
public static boolean hasLanguageTranslation(Element element, String lang) { public static boolean hasLanguageTranslation(Element element, String lang) {
for (Extension e : element.getExtension()) { for (Extension e : element.getExtension()) {
@ -687,23 +710,23 @@ public class ToolingExtensions {
return results; return results;
} }
// public static void addDEReference(DataElement de, String value) { // public static void addDEReference(DataElement de, String value) {
// for (Extension e : de.getExtension()) // for (Extension e : de.getExtension())
// if (e.getUrl().equals(EXT_CIMI_REFERENCE)) { // if (e.getUrl().equals(EXT_CIMI_REFERENCE)) {
// e.setValue(new UriType(value)); // e.setValue(new UriType(value));
// return; // return;
// } // }
// de.getExtension().add(new Extension().setUrl(EXT_CIMI_REFERENCE).setValue(new UriType(value))); // de.getExtension().add(new Extension().setUrl(EXT_CIMI_REFERENCE).setValue(new UriType(value)));
// } // }
// public static void setDeprecated(Element nc) { // public static void setDeprecated(Element nc) {
// for (Extension e : nc.getExtension()) // for (Extension e : nc.getExtension())
// if (e.getUrl().equals(EXT_DEPRECATED)) { // if (e.getUrl().equals(EXT_DEPRECATED)) {
// e.setValue(new BooleanType(true)); // e.setValue(new BooleanType(true));
// return; // return;
// } // }
// nc.getExtension().add(new Extension().setUrl(EXT_DEPRECATED).setValue(new BooleanType(true))); // nc.getExtension().add(new Extension().setUrl(EXT_DEPRECATED).setValue(new BooleanType(true)));
// } // }
public static void setExtension(Element focus, String url, Coding c) { public static void setExtension(Element focus, String url, Coding c) {
for (Extension e : focus.getExtension()) for (Extension e : focus.getExtension())
@ -908,14 +931,14 @@ public class ToolingExtensions {
return type.primitiveValue(); return type.primitiveValue();
} }
// public static boolean hasOID(ValueSet vs) { // public static boolean hasOID(ValueSet vs) {
// return hasExtension(vs, EXT_OID); // return hasExtension(vs, EXT_OID);
// } // }
// //
// public static boolean hasOID(CodeSystem cs) { // public static boolean hasOID(CodeSystem cs) {
// return hasExtension(cs, EXT_OID); // return hasExtension(cs, EXT_OID);
// } // }
// //
public static void addUrlExtension(Element e, String url, String content) { public static void addUrlExtension(Element e, String url, String content) {
if (!StringUtils.isBlank(content)) { if (!StringUtils.isBlank(content)) {
Extension ex = getExtension(e, url); Extension ex = getExtension(e, url);

View File

@ -8,7 +8,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
/** /**
* This doesn't do anythign at this time * This works around known issues in struture definitions
* *
* @author graha * @author graha
* *

View File

@ -2472,7 +2472,30 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return res; return res;
} }
} }
return typeManager.fetchTypeDefinition(typeName); StructureDefinition p = typeManager.fetchTypeDefinition(typeName);
if (p != null && !p.isGeneratedSnapshot()) {
if (p.isGeneratingSnapshot()) {
throw new FHIRException("Attempt to fetch the profile "+p.getVersionedUrl()+" while generating the snapshot for it");
}
try {
if (logger.isDebugLogging()) {
System.out.println("Generating snapshot for "+p.getVersionedUrl());
}
p.setGeneratingSnapshot(true);
try {
new ContextUtilities(this).generateSnapshot(p);
} finally {
p.setGeneratingSnapshot(false);
}
} catch (Exception e) {
// not sure what to do in this case?
System.out.println("Unable to generate snapshot @4 for "+p.getVersionedUrl()+": "+e.getMessage());
if (logger.isDebugLogging()) {
e.printStackTrace();
}
}
}
return p;
} }
@Override @Override

View File

@ -95,6 +95,9 @@ public class Manager {
return null; return null;
} }
public static FhirFormat readFromMimeType(String mt) { public static FhirFormat readFromMimeType(String mt) {
if (mt == null) {
return null;
}
if (mt.contains("/xml") || mt.contains("+xml")) { if (mt.contains("/xml") || mt.contains("+xml")) {
return FhirFormat.XML; return FhirFormat.XML;
} }

View File

@ -49,6 +49,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.IDigitalSignatureServices;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
@ -86,6 +87,7 @@ public abstract class ParserBase {
protected boolean showDecorations; protected boolean showDecorations;
protected IdRenderingPolicy idPolicy = IdRenderingPolicy.All; protected IdRenderingPolicy idPolicy = IdRenderingPolicy.All;
protected StructureDefinition logical; protected StructureDefinition logical;
protected IDigitalSignatureServices signatureServices;
public ParserBase(IWorkerContext context) { public ParserBase(IWorkerContext context) {
super(); super();
@ -281,4 +283,12 @@ public abstract class ParserBase {
return this; return this;
} }
public IDigitalSignatureServices getSignatureServices() {
return signatureServices;
}
public void setSignatureServices(IDigitalSignatureServices signatureServices) {
this.signatureServices = signatureServices;
}
} }

View File

@ -329,7 +329,7 @@ public class SHCParser extends ParserBase {
String url = Utilities.pathURL(iss, "/.well-known/jwks.json"); String url = Utilities.pathURL(iss, "/.well-known/jwks.json");
JsonObject jwks = null; JsonObject jwks = null;
try { try {
jwks = org.hl7.fhir.utilities.json.parser.JsonParser.parseObjectFromUrl(url); jwks = signatureServices != null ? signatureServices.fetchJWKS(url) : org.hl7.fhir.utilities.json.parser.JsonParser.parseObjectFromUrl(url);
} catch (Exception e) { } catch (Exception e) {
logError(errors, "2023-09-08", 1, 1, name, IssueType.NOTFOUND, "Unable to verify the signature, because unable to retrieve JWKS from "+url+": "+ logError(errors, "2023-09-08", 1, 1, name, IssueType.NOTFOUND, "Unable to verify the signature, because unable to retrieve JWKS from "+url+": "+
e.getMessage().replace("Connection refused (Connection refused)", "Connection refused"), IssueSeverity.ERROR); e.getMessage().replace("Connection refused (Connection refused)", "Connection refused"), IssueSeverity.ERROR);

View File

@ -326,8 +326,7 @@ public class XmlParser extends ParserBase {
n.setPath(element.getPath()+"."+property.getName()); n.setPath(element.getPath()+"."+property.getName());
element.getChildren().add(n); element.getChildren().add(n);
} }
} } else {
else {
Node n = node.getFirstChild(); Node n = node.getFirstChild();
while (n != null) { while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) { if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) {

View File

@ -323,7 +323,48 @@ Modifier extensions SHALL NOT change the meaning of any elements on Resource or
} }
} }
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r5.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition // end addition

View File

@ -35,6 +35,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hl7.fhir.r5.model.Enumerations.*; import org.hl7.fhir.r5.model.Enumerations.*;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.ICompositeType;
@ -243,14 +244,67 @@ Modifier extensions SHALL NOT change the meaning of any elements on Resource or
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension);
} }
// Manual code (from Configuration.txt): // Manual code (from Configuration.txt):
public void checkNoModifiers(String noun, String verb) throws FHIRException { public void checkNoModifiers(String noun, String verb) throws FHIRException {
if (hasModifierExtension()) { if (hasModifierExtension()) {
throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb); throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb);
} }
} }
// end addition
public void copyExtensions(org.hl7.fhir.r5.model.BackboneElement src, String... urls) {
super.copyExtensions(src,urls);
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls)) {
addModifierExtension(e.copy());
}
}
}
public List<Extension> getExtensionsByUrl(String... theUrls) {
ArrayList<Extension> retVal = new ArrayList<>();
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
retVal.add(next);
}
}
retVal.addAll(super.getExtensionsByUrl(theUrls));
return java.util.Collections.unmodifiableList(retVal);
}
public boolean hasExtension(String... theUrls) {
for (Extension next : getModifierExtension()) {
if (Utilities.existsInList(next.getUrl(), theUrls)) {
return true;
}
}
return super.hasExtension(theUrls);
}
public boolean hasExtension(String theUrl) {
for (Extension ext : getModifierExtension()) {
if (theUrl.equals(ext.getUrl())) {
return true;
}
}
return super.hasExtension(theUrl);
}
public void copyNewExtensions(org.hl7.fhir.r5.model.BackboneElement src, String... urls) {
for (Extension e : src.getModifierExtension()) {
if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) {
addExtension(e.copy());
}
}
super.copyNewExtensions(src, urls);
}
// end addition
} }

View File

@ -132,6 +132,7 @@ public class TypeDetails {
private List<ProfiledType> types = new ArrayList<ProfiledType>(); private List<ProfiledType> types = new ArrayList<ProfiledType>();
private CollectionStatus collectionStatus; private CollectionStatus collectionStatus;
private Set<String> targets; // or, not and, canonical urls private Set<String> targets; // or, not and, canonical urls
private boolean choice;
public TypeDetails(CollectionStatus collectionStatus, String... names) { public TypeDetails(CollectionStatus collectionStatus, String... names) {
super(); super();
@ -308,6 +309,9 @@ public class TypeDetails {
} }
targets.addAll(source.targets); targets.addAll(source.targets);
} }
if (source.isChoice()) {
choice = true;
}
} }
public TypeDetails union(TypeDetails right) { public TypeDetails union(TypeDetails right) {
@ -537,4 +541,12 @@ public class TypeDetails {
return collectionStatus != null && collectionStatus.isList(); return collectionStatus != null && collectionStatus.isList();
} }
// for SQL-on-FHIR: warnings when .ofType() is not paired with a choice element
public void setChoice(boolean b) {
choice = true;
}
public boolean isChoice() {
return choice;
}
} }

View File

@ -169,8 +169,8 @@ public class ConceptMapRenderer extends TerminologyRenderer {
if (!ccm.hasRelationship()) if (!ccm.hasRelationship())
tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")"); tr.td().tx(":"+"("+ConceptMapRelationship.EQUIVALENT.toCode()+")");
else { else {
if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) { if (ccm.hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE); String code = ToolingExtensions.readStringExtension(ccm, ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
tr.td().ah(eqpath+"#"+code, code).tx(presentEquivalenceCode(code)); tr.td().ah(eqpath+"#"+code, code).tx(presentEquivalenceCode(code));
} else { } else {
tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode(), ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode())); tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode(), ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));

View File

@ -848,8 +848,16 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
if (element.hasSliceName()) if (element.hasSliceName())
sName = sName +":"+element.getSliceName(); sName = sName +":"+element.getSliceName();
used.used = true; used.used = true;
if (logicalModel && element.hasRepresentation(PropertyRepresentation.XMLATTR)) if (logicalModel) {
if (element.hasRepresentation(PropertyRepresentation.XMLATTR)) {
sName = "@"+sName; sName = "@"+sName;
} else if (element.hasUserData("derived.pointer")) {
ElementDefinition drv = (ElementDefinition) element.getUserData("derived.pointer");
if (drv.hasRepresentation(PropertyRepresentation.XMLATTR)) {
sName = "@"+sName;
}
}
}
Cell nc = genElementNameCell(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, all); Cell nc = genElementNameCell(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, all);
switch (context.getStructureMode()) { switch (context.getStructureMode()) {
case BINDINGS: case BINDINGS:

View File

@ -135,6 +135,7 @@ public class FHIRPathEngine {
private boolean doNotEnforceAsCaseSensitive; private boolean doNotEnforceAsCaseSensitive;
private boolean allowDoubleQuotes; private boolean allowDoubleQuotes;
private List<String> typeWarnings = new ArrayList<>(); private List<String> typeWarnings = new ArrayList<>();
private boolean emitSQLonFHIRWarning;
// if the fhir path expressions are allowed to use constants beyond those defined in the specification // if the fhir path expressions are allowed to use constants beyond those defined in the specification
// the application can implement them by providing a constant resolver // the application can implement them by providing a constant resolver
@ -474,7 +475,7 @@ public class FHIRPathEngine {
} }
} }
return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, elementDependencies, true, false); return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, elementDependencies, true, false, expr);
} }
/** /**
@ -531,14 +532,14 @@ public class FHIRPathEngine {
} }
} }
} }
TypeDetails res = executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, null, true, false); TypeDetails res = executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, null, true, false, expr);
warnings.addAll(typeWarnings); warnings.addAll(typeWarnings);
return res; return res;
} }
public TypeDetails checkOnTypes(Object appContext, String resourceType, TypeDetails types, ExpressionNode expr, List<String> warnings) throws FHIRLexerException, PathEngineException, DefinitionException { public TypeDetails checkOnTypes(Object appContext, String resourceType, TypeDetails types, ExpressionNode expr, List<String> warnings) throws FHIRLexerException, PathEngineException, DefinitionException {
typeWarnings.clear(); typeWarnings.clear();
TypeDetails res = executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, null, true, false); TypeDetails res = executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, null, true, false, expr);
warnings.addAll(typeWarnings); warnings.addAll(typeWarnings);
return res; return res;
} }
@ -566,7 +567,7 @@ public class FHIRPathEngine {
} }
} }
return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, elementDependencies, true, false); return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, elementDependencies, true, false, expr);
} }
private FHIRException makeExceptionPlural(Integer num, ExpressionNode holder, String constName, Object... args) { private FHIRException makeExceptionPlural(Integer num, ExpressionNode holder, String constName, Object... args) {
@ -615,13 +616,13 @@ public class FHIRPathEngine {
} }
} }
return executeType(new ExecutionTypeContext(appContext, sd.getUrl(), types, types), types, expr, null, true, false); return executeType(new ExecutionTypeContext(appContext, sd.getUrl(), types, types), types, expr, null, true, false, expr);
} }
public TypeDetails check(Object appContext, StructureDefinition sd, ExpressionNode expr) throws FHIRLexerException, PathEngineException, DefinitionException { public TypeDetails check(Object appContext, StructureDefinition sd, ExpressionNode expr) throws FHIRLexerException, PathEngineException, DefinitionException {
// if context is a path that refers to a type, do that conversion now // if context is a path that refers to a type, do that conversion now
TypeDetails types = null; // this is a special case; the first path reference will have to resolve to something in the context TypeDetails types = null; // this is a special case; the first path reference will have to resolve to something in the context
return executeType(new ExecutionTypeContext(appContext, sd == null ? null : sd.getUrl(), null, types), types, expr, null, true, false); return executeType(new ExecutionTypeContext(appContext, sd == null ? null : sd.getUrl(), null, types), types, expr, null, true, false, expr);
} }
public TypeDetails check(Object appContext, String resourceType, String context, String expr) throws FHIRLexerException, PathEngineException, DefinitionException { public TypeDetails check(Object appContext, String resourceType, String context, String expr) throws FHIRLexerException, PathEngineException, DefinitionException {
@ -1515,7 +1516,8 @@ public class FHIRPathEngine {
return new TypeDetails(CollectionStatus.SINGLETON, exp.getName()); return new TypeDetails(CollectionStatus.SINGLETON, exp.getName());
} }
private TypeDetails executeType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies, boolean atEntry, boolean canBeNone) throws PathEngineException, DefinitionException { private TypeDetails executeType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies, boolean atEntry, boolean canBeNone, ExpressionNode container) throws PathEngineException, DefinitionException {
TypeDetails result = new TypeDetails(null); TypeDetails result = new TypeDetails(null);
switch (exp.getKind()) { switch (exp.getKind()) {
case Name: case Name:
@ -1539,9 +1541,10 @@ public class FHIRPathEngine {
} }
} }
} }
doSQLOnFHIRCheck(result, exp);
break; break;
case Function: case Function:
result.update(evaluateFunctionType(context, focus, exp, elementDependencies)); result.update(evaluateFunctionType(context, focus, exp, elementDependencies, container));
break; break;
case Unary: case Unary:
result.addType(TypeDetails.FP_Integer); result.addType(TypeDetails.FP_Integer);
@ -1552,12 +1555,12 @@ public class FHIRPathEngine {
result.update(resolveConstantType(context, exp.getConstant(), exp)); result.update(resolveConstantType(context, exp.getConstant(), exp));
break; break;
case Group: case Group:
result.update(executeType(context, focus, exp.getGroup(), elementDependencies, atEntry, canBeNone)); result.update(executeType(context, focus, exp.getGroup(), elementDependencies, atEntry, canBeNone, exp));
} }
exp.setTypes(result); exp.setTypes(result);
if (exp.getInner() != null) { if (exp.getInner() != null) {
result = executeType(context, result, exp.getInner(), elementDependencies, false, false); result = executeType(context, result, exp.getInner(), elementDependencies, false, false, exp);
} }
if (exp.isProximal() && exp.getOperation() != null) { if (exp.isProximal() && exp.getOperation() != null) {
@ -1568,7 +1571,7 @@ public class FHIRPathEngine {
if (last.getOperation() == Operation.Is || last.getOperation() == Operation.As) { if (last.getOperation() == Operation.Is || last.getOperation() == Operation.As) {
work = executeTypeName(context, focus, next, atEntry); work = executeTypeName(context, focus, next, atEntry);
} else { } else {
work = executeType(context, focus, next, elementDependencies, atEntry, canBeNone); work = executeType(context, focus, next, elementDependencies, atEntry, canBeNone, exp);
} }
result = operateTypes(result, last.getOperation(), work, last); result = operateTypes(result, last.getOperation(), work, last);
last = next; last = next;
@ -1579,6 +1582,19 @@ public class FHIRPathEngine {
return result; return result;
} }
private void doSQLOnFHIRCheck(TypeDetails focus, ExpressionNode expr) {
if (emitSQLonFHIRWarning) {
// special Logic for SQL-on-FHIR:
if (focus.isChoice()) {
if (expr.getInner() == null || expr.getInner().getFunction() != Function.OfType) {
typeWarnings.add(worker.formatMessage(I18nConstants.FHIRPATH_CHOICE_NO_TYPE_SPECIFIER, expr.toString()));
}
} else if (expr.getInner() != null && expr.getInner().getFunction() == Function.OfType) {
typeWarnings.add(worker.formatMessage(I18nConstants.FHIRPATH_CHOICE_SPURIOUS_TYPE_SPECIFIER, expr.toString()));
}
}
}
private List<Base> resolveConstant(ExecutionContext context, Base constant, boolean beforeContext, ExpressionNode expr) throws PathEngineException { private List<Base> resolveConstant(ExecutionContext context, Base constant, boolean beforeContext, ExpressionNode expr) throws PathEngineException {
if (constant == null) { if (constant == null) {
return new ArrayList<Base>(); return new ArrayList<Base>();
@ -3129,16 +3145,16 @@ public class FHIRPathEngine {
int i = 0; int i = 0;
for (ExpressionNode expr : exp.getParameters()) { for (ExpressionNode expr : exp.getParameters()) {
if (isExpressionParameter(exp, i)) { if (isExpressionParameter(exp, i)) {
paramTypes.add(executeType(changeThis(context, focus), focus, expr, elementDependencies, true, canBeNone)); paramTypes.add(executeType(changeThis(context, focus), focus, expr, elementDependencies, true, canBeNone, expr));
} else { } else {
paramTypes.add(executeType(context, context.thisItem, expr, elementDependencies, true, canBeNone)); paramTypes.add(executeType(context, context.thisItem, expr, elementDependencies, true, canBeNone, expr));
} }
i++; i++;
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TypeDetails evaluateFunctionType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies) throws PathEngineException, DefinitionException { private TypeDetails evaluateFunctionType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies, ExpressionNode container) throws PathEngineException, DefinitionException {
List<TypeDetails> paramTypes = new ArrayList<TypeDetails>(); List<TypeDetails> paramTypes = new ArrayList<TypeDetails>();
if (exp.getFunction() == Function.Is || exp.getFunction() == Function.As || exp.getFunction() == Function.OfType) { if (exp.getFunction() == Function.Is || exp.getFunction() == Function.As || exp.getFunction() == Function.OfType) {
paramTypes.add(new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String)); paramTypes.add(new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
@ -3164,6 +3180,12 @@ public class FHIRPathEngine {
} else { } else {
evaluateParameters(context, focus, exp, elementDependencies, paramTypes, false); evaluateParameters(context, focus, exp, elementDependencies, paramTypes, false);
} }
if (exp.getFunction() == Function.First || exp.getFunction() == Function.Last || exp.getFunction() == Function.Tail || exp.getFunction() == Function.Skip || exp.getFunction() == Function.Take) {
if (focus.getCollectionStatus() == CollectionStatus.SINGLETON) {
typeWarnings.add(worker.formatMessage(I18nConstants.FHIRPATH_NOT_A_COLLECTION, container.toString()));
}
}
switch (exp.getFunction()) { switch (exp.getFunction()) {
case Empty : case Empty :
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean); return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
@ -5926,6 +5948,9 @@ public class FHIRPathEngine {
ElementDefinitionMatch ed = getElementDefinition(sdi, path, isAllowPolymorphicNames(), expr); ElementDefinitionMatch ed = getElementDefinition(sdi, path, isAllowPolymorphicNames(), expr);
if (ed != null) { if (ed != null) {
if (ed.getDefinition().isChoice()) {
result.setChoice(true);
}
if (!Utilities.noString(ed.getFixedType())) { if (!Utilities.noString(ed.getFixedType())) {
if (elementDependencies != null) { if (elementDependencies != null) {
elementDependencies.add(ed.definition); elementDependencies.add(ed.definition);
@ -6024,7 +6049,11 @@ public class FHIRPathEngine {
if (ed.getPath().equals(path)) { if (ed.getPath().equals(path)) {
if (ed.hasContentReference()) { if (ed.hasContentReference()) {
ElementDefinitionMatch res = getElementDefinitionById(sd, ed.getContentReference()); ElementDefinitionMatch res = getElementDefinitionById(sd, ed.getContentReference());
if (res == null) {
throw new Error("Unable to find "+ed.getContentReference());
} else {
res.sourceDefinition = ed; res.sourceDefinition = ed;
}
return res; return res;
} else { } else {
return new ElementDefinitionMatch(ed, null); return new ElementDefinitionMatch(ed, null);
@ -6055,7 +6084,11 @@ public class FHIRPathEngine {
if (ed.hasContentReference() && path.startsWith(ed.getPath()+".")) { if (ed.hasContentReference() && path.startsWith(ed.getPath()+".")) {
ElementDefinitionMatch m = getElementDefinitionById(sd, ed.getContentReference()); ElementDefinitionMatch m = getElementDefinitionById(sd, ed.getContentReference());
ElementDefinitionMatch res = getElementDefinition(sd, m.definition.getPath()+path.substring(ed.getPath().length()), allowTypedName, expr); ElementDefinitionMatch res = getElementDefinition(sd, m.definition.getPath()+path.substring(ed.getPath().length()), allowTypedName, expr);
if (res == null) {
throw new Error("Unable to find "+ed.getContentReference());
} else {
res.sourceDefinition = ed; res.sourceDefinition = ed;
}
return res; return res;
} }
} }
@ -6090,6 +6123,9 @@ public class FHIRPathEngine {
} }
private ElementDefinitionMatch getElementDefinitionById(StructureDefinition sd, String ref) { private ElementDefinitionMatch getElementDefinitionById(StructureDefinition sd, String ref) {
if (ref.startsWith(sd.getUrl()+"#")) {
ref = ref.replace(sd.getUrl()+"#", "#");
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) { for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ref.equals("#"+ed.getId())) { if (ref.equals("#"+ed.getId())) {
return new ElementDefinitionMatch(ed, null); return new ElementDefinitionMatch(ed, null);
@ -6411,4 +6447,13 @@ public class FHIRPathEngine {
public void setAllowDoubleQuotes(boolean allowDoubleQuotes) { public void setAllowDoubleQuotes(boolean allowDoubleQuotes) {
this.allowDoubleQuotes = allowDoubleQuotes; this.allowDoubleQuotes = allowDoubleQuotes;
} }
public boolean isEmitSQLonFHIRWarning() {
return emitSQLonFHIRWarning;
}
public void setEmitSQLonFHIRWarning(boolean emitSQLonFHIRWarning) {
this.emitSQLonFHIRWarning = emitSQLonFHIRWarning;
}
} }

View File

@ -73,7 +73,7 @@ import org.hl7.fhir.utilities.npm.ToolsVersion;
public class NPMPackageGenerator { public class NPMPackageGenerator {
public enum Category { public enum Category {
RESOURCE, EXAMPLE, OPENAPI, SCHEMATRON, RDF, OTHER, TOOL, TEMPLATE, JEKYLL; RESOURCE, EXAMPLE, OPENAPI, SCHEMATRON, RDF, OTHER, TOOL, TEMPLATE, JEKYLL, TEST;
private String getDirectory() { private String getDirectory() {
switch (this) { switch (this) {
@ -85,6 +85,7 @@ public class NPMPackageGenerator {
case OTHER: return "package/other/"; case OTHER: return "package/other/";
case TEMPLATE: return "package/other/"; case TEMPLATE: return "package/other/";
case JEKYLL: return "package/jekyll/"; case JEKYLL: return "package/jekyll/";
case TEST: return "package/tests/";
case TOOL: return "package/bin/"; case TOOL: return "package/bin/";
} }
return "/"; return "/";

View File

@ -74,6 +74,7 @@ import java.util.HashSet;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.fhir.ucum.Utilities; import org.fhir.ucum.Utilities;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.BackboneElement;
import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.BooleanType; import org.hl7.fhir.r5.model.BooleanType;
import org.hl7.fhir.r5.model.CanonicalType; import org.hl7.fhir.r5.model.CanonicalType;
@ -205,7 +206,7 @@ public class ToolingExtensions {
public static final String EXT_VS_KEYWORD = "http://hl7.org/fhir/StructureDefinition/valueset-keyWord"; public static final String EXT_VS_KEYWORD = "http://hl7.org/fhir/StructureDefinition/valueset-keyWord";
public static final String EXT_WORKGROUP = "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg"; public static final String EXT_WORKGROUP = "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg";
public static final String EXT_XML_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; public static final String EXT_XML_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence"; public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.group.element.target.equivalence";
public static final String EXT_Q_IS_SUBJ = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject"; public static final String EXT_Q_IS_SUBJ = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject";
public static final String EXT_Q_HIDDEN = "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden"; public static final String EXT_Q_HIDDEN = "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden";
public static final String EXT_Q_OTP_DISP = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay"; public static final String EXT_Q_OTP_DISP = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay";
@ -674,6 +675,28 @@ public class ToolingExtensions {
resource.getExtension().add(new Extension(uri).setValue(new CodeType(value))); resource.getExtension().add(new Extension(uri).setValue(new CodeType(value)));
} }
public static void setCodeExtensionMod(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setCodeExtensionMod(BackboneElement resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new CodeType(value));
else
resource.getModifierExtension().add(new Extension(uri).setValue(new CodeType(value)));
}
public static void setCodeExtension(Element element, String uri, String value) { public static void setCodeExtension(Element element, String uri, String value) {
if (Utilities.noString(value)) if (Utilities.noString(value))
return; return;

View File

@ -74,6 +74,7 @@ public class Runner implements IEvaluationContext {
} }
fpe = new FHIRPathEngine(context); fpe = new FHIRPathEngine(context);
fpe.setHostServices(this); fpe.setHostServices(this);
fpe.setEmitSQLonFHIRWarning(true);
if (viewDefinition == null) { if (viewDefinition == null) {
throw new FHIRException("No viewDefinition provided"); throw new FHIRException("No viewDefinition provided");
} }

View File

@ -1256,7 +1256,7 @@ public class StructureMapUtilities {
vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target); vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target);
else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) { else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) {
String type = getInputType(g, StructureMapInputMode.TARGET); String type = getInputType(g, StructureMapInputMode.TARGET);
throw new Error("not handled yet: creating a type of " + type); throw new FHIRException("not handled yet: creating a type of " + type);
} }
executeGroup("", context, map, vars, g, true); executeGroup("", context, map, vars, g, true);
@ -1424,7 +1424,7 @@ public class StructureMapUtilities {
Set<String> check = new HashSet<String>(); Set<String> check = new HashSet<String>();
for (StructureMap sm : res) { for (StructureMap sm : res) {
if (check.contains(sm.getUrl())) if (check.contains(sm.getUrl()))
throw new Error("duplicate"); throw new FHIRException("duplicate");
else else
check.add(sm.getUrl()); check.add(sm.getUrl());
} }
@ -1753,7 +1753,7 @@ public class StructureMapUtilities {
else if (srcVar != null) { else if (srcVar != null) {
tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types); tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types);
} else } else
throw new Error("Cannot determine type implicitly because there is no single input variable"); throw new FHIRException("Cannot determine type implicitly because there is no single input variable");
} else { } else {
tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()); tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString());
// ok, now we resolve the type name against the import statements // ok, now we resolve the type name against the import statements
@ -1799,7 +1799,7 @@ public class StructureMapUtilities {
} }
return new StringType(src); return new StringType(src);
case ESCAPE: case ESCAPE:
throw new Error("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet"); throw new FHIRException("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet");
case CAST: case CAST:
src = getParamString(vars, tgt.getParameter().get(0)); src = getParamString(vars, tgt.getParameter().get(0));
if (tgt.getParameter().size() == 1) if (tgt.getParameter().size() == 1)
@ -1870,7 +1870,7 @@ public class StructureMapUtilities {
return new StringType(b.fhirType() + "/" + id); return new StringType(b.fhirType() + "/" + id);
} }
case DATEOP: case DATEOP:
throw new Error("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet"); throw new FHIRException("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet");
case UUID: case UUID:
return new IdType(UUID.randomUUID().toString()); return new IdType(UUID.randomUUID().toString());
case POINTER: case POINTER:
@ -1887,7 +1887,7 @@ public class StructureMapUtilities {
Coding c = buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString())); Coding c = buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString()));
return c; return c;
default: default:
throw new Error("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode()); throw new FHIRException("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode());
} }
} catch (Exception e) { } catch (Exception e) {
throw new FHIRException("Exception executing transform " + tgt.toString() + " on Rule \"" + rulePath + "\": " + e.getMessage(), e); throw new FHIRException("Exception executing transform " + tgt.toString() + " on Rule \"" + rulePath + "\": " + e.getMessage(), e);
@ -2214,7 +2214,7 @@ public class StructureMapUtilities {
TypeDetails type = new TypeDetails(CollectionStatus.SINGLETON); TypeDetails type = new TypeDetails(CollectionStatus.SINGLETON);
for (TypeRefComponent tr : element.getDefinition().getType()) { for (TypeRefComponent tr : element.getDefinition().getType()) {
if (!tr.hasCode()) if (!tr.hasCode())
throw new Error("Rule \"" + ruleId + "\": Element has no type"); throw new FHIRException("Rule \"" + ruleId + "\": Element has no type");
ProfiledType pt = new ProfiledType(tr.getWorkingCode()); ProfiledType pt = new ProfiledType(tr.getWorkingCode());
if (tr.hasProfile()) if (tr.hasProfile())
pt.addProfiles(tr.getProfile()); pt.addProfiles(tr.getProfile());
@ -2268,7 +2268,7 @@ public class StructureMapUtilities {
} }
if (mapsSrc) { if (mapsSrc) {
if (var == null) if (var == null)
throw new Error("Rule \"" + ruleId + "\": Attempt to assign with no context"); throw new FHIRException("Rule \"" + ruleId + "\": Attempt to assign with no context");
tw.valueAssignment(tgt.getContext(), var.getProperty().getPath() + "." + tgt.getElement() + getTransformSuffix(tgt.getTransform())); tw.valueAssignment(tgt.getContext(), var.getProperty().getPath() + "." + tgt.getElement() + getTransformSuffix(tgt.getTransform()));
} else if (tgt.hasContext()) { } else if (tgt.hasContext()) {
if (isSignificantElement(var.getProperty(), tgt.getElement())) { if (isSignificantElement(var.getProperty(), tgt.getElement())) {
@ -2531,8 +2531,10 @@ public class StructureMapUtilities {
TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON); TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON);
td.addType("Reference", profile); td.addType("Reference", profile);
return td; return td;
case UUID:
return new TypeDetails(CollectionStatus.SINGLETON, "id");
default: default:
throw new Error("Transform Unknown or not handled yet: " + tgt.getTransform().toCode()); throw new FHIRException("Transform Unknown or not handled yet: " + tgt.getTransform().toCode());
} }
} }

View File

@ -1003,6 +1003,9 @@ public class I18nConstants {
public static final String CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM = "CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM"; public static final String CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM = "CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM";
public static final String LOGICAL_MODEL_NAME_MISMATCH = "LOGICAL_MODEL_NAME_MISMATCH"; public static final String LOGICAL_MODEL_NAME_MISMATCH = "LOGICAL_MODEL_NAME_MISMATCH";
public static final String LOGICAL_MODEL_QNAME_MISMATCH = "LOGICAL_MODEL_QNAME_MISMATCH"; public static final String LOGICAL_MODEL_QNAME_MISMATCH = "LOGICAL_MODEL_QNAME_MISMATCH";
public static final String FHIRPATH_CHOICE_NO_TYPE_SPECIFIER = "FHIRPATH_CHOICE_NO_TYPE_SPECIFIER";
public static final String FHIRPATH_CHOICE_SPURIOUS_TYPE_SPECIFIER = "FHIRPATH_CHOICE_SPURIOUS_TYPE_SPECIFIER";
public static final String FHIRPATH_NOT_A_COLLECTION = "FHIRPATH_NOT_A_COLLECTION";
} }

View File

@ -0,0 +1,11 @@
package org.hl7.fhir.utilities.validation;
import java.io.IOException;
import org.hl7.fhir.utilities.json.JsonException;
import org.hl7.fhir.utilities.json.model.JsonObject;
public interface IDigitalSignatureServices {
JsonObject fetchJWKS(String address) throws JsonException, IOException;
}

View File

@ -736,8 +736,8 @@ BUNDLE_SEARCH_ENTRY_WRONG_RESOURCE_TYPE_MODE = This is not a matching resource t
BUNDLE_SEARCH_ENTRY_WRONG_RESOURCE_TYPE_OUTCOME = This is not an OperationOutcome ({0}) BUNDLE_SEARCH_ENTRY_WRONG_RESOURCE_TYPE_OUTCOME = This is not an OperationOutcome ({0})
BUNDLE_SEARCH_ENTRY_WRONG_RESOURCE_TYPE_NO_MODE = This is not a matching resource type for the specified search (is a search mode needed?) ({0} expecting {1}) BUNDLE_SEARCH_ENTRY_WRONG_RESOURCE_TYPE_NO_MODE = This is not a matching resource type for the specified search (is a search mode needed?) ({0} expecting {1})
BUNDLE_SEARCH_NO_MODE = SearchSet bundles should have search modes on the entries BUNDLE_SEARCH_NO_MODE = SearchSet bundles should have search modes on the entries
INV_FAILED = Rule {0} Failed INV_FAILED = Constraint failed: {0}
INV_FAILED_SOURCE = Rule {0} Failed (defined in {1}) INV_FAILED_SOURCE = Constraint failed: {0} (defined in {1})
PATTERN_CHECK_STRING = The pattern [{0}] defined in the profile {1} not found. Issues: {2} PATTERN_CHECK_STRING = The pattern [{0}] defined in the profile {1} not found. Issues: {2}
TYPE_SPECIFIC_CHECKS_DT_URL_EXAMPLE = Example URLs are not allowed in this context ({0}) TYPE_SPECIFIC_CHECKS_DT_URL_EXAMPLE = Example URLs are not allowed in this context ({0})
UNICODE_BIDI_CONTROLS_CHARS_DISALLOWED = The Unicode sequence has bi-di control characters which are not allowed in this context: {0} UNICODE_BIDI_CONTROLS_CHARS_DISALLOWED = The Unicode sequence has bi-di control characters which are not allowed in this context: {0}
@ -1060,3 +1060,7 @@ TYPE_SPECIFIC_CHECKS_DT_QTY_UCUM_ANNOTATIONS_NOT_IN_UNIT = UCUM Codes that conta
TYPE_SPECIFIC_CHECKS_DT_QTY_UCUM_ANNOTATIONS = UCUM Codes that contain human readable annotations like {0} can be misleading (e.g. they are ignored when comparing units). Best Practice is not to depend on annotations in the UCUM code, so this usage should be checked TYPE_SPECIFIC_CHECKS_DT_QTY_UCUM_ANNOTATIONS = UCUM Codes that contain human readable annotations like {0} can be misleading (e.g. they are ignored when comparing units). Best Practice is not to depend on annotations in the UCUM code, so this usage should be checked
LOGICAL_MODEL_NAME_MISMATCH = The name ''{0}'' does not match the expected name ''{1}'' LOGICAL_MODEL_NAME_MISMATCH = The name ''{0}'' does not match the expected name ''{1}''
LOGICAL_MODEL_QNAME_MISMATCH = The QName ''{0}'' does not match the expected QName ''{1}'' LOGICAL_MODEL_QNAME_MISMATCH = The QName ''{0}'' does not match the expected QName ''{1}''
FHIRPATH_CHOICE_NO_TYPE_SPECIFIER = The expression ''{0}'' refers to an element that is a choice, but doesn''t have an .ofType() so that SQL view runners can pre-determine the full element name
FHIRPATH_CHOICE_SPURIOUS_TYPE_SPECIFIER = The expression ''{0}'' refers to an element that is not a choice, but has an .ofType(). SQL view runners are likely to pre-determine an incorrect full element name
FHIRPATH_NOT_A_COLLECTION = Found a use of a collection operator on something that is not a collection at ''{0}'' - check that there's no mistakes in the expression syntax

View File

@ -185,6 +185,7 @@ import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.VersionUtilities.VersionURLInfo; import org.hl7.fhir.utilities.VersionUtilities.VersionURLInfo;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.json.model.JsonObject; import org.hl7.fhir.utilities.json.model.JsonObject;
import org.hl7.fhir.utilities.validation.IDigitalSignatureServices;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
@ -493,6 +494,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
public List<ValidatedFragment> validatedContent; public List<ValidatedFragment> validatedContent;
public boolean testMode; public boolean testMode;
private boolean example ; private boolean example ;
private IDigitalSignatureServices signatureServices;
public InstanceValidator(@Nonnull IWorkerContext theContext, @Nonnull IEvaluationContext hostServices, @Nonnull XVerExtensionManager xverManager) { public InstanceValidator(@Nonnull IWorkerContext theContext, @Nonnull IEvaluationContext hostServices, @Nonnull XVerExtensionManager xverManager) {
super(theContext, xverManager, false); super(theContext, xverManager, false);
@ -710,6 +712,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (parser instanceof JsonParser) { if (parser instanceof JsonParser) {
((JsonParser) parser).setAllowComments(allowComments); ((JsonParser) parser).setAllowComments(allowComments);
} }
parser.setSignatureServices(signatureServices);
long t = System.nanoTime(); long t = System.nanoTime();
validatedContent = null; validatedContent = null;
try { try {
@ -5586,9 +5590,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
long t = System.nanoTime(); long t = System.nanoTime();
StructureDefinition profile = this.context.fetchResource(StructureDefinition.class, typeForResource.getProfile().get(0).asStringValue(), parentProfile); StructureDefinition profile = this.context.fetchResource(StructureDefinition.class, typeForResource.getProfile().get(0).asStringValue(), parentProfile);
timeTracker.sd(t); timeTracker.sd(t);
trackUsage(profile, valContext, element);
if (rule(errors, NO_RULE_DATE, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), if (rule(errors, NO_RULE_DATE, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(),
profile != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_NOPROFILE_EXPL, special.toHuman(), resourceName, typeForResource.getProfile().get(0).asStringValue())) { profile != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_NOPROFILE_EXPL, special == null ? "??" : special.toHuman(), resourceName, typeForResource.getProfile().get(0).asStringValue())) {
trackUsage(profile, valContext, element);
ok = validateResource(hc, errors, resource, element, profile, idstatus, stack, pct, mode) && ok; ok = validateResource(hc, errors, resource, element, profile, idstatus, stack, pct, mode) && ok;
} else { } else {
ok = false; ok = false;
@ -5841,6 +5845,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
boolean ok = true; boolean ok = true;
List<String> profiles = new ArrayList<String>(); List<String> profiles = new ArrayList<String>();
String type = null; String type = null;
String typeName = null;
ElementDefinition typeDefn = null; ElementDefinition typeDefn = null;
checkMustSupport(profile, ei); checkMustSupport(profile, ei);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
@ -5848,21 +5853,29 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (checkDefn.getType().size() == 1 && !"*".equals(checkDefn.getType().get(0).getWorkingCode()) && !"Element".equals(checkDefn.getType().get(0).getWorkingCode()) if (checkDefn.getType().size() == 1 && !"*".equals(checkDefn.getType().get(0).getWorkingCode()) && !"Element".equals(checkDefn.getType().get(0).getWorkingCode())
&& !"BackboneElement".equals(checkDefn.getType().get(0).getWorkingCode())) { && !"BackboneElement".equals(checkDefn.getType().get(0).getWorkingCode())) {
type = checkDefn.getType().get(0).getWorkingCode(); type = checkDefn.getType().get(0).getWorkingCode();
typeName = type;
if (Utilities.isAbsoluteUrl(type)) {
StructureDefinition sdt = context.fetchTypeDefinition(type);
if (sdt != null) {
typeName = sdt.getTypeName();
}
}
String stype = ei.getElement().fhirType(); String stype = ei.getElement().fhirType();
if (!stype.equals(type)) { if (!stype.equals(type)) {
if (checkDefn.isChoice()) { if (checkDefn.isChoice()) {
if (extensionUrl != null && !isAbsolute(extensionUrl)) { if (extensionUrl != null && !isAbsolute(extensionUrl)) {
ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), false, I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok; ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), false, I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok;
} else if (!isAbstractType(type) && !"Extension".equals(profile.getType())) { } else if (!isAbstractType(type) && !"Extension".equals(profile.getType())) {
ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), stype.equals(type), I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok; ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), stype.equals(typeName), I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok;
} }
} else if (!isAbstractType(type)) { } else if (!isAbstractType(type)) {
ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), stype.equals(type) || ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), ei.getPath(), stype.equals(typeName) ||
(Utilities.existsInList(type, "string", "id") && Utilities.existsInList(stype, "string", "id")), // work around a r4 problem with id/string (Utilities.existsInList(type, "string", "id") && Utilities.existsInList(stype, "string", "id")), // work around a r4 problem with id/string
I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok; I18nConstants.EXTENSION_PROF_TYPE, profile.getVersionedUrl(), type, stype) && ok;
} else if (!isResource(type)) { } else if (!isResource(type)) {
// System.out.println("update type "+type+" to "+stype+"?"); // System.out.println("update type "+type+" to "+stype+"?");
type = stype; type = stype;
typeName = type;
} else { } else {
// this will be sorted out in contains ... System.out.println("update type "+type+" to "+stype+"?"); // this will be sorted out in contains ... System.out.println("update type "+type+" to "+stype+"?");
} }
@ -5878,8 +5891,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
String prefix = tail(checkDefn.getPath()); String prefix = tail(checkDefn.getPath());
assert prefix.endsWith("[x]"); assert prefix.endsWith("[x]");
type = ei.getName().substring(prefix.length() - 3); type = ei.getName().substring(prefix.length() - 3);
if (isPrimitiveType(type)) typeName = type;
if (isPrimitiveType(type)) {
type = Utilities.uncapitalize(type); type = Utilities.uncapitalize(type);
typeName = type;
}
if (checkDefn.getType().get(0).hasProfile()) { if (checkDefn.getType().get(0).hasProfile()) {
for (CanonicalType p : checkDefn.getType().get(0).getProfile()) { for (CanonicalType p : checkDefn.getType().get(0).getProfile()) {
profiles.add(p.getValue()); profiles.add(p.getValue());
@ -5892,13 +5908,16 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (checkDefn.hasRepresentation(PropertyRepresentation.TYPEATTR)) { if (checkDefn.hasRepresentation(PropertyRepresentation.TYPEATTR)) {
type = ei.getElement().getType(); type = ei.getElement().getType();
typeName = type;
} else if (ei.getElement().isResource()) { } else if (ei.getElement().isResource()) {
type = ei.getElement().fhirType(); type = ei.getElement().fhirType();
typeName = type;
} else { } else {
prefix = prefix.substring(0, prefix.length() - 3); prefix = prefix.substring(0, prefix.length() - 3);
for (TypeRefComponent t : checkDefn.getType()) for (TypeRefComponent t : checkDefn.getType())
if ((prefix + Utilities.capitalize(t.getWorkingCode())).equals(ei.getName())) { if ((prefix + Utilities.capitalize(t.getWorkingCode())).equals(ei.getName())) {
type = t.getWorkingCode(); type = t.getWorkingCode();
typeName = type;
// Excluding reference is a kludge to get around versioning issues // Excluding reference is a kludge to get around versioning issues
if (t.hasProfile() && !type.equals("Reference")) if (t.hasProfile() && !type.equals("Reference"))
profiles.add(t.getProfile().get(0).getValue()); profiles.add(t.getProfile().get(0).getValue());
@ -5906,9 +5925,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
if (type == null) { if (type == null) {
TypeRefComponent trc = checkDefn.getType().get(0); TypeRefComponent trc = checkDefn.getType().get(0);
if (trc.getWorkingCode().equals("Reference")) if (trc.getWorkingCode().equals("Reference")) {
type = "Reference"; type = "Reference";
else typeName = type;
} else
ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), false, I18nConstants.VALIDATION_VAL_PROFILE_NOTYPE, ei.getName(), describeTypes(checkDefn.getType())) && ok; ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, ei.line(), ei.col(), stack.getLiteralPath(), false, I18nConstants.VALIDATION_VAL_PROFILE_NOTYPE, ei.getName(), describeTypes(checkDefn.getType())) && ok;
} }
} else if (checkDefn.getContentReference() != null) { } else if (checkDefn.getContentReference() != null) {
@ -5933,6 +5953,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
ei.definition = ei.definition; ei.definition = ei.definition;
} }
type = null; type = null;
typeName = type;
} }
} }
NodeStack localStack = stack.push(ei.getElement(), "*".equals(ei.getDefinition().getBase().getMax()) && ei.count == -1 ? 0 : ei.count, checkDefn, type == null ? typeDefn : resolveType(type, checkDefn.getType())); NodeStack localStack = stack.push(ei.getElement(), "*".equals(ei.getDefinition().getBase().getMax()) && ei.count == -1 ? 0 : ei.count, checkDefn, type == null ? typeDefn : resolveType(type, checkDefn.getType()));
@ -7115,4 +7136,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
this.example = example; this.example = example;
return this; return this;
} }
public IDigitalSignatureServices getSignatureServices() {
return signatureServices;
}
public void setSignatureServices(IDigitalSignatureServices signatureServices) {
this.signatureServices = signatureServices;
}
} }

View File

@ -70,11 +70,13 @@ import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.json.JsonException;
import org.hl7.fhir.utilities.json.JsonTrackingParser; import org.hl7.fhir.utilities.json.JsonTrackingParser;
import org.hl7.fhir.utilities.json.JsonUtilities; import org.hl7.fhir.utilities.json.JsonUtilities;
import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.utilities.settings.FhirSettings;
import org.hl7.fhir.utilities.tests.CacheVerificationLogger; import org.hl7.fhir.utilities.tests.CacheVerificationLogger;
import org.hl7.fhir.utilities.validation.IDigitalSignatureServices;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.IgLoader; import org.hl7.fhir.validation.IgLoader;
import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.validation.ValidationEngine;
@ -98,7 +100,7 @@ import com.google.gson.JsonObject;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class ValidationTests implements IEvaluationContext, IValidatorResourceFetcher, IValidationPolicyAdvisor { public class ValidationTests implements IEvaluationContext, IValidatorResourceFetcher, IValidationPolicyAdvisor, IDigitalSignatureServices {
public class TestSorter implements Comparator<Object> { public class TestSorter implements Comparator<Object> {
@ -319,6 +321,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
if (content.has("noHtmlInMarkdown")) { if (content.has("noHtmlInMarkdown")) {
val.setHtmlInMarkdownCheck(HtmlInMarkdownCheck.ERROR); val.setHtmlInMarkdownCheck(HtmlInMarkdownCheck.ERROR);
} }
val.setSignatureServices(this);
if (content.has("logical")==false) { if (content.has("logical")==false) {
val.setAssumeValidRestReferences(content.has("assumeValidRestReferences") ? content.get("assumeValidRestReferences").getAsBoolean() : false); val.setAssumeValidRestReferences(content.has("assumeValidRestReferences") ? content.get("assumeValidRestReferences").getAsBoolean() : false);
logOutput(String.format("Start Validating (%d to set up)", (System.nanoTime() - setup) / 1000000)); logOutput(String.format("Start Validating (%d to set up)", (System.nanoTime() - setup) / 1000000));
@ -792,4 +795,13 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
return false; return false;
} }
@Override
public org.hl7.fhir.utilities.json.model.JsonObject fetchJWKS(String address) throws JsonException, IOException {
if ("https://test.fhir.org/icao/.well-known/jwks.json".equals(address)) {
return org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(TestingUtilities.loadTestResourceBytes("validator", "test.fhir.org-jwks.json"));
} else {
return org.hl7.fhir.utilities.json.parser.JsonParser.parseObjectFromUrl(address);
}
}
} }

View File

@ -20,7 +20,7 @@
<properties> <properties>
<guava_version>32.0.1-jre</guava_version> <guava_version>32.0.1-jre</guava_version>
<hapi_fhir_version>6.4.1</hapi_fhir_version> <hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.4.8</validator_test_case_version> <validator_test_case_version>1.4.9-SNAPSHOT</validator_test_case_version>
<jackson_version>2.15.2</jackson_version> <jackson_version>2.15.2</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version> <junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version> <junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>