Search in sources :

Example 26 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateToAllergyType.

@Test
public void toFhirResource_shouldTranslateToAllergyType() {
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getType(), equalTo(AllergyIntolerance.AllergyIntoleranceType.ALLERGY));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.Test)

Example 27 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslateNoteToComment.

@Test
public void toOpenmrsType_shouldTranslateNoteToComment() {
    AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
    allergyIntolerance.addNote(new Annotation().setText("Test Allergy"));
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergyIntolerance);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getComment(), equalTo("Test Allergy"));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Annotation(org.hl7.fhir.r4.model.Annotation) Test(org.junit.Test)

Example 28 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldReturnNullCodedAllergenIfCodeIsNull.

@Test
public void toFhirResource_shouldReturnNullCodedAllergenIfCodeIsNull() {
    omrsAllergy.setAllergen(new Allergen(AllergenType.FOOD, null, null));
    AllergyIntolerance allergy = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergy.getCode(), notNullValue());
    assertThat(allergy.getCode().getCoding().size(), equalTo(0));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Allergen(org.openmrs.Allergen) Test(org.junit.Test)

Example 29 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toOpenmrsType_shouldTranslatePatientReferenceToPatient.

@Test
public void toOpenmrsType_shouldTranslatePatientReferenceToPatient() {
    Reference patientReference = new Reference().setReference(FhirTestConstants.PATIENT + "/" + PATIENT_UUID).setType(FhirTestConstants.PATIENT).setIdentifier(new Identifier().setValue(PATIENT_UUID));
    AllergyIntolerance allergy = new AllergyIntolerance();
    allergy.setPatient(patientReference);
    Patient omrsPatient = new Patient();
    omrsPatient.setUuid(PATIENT_UUID);
    when(patientReferenceTranslator.toOpenmrsType(patientReference)).thenReturn(omrsPatient);
    allergyIntoleranceTranslator.toOpenmrsType(omrsAllergy, allergy);
    assertThat(omrsAllergy, notNullValue());
    assertThat(omrsAllergy.getPatient(), is(omrsPatient));
    assertThat(omrsAllergy.getPatient().getUuid(), is(PATIENT_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Identifier(org.hl7.fhir.r4.model.Identifier) Reference(org.hl7.fhir.r4.model.Reference) Patient(org.openmrs.Patient) Test(org.junit.Test)

Example 30 with AllergyIntolerance

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

the class AllergyIntoleranceTranslatorImplTest method toFhirResource_shouldTranslateToLowCriticality.

@Test
public void toFhirResource_shouldTranslateToLowCriticality() {
    Concept mildConcept = new Concept();
    mildConcept.setUuid(GLOBAL_PROPERTY_MILD_VALUE);
    omrsAllergy.setSeverity(mildConcept);
    when(severityTranslator.toFhirResource(mildConcept)).thenReturn(AllergyIntolerance.AllergyIntoleranceSeverity.MILD);
    when(criticalityTranslator.toFhirResource(AllergyIntolerance.AllergyIntoleranceSeverity.MILD)).thenReturn(AllergyIntolerance.AllergyIntoleranceCriticality.LOW);
    AllergyIntolerance allergyIntolerance = allergyIntoleranceTranslator.toFhirResource(omrsAllergy);
    assertThat(allergyIntolerance, notNullValue());
    assertThat(allergyIntolerance.getCriticality(), equalTo(AllergyIntolerance.AllergyIntoleranceCriticality.LOW));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) 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