use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueType in project org.hl7.fhir.core by hapifhir.
the class BaseValidator method txWarning.
/**
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
*
* @param thePass
* Set this parameter to <code>false</code> if the validation does not pass
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/
protected boolean txWarning(List<ValidationMessage> errors, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings()) {
String nmsg = context.formatMessage(msg, theMessageArguments);
ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg);
if (checkMsgId(msg, vmsg)) {
errors.add(vmsg);
}
}
return thePass;
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueType in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method validateOnServer.
private ValidationResult validateOnServer(ValueSet vs, Parameters pin) throws FHIRException {
if (vs != null)
pin.addParameter().setName("valueSet").setResource(vs);
for (ParametersParameterComponent pp : pin.getParameter()) if (pp.getName().equals("profile"))
throw new Error("Can only specify profile in the context");
if (expParameters == null)
throw new Error("No ExpansionProfile provided");
pin.addParameter().setName("profile").setResource(expParameters);
txLog.clearLastId();
Parameters pOut;
if (vs == null)
pOut = txClient.validateCS(pin);
else
pOut = txClient.validateVS(pin);
boolean ok = false;
String message = "No Message returned";
String display = null;
TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
for (ParametersParameterComponent p : pOut.getParameter()) {
if (p.getName().equals("result"))
ok = ((BooleanType) p.getValue()).getValue().booleanValue();
else if (p.getName().equals("message"))
message = ((StringType) p.getValue()).getValue();
else if (p.getName().equals("display"))
display = ((StringType) p.getValue()).getValue();
else if (p.getName().equals("cause")) {
try {
IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
if (it == IssueType.UNKNOWN)
err = TerminologyServiceErrorClass.UNKNOWN;
else if (it == IssueType.NOTSUPPORTED)
err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
} catch (FHIRException e) {
}
}
}
if (!ok)
return new ValidationResult(IssueSeverity.ERROR, message, err).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else if (message != null && !message.equals("No Message returned"))
return new ValidationResult(IssueSeverity.WARNING, message, new ConceptDefinitionComponent().setDisplay(display)).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else if (display != null)
return new ValidationResult(new ConceptDefinitionComponent().setDisplay(display)).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else
return new ValidationResult(new ConceptDefinitionComponent()).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueType in project MobileAccessGateway by i4mi.
the class Iti78ResponseConverter method error.
public OperationOutcome error(IssueType type, String diagnostics) {
OperationOutcome result = new OperationOutcome();
OperationOutcomeIssueComponent issue = result.addIssue();
issue.setSeverity(OperationOutcome.IssueSeverity.ERROR);
issue.setCode(type);
issue.setDiagnostics(diagnostics);
return result;
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueType in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method addWarningIssue.
/**
* see
* https://gpconnect-1-2-4.netlify.com/accessrecord_structured_development_version_compatibility.html
* add an issue to the OperationOutcome to be returned in a successful
* response bundle this is for forward compatibility as specified in 1.2.4
*
* @param param
* @param paramPart
* @param issueType
* @param details lower level details to be added to the text element
*/
private void addWarningIssue(ParametersParameterComponent param, ParametersParameterComponent paramPart, IssueType issueType, String details) {
if (operationOutcome == null) {
createOperationOutcome();
}
OperationOutcomeIssueComponent issue = new OperationOutcomeIssueComponent();
issue.setSeverity(OperationOutcome.IssueSeverity.WARNING);
CodeableConcept codeableConcept = new CodeableConcept();
Coding coding = new Coding();
coding.setSystem(VS_GPC_ERROR_WARNING_CODE);
switch(issueType) {
case NOTSUPPORTED:
issue.setCode(issueType);
coding.setCode(SystemCode.NOT_IMPLEMENTED);
coding.setDisplay("Not implemented");
break;
case REQUIRED:
issue.setCode(issueType);
coding.setCode(SystemCode.PARAMETER_NOT_FOUND);
coding.setDisplay("Parameter not found");
break;
case INVALID:
issue.setCode(issueType);
coding.setCode(SystemCode.INVALID_PARAMETER);
coding.setDisplay("Invalid Parameter");
break;
}
codeableConcept.addCoding(coding);
issue.setDetails(codeableConcept);
String locus = paramPart != null ? "." + paramPart.getName() : "";
issue.setDiagnostics(param.getName() + locus);
if (details == null) {
// mod to remove more informative text which was off spec
codeableConcept.setText(param.getName() + locus + " is an unrecognised parameter");
} else {
codeableConcept.setText(details);
}
operationOutcome.addIssue(issue);
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.IssueType in project gpconnect-demonstrator by nhsconnect.
the class OperationOutcomeFactory method buildOperationOutcomeException.
/**
* @param exception carries message used for diagnostics
* @param code
* @param issueType
* @param diagnostics may be null but will override exception.message if set
* @return BaseServerResponseException
*/
public static BaseServerResponseException buildOperationOutcomeException(BaseServerResponseException exception, String code, IssueType issueType, String diagnostics) {
CodeableConcept codeableConcept = new CodeableConcept();
Coding coding = new Coding(SystemURL.VS_GPC_ERROR_WARNING_CODE, code, code);
codeableConcept.addCoding(coding);
OperationOutcome operationOutcome = new OperationOutcome();
OperationOutcomeIssueComponent ooIssue = new OperationOutcomeIssueComponent();
ooIssue.setSeverity(IssueSeverity.ERROR).setDetails(codeableConcept).setCode(issueType);
if (diagnostics != null) {
ooIssue.setDiagnostics(diagnostics);
} else {
// #248 move exception.getMessage() from text to diagnostics element
ooIssue.setDiagnostics(exception.getMessage());
}
operationOutcome.addIssue(ooIssue);
operationOutcome.getMeta().addProfile(SystemURL.SD_GPC_OPERATIONOUTCOME);
exception.setOperationOutcome(operationOutcome);
return exception;
}
Aggregations