mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-27 16:15:56 +00:00
fix issue converting value set binding R3 <-> R5
This commit is contained in:
parent
27ecd52d97
commit
1848c4ca3e
@ -77,6 +77,7 @@ import org.hl7.fhir.utilities.Utilities;
|
|||||||
|
|
||||||
|
|
||||||
public class VersionConvertor_30_40 {
|
public class VersionConvertor_30_40 {
|
||||||
|
private static final String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
|
||||||
private static List<String> CANONICAL_URLS = new ArrayList<>();
|
private static List<String> CANONICAL_URLS = new ArrayList<>();
|
||||||
static {
|
static {
|
||||||
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
|
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
|
||||||
@ -98,19 +99,23 @@ public class VersionConvertor_30_40 {
|
|||||||
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
|
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException {
|
private static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException {
|
||||||
if (src.hasId())
|
if (src.hasId())
|
||||||
tgt.setId(src.getId());
|
tgt.setId(src.getId());
|
||||||
for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) {
|
for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) {
|
||||||
tgt.addExtension(convertExtension(e));
|
if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) {
|
||||||
|
tgt.addExtension(convertExtension(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException {
|
private static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException {
|
||||||
if (src.hasId())
|
if (src.hasId())
|
||||||
tgt.setId(src.getId());
|
tgt.setId(src.getId());
|
||||||
for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) {
|
for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) {
|
||||||
tgt.addExtension(convertExtension(e));
|
if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) {
|
||||||
|
tgt.addExtension(convertExtension(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1953,17 +1958,20 @@ public class VersionConvertor_30_40 {
|
|||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent();
|
org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent();
|
||||||
copyElement(src, tgt);
|
copyElement(src, tgt, EXT_SRC_TYPE);
|
||||||
if (src.hasStrength())
|
if (src.hasStrength())
|
||||||
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
||||||
if (src.hasDescription())
|
if (src.hasDescription())
|
||||||
tgt.setDescription(src.getDescription());
|
tgt.setDescription(src.getDescription());
|
||||||
if (src.hasValueSet()) {
|
if (src.hasValueSet()) {
|
||||||
Type t = convertType(src.getValueSet());
|
Type t = convertType(src.getValueSet());
|
||||||
if (t instanceof org.hl7.fhir.r4.model.Reference)
|
if (t instanceof org.hl7.fhir.r4.model.Reference) {
|
||||||
tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference());
|
tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference());
|
||||||
else
|
tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference"));
|
||||||
|
} else {
|
||||||
tgt.setValueSet(t.primitiveValue());
|
tgt.setValueSet(t.primitiveValue());
|
||||||
|
tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri"));
|
||||||
|
}
|
||||||
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
||||||
}
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
@ -1973,17 +1981,26 @@ public class VersionConvertor_30_40 {
|
|||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent();
|
org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent();
|
||||||
copyElement(src, tgt);
|
copyElement(src, tgt, EXT_SRC_TYPE);
|
||||||
if (src.hasStrength())
|
if (src.hasStrength())
|
||||||
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
||||||
if (src.hasDescription())
|
if (src.hasDescription())
|
||||||
tgt.setDescription(src.getDescription());
|
tgt.setDescription(src.getDescription());
|
||||||
if (src.hasValueSet()) {
|
if (src.hasValueSet()) {
|
||||||
|
org.hl7.fhir.r4.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE);
|
||||||
String vsr = VersionConvertorConstants.vsToRef(src.getValueSet());
|
String vsr = VersionConvertorConstants.vsToRef(src.getValueSet());
|
||||||
if (vsr != null)
|
if (ex != null) {
|
||||||
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr));
|
if ("uri".equals(ex.getValue().primitiveValue())) {
|
||||||
else
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr));
|
||||||
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
} else {
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vsr != null)
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr));
|
||||||
|
else
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ import org.hl7.fhir.utilities.Utilities;
|
|||||||
|
|
||||||
|
|
||||||
public class VersionConvertor_30_50 {
|
public class VersionConvertor_30_50 {
|
||||||
|
private static final String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
|
||||||
private static List<String> CANONICAL_URLS = new ArrayList<>();
|
private static List<String> CANONICAL_URLS = new ArrayList<>();
|
||||||
static {
|
static {
|
||||||
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
|
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
|
||||||
@ -99,19 +100,23 @@ public class VersionConvertor_30_50 {
|
|||||||
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
|
CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r5.model.Element tgt) throws FHIRException {
|
private static void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException {
|
||||||
if (src.hasId())
|
if (src.hasId())
|
||||||
tgt.setId(src.getId());
|
tgt.setId(src.getId());
|
||||||
for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) {
|
for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) {
|
||||||
tgt.addExtension(convertExtension(e));
|
if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) {
|
||||||
|
tgt.addExtension(convertExtension(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException {
|
private static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException {
|
||||||
if (src.hasId())
|
if (src.hasId())
|
||||||
tgt.setId(src.getId());
|
tgt.setId(src.getId());
|
||||||
for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) {
|
for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) {
|
||||||
tgt.addExtension(convertExtension(e));
|
if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) {
|
||||||
|
tgt.addExtension(convertExtension(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1933,17 +1938,20 @@ public class VersionConvertor_30_50 {
|
|||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent();
|
org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent();
|
||||||
copyElement(src, tgt);
|
copyElement(src, tgt, EXT_SRC_TYPE);
|
||||||
if (src.hasStrength())
|
if (src.hasStrength())
|
||||||
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
||||||
if (src.hasDescription())
|
if (src.hasDescription())
|
||||||
tgt.setDescription(src.getDescription());
|
tgt.setDescription(src.getDescription());
|
||||||
if (src.hasValueSet()) {
|
if (src.hasValueSet()) {
|
||||||
Type t = convertType(src.getValueSet());
|
Type t = convertType(src.getValueSet());
|
||||||
if (t instanceof org.hl7.fhir.r5.model.Reference)
|
if (t instanceof org.hl7.fhir.r5.model.Reference) {
|
||||||
tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
|
tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
|
||||||
else
|
tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference"));
|
||||||
|
} else {
|
||||||
tgt.setValueSet(t.primitiveValue());
|
tgt.setValueSet(t.primitiveValue());
|
||||||
|
tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri"));
|
||||||
|
}
|
||||||
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
||||||
}
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
@ -1953,17 +1961,26 @@ public class VersionConvertor_30_50 {
|
|||||||
if (src == null)
|
if (src == null)
|
||||||
return null;
|
return null;
|
||||||
org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent();
|
org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent();
|
||||||
copyElement(src, tgt);
|
copyElement(src, tgt, EXT_SRC_TYPE);
|
||||||
if (src.hasStrength())
|
if (src.hasStrength())
|
||||||
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
tgt.setStrength(convertBindingStrength(src.getStrength()));
|
||||||
if (src.hasDescription())
|
if (src.hasDescription())
|
||||||
tgt.setDescription(src.getDescription());
|
tgt.setDescription(src.getDescription());
|
||||||
if (src.hasValueSet()) {
|
if (src.hasValueSet()) {
|
||||||
|
org.hl7.fhir.r5.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE);
|
||||||
String vsr = VersionConvertorConstants.vsToRef(src.getValueSet());
|
String vsr = VersionConvertorConstants.vsToRef(src.getValueSet());
|
||||||
if (vsr != null)
|
if (ex != null) {
|
||||||
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr));
|
if ("uri".equals(ex.getValue().primitiveValue())) {
|
||||||
else
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr));
|
||||||
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
} else {
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vsr != null)
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr));
|
||||||
|
else
|
||||||
|
tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user