From 455cc5cf7f905f834b7a51776eb9b4ec54bec5a8 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 6 Mar 2021 08:58:40 +1100 Subject: [PATCH] Add resource name mapping for DataRequirement --- .../convertors/VersionConvertor_40_50.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java index b6b7af5dc..3bc4ded03 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java @@ -967,7 +967,7 @@ public class VersionConvertor_40_50 { if (src == null) return null; org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement(); copyElement(src, tgt); - if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); + if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(convertResourceName4to5(src.getType()))); for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject())); for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); @@ -981,11 +981,12 @@ public class VersionConvertor_40_50 { return tgt; } + public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException { if (src == null) return null; org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement(); copyElement(src, tgt); - if (src.hasType()) tgt.setType(src.getType().toCode()); + if (src.hasType()) tgt.setType(convertResourceName5to4(src.getType().toCode())); for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject())); for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); @@ -999,6 +1000,22 @@ public class VersionConvertor_40_50 { return tgt; } + private static String convertResourceName4to5(String name) { + if (name == null) return null; + if (name.equals("MedicationStatement")) { + return "MedicationUsage"; + } + return name; + } + + private static String convertResourceName5to4(String name) { + if (name == null) return null; + if (name.equals("MedicationUsage")) { + return "MedicationStatement"; + } + return name; + } + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { if (src == null) return null; org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent();