Search in sources :

Example 21 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateUuidToId.

@Test
public void toFhirResource_shouldTranslateUuidToId() {
    omrsAllergy.setUuid(ALLERGY_UUID);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getId(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 22 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldReturnNullSeverityIfSeverityConceptIsNull.

@Test
public void toFhirResource_shouldReturnNullSeverityIfSeverityConceptIsNull() {
    omrsAllergy.setSeverity(null);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance.getReaction().get(0).getSeverity(), nullValue());
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 23 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate.

@Test
public void toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate() {
    omrsAllergy.setDateChanged(new Date());
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getMeta().getLastUpdated(), DateMatchers.sameDay(new Date()));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Date(java.util.Date) Test(org.junit.Test)

Example 24 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateToNullCriticality.

@Test
public void toFhirResource_shouldTranslateToNullCriticality() {
    Concept otherConcept = new Concept();
    otherConcept.setUuid(GLOBAL_PROPERTY_OTHER_VALUE);
    omrsAllergy.setSeverity(otherConcept);
    when(severityTranslator.toFhirResource(otherConcept)).thenReturn(AllergyIntolerance.AllergyIntoleranceSeverity.NULL);
    when(criticalityTranslator.toFhirResource(AllergyIntolerance.AllergyIntoleranceSeverity.NULL)).thenReturn(AllergyIntolerance.AllergyIntoleranceCriticality.NULL);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getCriticality(), equalTo(AllergyIntolerance.AllergyIntoleranceCriticality.NULL));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 25 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateVoidedTrueToInactive.

@Test
public void toFhirResource_shouldTranslateVoidedTrueToInactive() {
    omrsAllergy.setVoided(true);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance.getClinicalStatus().getCoding().get(0).getCode(), equalTo("inactive"));
    assertThat(allergyIntolerance.getClinicalStatus().getCoding().get(0).getDisplay(), equalTo("Inactive"));
    assertThat(allergyIntolerance.getClinicalStatus().getText(), equalTo("Inactive"));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)158 AllergyIntolerance (org.hl7.fhir.r4.model.AllergyIntolerance)93 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)53 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)53 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)43 AllergyIntolerance (org.hl7.fhir.dstu3.model.AllergyIntolerance)42 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)29 TokenParam (ca.uhn.fhir.rest.param.TokenParam)29 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)26 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)25 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)25 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)23 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)23 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)23 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)14 InputStream (java.io.InputStream)12 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)12 Date (java.util.Date)10 IdType (org.hl7.fhir.r4.model.IdType)10