use of org.hl7.fhir.dstu2.model.OperationOutcome in project elexis-server by elexis.
the class ResourceProviderUtil method updateResource.
protected <T extends BaseResource, U extends Identifiable> MethodOutcome updateResource(IdType theId, IFhirTransformer<T, U> transformer, T fhirObject, Logger log) {
String versionId = theId.getVersionIdPart();
Optional<U> localObject = transformer.getLocalObject(fhirObject);
MethodOutcome outcome = new MethodOutcome();
if (localObject.isPresent()) {
if (versionId == null) {
log.warn("Version agnostic update on {}", localObject.get());
}
if (versionId != null && !versionId.equals(localObject.get().getLastupdate().toString())) {
throw new ResourceVersionConflictException("Expected version " + localObject.get().getLastupdate().toString());
}
try {
transformer.updateLocalObject(fhirObject, localObject.get());
} catch (IFhirTransformerException e) {
OperationOutcome opOutcome = generateOperationOutcome(e);
throw new PreconditionFailedException(e.getMessage(), opOutcome);
}
Optional<T> updatedObject = transformer.getFhirObject(localObject.get());
if (updatedObject.isPresent()) {
outcome.setId(updatedObject.get().getIdElement());
outcome.setResource(updatedObject.get());
return outcome;
}
log.warn("Object update failed [{}]", fhirObject);
throw new InternalErrorException("Object update failed");
} else {
OperationOutcome issueOutcome = new OperationOutcome();
issueOutcome.addIssue().setDiagnostics("No local object found");
outcome.setOperationOutcome(issueOutcome);
}
return outcome;
}
use of org.hl7.fhir.dstu2.model.OperationOutcome in project elexis-server by elexis.
the class IContactSearchFilterQueryAdapter method generateOperationOutcome.
private OperationOutcome generateOperationOutcome(Exception e) {
OperationOutcome opOutcome = new OperationOutcome();
OperationOutcomeIssueComponent ooc = new OperationOutcomeIssueComponent();
OperationOutcome.IssueSeverity severity = OperationOutcome.IssueSeverity.ERROR;
ooc.setSeverity(severity);
ooc.setCode(IssueType.PROCESSING);
ooc.setDiagnostics("_filter parameter: " + e.getMessage());
opOutcome.addIssue(ooc);
return opOutcome;
}
use of org.hl7.fhir.dstu2.model.OperationOutcome in project elexis-server by elexis.
the class IContactSearchFilterQueryAdapter method adapt.
public void adapt(IQuery<? extends IContact> query, StringAndListParam theFtFilter) {
List<StringOrListParam> stringOrListParams = theFtFilter.getValuesAsQueryTokens();
if (!stringOrListParams.isEmpty()) {
List<StringParam> stringParams = stringOrListParams.get(0).getValuesAsQueryTokens();
if (!stringParams.isEmpty()) {
StringParam stringParam = stringParams.get(0);
try {
Filter filter = SearchFilterParser.parse(stringParam.getValue());
handleFilter(query, filter, 1);
} catch (FilterSyntaxException | IllegalArgumentException e) {
OperationOutcome opOutcome = generateOperationOutcome(e);
throw new PreconditionFailedException(e.getMessage(), opOutcome);
}
}
}
}
use of org.hl7.fhir.dstu2.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderTest method deleteAllergyIntolerance_shouldDeleteRequestedAllergyIntolerance.
@Test
public void deleteAllergyIntolerance_shouldDeleteRequestedAllergyIntolerance() {
when(service.delete(ALLERGY_UUID)).thenReturn(allergyIntolerance);
OperationOutcome result = resourceProvider.deleteAllergy(new IdType().setValue(ALLERGY_UUID));
assertThat(result, notNullValue());
assertThat(result.getIssue(), notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
}
use of org.hl7.fhir.dstu2.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method deleteDiagnosticReport_shouldDeleteRequestedDiagnosticReport.
@Test
public void deleteDiagnosticReport_shouldDeleteRequestedDiagnosticReport() {
when(service.delete(UUID)).thenReturn(diagnosticReport);
OperationOutcome result = resourceProvider.deleteDiagnosticReport(new IdType().setValue(UUID));
assertThat(result, notNullValue());
assertThat(result.getIssue(), notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
}
Aggregations