Search in sources :

Example 56 with IdType

use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.

the class ConditionFhirResourceProviderTest method getConditionHistory_shouldReturnProvenanceResources.

@Test
public void getConditionHistory_shouldReturnProvenanceResources() {
    IdType id = new IdType();
    id.setValue(CONDITION_UUID);
    when(conditionService.get(CONDITION_UUID)).thenReturn(condition);
    List<Resource> resources = resourceProvider.getConditionHistoryById(id);
    assertThat(resources, not(empty()));
    assertThat(resources.stream().findAny().isPresent(), is(true));
    assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 57 with IdType

use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateDiagnosticReport_shouldThrowInvalidRequestForMissingId() {
    DiagnosticReport noIdDiagnosticReport = new DiagnosticReport();
    when(service.update(UUID, noIdDiagnosticReport)).thenThrow(InvalidRequestException.class);
    resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), noIdDiagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 58 with IdType

use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportFhirResourceProviderTest method getDiagnosticReportById_shouldReturnMatchingDiagnosticReport.

@Test
public void getDiagnosticReportById_shouldReturnMatchingDiagnosticReport() {
    IdType id = new IdType();
    id.setValue(UUID);
    when(service.get(UUID)).thenReturn(diagnosticReport);
    DiagnosticReport result = resourceProvider.getDiagnosticReportById(id);
    assertThat(result, notNullValue());
    assertThat(result.isResource(), is(true));
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(UUID));
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 59 with IdType

use of org.hl7.fhir.r5.model.IdType 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"));
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 60 with IdType

use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist.

@Test(expected = MethodNotAllowedException.class)
public void updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist() {
    DiagnosticReport wrongDiagnosticReport = new DiagnosticReport();
    wrongDiagnosticReport.setId(WRONG_UUID);
    when(service.update(WRONG_UUID, wrongDiagnosticReport)).thenThrow(MethodNotAllowedException.class);
    resourceProvider.updateDiagnosticReport(new IdType().setValue(WRONG_UUID), wrongDiagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Aggregations

IdType (org.hl7.fhir.r4.model.IdType)240 Test (org.junit.Test)240 IdType (org.hl7.fhir.dstu3.model.IdType)217 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)87 Test (org.junit.jupiter.api.Test)72 HashMap (java.util.HashMap)70 JsonObject (javax.json.JsonObject)55 Path (javax.ws.rs.Path)55 Produces (javax.ws.rs.Produces)55 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)50 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)49 Bundle (org.hl7.fhir.r4.model.Bundle)45 Date (java.util.Date)44 GET (javax.ws.rs.GET)40 ArrayList (java.util.ArrayList)38 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)36 Coding (org.hl7.fhir.r4.model.Coding)34 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)33 Resource (org.hl7.fhir.r4.model.Resource)33 Provenance (org.hl7.fhir.r4.model.Provenance)32