public static Encounter GetEncounterFromEncounterEntry(this POCD_MT000040Encounter encounterEntry, Client client) { var encounter = new Encounter(client, encounterEntry?.moodCode == x_DocumentEncounterMood.EVN ? "PRF" : "ORD") { Code = encounterEntry?.code?.GetCode(), VisitDateRange = encounterEntry?.effectiveTime?.GetDateRange(), // //TODO: I can't find any examples that have an effectiveTime associated with the Service Delivery Location. // Officially, that template does not contain a date, or contain any other templates that might contain a date. // There is usually an effectiveTime above it in the data file, at the same level as the participant, but // that is where we are getting the VisitDateRange from. If the FacilityLocation DateRange is the same as // the top-level DateRange for this Encounter, what's the point of having it at the FacilityLocation level? FacilityLocation = encounterEntry?.participant?.FirstOrDefault(p => p.typeCode == "LOC")?.participantRole?.GetCodeWithDateRange(), // DischargeDisposition = encounterEntry?.dischargeDispositionCode?.GetCode(), PrincipalDiagnosis = ((encounterEntry?.entryRelationship?.FirstOrDefault(r => (r.Item as POCD_MT000040Act) ?.code?.code == LoincConstants.HOSPITAL_DISCHARGE_DIAGNOSIS)?.Item as POCD_MT000040Act) ?.entryRelationship?.FirstOrDefault(e => e.Item is POCD_MT000040Observation)?.Item as POCD_MT000040Observation)?.GetFirstNonNullValueCode(), EncounterDiagnosis = ((encounterEntry?.entryRelationship?.FirstOrDefault(r => (r.Item as POCD_MT000040Act) ?.code?.code == LoincConstants.ENCOUNTER_DIAGNOSIS)?.Item as POCD_MT000040Act) ?.entryRelationship?.FirstOrDefault(e => e.Item is POCD_MT000040Observation)?.Item as POCD_MT000040Observation)?.GetValueCodeWithDateRange() }; //TODO: distinguish between Principal Diagnosis and Encounter Diagnosis using priorityCode? Does this only apply to HospitalDischargeDiagnosis? /* * <!-- This denotes that the diagnosis is the principal diagnosis. There is generally only a single diagnosis for coded bill.--> * <!-- This current modeling aligns with QRDA. Substantial discussion occurred on the task force regarding this method. --> * <!-- Additional comments on this approach should be included in comments on the QRDA Implementation Guide. We will revisit if QRDA changes their standard approach. --> * <priorityCode code="63161005" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Principal"/> * * <!-- This denotes that the diagnosis is a secondary diagnosis. There may be multiple secondary diagnoses on coded bills.--> * <!-- This current modeling aligns with QRDA. Substantial discussion occurred on the task force regarding this method. --> * <!-- Additional comments on this approach should be included in comments on the QRDA Implementation Guide. We will revisit if QRDA changes their standard approach. --> * <priorityCode code="2603003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Secondary"/> * * https://github.com/HL7/C-CDA-Examples/blob/master/Encounters/Hospital%20Discharge%20Encounter%20with%20Billable%20Diagnoses/Hospital%20Discharge%20Encounter%20with%20Billable%20Diagnoses(C-CDA2.1).xml */ return(encounter); }
public override POCD_MT000040Component3 ToPocdComponent() { POCD_MT000040Component3 returnVal = base.ToPocdComponent(); // *** Skip unless we have a pediatrician name *** if (!string.IsNullOrWhiteSpace(this.PediatricianName)) { // *** Create encounter containing pediatrician name *** POCD_MT000040Encounter enc = new POCD_MT000040Encounter(); // *** Set Class, Mood *** enc.classCode = "ENC"; enc.moodCode = x_DocumentEncounterMood.PRP; // *** Set Template Ids *** CdaTemplateIdList templateIds = new CdaTemplateIdList("1.3.6.1.4.1.19376.1.5.3.1.4.14", "2.16.840.1.113883.10.20.1.21", "2.16.840.1.113883.10.20.1.25"); enc.templateId = templateIds.ToPocd(); // *** Add Id *** enc.id = new II[] { new II() { root = Guid.NewGuid().ToString() } }; // *** Code *** enc.code = new CD() { code = "Ambulatory", codeSystem = "2.16.840.1.113883.5.4", codeSystemName = "ActEncounterCode" }; // *** Add name as performer *** CdaName cdaName = new CdaName() { Last = this.PediatricianName }; enc.performer = new POCD_MT000040Performer2[] { new POCD_MT000040Performer2() { typeCode = ParticipationPhysicalPerformer.PRF, typeCodeSpecified = true, assignedEntity = new POCD_MT000040AssignedEntity() { assignedPerson = new POCD_MT000040Person() { name = new PN[] { cdaName.ToPN() } } } } }; // *** Add encounter to list of entries *** List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>(returnVal.section.entry); entryList.Add(new POCD_MT000040Entry() { Item = enc }); returnVal.section.entry = entryList.ToArray(); // *** Add pediatrician to human-readable *** List <object> items = new List <object>(returnVal.section.text.Items); // *** Create a new paragraph *** StrucDocParagraph para = new StrucDocParagraph(); para.Text = new[] { string.Format("Pediatrician: {0}", this.PediatricianName) }; // *** Add it to list *** items.Add(para); // *** Add list to document *** returnVal.section.text.Items = items.ToArray(); } return(returnVal); }