Search in sources :

Example 91 with IdType

use of org.hl7.fhir.r4b.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(eq(UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenThrow(InvalidRequestException.class);
    resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), noIdDiagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 92 with IdType

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

the class EncounterFhirResourceProviderTest method updateEncounter_shouldUpdateEncounter.

@Test
public void updateEncounter_shouldUpdateEncounter() {
    when(encounterService.update(eq(ENCOUNTER_UUID), any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter);
    MethodOutcome result = resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), Encounter30_40.convertEncounter(encounter));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID));
}
Also used : Encounter(org.hl7.fhir.dstu3.model.Encounter) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 93 with IdType

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

the class EncounterFhirResourceProviderTest method deleteEncounter_shouldDeleteRequestedEncounter.

@Test
public void deleteEncounter_shouldDeleteRequestedEncounter() {
    when(encounterService.delete(ENCOUNTER_UUID)).thenReturn(encounter);
    OperationOutcome result = resourceProvider.deleteEncounter(new IdType().setValue(ENCOUNTER_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.dstu3.model.OperationOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 94 with IdType

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

the class EncounterFhirResourceProviderTest method getEncounterWithWrongUuid_shouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void getEncounterWithWrongUuid_shouldThrowResourceNotFoundException() {
    IdType id = new IdType();
    id.setValue(WRONG_ENCOUNTER_UUID);
    resourceProvider.getEncounterById(id);
}
Also used : IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 95 with IdType

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

the class EncounterFhirResourceProviderTest method getEncounterByUuid_shouldReturnMatchingEncounter.

@Test
public void getEncounterByUuid_shouldReturnMatchingEncounter() {
    IdType id = new IdType();
    id.setValue(ENCOUNTER_UUID);
    when(encounterService.get(ENCOUNTER_UUID)).thenReturn(encounter);
    Encounter result = resourceProvider.getEncounterById(id);
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(ENCOUNTER_UUID));
    assertThat(result.getStatus(), equalTo(Encounter.EncounterStatus.UNKNOWN));
}
Also used : Encounter(org.hl7.fhir.dstu3.model.Encounter) IdType(org.hl7.fhir.dstu3.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