Example #1
0
        private static string GetDataSubType(POCD_MT000040SubstanceAdministration medicationEntry, Code productCode,
                                             List <AllergyAdverseEvent> allergyAdverseEvents, CqmSolutionDateRange dischargeDateRange, out bool notPresent)
        {
            notPresent = false;

            if (medicationEntry == null)
            {
                return(string.Empty);
            }

            notPresent = medicationEntry.negationInd;

            //TODO: is this correct? if so, should we compare the whole code, not just the value?
            if (!string.IsNullOrWhiteSpace(productCode?.Value))
            {
                //if patient has an allergy or adverse event for the same product, return the appropriate dataSubType
                var allergyAdverseEvent =
                    allergyAdverseEvents.FirstOrDefault(a => !a.NotPresent && a.Cause?.Value == productCode.Value);

                if (allergyAdverseEvent != null)
                {
                    return(allergyAdverseEvent.DataSubType);
                }
            }

            //TODO: Are these the correct logic and codes for Discharge/Discharge Not Done?
            if (dischargeDateRange?.DateHigh?.DateTime.HasValue == true)
            {
                return("DSC");
            }
            //
            if (dischargeDateRange?.DateLow?.DateTime.HasValue == true)
            {
                return("DSCND");
            }
            //

            var statusName = GetStatus(medicationEntry);

            switch (medicationEntry.moodCode)
            {
            case x_DocumentSubstanceMood.EVN:     //administered
                return(statusName.Equals("completed", StringComparison.InvariantCultureIgnoreCase) ? (notPresent ? "ADMND" : "ADM") : "ACT");

            //TODO: is this logic correct, and are these ^-------^
            //the right codes for Administered and Administered Not Done?
            case x_DocumentSubstanceMood.INT:     //to be administered
                return(statusName.Equals("active", StringComparison.InvariantCultureIgnoreCase) ? "ACT" : "DISP");

            //TODO: is this logic correct, and is this --^
            //the right code for Dispensed?
            //Also, shouldn't there be a subtype for "No Longer Active?"
            case x_DocumentSubstanceMood.RQO:     //ordered
                return(notPresent ? "ORDND" : "ORD");

            //TODO: Handle notPresent in all cases?

            default:
                return(string.Empty);    //TODO: default to what?
            }
        }
Example #2
0
        public static Medication GetMedicationFromMedicationEntry(this POCD_MT000040SubstanceAdministration medicationEntry, Client client,
                                                                  List <AllergyAdverseEvent> allergyAdverseEvents, CqmSolutionDateRange dischargeDateRange)
        {
            var productNode = (medicationEntry?.consumable?.manufacturedProduct?.Item as POCD_MT000040Material)?.code;
            var productCode = productNode?.GetCode();
            var dataSubType = GetDataSubType(medicationEntry, productCode, allergyAdverseEvents, dischargeDateRange, out var notPresent);

            var medication = new Medication(client, dataSubType)
            {
                Product = productCode,
                Generic = productNode?.translation?.FirstOrDefault()?.GetCode(),                 //TODO: handle multiple translation nodes?
                AdministeredDateRange = medicationEntry?.effectiveTime?.GetDateRangeFromArray(), //TODO: verify this date parsing logic
                Refills    = (medicationEntry?.entryRelationship?.FirstOrDefault(r => r.Item is POCD_MT000040Supply)?.Item as POCD_MT000040Supply)?.repeatNumber?.value,
                NotPresent = notPresent,
//TODO:                NegationRationale = notPresent ? medicationEntry.SelectSingleNode(@"entryrelationship/observation/value")?.GetCode() : null //TODO: is this correct?
            };

            return(medication);
        }
Example #3
0
        public static Medication GetMedicationFromMedicationEntry(this HtmlNode medicationEntry, Client client,
                                                                  List <AllergyAdverseEvent> allergyAdverseEvents, CqmSolutionDateRange dischargeDateRange)
        {
            var productNode = medicationEntry.SelectSingleNode(@"consumable/manufacturedproduct[@classcode='MANU']/manufacturedmaterial/code");
            var productCode = productNode?.GetCode();
            var dataSubType = GetDataSubType(medicationEntry, productCode, allergyAdverseEvents, dischargeDateRange, out var notPresent);

            var medication = new Medication(client, dataSubType)
            {
                Product = productCode,
                Generic = productNode?.SelectSingleNode("translation")?.GetCode(), //TODO: handle multiple translation nodes?
                AdministeredDateRange = medicationEntry.GetDateRange(),
                Refills = medicationEntry.SelectSingleNode(@"entryrelationship/supply/repeatnumber")
                          ?.Attributes["value"]?.Value,
                NotPresent        = notPresent,
                NegationRationale = notPresent ? medicationEntry.SelectSingleNode(@"entryrelationship/observation/value")?.GetCode() : null //TODO: is this correct?
            };

            return(medication);
        }
Example #4
0
        public static List <Medication> GetMedicationsFromComponentSection(this POCD_MT000040Section componentSection, Client client,
                                                                           List <AllergyAdverseEvent> allergyAdverseEvents, CqmSolutionDateRange dischargeDateRange)
        {
            var medications = new List <Medication>();

            var medicationEntries = componentSection?.entry?.Where(e => e.Item is POCD_MT000040SubstanceAdministration);

            if (medicationEntries != null)
            {
                foreach (var medicationEntry in medicationEntries)
                {
                    medications.Add(GetMedicationFromMedicationEntry(
                                        medicationEntry.Item as POCD_MT000040SubstanceAdministration,
                                        client, allergyAdverseEvents, dischargeDateRange));
                }
            }

            return(medications);
        }
Example #5
0
        public static List <Medication> GetMedicationsFromComponentSection(this HtmlNode componentSection, Client client,
                                                                           List <AllergyAdverseEvent> allergyAdverseEvents, CqmSolutionDateRange dischargeDateRange)
        {
            var medications = new List <Medication>();

            var medicationEntries = componentSection.SelectNodes(@"entry/substanceadministration[@classcode='SBADM']");

            foreach (var medicationEntry in medicationEntries)
            {
                medications.Add(GetMedicationFromMedicationEntry(medicationEntry, client, allergyAdverseEvents, dischargeDateRange));
            }

            return(medications);
        }