use of org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison in project org.hl7.fhir.core by hapifhir.
the class ComparisonRenderer method renderCodeSystem.
private void renderCodeSystem(String id, CodeSystemComparison comp) throws IOException {
String template = templates.get("CodeSystem");
Map<String, Base> vars = new HashMap<>();
CodeSystemComparer cs = new CodeSystemComparer(session);
vars.put("left", new StringType(comp.getLeft().present()));
vars.put("right", new StringType(comp.getRight().present()));
vars.put("leftId", new StringType(comp.getLeft().getId()));
vars.put("rightId", new StringType(comp.getRight().getId()));
vars.put("leftUrl", new StringType(comp.getLeft().getUrl()));
vars.put("rightUrl", new StringType(comp.getRight().getUrl()));
vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp))));
vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", ""))));
vars.put("concepts", new StringType(new XhtmlComposer(true).compose(cs.renderConcepts(comp, "", ""))));
String cnt = processTemplate(template, "CodeSystem", vars);
TextFile.stringToFile(cnt, file(comp.getId() + ".html"));
new org.hl7.fhir.r4b.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-union.json")), comp.getUnion());
new org.hl7.fhir.r4b.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-intersection.json")), comp.getIntersection());
}
use of org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison in project org.hl7.fhir.core by hapifhir.
the class CodeSystemComparer method addRow.
private void addRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ConceptDefinitionComponent> t, CodeSystemComparison comparison) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, t.either().getCode(), null, null));
if (t.hasLeft() && t.hasRight()) {
if (t.getLeft().hasDisplay() && t.getRight().hasDisplay()) {
if (t.getLeft().getDisplay().equals(t.getRight().getDisplay())) {
r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).span(2));
} else {
r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
} else if (t.getLeft().hasDisplay()) {
r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null));
r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
} else if (t.getRight().hasDisplay()) {
r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null));
} else {
r.getCells().add(missingCell(gen).span(2));
}
for (PropertyComponent p : comparison.getUnion().getProperty()) {
ConceptPropertyComponent lp = getProp(t.getLeft(), p, false, comparison);
ConceptPropertyComponent rp = getProp(t.getRight(), p, true, comparison);
if (lp != null && rp != null) {
if (lp.getValue().equals(rp.getValue())) {
r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).span(2));
} else {
r.getCells().add(gen.new Cell(null, null, lp.getValue().toString(), null, null));
r.getCells().add(gen.new Cell(null, null, rp.getValue().toString(), null, null));
}
} else if (lp != null) {
r.getCells().add(gen.new Cell(null, null, lp.getValue().toString(), null, null));
r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
} else if (rp != null) {
r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
r.getCells().add(gen.new Cell(null, null, rp.getValue().toString(), null, null));
} else {
r.getCells().add(missingCell(gen).span(2));
}
}
} else if (t.hasLeft()) {
r.setColor(COLOR_NO_ROW_RIGHT);
r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
r.getCells().add(missingCell(gen));
for (PropertyComponent p : comparison.getUnion().getProperty()) {
r.getCells().add(propertyCell(gen, t.getLeft(), p, false, comparison));
r.getCells().add(missingCell(gen));
}
} else {
r.setColor(COLOR_NO_ROW_LEFT);
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
for (PropertyComponent p : comparison.getUnion().getProperty()) {
r.getCells().add(missingCell(gen));
r.getCells().add(propertyCell(gen, t.getLeft(), p, true, comparison));
}
}
r.getCells().add(cellForMessages(gen, t.getMessages()));
}
use of org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison in project org.hl7.fhir.core by hapifhir.
the class CodeSystemComparer method getProp.
public ConceptPropertyComponent getProp(ConceptDefinitionComponent cd, PropertyComponent p, boolean right, CodeSystemComparison comp) {
String c = p.getCode();
if (right) {
c = comp.getPropMap().get(c);
}
ConceptPropertyComponent cp = null;
if (cd != null) {
for (ConceptPropertyComponent t : cd.getProperty()) {
if (t.getCode().equals(c)) {
cp = t;
}
}
}
return cp;
}
use of org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison in project org.hl7.fhir.core by hapifhir.
the class CodeSystemComparer method merge.
private ConceptDefinitionComponent merge(ConceptDefinitionComponent l, ConceptDefinitionComponent r, List<PropertyComponent> destProps, CodeSystemComparison res) {
ConceptDefinitionComponent cd = l.copy();
if (!l.hasDisplay() && r.hasDisplay()) {
cd.setDisplay(r.getDisplay());
}
if (!l.hasDefinition() && r.hasDefinition()) {
cd.setDefinition(r.getDefinition());
}
mergeProps(cd, l, r, destProps, res);
mergeDesignations(cd, l, r);
return cd;
}
use of org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison in project org.hl7.fhir.core by hapifhir.
the class CodeSystemComparer method intersect.
private ConceptDefinitionComponent intersect(ConceptDefinitionComponent l, ConceptDefinitionComponent r, CodeSystemComparison res) {
ConceptDefinitionComponent cd = l.copy();
if (l.hasDisplay() && !r.hasDisplay()) {
cd.setDisplay(null);
}
if (l.hasDefinition() && !r.hasDefinition()) {
cd.setDefinition(null);
}
intersectProps(cd, l, r, res);
// mergeDesignations(cd, l, r);
return cd;
}
Aggregations