Search in sources :

Example 1 with Procedure

use of org.mitre.synthea.world.concepts.HealthRecord.Procedure in project synthea by synthetichealth.

the class FhirR4 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle of the Patient and the
 * associated entries from their health record.
 *
 * @param person   Person to generate the FHIR JSON for
 * @param stopTime Time the simulation ended
 * @return FHIR Bundle containing the Person's health record
 */
public static Bundle convertToFHIR(Person person, long stopTime) {
    Bundle bundle = new Bundle();
    if (TRANSACTION_BUNDLE) {
        bundle.setType(BundleType.TRANSACTION);
    } else {
        bundle.setType(BundleType.COLLECTION);
    }
    BundleEntryComponent personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        BundleEntryComponent encounterEntry = encounter(person, personEntry, bundle, encounter);
        for (HealthRecord.Entry condition : encounter.conditions) {
            condition(person, personEntry, bundle, encounterEntry, condition);
        }
        for (HealthRecord.Allergy allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in v4 don't support Attachments
            if (observation.value instanceof Attachment) {
                media(person, personEntry, bundle, encounterEntry, observation);
            } else {
                observation(person, personEntry, bundle, encounterEntry, observation);
            }
        }
        for (Procedure procedure : encounter.procedures) {
            procedure(person, personEntry, bundle, encounterEntry, procedure);
        }
        for (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        for (Medication medication : encounter.medications) {
            medicationRequest(person, personEntry, bundle, encounterEntry, medication);
        }
        for (HealthRecord.Entry immunization : encounter.immunizations) {
            immunization(person, personEntry, bundle, encounterEntry, immunization);
        }
        for (Report report : encounter.reports) {
            report(person, personEntry, bundle, encounterEntry, report);
        }
        for (CarePlan careplan : encounter.careplans) {
            BundleEntryComponent careTeamEntry = careTeam(person, personEntry, bundle, encounterEntry, careplan);
            carePlan(person, personEntry, bundle, encounterEntry, encounter.provider, careTeamEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        if (USE_US_CORE_IG) {
            String clinicalNoteText = ClinicalNoteExporter.export(person, encounter);
            boolean lastNote = (encounter == person.record.encounters.get(person.record.encounters.size() - 1));
            clinicalNote(person, personEntry, bundle, encounterEntry, clinicalNoteText, lastNote);
        }
        // one claim per encounter
        BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
        explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
    }
    if (USE_US_CORE_IG) {
        // Add Provenance to the Bundle
        provenance(bundle, person, stopTime);
    }
    return bundle;
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Bundle(org.hl7.fhir.r4.model.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 2 with Procedure

use of org.mitre.synthea.world.concepts.HealthRecord.Procedure in project synthea by synthetichealth.

the class FhirDstu2 method procedure.

/**
 * Map the given Procedure into a FHIR Procedure resource, and add it to the given Bundle.
 *
 * @param rand
 *          Source of randomness to use when generating ids etc
 * @param personEntry
 *          The Person entry
 * @param bundle
 *          Bundle to add to
 * @param encounterEntry
 *          The current Encounter entry
 * @param procedure
 *          The Procedure
 * @return The added Entry
 */
private static Entry procedure(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, Procedure procedure) {
    ca.uhn.fhir.model.dstu2.resource.Procedure procedureResource = new ca.uhn.fhir.model.dstu2.resource.Procedure();
    procedureResource.setStatus(ProcedureStatusEnum.COMPLETED);
    procedureResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
    procedureResource.setEncounter(new ResourceReferenceDt(encounterEntry.getFullUrl()));
    Code code = procedure.codes.get(0);
    procedureResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
    if (procedure.stop != 0L) {
        Date startDate = new Date(procedure.start);
        Date endDate = new Date(procedure.stop);
        procedureResource.setPerformed(new PeriodDt().setStart(new DateTimeDt(startDate)).setEnd(new DateTimeDt(endDate)));
    } else {
        procedureResource.setPerformed(convertFhirDateTime(procedure.start, true));
    }
    if (!procedure.reasons.isEmpty()) {
        // Only one element in list
        Code reason = procedure.reasons.get(0);
        for (Entry entry : bundle.getEntry()) {
            if (entry.getResource().getResourceName().equals("Condition")) {
                Condition condition = (Condition) entry.getResource();
                // Only one element in list
                CodingDt coding = condition.getCode().getCoding().get(0);
                if (reason.code.equals(coding.getCode())) {
                    procedureResource.setReason(new ResourceReferenceDt(entry.getFullUrl()));
                }
            }
        }
    }
    Entry procedureEntry = newEntry(rand, bundle, procedureResource);
    procedure.fullUrl = procedureEntry.getFullUrl();
    return procedureEntry;
}
Also used : Condition(ca.uhn.fhir.model.dstu2.resource.Condition) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) PeriodDt(ca.uhn.fhir.model.dstu2.composite.PeriodDt) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 3 with Procedure

use of org.mitre.synthea.world.concepts.HealthRecord.Procedure in project synthea by synthetichealth.

the class FhirDstu2 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle with the Patient and the
 * associated entries from their health record.
 *
 * @param person Person to generate the FHIR Bundle
 * @param stopTime Time the simulation ended
 * @return String containing a FHIR Bundle containing the Person's health record
 */
public static Bundle convertToFHIR(Person person, long stopTime) {
    Bundle bundle = new Bundle();
    if (TRANSACTION_BUNDLE) {
        bundle.setType(BundleTypeEnum.TRANSACTION);
    } else {
        bundle.setType(BundleTypeEnum.COLLECTION);
    }
    Entry personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        Entry encounterEntry = encounter(person, personEntry, bundle, encounter);
        for (HealthRecord.Entry condition : encounter.conditions) {
            condition(person, personEntry, bundle, encounterEntry, condition);
        }
        for (HealthRecord.Entry allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in stu3 don't support Attachments
            if (observation.value instanceof Attachment) {
                media(person, personEntry, bundle, encounterEntry, observation);
            } else {
                observation(person, personEntry, bundle, encounterEntry, observation);
            }
        }
        for (Procedure procedure : encounter.procedures) {
            procedure(person, personEntry, bundle, encounterEntry, procedure);
        }
        for (Medication medication : encounter.medications) {
            medication(person, personEntry, bundle, encounterEntry, medication);
        }
        for (HealthRecord.Entry immunization : encounter.immunizations) {
            immunization(person, personEntry, bundle, encounterEntry, immunization);
        }
        for (Report report : encounter.reports) {
            report(person, personEntry, bundle, encounterEntry, report);
        }
        for (CarePlan careplan : encounter.careplans) {
            careplan(person, personEntry, bundle, encounterEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        for (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        // one claim per encounter
        encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
    }
    return bundle;
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) DiagnosticReport(ca.uhn.fhir.model.dstu2.resource.DiagnosticReport) Bundle(ca.uhn.fhir.model.dstu2.resource.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 4 with Procedure

use of org.mitre.synthea.world.concepts.HealthRecord.Procedure in project synthea by synthetichealth.

the class CPCDSExporter method claim.

/**
 * Method to write a single Claims file. Take an encounter in the parameters and
 * processes Diagnoses, Procedures, and Pharmacy claims for each one, in order.
 *
 * @param rand            Source of randomness to use when generating ids etc
 * @param encounter       The encounter object itself
 * @param personID        The Id of the involved patient
 * @param encounterID     The Id of the encounter
 * @param medRecordNumber The patients Medical Record Number
 * @param attributes      Calculated attributes for the entire encounter
 * @param payerId         The Id of the payer
 * @throws IOException Throws this exception
 */
private void claim(RandomNumberGenerator rand, Encounter encounter, String personID, String encounterID, UUID medRecordNumber, CPCDSAttributes attributes, String payerId, String coverageID) throws IOException {
    StringBuilder s = new StringBuilder();
    int i = 1;
    while (i <= attributes.getLength()) {
        // admin
        String billType = attributes.getBillTypeCode();
        String[] adminSection = { String.valueOf(dateFromTimestamp(encounter.start)), String.valueOf(dateFromTimestamp(encounter.stop)), String.valueOf(dateFromTimestamp(encounter.stop)), String.valueOf(dateFromTimestamp(encounter.start)), String.valueOf(dateFromTimestamp(encounter.start)), String.valueOf(dateFromTimestamp(encounter.stop)), personID.toString(), medRecordNumber.toString(), encounterID, "", "", "", attributes.getSourceAdminCode(), attributes.getAdmissionTypeCode(), Character.toString(billType.charAt(0)), Character.toString(billType.charAt(1)), Character.toString(billType.charAt(2)), attributes.getProcStatus(), attributes.getClaimType(), attributes.getDischarge(), attributes.getDenialCode(), coverageID, attributes.getPayeeType(), personID, attributes.getPaymentType(), coverageID };
        StringBuilder admin = new StringBuilder();
        for (String item : adminSection) {
            admin.append(item).append(',');
        }
        String adminString = admin.toString();
        // provider
        practitioner(encounter.clinician.attributes.get("specialty").toString(), attributes.getNpiProvider(), attributes.getServiceSiteNPI(), encounter.clinician.getFullname());
        String[] providerSection = { attributes.getNpiProvider(), attributes.getNetworkStatus(), attributes.getNpiProvider(), attributes.getNetworkStatus(), attributes.getServiceSiteNPI(), attributes.getNetworkStatus(), attributes.getNpiProvider(), attributes.getNetworkStatus(), attributes.getNpiProvider(), attributes.getNetworkStatus(), attributes.getNpiPrescribingProvider(), attributes.getNetworkStatus(), attributes.getNpiProvider() };
        StringBuilder provider = new StringBuilder();
        for (String item : providerSection) {
            provider.append(item).append(',');
        }
        String providerString = provider.toString();
        // totals
        // encounter.claim.getTotalClaimCost();
        double totalCost = attributes.getTotalClaimCost();
        double coveredCost = encounter.claim.getCoveredCost();
        double disallowed = totalCost - coveredCost;
        double patientPaid;
        double memberReimbursement;
        double paymentAmount;
        double toProvider;
        double deductible = encounter.claim.person.coverage.getTotalCoverage();
        double liability;
        double copay = 0.00;
        if (disallowed > 0) {
            memberReimbursement = 0.00;
            patientPaid = disallowed;
        } else {
            memberReimbursement = disallowed - 2 * disallowed;
            disallowed = 0.00;
            patientPaid = 0.00;
        }
        paymentAmount = coveredCost + patientPaid;
        toProvider = paymentAmount;
        liability = totalCost - paymentAmount;
        String[] claimTotalsSection = { String.valueOf(paymentAmount), String.valueOf(totalCost), String.valueOf(patientPaid), String.valueOf(toProvider), String.valueOf(memberReimbursement), String.valueOf(paymentAmount), String.valueOf(disallowed), String.valueOf(deductible), String.valueOf(""), String.valueOf(copay), String.valueOf(liability), String.valueOf(coveredCost), String.valueOf(0.00) };
        StringBuilder totals = new StringBuilder();
        for (String item : claimTotalsSection) {
            totals.append(item).append(',');
        }
        String totalsString = totals.toString();
        String pharmacyEMPTY = ",,,,,,," + attributes.getResidence() + ",";
        String procedureEMPTY = ",,,,,,,,";
        // diagnosis
        for (Entry condition : encounter.conditions) {
            StringBuilder cond = new StringBuilder();
            String presentOnAdmission;
            String[] poaCodes = { "Y", "N", "U", "W" };
            presentOnAdmission = poaCodes[(int) randomLongWithBounds(0, 3)];
            cond.append(adminString);
            cond.append(pharmacyEMPTY);
            cond.append(providerString);
            cond.append(totalsString);
            cond.append(dateFromTimestamp(condition.start)).append(',');
            cond.append(i).append(',');
            cond.append(dateFromTimestamp(condition.stop)).append(',');
            cond.append("").append(',');
            cond.append(attributes.getPlaceOfService()).append(',');
            cond.append(attributes.getRevenueCenterCode()).append(',');
            cond.append("").append(',');
            cond.append("").append(',');
            cond.append("").append(',');
            cond.append("").append(',');
            cond.append("").append(',');
            cond.append("").append(',');
            cond.append(attributes.getBenefitPaymentStatus()).append(',');
            cond.append(attributes.getDenialCode()).append(',');
            BigDecimal cost = condition.getCost();
            cond.append(0.00).append(',');
            cond.append(0.00).append(',');
            cond.append(0.00).append(',');
            cond.append("").append(',');
            cond.append(cost).append(',');
            cond.append(cost).append(',');
            cond.append(encounter.claim.person.coverage.getTotalCoverage()).append(',');
            cond.append(cost).append(',');
            cond.append(0.00).append(',');
            cond.append(cost).append(',');
            cond.append(cost).append(',');
            cond.append(0.00).append(',');
            cond.append(0.00).append(',');
            cond.append(0.00).append(',');
            Code coding = condition.codes.get(0);
            String diagnosisCode = "SNOMED";
            String diagnosisType = "principal";
            cond.append(coding.code).append(',');
            cond.append(clean(coding.display)).append(',');
            cond.append(presentOnAdmission).append(',');
            cond.append(diagnosisCode).append(',');
            cond.append(diagnosisType).append(',');
            cond.append("").append(',');
            cond.append(procedureEMPTY).append(NEWLINE);
            s.append(cond.toString());
            i++;
        }
        // procedures
        int k = 0;
        for (Procedure procedure : encounter.procedures) {
            String presentOnAdmission;
            String diagnosisCode = "SNOMED";
            String diagnosisType = "principal";
            String procedureType;
            if (k == 0) {
                procedureType = "primary";
            } else {
                procedureType = "secondary";
            }
            String[] poaCodes = { "Y", "N", "U", "W" };
            presentOnAdmission = poaCodes[(int) randomLongWithBounds(0, 3)];
            StringBuilder proc = new StringBuilder();
            proc.append(adminString);
            proc.append(",").append(",").append(",").append(",").append(",").append(",");
            proc.append("01,").append(attributes.getResidence()).append(',');
            proc.append(providerString);
            proc.append(totalsString);
            String typeOfService = "01";
            if (attributes.getNetworkStatus().equals("out")) {
                typeOfService = "11";
            }
            proc.append(dateFromTimestamp(procedure.start)).append(',');
            proc.append(i).append(',');
            proc.append(dateFromTimestamp(procedure.stop)).append(',');
            proc.append(typeOfService).append(',');
            proc.append(attributes.getPlaceOfService()).append(',');
            proc.append(attributes.getRevenueCenterCode()).append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append(attributes.getBenefitPaymentStatus()).append(',');
            proc.append(attributes.getDenialCode()).append(',');
            BigDecimal cost = procedure.getCost();
            proc.append(0.00).append(',');
            proc.append(0.00).append(',');
            proc.append(0.00).append(',');
            proc.append("").append(',');
            proc.append(cost).append(',');
            proc.append(cost).append(',');
            proc.append(encounter.claim.person.coverage.getTotalCoverage()).append(',');
            proc.append(cost).append(',');
            proc.append(0.00).append(',');
            proc.append(cost).append(',');
            proc.append(cost).append(',');
            proc.append(0.00).append(',');
            proc.append(0.00).append(',');
            proc.append(0.00).append(',');
            if (procedure.reasons.size() != 0) {
                Code reasons = procedure.reasons.get(0);
                proc.append(reasons.code).append(',');
                proc.append(clean(reasons.display)).append(',');
                proc.append(presentOnAdmission).append(',');
                proc.append(diagnosisCode).append(',');
                proc.append(diagnosisType).append(',');
            } else {
                proc.append("").append(',');
                proc.append("").append(',');
                proc.append("").append(',');
                proc.append("").append(',');
                proc.append("").append(',');
            }
            proc.append("").append(',');
            Code procedureCode = procedure.codes.get(0);
            proc.append(procedureCode.code).append(',');
            proc.append(clean(procedureCode.display)).append(',');
            proc.append(dateFromTimestamp(procedure.start)).append(',');
            proc.append(diagnosisCode).append(',');
            proc.append(procedureType).append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(',');
            proc.append("").append(NEWLINE);
            s.append(proc.toString());
            i++;
        }
        // pharmacy
        for (Medication medication : encounter.medications) {
            StringBuilder med = new StringBuilder();
            String presentOnAdmission;
            String diagnosisCode = "SNOMED";
            String diagnosisType = "principal";
            String[] poaCodes = { "Y", "N", "U", "W" };
            presentOnAdmission = poaCodes[(int) randomLongWithBounds(0, 3)];
            String[] brandGenericList = { "b", "g" };
            String brandGenericCode = brandGenericList[(int) randomLongWithBounds(0, 1)];
            String[] dawCodeList = { "1", "2", "3", "4", "7", "1", "3", "5", "8" };
            String dawCode;
            if (brandGenericCode.equals("b")) {
                dawCode = dawCodeList[(int) randomLongWithBounds(0, 4)];
            } else {
                if (brandGenericCode.equals("g")) {
                    dawCode = dawCodeList[(int) randomLongWithBounds(5, 8)];
                } else {
                    dawCode = "0";
                }
            }
            /*
         * {"dosage": {"amount":1,"frequency":2,"period":1,"unit":"days"},
         * "duration":{"quantity":2,"unit":"weeks"}, "instructions":[ {
         * "system":"SNOMED-CT", "code":"code", "display":"display string"} ] }
         */
            JsonObject medicationDetails = medication.prescriptionDetails;
            Dictionary<String, Integer> dayMultiplier = new Hashtable<String, Integer>();
            dayMultiplier.put("hours", 1);
            dayMultiplier.put("days", 1);
            dayMultiplier.put("weeks", 2);
            dayMultiplier.put("months", 30);
            dayMultiplier.put("years", 365);
            int dailyDosage;
            int daysSupply;
            JsonObject dosage;
            JsonObject duration;
            if (medicationDetails == null || medicationDetails.has("as_needed")) {
                dailyDosage = 0;
                daysSupply = 0;
            } else {
                if (medicationDetails != null && medicationDetails.has("dosage")) {
                    dosage = medicationDetails.get("dosage").getAsJsonObject();
                    if (dosage.has("amount") == false) {
                        dosage.addProperty("amount", 0);
                    }
                    if (dosage.has("frequency") == false) {
                        dosage.addProperty("frequency", 0);
                    }
                    if (dosage.has("period") == false) {
                        dosage.addProperty("period", 0);
                    }
                    if (dosage.has("unit") == false) {
                        dosage.addProperty("unit", "days");
                    }
                } else {
                    dosage = new JsonObject();
                    dosage.addProperty("amount", 0);
                    dosage.addProperty("frequency", 0);
                    dosage.addProperty("period", 0);
                    dosage.addProperty("unit", "days");
                }
                if (medicationDetails != null && medicationDetails.has("duration")) {
                    duration = medicationDetails.get("duration").getAsJsonObject();
                    if (duration.has("quantity") == false) {
                        duration.addProperty("quantity", 0);
                    }
                    if (duration.has("unit") == false) {
                        duration.addProperty("unit", "days");
                    }
                } else {
                    duration = new JsonObject();
                    duration.addProperty("quantity", 0);
                    duration.addProperty("unit", "days");
                }
                dailyDosage = dosage.get("amount").getAsInt() * dosage.get("frequency").getAsInt() * dosage.get("period").getAsInt() * (int) dayMultiplier.get(dosage.get("unit").getAsString());
                daysSupply = duration.get("quantity").getAsInt() * dayMultiplier.get(duration.get("unit").getAsString());
            }
            UUID rxRef = rand.randUUID();
            String[] serviceTypeList = { "01", "04", "06" };
            String serviceType = serviceTypeList[(int) randomLongWithBounds(0, 2)];
            med.append(adminString);
            med.append(daysSupply).append(',');
            med.append(rxRef).append(',');
            med.append(dawCode).append(',');
            med.append("0").append(',');
            med.append("0").append(',');
            med.append(brandGenericCode).append(',');
            med.append(serviceType).append(',');
            med.append(attributes.getResidence()).append(',');
            med.append(providerString);
            med.append(totalsString);
            Code coding = medication.codes.get(0);
            med.append(dateFromTimestamp(medication.start)).append(',');
            med.append(i).append(',');
            med.append(dateFromTimestamp(medication.stop)).append(',');
            med.append("16").append(',');
            med.append("01").append(',');
            med.append(attributes.getRevenueCenterCode()).append(',');
            med.append(dailyDosage * daysSupply).append(',');
            med.append(dailyDosage * daysSupply).append(',');
            med.append(coding.code).append(',');
            med.append(randomLongWithBounds(0, 2)).append(',');
            med.append(dailyDosage * daysSupply).append(',');
            med.append("UN").append(',');
            med.append(attributes.getBenefitPaymentStatus()).append(',');
            med.append(attributes.getDenialCode()).append(',');
            BigDecimal cost = medication.getCost();
            med.append(0.00).append(',');
            med.append(0.00).append(',');
            med.append(0.00).append(',');
            med.append((dailyDosage == 0 || daysSupply == 0 ? 0 : cost.longValue() / (dailyDosage * daysSupply))).append(',');
            med.append(cost).append(',');
            med.append(cost).append(',');
            med.append(encounter.claim.person.coverage.getTotalCoverage()).append(',');
            med.append(cost).append(',');
            med.append(0.00).append(',');
            med.append(cost).append(',');
            med.append(cost).append(',');
            med.append(0.00).append(',');
            med.append(0.00).append(',');
            med.append(0.00).append(',');
            if (medication.reasons.size() != 0) {
                Code reasons = medication.reasons.get(0);
                med.append(reasons.code).append(',');
                med.append(clean(reasons.display)).append(',');
                med.append(presentOnAdmission).append(',');
                med.append(diagnosisCode).append(',');
                med.append(diagnosisType).append(',');
            } else {
                med.append("").append(',');
                med.append("").append(',');
                med.append("").append(',');
                med.append("").append(',');
                med.append("").append(',');
            }
            med.append("").append(',');
            med.append(procedureEMPTY).append(NEWLINE);
            s.append(med.toString());
            i++;
        }
        // Devices
        for (Device device : encounter.devices) {
            StringBuilder dev = new StringBuilder();
            dev.append(adminString);
            dev.append(",").append(",").append(",").append(",").append(",").append(",");
            dev.append("01,").append(attributes.getResidence()).append(',');
            dev.append(providerString);
            dev.append(totalsString);
            String typeOfService = "01";
            if (attributes.getNetworkStatus().equals("out")) {
                typeOfService = "11";
            }
            dev.append(dateFromTimestamp(device.start)).append(',');
            dev.append(i).append(',');
            dev.append(dateFromTimestamp(device.stop)).append(',');
            dev.append(typeOfService).append(',');
            dev.append(attributes.getPlaceOfService()).append(',');
            dev.append(attributes.getRevenueCenterCode()).append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append(attributes.getBenefitPaymentStatus()).append(',');
            dev.append(attributes.getDenialCode()).append(',');
            BigDecimal cost = device.getCost();
            dev.append(0.00).append(',');
            dev.append(0.00).append(',');
            dev.append(0.00).append(',');
            dev.append("").append(',');
            dev.append(cost).append(',');
            dev.append(cost).append(',');
            dev.append(encounter.claim.person.coverage.getTotalCoverage()).append(',');
            dev.append(cost).append(',');
            dev.append(0.00).append(',');
            dev.append(cost).append(',');
            dev.append(cost).append(',');
            dev.append(0.00).append(',');
            dev.append(0.00).append(',');
            dev.append(0.00).append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            String diagnosisCode = "SNOMED";
            String deviceType = "";
            Code deviceCode = device.codes.get(0);
            dev.append(deviceCode.code).append(',');
            dev.append(clean(deviceCode.display)).append(',');
            dev.append(dateFromTimestamp(device.start)).append(',');
            dev.append(diagnosisCode).append(',');
            dev.append(deviceType).append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(',');
            dev.append("").append(NEWLINE);
            s.append(dev.toString());
            i++;
        }
    }
    write(s.toString(), claims);
}
Also used : Hashtable(java.util.Hashtable) Device(org.mitre.synthea.world.concepts.HealthRecord.Device) JsonObject(com.google.gson.JsonObject) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) BigDecimal(java.math.BigDecimal) Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) UUID(java.util.UUID)

Example 5 with Procedure

use of org.mitre.synthea.world.concepts.HealthRecord.Procedure in project synthea by synthetichealth.

the class ValueSetCodeResolverTest method resolveProcedureReason.

@Test
public void resolveProcedureReason() {
    Code procedureType = new Code(SNOMED_URI, "236172004", "Nephroscopic lithotripsy of ureteric calculus");
    Code procedureReason = new Code(SNOMED_URI, "95570007", "Renal calculus");
    procedureReason.valueSet = SNOMED_URI + "?fhir_vs=ecl/<" + procedureReason.code;
    Procedure procedure = person.record.procedure(time, procedureType.display);
    procedure.reasons.add(procedureReason);
    ValueSetCodeResolver valueSetCodeResolver = new ValueSetCodeResolver(person);
    Person resolvedPerson = valueSetCodeResolver.resolve();
    assertEquals(1, resolvedPerson.record.encounters.size());
    Encounter resolvedEncounter = resolvedPerson.record.encounters.get(0);
    assertEquals(1, resolvedEncounter.procedures.size());
    Procedure resolvedProcedure = resolvedEncounter.procedures.get(0);
    assertEquals(1, resolvedProcedure.reasons.size());
    Code actualProcedureReason = resolvedProcedure.reasons.get(0);
    assertEquals(SNOMED_URI, actualProcedureReason.system);
    assertEquals("699322002", actualProcedureReason.code);
    assertEquals("Matrix stone of kidney", actualProcedureReason.display);
}
Also used : Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Person(org.mitre.synthea.world.agents.Person) Test(org.junit.Test)

Aggregations

Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)17 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)13 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)9 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)9 Entry (org.mitre.synthea.world.concepts.HealthRecord.Entry)8 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)7 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)7 CarePlan (org.mitre.synthea.world.concepts.HealthRecord.CarePlan)6 ImagingStudy (org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy)6 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)6 Date (java.util.Date)3 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)2 ArrayList (java.util.ArrayList)2 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)2 CodeType (org.hl7.fhir.dstu3.model.CodeType)2 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)2 Coding (org.hl7.fhir.dstu3.model.Coding)2 CodeType (org.hl7.fhir.r4.model.CodeType)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)2