Search in sources :

Example 61 with IdType

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

the class EncounterFhirResourceProviderTest method updateEncounter_shouldThrowMethodNotAllowedIfDoesNotExist.

@Test(expected = MethodNotAllowedException.class)
public void updateEncounter_shouldThrowMethodNotAllowedIfDoesNotExist() {
    Encounter wrongEncounter = new Encounter();
    wrongEncounter.setId(WRONG_ENCOUNTER_UUID);
    when(encounterService.update(WRONG_ENCOUNTER_UUID, wrongEncounter)).thenThrow(MethodNotAllowedException.class);
    resourceProvider.updateEncounter(new IdType().setValue(WRONG_ENCOUNTER_UUID), wrongEncounter);
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 62 with IdType

use of org.hl7.fhir.r5.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);
    Encounter result = resourceProvider.getEncounterByUuid(id);
    assertThat(result, nullValue());
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 63 with IdType

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

the class EncounterFhirResourceProviderTest method updateEncounter_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateEncounter_shouldThrowInvalidRequestForMissingId() {
    Encounter noIdEncounter = new Encounter();
    when(encounterService.update(ENCOUNTER_UUID, noIdEncounter)).thenThrow(InvalidRequestException.class);
    resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), noIdEncounter);
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 64 with IdType

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

the class EncounterFhirResourceProviderTest method getEncounterHistory_shouldReturnProvenanceResources.

@Test
public void getEncounterHistory_shouldReturnProvenanceResources() {
    IdType id = new IdType();
    id.setValue(ENCOUNTER_UUID);
    when(encounterService.get(ENCOUNTER_UUID)).thenReturn(encounter);
    List<Resource> resources = resourceProvider.getEncounterHistoryById(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 65 with IdType

use of org.hl7.fhir.r5.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.getEncounterByUuid(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.r4.model.Encounter) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) 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