diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/structuremap/StructureMapUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/structuremap/StructureMapUtilities.java index fcf608def..9f66c0e50 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/structuremap/StructureMapUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/structuremap/StructureMapUtilities.java @@ -106,7 +106,7 @@ public class StructureMapUtilities { private static final boolean RENDER_MULTIPLE_TARGETS_ONELINE = true; public static final String AUTO_VAR_NAME = "vvv"; public static final String DEF_GROUP_NAME = "DefaultMappingGroupAnonymousAlias"; - + private final IWorkerContext worker; private final FHIRPathEngine fpe; private ITransformerServices services; @@ -658,6 +658,9 @@ public class StructureMapUtilities { case "title" : result.setTitle(lexer.readConstant("title")); break; + case "status" : + result.setStatus(PublicationStatus.fromCode(lexer.readConstant("status"))); + break; default: lexer.readConstant("nothing"); // nothing @@ -666,7 +669,7 @@ public class StructureMapUtilities { } if (!result.hasId() && result.hasName()) { String id = Utilities.makeId(result.getName()); - if (Utilities.noString(id)) { + if (!Utilities.noString(id)) { result.setId(id); } } @@ -2697,4 +2700,65 @@ public class StructureMapUtilities { this.exceptionsForChecks = exceptionsForChecks; } + public List getMapsForUrl(List maps, String url, StructureMapInputMode mode) { + List res = new ArrayList<>(); + for (StructureMap map : maps) { + if (mapIsForUrl(map, url, mode)) { + res.add(map); + } + } + return res; + } + + private boolean mapIsForUrl(StructureMap map, String url, StructureMapInputMode mode) { + for (StructureMapGroupComponent grp : map.getGroup()) { + if (grp.getTypeMode() != StructureMapGroupTypeMode.NULL) { + for (StructureMapGroupInputComponent p : grp.getInput()) { + if (mode == null || mode == p.getMode()) { + String t = resolveInputType(p, map); + if (url.equals(t)) { + return true; + } + } + } + } + } + return false; + } + + public List getMapsForUrlPrefix(List maps, String url, StructureMapInputMode mode) { + List res = new ArrayList<>(); + for (StructureMap map : maps) { + if (mapIsForUrlPrefix(map, url, mode)) { + res.add(map); + } + } + return res; + } + + private boolean mapIsForUrlPrefix(StructureMap map, String url, StructureMapInputMode mode) { + for (StructureMapGroupComponent grp : map.getGroup()) { + if (grp.getTypeMode() != StructureMapGroupTypeMode.NULL) { + for (StructureMapGroupInputComponent p : grp.getInput()) { + if (mode == null || mode == p.getMode()) { + String t = resolveInputType(p, map); + if (t != null && t.startsWith(url)) { + return true; + } + } + } + } + } + return false; + } + + private String resolveInputType(StructureMapGroupInputComponent p, StructureMap map) { + for (StructureMapStructureComponent struc : map.getStructure()) { + if (struc.hasAlias() && struc.getAlias().equals(p.getType())) { + return struc.getUrl(); + } + } + return null; + } + } \ No newline at end of file