use of org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method analyseGroup.
private void analyseGroup(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapAnalysis result) throws FHIRException {
log(indent + "Analyse Group : " + group.getName());
// todo: extends
// todo: check inputs
XhtmlNode tr = result.summary.addTag("tr").setAttribute("class", "diff-title");
XhtmlNode xs = tr.addTag("td");
XhtmlNode xt = tr.addTag("td");
for (StructureMapGroupInputComponent inp : group.getInput()) {
if (inp.getMode() == StructureMapInputMode.SOURCE)
noteInput(vars, inp, VariableMode.INPUT, xs);
if (inp.getMode() == StructureMapInputMode.TARGET)
noteInput(vars, inp, VariableMode.OUTPUT, xt);
}
for (StructureMapGroupRuleComponent r : group.getRule()) {
analyseRule(indent + " ", context, map, vars, group, r, result);
}
}
use of org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method analyse.
/**
* Given a structure map, return a set of analyses on it.
* <p>
* Returned:
* - a list or profiles for what it will create. First profile is the target
* - a table with a summary (in xhtml) for easy human undertanding of the mapping
*
* @param appInfo
* @param map
* @return
* @throws Exception
*/
public StructureMapAnalysis analyse(Object appInfo, StructureMap map) throws FHIRException {
ids.clear();
StructureMapAnalysis result = new StructureMapAnalysis();
TransformContext context = new TransformContext(appInfo);
VariablesForProfiling vars = new VariablesForProfiling(this, false, false);
StructureMapGroupComponent start = map.getGroup().get(0);
for (StructureMapGroupInputComponent t : start.getInput()) {
PropertyWithType ti = resolveType(map, t.getType(), t.getMode());
if (t.getMode() == StructureMapInputMode.SOURCE)
vars.add(VariableMode.INPUT, t.getName(), ti);
else
vars.add(VariableMode.OUTPUT, t.getName(), createProfile(map, result.profiles, ti, start.getName(), start));
}
result.summary = new XhtmlNode(NodeType.Element, "table").setAttribute("class", "grid");
XhtmlNode tr = result.summary.addTag("tr");
tr.addTag("td").addTag("b").addText("Source");
tr.addTag("td").addTag("b").addText("Target");
log("Start Profiling Transform " + map.getUrl());
analyseGroup("", context, map, vars, start, result);
ProfileUtilities pu = new ProfileUtilities(worker, null, pkp);
for (StructureDefinition sd : result.getProfiles()) pu.cleanUpDifferential(sd);
return result;
}
use of org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method parseInput.
private void parseInput(StructureMapGroupComponent group, FHIRLexer lexer) throws FHIRException {
lexer.token("input");
StructureMapGroupInputComponent input = group.addInput();
input.setName(lexer.take());
if (lexer.hasToken(":")) {
lexer.token(":");
input.setType(lexer.take());
}
lexer.token("as");
input.setMode(StructureMapInputMode.fromCode(lexer.take()));
if (lexer.hasComment()) {
input.setDocumentation(lexer.take().substring(2).trim());
}
lexer.skipToken(";");
lexer.skipComments();
}
use of org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method analyseGroup.
private void analyseGroup(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapAnalysis result) throws Exception {
log(indent + "Analyse Group : " + group.getName());
// todo: extends
// todo: check inputs
XhtmlNode tr = result.summary.addTag("tr").setAttribute("class", "diff-title");
XhtmlNode xs = tr.addTag("td");
XhtmlNode xt = tr.addTag("td");
for (StructureMapGroupInputComponent inp : group.getInput()) {
if (inp.getMode() == StructureMapInputMode.SOURCE)
noteInput(vars, inp, VariableMode.INPUT, xs);
if (inp.getMode() == StructureMapInputMode.TARGET)
noteInput(vars, inp, VariableMode.OUTPUT, xt);
}
for (StructureMapGroupRuleComponent r : group.getRule()) {
analyseRule(indent + " ", context, map, vars, group, r, result);
}
}
use of org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method renderGroup.
private static void renderGroup(StringBuilder b, StructureMapGroupComponent g) {
b.append("group ");
b.append(g.getName());
b.append("(");
boolean first = true;
for (StructureMapGroupInputComponent gi : g.getInput()) {
if (first)
first = false;
else
b.append(", ");
b.append(gi.getMode().toCode());
b.append(" ");
b.append(gi.getName());
if (gi.hasType()) {
b.append(" : ");
b.append(gi.getType());
}
}
b.append(")");
if (g.hasExtends()) {
b.append(" extends ");
b.append(g.getExtends());
}
if (g.hasTypeMode()) {
switch(g.getTypeMode()) {
case TYPES:
b.append(" <<types>>");
break;
case TYPEANDTYPES:
b.append(" <<type+>>");
break;
// NONE, NULL
default:
}
}
b.append(" {\r\n");
for (StructureMapGroupRuleComponent r : g.getRule()) {
renderRule(b, r, 2);
}
b.append("}\r\n\r\n");
}
Aggregations