use of org.hl7.fhir.r5.model.TypeDetails in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method getParam.
private TypeDetails getParam(VariablesForProfiling vars, StructureMapGroupRuleTargetParameterComponent parameter) throws DefinitionException {
DataType p = parameter.getValue();
if (!(p instanceof IdType))
return new TypeDetails(CollectionStatus.SINGLETON, ProfileUtilities.sdNs(p.fhirType(), worker.getOverrideVersionNs()));
else {
String n = ((IdType) p).asStringValue();
VariableForProfiling b = vars.get(VariableMode.INPUT, n);
if (b == null)
b = vars.get(VariableMode.OUTPUT, n);
if (b == null)
throw new DefinitionException("Variable " + n + " not found (" + vars.summary() + ")");
return b.getProperty().getTypes();
}
}
use of org.hl7.fhir.r5.model.TypeDetails in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method updateProfile.
private PropertyWithType updateProfile(VariableForProfiling var, String element, TypeDetails type, StructureMap map, List<StructureDefinition> profiles, String sliceName, DataType fixed, StructureMapGroupRuleTargetComponent tgt) throws FHIRException {
if (var == null) {
assert (Utilities.noString(element));
// 1. start the new structure definition
StructureDefinition sdn = worker.fetchResource(StructureDefinition.class, type.getType());
if (sdn == null)
throw new FHIRException("Unable to find definition for " + type.getType());
ElementDefinition edn = sdn.getSnapshot().getElementFirstRep();
PropertyWithType pn = createProfile(map, profiles, new PropertyWithType(sdn.getId(), new Property(worker, edn, sdn), null, type), sliceName, tgt);
return pn;
} else {
assert (!Utilities.noString(element));
Property pvb = var.getProperty().getBaseProperty();
Property pvd = var.getProperty().getProfileProperty();
Property pc = pvb.getChild(element, var.getProperty().getTypes());
if (pc == null)
throw new DefinitionException("Unable to find a definition for " + pvb.getDefinition().getPath() + "." + element);
// the profile structure definition (derived)
StructureDefinition sd = var.getProperty().getProfileProperty().getStructure();
ElementDefinition ednew = sd.getDifferential().addElement();
ednew.setPath(var.getProperty().getProfileProperty().getDefinition().getPath() + "." + pc.getName());
ednew.setUserData("slice-name", sliceName);
ednew.setFixed(fixed);
for (ProfiledType pt : type.getProfiledTypes()) {
if (pt.hasBindings())
ednew.setBinding(pt.getBindings().get(0));
if (pt.getUri().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
String t = pt.getUri().substring(40);
t = checkType(t, pc, pt.getProfiles());
if (t != null) {
if (pt.hasProfiles()) {
for (String p : pt.getProfiles()) if (t.equals("Reference"))
ednew.getType(t).addTargetProfile(p);
else
ednew.getType(t).addProfile(p);
} else
ednew.getType(t);
}
}
}
return new PropertyWithType(var.getProperty().getPath() + "." + element, pc, new Property(worker, ednew, sd), type);
}
}
use of org.hl7.fhir.r5.model.TypeDetails in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method analyseTransform.
private TypeDetails analyseTransform(TransformContext context, StructureMap map, StructureMapGroupRuleTargetComponent tgt, VariableForProfiling var, VariablesForProfiling vars) throws FHIRException {
switch(tgt.getTransform()) {
case CREATE:
String p = getParamString(vars, tgt.getParameter().get(0));
return new TypeDetails(CollectionStatus.SINGLETON, p);
case COPY:
return getParam(vars, tgt.getParameter().get(0));
case EVALUATE:
ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
if (expr == null) {
expr = fpe.parse(getParamString(vars, tgt.getParameter().get(tgt.getParameter().size() - 1)));
tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
}
return fpe.check(vars, null, expr);
case TRANSLATE:
return new TypeDetails(CollectionStatus.SINGLETON, "CodeableConcept");
case CC:
ProfiledType res = new ProfiledType("CodeableConcept");
if (tgt.getParameter().size() >= 2 && isParamId(vars, tgt.getParameter().get(1))) {
TypeDetails td = vars.get(null, getParamId(vars, tgt.getParameter().get(1))).getProperty().getTypes();
if (td != null && td.hasBinding())
// todo: do we need to check that there's no implicit translation her? I don't think we do...
res.addBinding(td.getBinding());
}
return new TypeDetails(CollectionStatus.SINGLETON, res);
case C:
return new TypeDetails(CollectionStatus.SINGLETON, "Coding");
case QTY:
return new TypeDetails(CollectionStatus.SINGLETON, "Quantity");
case REFERENCE:
VariableForProfiling vrs = vars.get(VariableMode.OUTPUT, getParamId(vars, tgt.getParameterFirstRep()));
if (vrs == null)
throw new FHIRException("Unable to resolve variable \"" + getParamId(vars, tgt.getParameterFirstRep()) + "\"");
String profile = vrs.getProperty().getProfileProperty().getStructure().getUrl();
TypeDetails td = new TypeDetails(CollectionStatus.SINGLETON);
td.addType("Reference", profile);
return td;
default:
throw new Error("Transform Unknown or not handled yet: " + tgt.getTransform().toCode());
}
}
use of org.hl7.fhir.r5.model.TypeDetails in project org.hl7.fhir.core by hapifhir.
the class FFHIRPathHostServices method resolveConstantType.
@Override
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
if (!(appContext instanceof VariablesForProfiling))
throw new Error("Internal Logic Error (wrong type '" + appContext.getClass().getName() + "' in resolveConstantType)");
VariablesForProfiling vars = (VariablesForProfiling) appContext;
VariableForProfiling v = vars.get(null, name);
if (v == null)
throw new PathEngineException("Unknown variable '" + name + "' from variables " + vars.summary());
return v.getProperty().getTypes();
}
use of org.hl7.fhir.r5.model.TypeDetails in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method executeType.
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry) throws PathEngineException, DefinitionException {
if (// special case for start up
atEntry && Character.isUpperCase(exp.getName().charAt(0)) && type.equals(exp.getName()))
return new TypeDetails(CollectionStatus.SINGLETON, type);
TypeDetails result = new TypeDetails(null);
getChildTypesByName(type, exp.getName(), result);
return result;
}
Aggregations