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);
else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) {
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);
@ -1424,7 +1424,7 @@ public class StructureMapUtilities {
Set<String> check = new HashSet<String>();
for (StructureMap sm : res) {
if (check.contains(sm.getUrl()))
throw new Error("duplicate");
throw new FHIRException("duplicate");
else
check.add(sm.getUrl());
}
@ -1753,7 +1753,7 @@ public class StructureMapUtilities {
else if (srcVar != null) {
tn = determineTypeFromSourceType(map, group, vars.get(VariableMode.INPUT, srcVar), types);
} 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 {
tn = getParamStringNoNull(vars, tgt.getParameter().get(0), tgt.toString());
// ok, now we resolve the type name against the import statements
@ -1799,7 +1799,7 @@ public class StructureMapUtilities {
}
return new StringType(src);
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:
src = getParamString(vars, tgt.getParameter().get(0));
if (tgt.getParameter().size() == 1)
@ -1870,7 +1870,7 @@ public class StructureMapUtilities {
return new StringType(b.fhirType() + "/" + id);
}
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:
return new IdType(UUID.randomUUID().toString());
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()));
return c;
default:
throw new Error("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode());
throw new FHIRException("Rule \"" + rulePath + "\": Transform Unknown: " + tgt.getTransform().toCode());
}
} catch (Exception 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);
for (TypeRefComponent tr : element.getDefinition().getType()) {
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());
if (tr.hasProfile())
pt.addProfiles(tr.getProfile());
@ -2268,7 +2268,7 @@ public class StructureMapUtilities {
}
if (mapsSrc) {
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()));
} else if (tgt.hasContext()) {
if (isSignificantElement(var.getProperty(), tgt.getElement())) {
@ -2531,8 +2531,10 @@ public class StructureMapUtilities {
TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON);
td.addType("Reference", profile);
return td;
case UUID:
return new TypeDetails(CollectionStatus.SINGLETON, "id");
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());
}
}