use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project summary-care-record-api by NHSDigital.
the class GetScrControllerTest method verifyOperationOutcome.
private void verifyOperationOutcome(String responseBody, IssueType code, IssueSeverity severity, String details) {
var response = parser.parseResource(responseBody);
assertThat(response).isInstanceOf(OperationOutcome.class);
OperationOutcome operationOutcome = (OperationOutcome) response;
assertThat(operationOutcome.getIssueFirstRep().getCode()).isEqualTo(code);
assertThat(operationOutcome.getIssueFirstRep().getSeverity()).isEqualTo(severity);
assertThat(operationOutcome.getIssueFirstRep().getDetails().getText()).isEqualTo(details);
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project kindling by HL7.
the class RDFValidator method assertion.
public List<ValidationMessage> assertion(String sparql, String id, String rowType, String message, String description, IssueSeverity level) {
List<ValidationMessage> msgs = new ArrayList<ValidationMessage>();
Query query = QueryFactory.create(prefixes + sparql);
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
if (results.hasNext()) {
// Output query results
ByteArrayOutputStream ba = new ByteArrayOutputStream();
msgs.add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "rdf:" + id, description, level));
while (results.hasNext()) {
QuerySolution row = results.next();
String cell = row.getResource(results.getResultVars().get(0)).getURI();
if (cell.startsWith("http://hl7.org/fhir/"))
cell = cell.substring(20);
msgs.add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "rdf:" + id, cell + ": " + message, level));
}
}
// Important - free up resources used running the query
qe.close();
return msgs;
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.
the class ParserBase method logError.
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
if (policy == ValidationPolicy.EVERYTHING) {
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
errors.add(msg);
} else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
throw new FHIRFormatError(message + String.format(" at line %d col %d", line, col));
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.
the class TerminologyCache method load.
private void load() throws FHIRException {
for (String fn : new File(folder).list()) {
if (fn.endsWith(".cache") && !fn.equals("validation.cache")) {
try {
// System.out.println("Load "+fn);
String title = fn.substring(0, fn.lastIndexOf("."));
NamedCache nc = new NamedCache();
nc.name = title;
caches.put(title, nc);
System.out.print(" - load " + title + ".cache");
String src = TextFile.fileToString(Utilities.path(folder, fn));
if (src.startsWith("?"))
src = src.substring(1);
int i = src.indexOf(ENTRY_MARKER);
while (i > -1) {
String s = src.substring(0, i);
System.out.print(".");
src = src.substring(i + ENTRY_MARKER.length() + 1);
i = src.indexOf(ENTRY_MARKER);
if (!Utilities.noString(s)) {
int j = s.indexOf(BREAK);
String q = s.substring(0, j);
String p = s.substring(j + BREAK.length() + 1).trim();
CacheEntry ce = new CacheEntry();
ce.persistent = true;
ce.request = q;
boolean e = p.charAt(0) == 'e';
p = p.substring(3);
JsonObject o = (JsonObject) new com.google.gson.JsonParser().parse(p);
String error = loadJS(o.get("error"));
if (e) {
if (o.has("valueSet"))
ce.e = new ValueSetExpansionOutcome((ValueSet) new JsonParser().parse(o.getAsJsonObject("valueSet")), error, TerminologyServiceErrorClass.UNKNOWN);
else
ce.e = new ValueSetExpansionOutcome(error, TerminologyServiceErrorClass.UNKNOWN);
} else {
IssueSeverity severity = o.get("severity") instanceof JsonNull ? null : IssueSeverity.fromCode(o.get("severity").getAsString());
String display = loadJS(o.get("display"));
ce.v = new ValidationResult(severity, error, new ConceptDefinitionComponent().setDisplay(display));
}
nc.map.put(String.valueOf(hashNWS(ce.request)), ce);
nc.list.add(ce);
}
}
System.out.println("done");
} catch (Exception e) {
throw new FHIRException("Error loading " + fn + ": " + e.getMessage(), e);
}
}
}
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity in project org.hl7.fhir.core by hapifhir.
the class CanonicalResourceComparer method compareCodeList.
protected void compareCodeList(String name, List<CodeType> left, List<CodeType> right, Map<String, StructuralMatch<String>> comp, IssueSeverity level, CanonicalResourceComparison<? extends CanonicalResource> res, List<CodeType> union, List<CodeType> intersection) {
List<CodeType> matchR = new ArrayList<>();
StructuralMatch<String> combined = new StructuralMatch<String>();
for (CodeType l : left) {
CodeType r = findCodeInList(right, l);
if (r == null) {
union.add(l);
combined.getChildren().add(new StructuralMatch<String>(l.getValue(), vm(IssueSeverity.INFORMATION, "Removed the item '" + l.getValue() + "'", fhirType() + "." + name, res.getMessages())));
} else {
matchR.add(r);
union.add(r);
intersection.add(r);
StructuralMatch<String> sm = new StructuralMatch<String>(l.getValue(), r.getValue());
combined.getChildren().add(sm);
}
}
for (CodeType r : right) {
if (!matchR.contains(r)) {
union.add(r);
combined.getChildren().add(new StructuralMatch<String>(vm(IssueSeverity.INFORMATION, "Added the item '" + r.getValue() + "'", fhirType() + "." + name, res.getMessages()), r.getValue()));
}
}
comp.put(name, combined);
}
Aggregations