Search in sources :

Example 96 with IdType

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

the class EncounterFhirResourceProviderTest method getEncounterHistoryByWithWrongId_shouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void getEncounterHistoryByWithWrongId_shouldThrowResourceNotFoundException() {
    IdType idType = new IdType();
    idType.setValue(WRONG_ENCOUNTER_UUID);
    assertThat(resourceProvider.getEncounterHistoryById(idType).isEmpty(), is(true));
    assertThat(resourceProvider.getEncounterHistoryById(idType).size(), Matchers.equalTo(0));
}
Also used : IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 97 with IdType

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

the class GroupFhirResourceProviderTest method shouldDeleteRequestedGroup.

@Test
public void shouldDeleteRequestedGroup() {
    when(fhirGroupService.delete(COHORT_UUID)).thenReturn(group);
    OperationOutcome result = resourceProvider.deleteGroup(new IdType().setValue(COHORT_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 98 with IdType

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

the class GroupFhirResourceProviderTest method shouldUpdateExistingGroup.

@Test
public void shouldUpdateExistingGroup() {
    org.hl7.fhir.r4.model.Group.GroupMemberComponent groupMemberComponent = mock(org.hl7.fhir.r4.model.Group.GroupMemberComponent.class);
    group.setActual(false);
    group.addMember(groupMemberComponent);
    when(fhirGroupService.update(eq(COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group);
    MethodOutcome result = resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), Group30_40.convertGroup(group));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
    assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.DSTU3));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 99 with IdType

use of org.hl7.fhir.dstu2.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(), is(true));
    assertThat(resources.stream().findAny().get().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.dstu3.model.Resource) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 100 with IdType

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

the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestForMissingId() {
    Location noIdLocation = new Location();
    when(locationService.update(eq(LOCATION_UUID), any(org.hl7.fhir.r4.model.Location.class))).thenThrow(InvalidRequestException.class);
    resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
Also used : Location(org.hl7.fhir.dstu3.model.Location) 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