use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareRestResources.
private void compareRestResources(CapabilityStatementRestComponent left, CapabilityStatementRestComponent right, StructuralMatch<Element> combined, CapabilityStatementRestComponent union, CapabilityStatementRestComponent intersection, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
List<CapabilityStatementRestResourceComponent> matchR = new ArrayList<>();
for (CapabilityStatementRestResourceComponent l : left.getResource()) {
CapabilityStatementRestResourceComponent r = findInList(right.getResource(), l);
if (r == null) {
union.getResource().add(l);
combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this item", path)));
} else {
matchR.add(r);
CapabilityStatementRestResourceComponent cdM = mergeRestResource(l, r);
CapabilityStatementRestResourceComponent cdI = intersectRestResource(l, r);
union.getResource().add(cdM);
intersection.getResource().add(cdI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
compareRestResource(sm, l, r, path, res, cdM, cdI);
combined.getChildren().add(sm);
}
}
for (CapabilityStatementRestResourceComponent r : right.getResource()) {
if (!matchR.contains(r)) {
union.getResource().add(r);
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this concept", path), 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 compareRestSecurity.
private void compareRestSecurity(CapabilityStatementRestComponent l, CapabilityStatementRestComponent r, StructuralMatch<Element> smp, CapabilityStatementRestSecurityComponent merge, CapabilityStatementRestSecurityComponent intersect, CapabilityStatement csU, CapabilityStatement csI, CapabilityStatementComparison res, String path) {
CapabilityStatementRestSecurityComponent ls = l.hasSecurity() ? l.getSecurity() : null;
CapabilityStatementRestSecurityComponent rs = r.hasSecurity() ? r.getSecurity() : null;
StructuralMatch<Element> sm = new StructuralMatch<Element>(ls, rs);
smp.getChildren().add(sm);
compareBooleans(path, sm.getMessages(), l.getSecurity().getCorsElement(), r.getSecurity().getCorsElement(), "security.cors", IssueSeverity.WARNING, res);
compareStrings(path, sm.getMessages(), l.getSecurity().getDescription(), r.getSecurity().getDescription(), "security.description", IssueSeverity.INFORMATION, res);
compareRestSecurityService(ls, rs, sm, merge, intersect, csU, csI, res, path + ".security");
}
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;
}
use of org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compareExpectations.
private void compareExpectations(StructuralMatch<Element> combined, Element left, Element right, String path, CapabilityStatementComparison res, Element union, Element intersection) {
Extension l = left.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation");
Extension r = right.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation");
if (l != null || r != null) {
if (l == null) {
union.addExtension(r.copy());
combined.getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added this expectation", path), r));
} else if (r == null) {
union.addExtension(l.copy());
combined.getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed this expectation", path)));
} else {
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
combined.getChildren().add(sm);
String ls = l.getValue().primitiveValue();
String rs = r.getValue().primitiveValue();
if (ls.equals(rs)) {
union.addExtension(l.copy());
intersection.addExtension(l.copy());
} else {
sm.getMessages().add(new ValidationMessage(Source.ProfileComparer, IssueType.INFORMATIONAL, path + ".extension('http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation')", "Changed value for expectation: '" + ls + "' vs '" + rs + "'", IssueSeverity.WARNING));
String lowest = lower(ls, rs) ? ls : rs;
String highest = lower(ls, rs) ? rs : ls;
union.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation", new CodeType(lowest));
intersection.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation", new CodeType(highest));
}
}
}
}
Aggregations