Merge pull request #73 from lmckenzi/Conversion-issues
Fixed issues with version-conversion differentiating profile and targ…
This commit is contained in:
commit
6dbca158f7
|
@ -28,6 +28,7 @@ public class VersionConvertorConstants {
|
|||
public final static String MODIFIER_REASON_EXTENSION = "http://hl7.org/fhir/4.0/StructureDefinition/extension-ElementDefinition.isModifierReason";
|
||||
public final static String MODIFIER_TAKEN = "http://hl7.org/fhir/4.0/StructureDefinition/extension-MedicationStatment.taken";
|
||||
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 static String refToVS(String url) {
|
||||
if (url == null)
|
||||
|
|
|
@ -1421,17 +1421,15 @@ public class VersionConvertor_14_30 {
|
|||
org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent();
|
||||
copyElement(src, tgt);
|
||||
tgt.setCode(src.getCode());
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) {
|
||||
if (src.hasTarget()) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
String baseName = t.getValue().toLowerCase();
|
||||
if (baseName.contains("reference") && !baseName.contains("documentreference"))
|
||||
tgt.setProfile(t.getValueAsString());
|
||||
else
|
||||
tgt.setTargetProfile(t.getValueAsString());
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) {
|
||||
if (src.getCode().equals("Reference"))
|
||||
tgt.setTargetProfile(u.getValue());
|
||||
else
|
||||
tgt.setProfile(t.getValueAsString());
|
||||
tgt.setProfile(u.getValue());
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
tgt.setProfile(t.getValue().toString());
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode> t : src.getAggregation())
|
||||
tgt.addAggregation(convertAggregationMode(t.getValue()));
|
||||
|
@ -1448,14 +1446,16 @@ public class VersionConvertor_14_30 {
|
|||
if (src.hasTarget()) {
|
||||
if (src.hasTargetProfile()) {
|
||||
tgt.addProfile(src.getTargetProfile());
|
||||
String baseName = src.getTargetProfile().toLowerCase();
|
||||
if (baseName.contains("reference") && !baseName.contains("documentreference"))
|
||||
throw new Error("2016May Target profile contains the word 'reference':" + src.getTargetProfile());
|
||||
}
|
||||
if (src.hasProfile()) {
|
||||
tgt.addProfile(src.getProfile());
|
||||
if (!src.getProfile().toLowerCase().contains("reference"))
|
||||
throw new Error("2016May profile doesn't contain the word 'reference':" + src.getTargetProfile());
|
||||
if (src.getCode().equals("Reference")) {
|
||||
org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION);
|
||||
t.setValue(new org.hl7.fhir.dstu2016may.model.StringType(src.getProfile()));
|
||||
tgt.addExtension(t);
|
||||
} else
|
||||
tgt.addProfile(src.getProfile());
|
||||
// if (!u.toString().toLowerCase().contains("reference"))
|
||||
// throw new Error("2016May profile doesn't contain the word 'reference':" + u);
|
||||
}
|
||||
} else
|
||||
tgt.addProfile(src.getProfile());
|
||||
|
|
|
@ -1506,12 +1506,14 @@ public class VersionConvertor_14_40 {
|
|||
}
|
||||
if (tgt.hasTarget()) {
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
String baseName = u.getValue().toLowerCase();
|
||||
if (baseName.contains("reference") && !baseName.contains("documentreference"))
|
||||
tgt.addProfile(u.getValue());
|
||||
if (src.getCode().equals("Reference"))
|
||||
tgt.addTargetProfile(u.getValue());
|
||||
else
|
||||
tgt.addTargetProfile(u.getValue());
|
||||
tgt.addProfile(u.getValue());
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
tgt.addProfile(t.getValue().toString());
|
||||
}
|
||||
} else {
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
|
||||
|
@ -1541,9 +1543,14 @@ public class VersionConvertor_14_40 {
|
|||
throw new Error("2016May Target profile contains the word 'reference':" + u);
|
||||
}
|
||||
for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) {
|
||||
tgt.addProfile(u.getValue());
|
||||
if (!u.toString().toLowerCase().contains("reference"))
|
||||
throw new Error("2016May profile doesn't contain the word 'reference':" + u);
|
||||
if (src.getCode().equals("Reference")) {
|
||||
org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION);
|
||||
t.setValue(convertType(u));
|
||||
tgt.addExtension(t);
|
||||
} else
|
||||
tgt.addProfile(u.getValue());
|
||||
// if (!u.toString().toLowerCase().contains("reference"))
|
||||
// throw new Error("2016May profile doesn't contain the word 'reference':" + u);
|
||||
}
|
||||
} else {
|
||||
for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) {
|
||||
|
|
|
@ -1507,11 +1507,14 @@ public class VersionConvertor_14_50 {
|
|||
if (tgt.hasTarget()) {
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
String baseName = u.getValue().toLowerCase();
|
||||
if (baseName.contains("reference") && !baseName.contains("documentreference"))
|
||||
tgt.addProfile(u.getValue());
|
||||
if (src.getCode().equals("Reference"))
|
||||
tgt.addTargetProfile(u.getValue());
|
||||
else
|
||||
tgt.addTargetProfile(u.getValue());
|
||||
tgt.addProfile(u.getValue());
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) {
|
||||
// We don't have a good way to distinguish resources that have both 'profile' and 'targetProfile' when the type is reference, so the best we can do is by name.
|
||||
tgt.addProfile(t.getValue().toString());
|
||||
}
|
||||
} else {
|
||||
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
|
||||
|
@ -1534,16 +1537,18 @@ public class VersionConvertor_14_50 {
|
|||
tgt.setCode(src.getCode());
|
||||
list.add(tgt);
|
||||
if (src.hasTarget()) {
|
||||
for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) {
|
||||
tgt.addProfile(u.getValue());
|
||||
String baseName = u.getValue().toLowerCase();
|
||||
if (baseName.contains("reference") && !baseName.contains("documentreference"))
|
||||
throw new Error("2016May Target profile contains the word 'reference':" + u);
|
||||
}
|
||||
for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) {
|
||||
org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION);
|
||||
t.setValue(convertType(u));
|
||||
tgt.addExtension(t);
|
||||
}
|
||||
for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) {
|
||||
if (!u.equals(src.getTargetProfile().get(0))) {
|
||||
tgt = tgt.copy();
|
||||
tgt.getProfile().clear();
|
||||
list.add(tgt);
|
||||
}
|
||||
tgt.addProfile(u.getValue());
|
||||
if (!u.toString().toLowerCase().contains("reference"))
|
||||
throw new Error("2016May profile doesn't contain the word 'reference':" + u);
|
||||
}
|
||||
} else {
|
||||
for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.hl7.fhir.dstu3.model.Parameters;
|
|||
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.model.BooleanType;
|
||||
import org.hl7.fhir.r5.model.CanonicalType;
|
||||
import org.hl7.fhir.r5.model.Questionnaire;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Enumeration;
|
||||
|
@ -1736,8 +1737,15 @@ public class VersionConvertor_30_50 {
|
|||
copyElement(src, tgt);
|
||||
tgt.setCodeElement(convertUri(src.getCodeElement()));
|
||||
}
|
||||
if (src.hasProfile())
|
||||
tgt.addProfile(src.getProfile());
|
||||
if (src.hasProfile()) {
|
||||
boolean found = false;
|
||||
for (CanonicalType p: tgt.getProfile()) {
|
||||
if (p.equals(src.getProfile()))
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
tgt.addProfile(src.getProfile());
|
||||
}
|
||||
if (src.hasTargetProfile())
|
||||
tgt.addTargetProfile(src.getTargetProfile());
|
||||
for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode> t : src.getAggregation()) {
|
||||
|
|
|
@ -285,9 +285,11 @@ public abstract class XmlParserBase extends ParserBase implements IParser {
|
|||
}
|
||||
|
||||
|
||||
protected void unknownContent(XmlPullParser xpp) throws FHIRFormatError {
|
||||
protected void unknownContent(XmlPullParser xpp) throws FHIRFormatError, XmlPullParserException, IOException {
|
||||
if (!isAllowUnknownContent())
|
||||
throw new FHIRFormatError("Unknown Content "+xpp.getName()+" @ "+pathForLocation(xpp));
|
||||
else if (xpp.getEventType()==XmlPullParser.START_TAG)
|
||||
skipElementWithContent(xpp);
|
||||
}
|
||||
|
||||
protected XhtmlNode parseXhtml(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError {
|
||||
|
|
|
@ -1511,7 +1511,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
j++;
|
||||
if (j < markdown.length()) {
|
||||
String url = markdown.substring(i+2, j);
|
||||
if (!Utilities.isAbsoluteUrl(url)) {
|
||||
if (!Utilities.isAbsoluteUrl(url) && !url.startsWith("..")) {
|
||||
b.append("](");
|
||||
b.append(webUrl);
|
||||
i = i + 1;
|
||||
|
|
Loading…
Reference in New Issue