Merge pull request #14 from lmckenzi/Handle-profile+targetProfile-in-2016may

Add support for both targetProfile and profile when converting to and…
This commit is contained in:
Lloyd McKenzie 2019-03-26 20:19:38 -06:00 committed by GitHub
commit d419c117ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 9 deletions

View File

@ -1422,8 +1422,14 @@ public class VersionConvertor_14_30 {
copyElement(src, tgt);
tgt.setCode(src.getCode());
for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) {
if (src.hasTarget())
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());
}
else
tgt.setProfile(t.getValueAsString());
}
@ -1439,9 +1445,19 @@ public class VersionConvertor_14_30 {
org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent();
copyElement(src, tgt);
tgt.setCode(src.getCode());
if (src.hasTarget())
if (src.hasTarget()) {
if (src.hasTargetProfile()) {
tgt.addProfile(src.getTargetProfile());
else
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());
}
} else
tgt.addProfile(src.getProfile());
for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode> t : src.getAggregation())
tgt.addAggregation(convertAggregationMode(t.getValue()));

View File

@ -1505,8 +1505,14 @@ public class VersionConvertor_14_40 {
tgt.setCode(src.getCode());
}
if (tgt.hasTarget()) {
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
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());
else
tgt.addTargetProfile(u.getValue());
}
} else {
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
tgt.addProfile(u.getValue());
@ -1530,6 +1536,14 @@ public class VersionConvertor_14_40 {
if (src.hasTarget()) {
for (org.hl7.fhir.r4.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.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);
}
} else {
for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) {

View File

@ -1505,8 +1505,14 @@ public class VersionConvertor_14_50 {
tgt.setCode(src.getCode());
}
if (tgt.hasTarget()) {
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
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());
else
tgt.addTargetProfile(u.getValue());
}
} else {
for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile())
tgt.addProfile(u.getValue());
@ -1530,6 +1536,14 @@ public class VersionConvertor_14_50 {
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()) {
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()) {