Example #1
0
        ///<summary>Inserts the new medication and returns it.</summary>
        public static Medication CreateMedication(string medName = "", string rxCui = "")
        {
            Medication medication = new Medication();

            medication.MedName = medName;
            if (medication.MedName == "")
            {
                medication.MedName = "Med_" + MiscUtils.CreateRandomAlphaNumericString(8);
            }
            medication.RxCui = PIn.Long(rxCui, false);
            if (medication.RxCui != 0 && RxNorms.GetByRxCUI(rxCui) == null)
            {
                RxNorm rxNorm = new RxNorm();
                rxNorm.RxCui       = rxCui;
                rxNorm.Description = medication.MedName;
                RxNorms.Insert(rxNorm);
            }
            Medications.Insert(medication);
            return(medication);
        }
Example #2
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Category", 80);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Code", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("CodeSystem", 120);
            gridMain.Columns.Add(col);
            //col=new ODGridColumn("Op+Value",80);//Example: >=150
            //gridMain.Columns.Add(col);
            col = new ODGridColumn("Description", 250);         //Also includes values for labloinc and demographics and vitals. Example: ">150, BP Systolic"
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //EhrTriggerCur.ProblemDefNumList-----------------------------------------------------------------------------------------------------------------------
            string[] arrayString = EhrTriggerCur.ProblemDefNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Problem Def");
                row.Cells.Add(DiseaseDefs.GetItem(PIn.Long(arrayString[i])).DiseaseName);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemIcd9List---------------------------------------------------------------------------------------------------------------------------
            arrayString = EhrTriggerCur.ProblemIcd9List.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("ICD9 CM");
                row.Cells.Add(ICD9s.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemIcd10List;
            arrayString = EhrTriggerCur.ProblemIcd10List.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("ICD10 CM");
                row.Cells.Add(Icd10s.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemSnomedList;
            arrayString = EhrTriggerCur.ProblemSnomedList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("SNOMED CT");
                row.Cells.Add(Snomeds.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.MedicationNumList
            arrayString = EhrTriggerCur.MedicationNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Medication Def");
                row.Cells.Add(Medications.GetDescription(PIn.Long(arrayString[i])));
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.RxCuiList
            arrayString = EhrTriggerCur.RxCuiList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("RxCui");
                row.Cells.Add(RxNorms.GetByRxCUI(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.CvxList
            arrayString = EhrTriggerCur.CvxList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Cvx");
                row.Cells.Add(Cvxs.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.AllergyDefNumList
            arrayString = EhrTriggerCur.AllergyDefNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Allergy");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Allergy Def");
                row.Cells.Add(AllergyDefs.GetOne(PIn.Long(arrayString[i])).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.DemographicsList
            arrayString = EhrTriggerCur.DemographicsList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                string[] arrayStringElements = arrayString[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                switch (arrayStringElements[0])
                {
                case "age":
                    row.Cells.Add("Demographic");
                    row.Cells.Add("30525-0");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Age" + arrayStringElements[1]);                          //Example "Age>55"
                    gridMain.Rows.Add(row);
                    break;

                case "gender":
                    row.Cells.Add("Demographic");
                    row.Cells.Add("46098-0");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Gender:" + arrayString[i].Replace("gender,", ""));                         //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                default:
                    //should never happen
                    continue;                            //next trigger
                }
            }
            //EhrTriggerCur.LabLoincList
            arrayString = EhrTriggerCur.LabLoincList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                Loinc _loincTemp = Loincs.GetByCode(arrayString[i]);              //.Split(new string[] { ";" },StringSplitOptions.None)[0]);
                if (_loincTemp == null)
                {
                    continue;
                }
                row.Cells.Add("Laboratory");
                row.Cells.Add(_loincTemp.LoincCode);
                row.Cells.Add("LOINC");
                row.Cells.Add(_loincTemp.NameShort);
                //switch(arrayString[i].Split(new string[] { ";" },StringSplitOptions.RemoveEmptyEntries).Length) {
                //	case 1://loinc only comparison
                //		row.Cells.Add(_loincTemp.NameShort);
                //		break;
                //	case 2://microbiology or unitless lab.
                //		Snomed _snomedTemp=Snomeds.GetByCode(arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]);
                //		row.Cells.Add(_loincTemp.NameShort+", "
                //			+(_snomedTemp==null?arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]:_snomedTemp.Description));//Example: Bacteria Identified, Campylobacter jenuni
                //		break;
                //	case 3://"traditional lab results"
                //		row.Cells.Add(_loincTemp.NameShort+" "
                //	+arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]+" "//example: >150 or a snomed code if microbiology
                //	+arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[2]    //example: mg/dL or blank
                //			);
                //		break;
                //	default://should never happen. Will display blank.
                //		row.Cells.Add("");
                //		break;
                //}
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.VitalLoincList
            arrayString = EhrTriggerCur.VitalLoincList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                string[] arrayStringElements = arrayString[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                switch (arrayStringElements[0])
                {
                case "height":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("8302-2");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Height" + arrayString[i].Replace("height,", "") + " in.");                       //Example "Age>55"
                    gridMain.Rows.Add(row);
                    break;

                case "weight":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("29463-7");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Weight:" + arrayString[i].Replace("weight,", ""));                         //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                case "bp???":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("???There are two.");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("???");                            //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                case "BMI":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("39156-5");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("BMI" + arrayString[i].Replace("BMI,", "").Replace("%", "") + "%");                      //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                default:
                    //should never happen
                    continue;                            //next trigger
                }
            }
            //End trigger fields.
            gridMain.EndUpdate();
        }
        private void FillGridInterventions()
        {
            gridInterventions.BeginUpdate();
            gridInterventions.Columns.Clear();
            gridInterventions.Columns.Add(new ODGridColumn("Date", 70));
            gridInterventions.Columns.Add(new ODGridColumn("Type", 150));
            gridInterventions.Columns.Add(new ODGridColumn("Description", 160));
            gridInterventions.Columns.Add(new ODGridColumn("Declined", 60)
            {
                TextAlign = HorizontalAlignment.Center
            });
            gridInterventions.Columns.Add(new ODGridColumn("Documentation", 140));
            gridInterventions.Rows.Clear();
            //build list of rows of CessationInterventions and CessationMedications so we can order the list by date and type before filling the grid
            List <ODGridRow> listRows = new List <ODGridRow>();
            ODGridRow        row;

            #region CessationInterventions
            List <Intervention> listInterventions = Interventions.Refresh(PatCur.PatNum, InterventionCodeSet.TobaccoCessation);
            foreach (Intervention iCur in listInterventions)
            {
                row = new ODGridRow();
                row.Cells.Add(iCur.DateEntry.ToShortDateString());
                string type     = InterventionCodeSet.TobaccoCessation.ToString() + " Counseling";
                string descript = "";
                switch (iCur.CodeSystem)
                {
                case "CPT":
                    Cpt cptCur = Cpts.GetByCode(iCur.CodeValue);
                    descript = cptCur != null?cptCur.Description:"";
                    break;

                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(iCur.CodeValue);
                    descript = sCur != null?sCur.Description:"";
                    break;

                case "RXNORM":
                    //if the user checks the "Patient Declined" checkbox, we enter the tobacco cessation medication as an intervention that was declined
                    type = InterventionCodeSet.TobaccoCessation.ToString() + " Medication";
                    RxNorm rCur = RxNorms.GetByRxCUI(iCur.CodeValue);
                    descript = rCur != null?rCur.Description:"";
                    break;
                }
                row.Cells.Add(type);
                row.Cells.Add(descript);
                row.Cells.Add(iCur.IsPatDeclined?"X":"");
                row.Cells.Add(iCur.Note);
                row.Tag = iCur;
                listRows.Add(row);
            }
            #endregion
            #region CessationMedications
            //Tobacco Use Cessation Pharmacotherapy Value Set
            string[] arrayRxCuiStrings = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1190"
            }, true)
                                         .Select(x => x.CodeValue).ToArray();
            //arrayRxCuiStrings will contain 41 RxCui strings for tobacco cessation medications if those exist in the rxnorm table
            List <MedicationPat> listMedPats = MedicationPats.Refresh(PatCur.PatNum, true).FindAll(x => arrayRxCuiStrings.Contains(x.RxCui.ToString()));
            foreach (MedicationPat medPatCur in listMedPats)
            {
                row = new ODGridRow();
                List <string> listMedDates = new List <string>();
                if (medPatCur.DateStart.Year > 1880)
                {
                    listMedDates.Add(medPatCur.DateStart.ToShortDateString());
                }
                if (medPatCur.DateStop.Year > 1880)
                {
                    listMedDates.Add(medPatCur.DateStop.ToShortDateString());
                }
                if (listMedDates.Count == 0)
                {
                    listMedDates.Add(medPatCur.DateTStamp.ToShortDateString());
                }
                row.Cells.Add(string.Join(" - ", listMedDates));
                row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication");
                row.Cells.Add(RxNorms.GetDescByRxCui(medPatCur.RxCui.ToString()));
                row.Cells.Add(medPatCur.PatNote);
                row.Tag = medPatCur;
                listRows.Add(row);
            }
            #endregion
            listRows.OrderBy(x => PIn.Date(x.Cells[0].Text))            //rows ordered by date, oldest first
            .ThenBy(x => x.Cells[3].Text != "")
            //interventions at the top, declined med interventions below normal interventions
            .ThenBy(x => x.Tag.GetType().Name != "Intervention" || ((Intervention)x.Tag).CodeSystem == "RXNORM").ToList()
            .ForEach(x => gridInterventions.Rows.Add(x));                    //then add rows to gridInterventions
            gridInterventions.EndUpdate();
        }