Search in sources :

Example 71 with IdType

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

the class ImmunizationFhirResourceProviderTest method updateImmunization_shouldUpdateRequestedImmunization.

@Test
public void updateImmunization_shouldUpdateRequestedImmunization() {
    when(immunizationService.update(IMMUNIZATION_UUID, immunization)).thenReturn(immunization);
    MethodOutcome result = resourceProvider.updateImmunization(new IdType().setValue(IMMUNIZATION_UUID), immunization);
    assertThat(result, notNullValue());
    assertThat(result.getResource(), equalTo(immunization));
}
Also used : MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 72 with IdType

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

the class ImmunizationFhirResourceProviderTest method getImmunizationHistory_shouldReturnListOfResource.

@Test
public void getImmunizationHistory_shouldReturnListOfResource() {
    IdType id = new IdType();
    id.setValue(IMMUNIZATION_UUID);
    when(immunizationService.get(IMMUNIZATION_UUID)).thenReturn(immunization);
    List<Resource> resources = resourceProvider.getImmunizationHistoryById(id);
    assertThat(resources, notNullValue());
    assertThat(resources, not(empty()));
    assertThat(resources.size(), equalTo(2));
}
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 73 with IdType

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

the class ImmunizationFhirResourceProviderTest method getImmunizationHistoryByWithWrongId_shouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void getImmunizationHistoryByWithWrongId_shouldThrowResourceNotFoundException() {
    IdType idType = new IdType();
    idType.setValue(WRONG_IMMUNIZATION_UUID);
    assertThat(resourceProvider.getImmunizationHistoryById(idType).isEmpty(), is(true));
    assertThat(resourceProvider.getImmunizationHistoryById(idType).size(), equalTo(0));
}
Also used : IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 74 with IdType

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

the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestExceptionForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestExceptionForMissingId() {
    Location noIdLocation = new Location();
    when(locationService.update(LOCATION_UUID, noIdLocation)).thenThrow(InvalidRequestException.class);
    resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
Also used : Location(org.hl7.fhir.r4.model.Location) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 75 with IdType

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

the class LocationFhirResourceProviderTest method getLocationHistoryById_shouldReturnProvenanceResources.

@Test
public void getLocationHistoryById_shouldReturnProvenanceResources() {
    IdType id = new IdType();
    id.setValue(LOCATION_UUID);
    when(locationService.get(LOCATION_UUID)).thenReturn(location);
    List<Resource> resources = resourceProvider.getLocationHistoryById(id);
    assertThat(resources, not(empty()));
    assertThat(resources.stream().findAny().isPresent(), Matchers.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)

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