use of org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method unionConstraints.
// we can't really know about constraints. We create warnings, and collate them
private List<ElementDefinitionConstraintComponent> unionConstraints(ElementDefinition ed, ProfileComparison outcome, String path, List<ElementDefinitionConstraintComponent> left, List<ElementDefinitionConstraintComponent> right) {
List<ElementDefinitionConstraintComponent> result = new ArrayList<ElementDefinitionConstraintComponent>();
for (ElementDefinitionConstraintComponent l : left) {
boolean found = false;
for (ElementDefinitionConstraintComponent r : right) if (Utilities.equals(r.getId(), l.getId()) || (Utilities.equals(r.getXpath(), l.getXpath()) && r.getSeverity() == l.getSeverity()))
found = true;
if (!found) {
outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "StructureDefinition " + outcome.leftName() + " has a constraint that is not found in " + outcome.rightName() + " and it is uncertain whether they are compatible (" + l.getXpath() + ")", ValidationMessage.IssueSeverity.INFORMATION));
status(ed, ProfileUtilities.STATUS_WARNING);
}
result.add(l);
}
for (ElementDefinitionConstraintComponent r : right) {
boolean found = false;
for (ElementDefinitionConstraintComponent l : left) if (Utilities.equals(r.getId(), l.getId()) || (Utilities.equals(r.getXpath(), l.getXpath()) && r.getSeverity() == l.getSeverity()))
found = true;
if (!found) {
outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, "StructureDefinition " + outcome.rightName() + " has a constraint that is not found in " + outcome.leftName() + " and it is uncertain whether they are compatible (" + r.getXpath() + ")", ValidationMessage.IssueSeverity.INFORMATION));
status(ed, ProfileUtilities.STATUS_WARNING);
result.add(r);
}
}
return result;
}
use of org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method mergeText.
private String mergeText(ElementDefinition ed, ProfileComparison outcome, String path, String name, String left, String right) {
if (left == null && right == null)
return null;
if (left == null)
return right;
if (right == null)
return left;
if (left.equalsIgnoreCase(right))
return left;
if (path != null) {
outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.INFORMATIONAL, path, "Elements differ in definition for " + name + ":\r\n \"" + left + "\"\r\n \"" + right + "\"", "Elements differ in definition for " + name + ":<br/>\"" + Utilities.escapeXml(left) + "\"<br/>\"" + Utilities.escapeXml(right) + "\"", ValidationMessage.IssueSeverity.INFORMATION));
status(ed, ProfileUtilities.STATUS_HINT);
}
return "left: " + left + "; right: " + right;
}
use of org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method genPCTable.
private String genPCTable() {
StringBuilder b = new StringBuilder();
b.append("<table class=\"grid\">\r\n");
b.append("<tr>");
b.append(" <td><b>Left</b></td>");
b.append(" <td><b>Right</b></td>");
b.append(" <td><b>Comparison</b></td>");
b.append(" <td><b>Error #</b></td>");
b.append(" <td><b>Warning #</b></td>");
b.append(" <td><b>Hint #</b></td>");
b.append("</tr>");
for (ProfileComparison cmp : getComparisons()) {
b.append("<tr>");
b.append(" <td><a href=\"" + cmp.getLeft().getUserString("path") + "\">" + Utilities.escapeXml(cmp.getLeft().getName()) + "</a></td>");
b.append(" <td><a href=\"" + cmp.getRight().getUserString("path") + "\">" + Utilities.escapeXml(cmp.getRight().getName()) + "</a></td>");
b.append(" <td><a href=\"" + getId() + "." + cmp.getId() + ".html\">Click Here</a></td>");
b.append(" <td>" + cmp.getErrorCount() + "</td>");
b.append(" <td>" + cmp.getWarningCount() + "</td>");
b.append(" <td>" + cmp.getHintCount() + "</td>");
b.append("</tr>");
}
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method resolveProfile.
private StructureDefinition resolveProfile(ElementDefinition ed, ProfileComparison outcome, String path, String url, String name) {
StructureDefinition res = context.fetchResource(StructureDefinition.class, url);
if (res == null) {
outcome.messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.INFORMATIONAL, path, "Unable to resolve profile " + url + " in profile " + name, ValidationMessage.IssueSeverity.WARNING));
status(ed, ProfileUtilities.STATUS_HINT);
}
return res;
}
use of org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method unionBindings.
private ElementDefinitionBindingComponent unionBindings(ElementDefinition ed, ProfileComparison outcome, String path, ElementDefinitionBindingComponent left, ElementDefinitionBindingComponent right) throws FHIRFormatError {
ElementDefinitionBindingComponent union = new ElementDefinitionBindingComponent();
if (left.getStrength().compareTo(right.getStrength()) < 0)
union.setStrength(left.getStrength());
else
union.setStrength(right.getStrength());
union.setDescription(mergeText(ed, outcome, path, "binding.description", left.getDescription(), right.getDescription()));
if (Base.compareDeep(left.getValueSet(), right.getValueSet(), false))
union.setValueSet(left.getValueSet());
else {
ValueSet lvs = resolveVS(outcome.left, left.getValueSet());
ValueSet rvs = resolveVS(outcome.left, right.getValueSet());
if (lvs != null && rvs != null)
union.setValueSet("#" + addValueSet(unite(ed, outcome, path, lvs, rvs)));
else if (lvs != null)
union.setValueSet("#" + addValueSet(lvs));
else if (rvs != null)
union.setValueSet("#" + addValueSet(rvs));
}
return union;
}
Aggregations