use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareProfiles.
private void compareProfiles(String path, StructuralMatch<Element> combined, CanonicalType left, CanonicalType right, CapabilityStatementComparison res, CapabilityStatementRestResourceComponent union, CapabilityStatementRestResourceComponent intersection) {
if (!left.hasValue() && !right.hasValue()) {
// nothing in this case
} else if (!left.hasValue()) {
// the intersection is anything in right. The union is everything (or nothing, in this case)
intersection.setProfileElement(right.copy());
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.WARNING, "Added this profile", path), right).setName("profile"));
} else if (!right.hasValue()) {
// the intersection is anything in right. The union is everything (or nothing, in this case)
intersection.setProfileElement(left.copy());
combined.getChildren().add(new StructuralMatch<Element>(left, vmI(IssueSeverity.WARNING, "Removed this profile", path)).setName("profile"));
} else {
// profiles on both sides...
StructureDefinition sdLeft = session.getContextLeft().fetchResource(StructureDefinition.class, left.getValue());
StructureDefinition sdRight = session.getContextRight().fetchResource(StructureDefinition.class, right.getValue());
if (sdLeft == null && sdRight == null) {
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because neither is known", path)).setName("profile"));
} else if (sdLeft == null) {
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because '" + left.getValue() + "' is not known", path)).setName("profile"));
} else if (sdRight == null) {
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.ERROR, "Cannot compare profiles because '" + right.getValue() + "' is not known", path)).setName("profile"));
} else if (sdLeft.getUrl().equals(sdRight.getUrl())) {
intersection.setProfileElement(left.copy());
union.setProfileElement(left.copy());
combined.getChildren().add(new StructuralMatch<Element>(left, right).setName("profile"));
} else if (profileInherits(sdLeft, sdRight, session.getContextLeft())) {
// if left inherits from right:
intersection.setProfileElement(left.copy());
union.setProfileElement(right.copy());
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Changed this profile to a broader profile", path)).setName("profile"));
} else if (profileInherits(sdRight, sdLeft, session.getContextRight())) {
intersection.setProfileElement(right.copy());
union.setProfileElement(left.copy());
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Changed this profile to a narrower one", path)).setName("profile"));
} else {
combined.getChildren().add(new StructuralMatch<Element>(left, right, vmI(IssueSeverity.WARNING, "Different", path)).setName("profile"));
throw new Error("Not done yet");
}
}
}
use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method addRestSearchParamRow.
private Row addRestSearchParamRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, CapabilityStatementComparison comparison) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, "searchParam", null, null));
CapabilityStatementRestResourceSearchParamComponent left = t.hasLeft() ? (CapabilityStatementRestResourceSearchParamComponent) t.getLeft() : null;
CapabilityStatementRestResourceSearchParamComponent right = t.hasRight() ? (CapabilityStatementRestResourceSearchParamComponent) t.getRight() : null;
r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getName() : "", null, null), left != null ? left.getName() : null, right != null ? right.getName() : null, true));
r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getName() : "", null, null), left != null ? left.getName() : null, right != null ? right.getName() : null, false));
r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getDocumentation() : "", null, null), left != null ? left.getDocumentation() : null, right != null ? right.getDocumentation() : null, true));
r.getCells().add(cellForMessages(gen, t.getMessages()));
return r;
}
use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareOperations.
private void compareOperations(StructuralMatch<Element> combined, List<CapabilityStatementRestResourceOperationComponent> left, List<CapabilityStatementRestResourceOperationComponent> right, String path, CapabilityStatementComparison res, List<CapabilityStatementRestResourceOperationComponent> union, List<CapabilityStatementRestResourceOperationComponent> intersection) {
List<CapabilityStatementRestResourceOperationComponent> matchR = new ArrayList<>();
for (CapabilityStatementRestResourceOperationComponent l : left) {
CapabilityStatementRestResourceOperationComponent r = findInList(right, l);
if (r == null) {
union.add(l);
combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this Search Parameter", path)));
} else {
matchR.add(r);
CapabilityStatementRestResourceOperationComponent cdM = mergeOperations(l, r);
CapabilityStatementRestResourceOperationComponent cdI = intersectOperations(l, r);
union.add(cdM);
intersection.add(cdI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
compareStrings(path, sm.getMessages(), l.getDocumentation(), r.getDocumentation(), "documentation", IssueSeverity.INFORMATION, res);
compareItemProperty(sm, "definition", l.getDefinitionElement(), r.getDefinitionElement(), path, res, cdM.getDefinitionElement(), cdI.getDefinitionElement(), IssueSeverity.ERROR);
compareExpectations(sm, l, r, path, res, cdM, cdI);
combined.getChildren().add(sm);
}
}
for (CapabilityStatementRestResourceOperationComponent r : right) {
if (!matchR.contains(r)) {
union.add(r);
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this Search Parameter", path), r));
}
}
}
use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method renderStatements.
// 6 columns: path | left value | left doco | right value | right doco | comments
public XhtmlNode renderStatements(CapabilityStatementComparison comparison, String id, String prefix) throws FHIRException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "compare"), false);
TableModel model = gen.new TableModel(id, true);
model.setAlternating(true);
model.getTitles().add(gen.new Title(null, null, "Type", "The type of item", null, 100));
model.getTitles().add(gen.new Title(null, null, "Left Value", "The left value for the item", null, 200, 1));
model.getTitles().add(gen.new Title(null, null, "Left Doco", "The left documentation for the item", null, 200, 1));
model.getTitles().add(gen.new Title(null, null, "Right Value", "The right value for the item", null, 200, 1));
model.getTitles().add(gen.new Title(null, null, "Right Doco", "The right documentation for the item", null, 200, 1));
model.getTitles().add(gen.new Title(null, null, "Comments", "Additional information about the comparison", null, 200));
for (StructuralMatch<Element> t : comparison.getCombined().getChildren()) {
addRow(gen, model.getRows(), t, comparison);
}
return gen.generate(model, prefix, 0, null);
}
use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method addRestSecurityServiceRow.
private Row addRestSecurityServiceRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, CapabilityStatementComparison comparison) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, "service", null, null));
CodeableConcept left = t.hasLeft() ? (CodeableConcept) t.getLeft() : null;
CodeableConcept right = t.hasRight() ? (CodeableConcept) t.getRight() : null;
r.getCells().add(style(gen.new Cell(null, null, left != null ? gen(left) : "", null, null), left != null ? gen(left) : null, right != null ? gen(right) : null, true));
r.getCells().add(style(gen.new Cell(null, null, left != null ? left.getText() : "", null, null), left != null ? left.getText() : null, right != null ? right.getText() : null, true));
r.getCells().add(style(gen.new Cell(null, null, right != null ? gen(right) : "", null, null), left != null ? gen(left) : null, right != null ? gen(right) : null, false));
r.getCells().add(style(gen.new Cell(null, null, right != null ? right.getText() : "", null, null), left != null ? left.getText() : null, right != null ? right.getText() : null, true));
r.getCells().add(cellForMessages(gen, t.getMessages()));
return r;
}
Aggregations