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));
}
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"));
}
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));
}
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));
}
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));
}
Aggregations