Fix conversion issue associated with ConceptMap.element.target.equivalence in versions previous to R5 (use proper extension URL, and move extension so it can be a modifier. And fix for modifierExtension handling)

This commit is contained in:
Grahame Grieve 2023-10-09 17:41:26 +11:00
parent 0140fa1ad1
commit f860af857d
18 changed files with 774 additions and 214 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

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

@ -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;
@ -286,6 +287,120 @@ public abstract class BackboneElement extends Element implements IBaseBackboneEl
} }
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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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 // end addition
} }

View File

@ -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;
@ -273,9 +274,60 @@ public abstract class BackboneType extends Type implements IBaseBackboneElement
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);
} }
} }
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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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 // end addition
} }

View File

@ -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;
@ -446,6 +447,58 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
return this; return this;
} }
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 // end addition
} }

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,58 @@ 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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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,59 @@ 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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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;
@ -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";
@ -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)

View File

@ -323,7 +323,49 @@ 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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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

@ -250,6 +250,60 @@ public void checkNoModifiers(String noun, String verb) throws FHIRException {
} }
} }
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);
}
}
List<Extension> sv = super.getExtensionsByUrl(theUrls);
sv.addAll(retVal);
return sv;
}
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

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