Search in sources :

Example 1 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7AllergyFHIRConversionTest method test_allergy_no_severity_no_coding_system.

@Test
void test_allergy_no_severity_no_coding_system() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234^5^M11^A^MR^HOSP~1234568965^^^USA^SS||DOE^JOHN^A^||19800202|F||W|111 TEST_STREET_NAME^^TEST_CITY^NY^111-1111^USA||(905)111-1111|||S|ZZ|12^^^124|34-13-312||||TEST_BIRTH_PLACE\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION\r";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.hasCriticality()).isFalse();
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("OXYCODONE");
    List<Coding> codings = allergy.getCode().getCoding();
    Assertions.assertEquals(1, codings.size());
    Coding coding = codings.get(0);
    Assertions.assertEquals("00000741", coding.getCode());
    Assertions.assertEquals("OXYCODONE", coding.getDisplay());
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactly("HYPOTENSION");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 2 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7AllergyFHIRConversionTest method test_allergy_single.

@Test
void test_allergy_single() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234^5^M11^A^MR^HOSP~1234568965^^^USA^SS||DOE^JOHN^A^||19800202|F||W|111 TEST_STREET_NAME^^TEST_CITY^NY^111-1111^USA||(905)111-1111|||S|ZZ|12^^^124|34-13-312||||TEST_BIRTH_PLACE\r" + "AL1|1|DA|^PENICILLIN|MI|PRODUCES HIVES~RASH|MI\r" + "AL1|2|AA|^CAT DANDER|SV";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.getCriticality().toCode()).isEqualTo("low");
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("PENICILLIN");
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactlyInAnyOrder("PRODUCES HIVES", "RASH");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.jupiter.api.Test)

Example 3 with AllergyIntolerance

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

the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesByCategoryEnvironment.

@Test
public void searchForAllergies_shouldSearchForAllergiesByCategoryEnvironment() {
    TokenAndListParam category = new TokenAndListParam();
    category.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(CATEGORY_ENVIRONMENT)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CATEGORY_SEARCH_HANDLER, category);
    IBundleProvider results = search(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getCategory().get(0).getValue(), equalTo(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 4 with AllergyIntolerance

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

the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesByPatientName.

@Test
public void searchForAllergies_shouldSearchForAllergiesByPatientName() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam allergyParam = new ReferenceParam();
    allergyParam.setValue(PATIENT_NAME);
    allergyParam.setChain(Patient.SP_NAME);
    referenceParam.addValue(new ReferenceOrListParam().add(allergyParam));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 5 with AllergyIntolerance

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

the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesByIdentifier.

@Test
public void searchForAllergies_shouldSearchForAllergiesByIdentifier() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam allergyParam = new ReferenceParam();
    allergyParam.setValue(PATIENT_IDENTIFIER);
    allergyParam.setChain(Patient.SP_IDENTIFIER);
    referenceParam.addValue(new ReferenceOrListParam().add(allergyParam));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getPatient().getReference(), endsWith(PATIENT_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)159 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