Search in sources :

Example 51 with IdType

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

the class AllergyIntoleranceFhirResourceProviderTest method deleteAllergyIntolerance_shouldDeleteRequestedAllergyIntolerance.

@Test
public void deleteAllergyIntolerance_shouldDeleteRequestedAllergyIntolerance() {
    when(service.delete(ALLERGY_UUID)).thenReturn(allergyIntolerance);
    OperationOutcome result = resourceProvider.deleteAllergy(new IdType().setValue(ALLERGY_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) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 52 with IdType

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

the class AllergyIntoleranceFhirResourceProviderTest method getAllergyIntoleranceHistoryByWithWrongId_shouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void getAllergyIntoleranceHistoryByWithWrongId_shouldThrowResourceNotFoundException() {
    IdType idType = new IdType();
    idType.setValue(WRONG_ALLERGY_UUID);
    assertThat(resourceProvider.getAllergyIntoleranceHistoryById(idType).isEmpty(), is(true));
    assertThat(resourceProvider.getAllergyIntoleranceHistoryById(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 53 with IdType

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

the class AllergyIntoleranceFhirResourceProviderTest method updateAllergyIntolerance_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateAllergyIntolerance_shouldThrowInvalidRequestForMissingId() {
    AllergyIntolerance noIdAllergyIntolerance = new AllergyIntolerance();
    when(service.update(ALLERGY_UUID, noIdAllergyIntolerance)).thenThrow(InvalidRequestException.class);
    resourceProvider.updateAllergy(new IdType().setValue(ALLERGY_UUID), noIdAllergyIntolerance);
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 54 with IdType

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

the class AllergyIntoleranceFhirResourceProviderTest method getAllergyIntoleranceByUuid_shouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void getAllergyIntoleranceByUuid_shouldThrowResourceNotFoundException() {
    IdType id = new IdType();
    id.setValue(WRONG_ALLERGY_UUID);
    AllergyIntolerance result = resourceProvider.getAllergyIntoleranceByUuid(id);
    assertThat(result, nullValue());
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 55 with IdType

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

the class ConditionFhirResourceProviderTest method updateCondition_shouldUpdateRequestedCondition.

@Test
public void updateCondition_shouldUpdateRequestedCondition() {
    when(conditionService.update(CONDITION_UUID, condition)).thenReturn(condition);
    MethodOutcome result = resourceProvider.updateCondition(new IdType().setValue(CONDITION_UUID), condition);
    assertThat(result, notNullValue());
    assertThat(result.getResource(), equalTo(condition));
}
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)

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