Search in sources :

Example 96 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project gpconnect-demonstrator by nhsconnect.

the class StructuredAllergyIntoleranceBuilder method createNoKnownAllergy.

/**
 * This relates to the positively asserted this patient has no know
 * allergies as opposed to the the negatively asserted no allergies recorded
 * patient 5 example 2 from the spec
 *
 * @param allergyIntoleranceEntity object from the db
 * @return the allergy intolerance resource
 */
private AllergyIntolerance createNoKnownAllergy(StructuredAllergyIntoleranceEntity allergyIntoleranceEntity) {
    AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
    allergyIntolerance.setId(allergyIntoleranceEntity.getGuid());
    allergyIntolerance.setAssertedDate(allergyIntoleranceEntity.getAssertedDate());
    // db has clinical status of "no known" which is not a valid value
    allergyIntolerance.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
    allergyIntolerance.setVerificationStatus(AllergyIntoleranceVerificationStatus.valueOf(allergyIntoleranceEntity.getVerificationStatus().toUpperCase()));
    allergyIntolerance.setType(AllergyIntoleranceType.ALLERGY);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setDisplay(allergyIntoleranceEntity.getConceptDisplay());
    // That's as in db under concept code 716186003
    coding.setCode(allergyIntoleranceEntity.getConceptCode());
    coding.setSystem(SystemConstants.SNOMED_URL);
    Extension extension = new Extension(SystemURL.SD_EXT_SCT_DESC_ID);
    // 3305010017
    extension.addExtension("descriptionId", new StringType(allergyIntoleranceEntity.getDescCode()));
    // NKA - No known allergy
    extension.addExtension("descriptionDisplay", new StringType(allergyIntoleranceEntity.getDescDisplay()));
    coding.addExtension(extension);
    codeableConcept.addCoding(coding);
    allergyIntolerance.setCode(codeableConcept);
    return allergyIntolerance;
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance)

Example 97 with AllergyIntolerance

use of org.hl7.fhir.r4.model.AllergyIntolerance in project synthea by synthetichealth.

the class FhirR4 method allergy.

/**
 * Map the Condition into a FHIR AllergyIntolerance resource, and add it to the given Bundle.
 *
 * @param rand           Source of randomness to use when generating ids etc
 * @param personEntry    The Entry for the Person
 * @param bundle         The Bundle to add to
 * @param encounterEntry The current Encounter entry
 * @param allergy        The Allergy Entry
 * @return The added Entry
 */
private static BundleEntryComponent allergy(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, HealthRecord.Allergy allergy) {
    AllergyIntolerance allergyResource = new AllergyIntolerance();
    allergyResource.setRecordedDate(new Date(allergy.start));
    CodeableConcept status = new CodeableConcept();
    status.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical");
    allergyResource.setClinicalStatus(status);
    if (allergy.stop == 0) {
        status.getCodingFirstRep().setCode("active");
    } else {
        status.getCodingFirstRep().setCode("inactive");
    }
    if (allergy.allergyType == null || allergy.allergyType.equalsIgnoreCase("allergy")) {
        allergyResource.setType(AllergyIntoleranceType.ALLERGY);
    } else {
        allergyResource.setType(AllergyIntoleranceType.INTOLERANCE);
    }
    AllergyIntoleranceCategory category = null;
    if (allergy.category != null) {
        switch(allergy.category) {
            case "food":
                category = AllergyIntoleranceCategory.FOOD;
                break;
            case "medication":
                category = AllergyIntoleranceCategory.MEDICATION;
                break;
            case "environment":
                category = AllergyIntoleranceCategory.ENVIRONMENT;
                break;
            case "biologic":
                category = AllergyIntoleranceCategory.BIOLOGIC;
                break;
            default:
                category = AllergyIntoleranceCategory.MEDICATION;
        }
    }
    allergyResource.addCategory(category);
    allergyResource.setCriticality(AllergyIntoleranceCriticality.LOW);
    CodeableConcept verification = new CodeableConcept();
    verification.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("confirmed");
    allergyResource.setVerificationStatus(verification);
    allergyResource.setPatient(new Reference(personEntry.getFullUrl()));
    Code code = allergy.codes.get(0);
    allergyResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
    if (allergy.reactions != null) {
        allergy.reactions.keySet().stream().forEach(manifestation -> {
            AllergyIntolerance.AllergyIntoleranceReactionComponent reactionComponent = new AllergyIntolerance.AllergyIntoleranceReactionComponent();
            reactionComponent.addManifestation(mapCodeToCodeableConcept(manifestation, SNOMED_URI));
            HealthRecord.ReactionSeverity severity = allergy.reactions.get(manifestation);
            switch(severity) {
                case MILD:
                    reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.MILD);
                    break;
                case MODERATE:
                    reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE);
                    break;
                case SEVERE:
                    reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE);
                    break;
                default:
            }
            allergyResource.addReaction(reactionComponent);
        });
    }
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance");
        allergyResource.setMeta(meta);
    }
    BundleEntryComponent allergyEntry = newEntry(rand, bundle, allergyResource);
    allergy.fullUrl = allergyEntry.getFullUrl();
    return allergyEntry;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) AllergyIntoleranceCategory(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 98 with AllergyIntolerance

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

the class Hl7AllergyFHIRConversionTest method test_allergy_onset.

@Test
/**
 * Verifies AL1-6 is put into AllergyIntolerance.onsetDateTime; AllergyIntolerance.reaction.onset is not set.
 */
void test_allergy_onset() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234||DOE^JANE|||F\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION|20210101\r";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactly("HYPOTENSION");
    Date onsetReaction = allergy.getReaction().get(0).getOnset();
    Assertions.assertNull(onsetReaction);
    DateTimeType onsetAllergy = allergy.getOnsetDateTimeType();
    assertThat(onsetAllergy.getValueAsString()).isEqualTo("2021-01-01");
}
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) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 99 with AllergyIntolerance

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

the class Hl7IdentifierFHIRConversionTest method allergyIdentifierTest.

@Test
void allergyIdentifierTest() {
    // This identifier uses the logic from BUILD_IDENTIFIER_FROM_CWE (AL1.3) the three different messages test the three different outcomes
    // AL1-3.1 and AL1-3.3, concatenate together with a dash
    String Field1andField3 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|00000741^OXYCODONE^LN||HYPOTENSION\r";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, Field1andField3);
    // Expect a single identifier
    assertThat(allergy.hasIdentifier()).isTrue();
    assertThat(allergy.getIdentifier()).hasSize(1);
    // Identifier 1: extRef from AL1.3
    Identifier identifier = allergy.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    assertThat(value).isEqualTo("00000741-LN");
    assertThat(system).isEqualTo("urn:id:extID");
    // AL1-3.1 and AL1-3.2, use AL1-3.1
    String Field1andField2 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION\r";
    allergy = ResourceUtils.getAllergyResource(ftv, Field1andField2);
    // Expect a single identifier
    assertThat(allergy.hasIdentifier()).isTrue();
    assertThat(allergy.getIdentifier()).hasSize(1);
    // Identifier 1: extRef from AL1.3
    identifier = allergy.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    assertThat(value).isEqualTo("00000741");
    assertThat(system).isEqualTo("urn:id:extID");
    // AL1-3.2 only
    String justField2 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|^OXYCODONE||HYPOTENSION\r";
    allergy = ResourceUtils.getAllergyResource(ftv, justField2);
    // Expect a single identifier
    assertThat(allergy.hasIdentifier()).isTrue();
    assertThat(allergy.getIdentifier()).hasSize(1);
    // Identifier 1: extRef from AL1.3
    identifier = allergy.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    assertThat(value).isEqualTo("OXYCODONE");
    assertThat(system).isEqualTo("urn:id:extID");
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Identifier(org.hl7.fhir.r4.model.Identifier) Test(org.junit.jupiter.api.Test)

Example 100 with AllergyIntolerance

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

the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesBySeveritySevere.

@Test
public void searchForAllergies_shouldSearchForAllergiesBySeveritySevere() {
    TokenAndListParam severity = new TokenAndListParam();
    severity.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(SEVERITY_SEVERE)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.SEVERITY_SEARCH_HANDLER, severity);
    IBundleProvider results = search(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getReactionFirstRep().getSeverity(), equalTo(AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) 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)

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