Search in sources :

Example 1 with CodingDt

use of ca.uhn.fhir.model.dstu2.composite.CodingDt in project cqf-ruler by DBCG.

the class CompositionBuilder method initializeDstu2.

@Override
protected void initializeDstu2(T theResource) {
    super.initializeDstu2(theResource);
    ca.uhn.fhir.model.dstu2.resource.Composition composition = (ca.uhn.fhir.model.dstu2.resource.Composition) theResource;
    List<ResourceReferenceDt> author = new ArrayList<>();
    author.add(new ResourceReferenceDt(myAuthor));
    composition.setDate(new DateTimeDt(myDate)).setIdentifier(new IdentifierDt(getIdentifier().getKey(), getIdentifier().getValue())).setStatus(CompositionStatusEnum.forCode(myStatus)).setSubject(new ResourceReferenceDt(mySubject)).setTitle(myTitle).setType(new CodeableConceptDt().addCoding(new CodingDt().setSystem(getTypeSetting().getSystem()).setCode(getTypeSetting().getCode()).setDisplay(getTypeSetting().getDisplay()))).setAuthor(author).setCustodian(new ResourceReferenceDt(myCustodian));
}
Also used : IdentifierDt(ca.uhn.fhir.model.dstu2.composite.IdentifierDt) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) ArrayList(java.util.ArrayList) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt)

Example 2 with CodingDt

use of ca.uhn.fhir.model.dstu2.composite.CodingDt 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 CodingDt

use of ca.uhn.fhir.model.dstu2.composite.CodingDt in project synthea by synthetichealth.

the class FhirDstu2 method careplan.

/**
 * Map the given CarePlan to a FHIR CarePlan 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
 *          Bundle to add the CarePlan to
 * @param encounterEntry
 *          Current Encounter entry
 * @param carePlan
 *          The CarePlan to map to FHIR and add to the bundle
 * @return The added Entry
 */
private static Entry careplan(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, CarePlan carePlan) {
    ca.uhn.fhir.model.dstu2.resource.CarePlan careplanResource = new ca.uhn.fhir.model.dstu2.resource.CarePlan();
    careplanResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
    careplanResource.setContext(new ResourceReferenceDt(encounterEntry.getFullUrl()));
    Code code = carePlan.codes.get(0);
    careplanResource.addCategory(mapCodeToCodeableConcept(code, SNOMED_URI));
    NarrativeDt narrative = new NarrativeDt();
    narrative.setStatus(NarrativeStatusEnum.GENERATED);
    narrative.setDiv(code.display);
    careplanResource.setText(narrative);
    CarePlanActivityStatusEnum activityStatus;
    GoalStatusEnum goalStatus;
    PeriodDt period = new PeriodDt().setStart(new DateTimeDt(new Date(carePlan.start)));
    careplanResource.setPeriod(period);
    if (carePlan.stop != 0L) {
        period.setEnd(new DateTimeDt(new Date(carePlan.stop)));
        careplanResource.setStatus(CarePlanStatusEnum.COMPLETED);
        activityStatus = CarePlanActivityStatusEnum.COMPLETED;
        goalStatus = GoalStatusEnum.ACHIEVED;
    } else {
        careplanResource.setStatus(CarePlanStatusEnum.ACTIVE);
        activityStatus = CarePlanActivityStatusEnum.IN_PROGRESS;
        goalStatus = GoalStatusEnum.IN_PROGRESS;
    }
    if (!carePlan.activities.isEmpty()) {
        for (Code activity : carePlan.activities) {
            Activity activityComponent = new Activity();
            ActivityDetail activityDetailComponent = new ActivityDetail();
            activityDetailComponent.setStatus(activityStatus);
            activityDetailComponent.setCode(mapCodeToCodeableConcept(activity, SNOMED_URI));
            activityDetailComponent.setProhibited(new BooleanDt(false));
            activityComponent.setDetail(activityDetailComponent);
            careplanResource.addActivity(activityComponent);
        }
    }
    if (!carePlan.reasons.isEmpty()) {
        // Only one element in list
        Code reason = carePlan.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())) {
                    careplanResource.addAddresses().setReference(entry.getFullUrl());
                }
            }
        }
    }
    for (JsonObject goal : carePlan.goals) {
        Entry goalEntry = caregoal(rand, bundle, goalStatus, goal);
        careplanResource.addGoal().setReference(goalEntry.getFullUrl());
    }
    return newEntry(rand, bundle, careplanResource);
}
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) Activity(ca.uhn.fhir.model.dstu2.resource.CarePlan.Activity) JsonObject(com.google.gson.JsonObject) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) NarrativeDt(ca.uhn.fhir.model.dstu2.composite.NarrativeDt) Date(java.util.Date) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) GoalStatusEnum(ca.uhn.fhir.model.dstu2.valueset.GoalStatusEnum) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) BooleanDt(ca.uhn.fhir.model.primitive.BooleanDt) CarePlanActivityStatusEnum(ca.uhn.fhir.model.dstu2.valueset.CarePlanActivityStatusEnum) ActivityDetail(ca.uhn.fhir.model.dstu2.resource.CarePlan.ActivityDetail)

Example 4 with CodingDt

use of ca.uhn.fhir.model.dstu2.composite.CodingDt in project eCRNow by drajer-health.

the class Dstu2CdaHeaderGenerator method getPatientDetails.

public static String getPatientDetails(Dstu2FhirData data, Patient p, LaunchDetails details) {
    StringBuilder patientDetails = new StringBuilder();
    patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.RECORD_TARGET_EL_NAME));
    patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.PATIENT_ROLE_EL_NAME));
    IdentifierDt id = Dstu2CdaFhirUtilities.getIdentifierForType(p.getIdentifier(), IdentifierTypeCodesEnum.MR);
    if (id != null) {
        if (!StringUtils.isEmpty(id.getSystem()) && !StringUtils.isEmpty(id.getValue())) {
            logger.info(" Found Identifier with Type MR ");
            String system = CdaGeneratorUtils.getRootOid(id.getSystem(), details.getAssigningAuthorityId());
            patientDetails.append(CdaGeneratorUtils.getXmlForII(system, id.getValue()));
        } else {
            logger.info(" Using Resource Identifier as id ");
            ;
            patientDetails.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), p.getId().toString()));
        }
    } else {
        logger.info(" Using Resource Identifier as id ");
        ;
        patientDetails.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), p.getId().toString()));
    }
    // Add Address.
    patientDetails.append(Dstu2CdaFhirUtilities.getAddressXml(p.getAddress()));
    // Add Telecom
    patientDetails.append(Dstu2CdaFhirUtilities.getTelecomXml(p.getTelecom()));
    // Add patient
    patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.PATIENT_EL_NAME));
    patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.NAME_EL_NAME));
    patientDetails.append(Dstu2CdaFhirUtilities.getNameXml(p.getName()));
    patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.NAME_EL_NAME));
    patientDetails.append(Dstu2CdaFhirUtilities.getGenderXml(p.getGenderElement()));
    patientDetails.append(Dstu2CdaFhirUtilities.getDateTypeXml(p.getBirthDateElement(), CdaGeneratorConstants.BIRTH_TIME_EL_NAME));
    if (p.getDeceased() == null || (p.getDeceased() != null && p.getDeceased().isEmpty())) {
        patientDetails.append(CdaGeneratorUtils.getXmlForValue(CdaGeneratorConstants.SDTC_DECEASED_IND, CdaGeneratorConstants.CCDA_FALSE));
    } else {
        patientDetails.append(CdaGeneratorUtils.getXmlForValue(CdaGeneratorConstants.SDTC_DECEASED_IND, CdaGeneratorConstants.CCDA_TRUE));
        if (p.getDeceased() instanceof DateTimeDt) {
            DateTimeDt d = (DateTimeDt) p.getDeceased();
            patientDetails.append(CdaGeneratorUtils.getXmlForEffectiveTime(CdaGeneratorConstants.SDTC_DECEASED_TIME, d.getValue().toString()));
        } else {
            patientDetails.append(CdaGeneratorUtils.getXmlForNullEffectiveTime(CdaGeneratorConstants.SDTC_DECEASED_TIME, CdaGeneratorConstants.NF_NI));
        }
    }
    CodingDt race = Dstu2CdaFhirUtilities.getCodingExtension(p.getUndeclaredExtensions(), CdaGeneratorConstants.FHIR_ARGO_RACE_EXT_URL, CdaGeneratorConstants.OMB_RACE_CATEGORY_URL);
    if (race != null && race.getCode() != null) {
        patientDetails.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.RACE_CODE_EL_NAME, race.getCode(), CdaGeneratorConstants.RACE_CODE_SYSTEM, CdaGeneratorConstants.RACE_CODE_SYSTEM_NAME, race.getDisplay()));
    } else {
        patientDetails.append(CdaGeneratorUtils.getXmlForNullCD(CdaGeneratorConstants.RACE_CODE_EL_NAME, CdaGeneratorConstants.NF_NI));
    }
    CodingDt ethnicity = Dstu2CdaFhirUtilities.getCodingExtension(p.getUndeclaredExtensions(), CdaGeneratorConstants.FHIR_ARGO_ETHNICITY_EXT_URL, CdaGeneratorConstants.OMB_RACE_CATEGORY_URL);
    if (ethnicity != null && ethnicity.getCode() != null) {
        patientDetails.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.ETHNIC_CODE_EL_NAME, ethnicity.getCode(), CdaGeneratorConstants.RACE_CODE_SYSTEM, CdaGeneratorConstants.RACE_CODE_SYSTEM_NAME, ethnicity.getDisplay()));
    } else {
        patientDetails.append(CdaGeneratorUtils.getXmlForNullCD(CdaGeneratorConstants.ETHNIC_CODE_EL_NAME, CdaGeneratorConstants.NF_NI));
    }
    // Adding Guardian details for patient
    if (p.getContact() != null && p.getContact().size() > 0) {
        // Add Guardian element
        Contact guardianContact = Dstu2CdaFhirUtilities.getGuardianContact(p.getContact());
        if (guardianContact != null) {
            patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.GUARDIAN_EL_NAME));
            // Add Telecom
            patientDetails.append(Dstu2CdaFhirUtilities.getTelecomXml(guardianContact.getTelecom()));
            patientDetails.append(Dstu2CdaFhirUtilities.getEmailXml(guardianContact.getTelecom()));
            // Add Name
            patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.GUARDIAN_PERSON_EL_NAME));
            patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.NAME_EL_NAME));
            patientDetails.append(Dstu2CdaFhirUtilities.getNameXml(guardianContact.getName()));
            patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.NAME_EL_NAME));
            patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.GUARDIAN_PERSON_EL_NAME));
            patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.GUARDIAN_EL_NAME));
        }
    }
    // Add language communication
    patientDetails.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.LANGUAGE_COMM_EL_NAME));
    CodingDt language = Dstu2CdaFhirUtilities.getLanguage(p.getCommunication());
    if (language != null && language.getCode() != null) {
        patientDetails.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.LANGUAGE_CODE_EL_NAME, language.getCode()));
    } else {
        patientDetails.append(CdaGeneratorUtils.getXmlForNullCD(CdaGeneratorConstants.LANGUAGE_CODE_EL_NAME, CdaGeneratorConstants.NF_NI));
    }
    patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.LANGUAGE_COMM_EL_NAME));
    patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.PATIENT_EL_NAME));
    patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.PATIENT_ROLE_EL_NAME));
    patientDetails.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.RECORD_TARGET_EL_NAME));
    return patientDetails.toString();
}
Also used : IdentifierDt(ca.uhn.fhir.model.dstu2.composite.IdentifierDt) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) Contact(ca.uhn.fhir.model.dstu2.resource.Patient.Contact)

Example 5 with CodingDt

use of ca.uhn.fhir.model.dstu2.composite.CodingDt in project eCRNow by drajer-health.

the class Dstu2CdaResultGenerator method generateResultsSection.

public static String generateResultsSection(Dstu2FhirData data, LaunchDetails details) {
    StringBuilder hsb = new StringBuilder(5000);
    StringBuilder sb = new StringBuilder(2000);
    StringBuilder resultEntries = new StringBuilder();
    List<Observation> results = data.getLabResults();
    if (results != null && results.size() > 0) {
        hsb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.COMP_EL_NAME));
        hsb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.SECTION_EL_NAME));
        hsb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_SEC_TEMPLATE_ID));
        hsb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_SEC_TEMPLATE_ID, CdaGeneratorConstants.LAB_RESULTS_SEC_TEMPLATE_ID_EXT));
        hsb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.CODE_EL_NAME, CdaGeneratorConstants.LAB_RESULTS_SEC_CODE, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.LAB_RESULTS_SEC_NAME));
        // Add Title
        hsb.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.TITLE_EL_NAME, CdaGeneratorConstants.LAB_RESULTS_SEC_TITLE));
        // Add Narrative Text
        hsb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.TEXT_EL_NAME));
        // Create Table Header.
        List<String> list = new ArrayList<String>();
        list.add(CdaGeneratorConstants.LABTEST_TABLE_COL_1_TITLE);
        list.add(CdaGeneratorConstants.LABTEST_TABLE_COL_2_TITLE);
        list.add(CdaGeneratorConstants.LABTEST_TABLE_COL_3_TITLE);
        hsb.append(CdaGeneratorUtils.getXmlForTableHeader(list, CdaGeneratorConstants.TABLE_BORDER, CdaGeneratorConstants.TABLE_WIDTH));
        // Add Table Body
        hsb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.TABLE_BODY_EL_NAME));
        int rowNum = 1;
        Boolean triggerCodesAdded = false;
        for (Observation obs : results) {
            String obsDisplayName = CdaGeneratorConstants.UNKNOWN_VALUE;
            List<CodingDt> cds = null;
            if (obs.getCode() != null && obs.getCode().getCodingFirstRep() != null) {
                cds = obs.getCode().getCoding();
                if (!StringUtils.isEmpty(obs.getCode().getCodingFirstRep().getDisplay())) {
                    obsDisplayName = obs.getCode().getCodingFirstRep().getDisplay();
                } else if (!StringUtils.isEmpty(obs.getCode().getText())) {
                    obsDisplayName = obs.getCode().getText();
                }
            }
            Map<String, String> bodyvals = new HashMap<String, String>();
            bodyvals.put(CdaGeneratorConstants.LABTEST_TABLE_COL_1_BODY_CONTENT, obsDisplayName);
            String val = CdaGeneratorConstants.UNKNOWN_VALUE;
            if (obs.getValue() != null) {
                val = Dstu2CdaFhirUtilities.getStringForIDataType(obs.getValue());
            }
            bodyvals.put(CdaGeneratorConstants.LABTEST_TABLE_COL_2_BODY_CONTENT, val);
            String dt = CdaGeneratorConstants.UNKNOWN_VALUE;
            if (obs.getEffective() != null) {
                dt = Dstu2CdaFhirUtilities.getStringForIDataType(obs.getEffective());
            }
            bodyvals.put(CdaGeneratorConstants.LABTEST_TABLE_COL_3_BODY_CONTENT, dt);
            sb.append(CdaGeneratorUtils.addTableRow(bodyvals, rowNum));
            // Setup the Organizer and Entries
            StringBuilder lrEntry = new StringBuilder();
            // Add the Entries.
            lrEntry.append(CdaGeneratorUtils.getXmlForActEntry(CdaGeneratorConstants.TYPE_CODE_DEF));
            // Add the Organizer Act
            lrEntry.append(CdaGeneratorUtils.getXmlForAct(CdaGeneratorConstants.ORGANIZER_EL_NAME, CdaGeneratorConstants.ORGANIZER_CLASS_CODE_CLUSTER, CdaGeneratorConstants.MOOD_CODE_DEF));
            lrEntry.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_ORG_TEMPLATE_ID));
            lrEntry.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_ORG_TEMPLATE_ID, CdaGeneratorConstants.LAB_RESULTS_ORG_TEMPLATE_ID_EXT));
            lrEntry.append(CdaGeneratorUtils.getXmlForIIUsingGuid());
            // Fix the Code to be the same as the result code..
            lrEntry.append(Dstu2CdaFhirUtilities.getCodingXml(cds, CdaGeneratorConstants.CODE_EL_NAME));
            lrEntry.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.COMPLETED_STATUS));
            // Add the actual Result Observation
            lrEntry.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.COMP_EL_NAME));
            lrEntry.append(CdaGeneratorUtils.getXmlForAct(CdaGeneratorConstants.OBS_ACT_EL_NAME, CdaGeneratorConstants.OBS_CLASS_CODE, CdaGeneratorConstants.MOOD_CODE_DEF));
            lrEntry.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_ENTRY_TEMPLATE_ID));
            lrEntry.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.LAB_RESULTS_ENTRY_TEMPLATE_ID, CdaGeneratorConstants.LAB_RESULTS_ENTRY_TEMPLATE_ID_EXT));
            lrEntry.append(CdaGeneratorUtils.getXmlForIIUsingGuid());
            lrEntry.append(Dstu2CdaFhirUtilities.getCodingXml(cds, CdaGeneratorConstants.CODE_EL_NAME));
            lrEntry.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.COMPLETED_STATUS));
            lrEntry.append(Dstu2CdaFhirUtilities.getIDataTypeXml(obs.getEffective(), CdaGeneratorConstants.EFF_TIME_EL_NAME, false));
            lrEntry.append(Dstu2CdaFhirUtilities.getIDataTypeXml(obs.getValue(), CdaGeneratorConstants.VAL_EL_NAME, true));
            // Add interpretation code.
            if ((obs.getInterpretation() != null) && (obs.getInterpretation().getCoding() != null) && (obs.getInterpretation().getCoding().size() > 0)) {
                logger.info(" Adding Interpretaion Code ");
                List<CodeableConceptDt> cdt = new ArrayList<CodeableConceptDt>();
                cdt.add(obs.getInterpretation());
                lrEntry.append(Dstu2CdaFhirUtilities.getCodeableConceptXml(cdt, CdaGeneratorConstants.INTERPRETATION_CODE_EL_NAME, false));
            }
            // End Tag for Entry Relationship
            lrEntry.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.OBS_ACT_EL_NAME));
            lrEntry.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.COMP_EL_NAME));
            if (!triggerCodesAdded) {
                lrEntry.append(addTriggerCodes(data, details, obs, cds));
                triggerCodesAdded = true;
            }
            // End Tags for Entries
            lrEntry.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ORGANIZER_EL_NAME));
            lrEntry.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ENTRY_EL_NAME));
            resultEntries.append(lrEntry);
            rowNum++;
        }
        // End the Sb string.
        sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TABLE_BODY_EL_NAME));
        // End Table.
        sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TABLE_EL_NAME));
        sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TEXT_EL_NAME));
        hsb.append(sb);
        // Add lab results
        hsb.append(resultEntries);
        // Complete the section end tags.
        hsb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.SECTION_EL_NAME));
        hsb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.COMP_EL_NAME));
    } else {
        hsb.append(generateEmptyLabResults());
    }
    return hsb.toString();
}
Also used : CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Observation(ca.uhn.fhir.model.dstu2.resource.Observation) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt)

Aggregations

CodingDt (ca.uhn.fhir.model.dstu2.composite.CodingDt)17 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)7 CodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt)6 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)6 ArrayList (java.util.ArrayList)6 ResourceReferenceDt (ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt)5 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)5 PeriodDt (ca.uhn.fhir.model.dstu2.composite.PeriodDt)4 Condition (ca.uhn.fhir.model.dstu2.resource.Condition)4 BoundCodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.BoundCodeableConceptDt)3 IdentifierDt (ca.uhn.fhir.model.dstu2.composite.IdentifierDt)3 QuantityDt (ca.uhn.fhir.model.dstu2.composite.QuantityDt)3 JsonObject (com.google.gson.JsonObject)3 Date (java.util.Date)3 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)3 BaseQuantityDt (ca.uhn.fhir.model.base.composite.BaseQuantityDt)2 BooleanDt (ca.uhn.fhir.model.primitive.BooleanDt)2 BoundCodeDt (ca.uhn.fhir.model.primitive.BoundCodeDt)2 CodeDt (ca.uhn.fhir.model.primitive.CodeDt)2 JsonElement (com.google.gson.JsonElement)2