fix UUID() and don't throw errors processing StructureMaps

This commit is contained in:
Grahame Grieve 2023-10-09 21:09:56 +11:00
parent d08039a3a7
commit d2a8c91214
1 changed files with 11 additions and 9 deletions

View File

@ -1256,7 +1256,7 @@ public class StructureMapUtilities {
vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target); vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target);
else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) { else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) {
String type = getInputType(g, StructureMapInputMode.TARGET); String type = getInputType(g, StructureMapInputMode.TARGET);
throw new Error("not handled yet: creating a type of " + type); throw new FHIRException("not handled yet: creating a type of " + type);
} }
executeGroup("", context, map, vars, g, true); executeGroup("", context, map, vars, g, true);
@ -1424,7 +1424,7 @@ public class StructureMapUtilities {
Set<String> check = new HashSet<String>(); Set<String> check = new HashSet<String>();
for (StructureMap sm : res) { for (StructureMap sm : res) {
if (check.contains(sm.getUrl())) if (check.contains(sm.getUrl()))
throw new Error("duplicate"); throw new FHIRException("duplicate");
else else
check.add(sm.getUrl()); check.add(sm.getUrl());
} }
@ -1753,7 +1753,7 @@ public class StructureMapUtilities {
else if (srcVar != null) { else if (srcVar != null) {
tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types); tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types);
} else } else
throw new Error("Cannot determine type implicitly because there is no single input variable"); throw new FHIRException("Cannot determine type implicitly because there is no single input variable");
} else { } else {
tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()); tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString());
// ok, now we resolve the type name against the import statements // ok, now we resolve the type name against the import statements
@ -1799,7 +1799,7 @@ public class StructureMapUtilities {
} }
return new StringType(src); return new StringType(src);
case ESCAPE: case ESCAPE:
throw new Error("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet"); throw new FHIRException("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet");
case CAST: case CAST:
src = getParamString(vars, tgt.getParameter().get(0)); src = getParamString(vars, tgt.getParameter().get(0));
if (tgt.getParameter().size() == 1) if (tgt.getParameter().size() == 1)
@ -1870,7 +1870,7 @@ public class StructureMapUtilities {
return new StringType(b.fhirType() + "/" + id); return new StringType(b.fhirType() + "/" + id);
} }
case DATEOP: case DATEOP:
throw new Error("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet"); throw new FHIRException("Rule \"" + rulePath + "\": Transform " + tgt.getTransform().toCode() + " not supported yet");
case UUID: case UUID:
return new IdType(UUID.randomUUID().toString()); return new IdType(UUID.randomUUID().toString());
case POINTER: case POINTER:
@ -1887,7 +1887,7 @@ public class StructureMapUtilities {
Coding c = buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString())); Coding c = buildCoding(getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString()), getParamStringNoNull(vars, tgt.getParameter().get(1), tgt.toString()));
return c; return c;
default: default:
throw new Error("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode()); throw new FHIRException("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode());
} }
} catch (Exception e) { } catch (Exception e) {
throw new FHIRException("Exception executing transform " + tgt.toString() + " on Rule \"" + rulePath + "\": " + e.getMessage(), e); throw new FHIRException("Exception executing transform " + tgt.toString() + " on Rule \"" + rulePath + "\": " + e.getMessage(), e);
@ -2214,7 +2214,7 @@ public class StructureMapUtilities {
TypeDetails type = new TypeDetails(CollectionStatus.SINGLETON); TypeDetails type = new TypeDetails(CollectionStatus.SINGLETON);
for (TypeRefComponent tr : element.getDefinition().getType()) { for (TypeRefComponent tr : element.getDefinition().getType()) {
if (!tr.hasCode()) if (!tr.hasCode())
throw new Error("Rule \"" + ruleId + "\": Element has no type"); throw new FHIRException("Rule \"" + ruleId + "\": Element has no type");
ProfiledType pt = new ProfiledType(tr.getWorkingCode()); ProfiledType pt = new ProfiledType(tr.getWorkingCode());
if (tr.hasProfile()) if (tr.hasProfile())
pt.addProfiles(tr.getProfile()); pt.addProfiles(tr.getProfile());
@ -2268,7 +2268,7 @@ public class StructureMapUtilities {
} }
if (mapsSrc) { if (mapsSrc) {
if (var == null) if (var == null)
throw new Error("Rule \"" + ruleId + "\": Attempt to assign with no context"); throw new FHIRException("Rule \"" + ruleId + "\": Attempt to assign with no context");
tw.valueAssignment(tgt.getContext(), var.getProperty().getPath() + "." + tgt.getElement() + getTransformSuffix(tgt.getTransform())); tw.valueAssignment(tgt.getContext(), var.getProperty().getPath() + "." + tgt.getElement() + getTransformSuffix(tgt.getTransform()));
} else if (tgt.hasContext()) { } else if (tgt.hasContext()) {
if (isSignificantElement(var.getProperty(), tgt.getElement())) { if (isSignificantElement(var.getProperty(), tgt.getElement())) {
@ -2531,8 +2531,10 @@ public class StructureMapUtilities {
TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON); TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON);
td.addType("Reference", profile); td.addType("Reference", profile);
return td; return td;
case UUID:
return new TypeDetails(CollectionStatus.SINGLETON, "id");
default: default:
throw new Error("Transform Unknown or not handled yet: " + tgt.getTransform().toCode()); throw new FHIRException("Transform Unknown or not handled yet: " + tgt.getTransform().toCode());
} }
} }