Search in sources :

Example 1 with AllergyIntoleranceCategory

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

the class FhirStu3 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.Entry allergy) {
    AllergyIntolerance allergyResource = new AllergyIntolerance();
    allergyResource.setAssertedDate(new Date(allergy.start));
    if (allergy.stop == 0) {
        allergyResource.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
    } else {
        allergyResource.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
    }
    allergyResource.setType(AllergyIntoleranceType.ALLERGY);
    AllergyIntoleranceCategory category = AllergyIntoleranceCategory.FOOD;
    // TODO: allergy categories in GMF
    allergyResource.addCategory(category);
    allergyResource.setCriticality(AllergyIntoleranceCriticality.LOW);
    allergyResource.setVerificationStatus(AllergyIntoleranceVerificationStatus.CONFIRMED);
    allergyResource.setPatient(new Reference(personEntry.getFullUrl()));
    Code code = allergy.codes.get(0);
    allergyResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
    if (USE_SHR_EXTENSIONS) {
        Meta meta = new Meta();
        meta.addProfile(SHR_EXT + "shr-allergy-AllergyIntolerance");
        // required fields for AllergyIntolerance profile are:
        // verificationStatus, code, patient, assertedDate
        allergyResource.setMeta(meta);
    }
    BundleEntryComponent allergyEntry = newEntry(rand, bundle, allergyResource);
    allergy.fullUrl = allergyEntry.getFullUrl();
    return allergyEntry;
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.dstu3.model.Reference) AllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date)

Example 2 with AllergyIntoleranceCategory

use of org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory 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)

Aggregations

Date (java.util.Date)2 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)2 AllergyIntolerance (org.hl7.fhir.dstu3.model.AllergyIntolerance)1 AllergyIntoleranceCategory (org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory)1 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)1 Meta (org.hl7.fhir.dstu3.model.Meta)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 AllergyIntolerance (org.hl7.fhir.r4.model.AllergyIntolerance)1 AllergyIntoleranceCategory (org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)1 Meta (org.hl7.fhir.r4.model.Meta)1 Reference (org.hl7.fhir.r4.model.Reference)1 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)1