Example #1
0
        public static List <CDSIntervention> TriggerMatch(object triggerObject)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <CDSIntervention> >(MethodBase.GetCurrentMethod(), triggerObject));
            }
            //create one of: DiseaseDef, ICD9, Icd10, Snomed, Medication, RxNorm, Cvx, AllergyDef, EhrLabResult, Patient, Vitalsign, MedicationPat
            //fill List<object> with above objects
            //create CDSIntervention and set TriggerObjects=above list of objects
            Vitalsign vitalSign = (Vitalsign)triggerObject;

            vitalSign.WeightCode = DirtyString;
            List <object> listObjs = new List <object> {
                vitalSign,
                new Patient                             {
                    AddrNote = DirtyString
                },
                new MedicationPat       {
                    MedDescript = DirtyString
                },
                new EhrLabResult        {
                    UnitsText = DirtyString, ListEhrLabResultNotes = new List <EhrLabNote> {
                        new EhrLabNote {
                            Comments = DirtyString
                        }
                    }
                },
                new AllergyDef          {
                    Description = DirtyString
                },
                new Cvx                                         {
                    Description = DirtyString
                },
                new RxNorm                              {
                    Description = DirtyString
                },
                new Medication          {
                    Notes = DirtyString
                },
                new Snomed                              {
                    Description = DirtyString
                },
                new ICD9                                        {
                    Description = DirtyString
                },
                new Icd10                                       {
                    Description = DirtyString
                },
                new DiseaseDef          {
                    DiseaseName = DirtyString
                }
            };

            return(new List <CDSIntervention> {
                new CDSIntervention {
                    InterventionMessage = DirtyString,
                    TriggerObjects = EhrTriggers.ConvertListToKnowledgeRequests(listObjs)
                }
            });
        }
Example #2
0
        ///<summary>Medication merge tool.  Returns the number of rows changed.  Deletes the medication associated with medNumInto.</summary>
        public static long Merge(long medNumFrom, long medNumInto)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod(), medNumFrom, medNumInto));
            }
            string[] medNumForeignKeys = new string[] {           //add any new FKs to this list.
                "allergydef.MedicationNum",
                "eduresource.MedicationNum",
                "medication.GenericNum",
                "medicationpat.MedicationNum",
                "rxalert.MedicationNum"
            };
            string command     = "";
            long   rowsChanged = 0;

            for (int i = 0; i < medNumForeignKeys.Length; i++)        //actually change all of the FKs in the above tables.
            {
                string[] tableAndKeyName = medNumForeignKeys[i].Split(new char[] { '.' });
                command = "UPDATE " + tableAndKeyName[0]
                          + " SET " + tableAndKeyName[1] + "=" + POut.Long(medNumInto)
                          + " WHERE " + tableAndKeyName[1] + "=" + POut.Long(medNumFrom);
                rowsChanged += Db.NonQ(command);
            }
            command = "SELECT medication.RxCui FROM medication WHERE MedicationNum=" + medNumInto;         //update medicationpat's RxNorms to match medication.
            string rxNorm = Db.GetScalar(command);

            command = "UPDATE medicationpat SET RxCui=" + rxNorm + " WHERE MedicationNum=" + medNumInto;
            Db.NonQ(command);
            command = "SELECT * FROM ehrtrigger WHERE MedicationNumList LIKE '% " + POut.Long(medNumFrom) + " %'";
            List <EhrTrigger> ListEhrTrigger = Crud.EhrTriggerCrud.SelectMany(command);                      //get all ehr triggers with matching mednum in mednumlist

            for (int i = 0; i < ListEhrTrigger.Count; i++)                                                   //for each trigger...
            {
                string[] arrayMedNums       = ListEhrTrigger[i].MedicationNumList.Split(new char[] { ' ' }); //get an array of their medicationNums.
                bool     containsMedNumInto = arrayMedNums.Any(x => x == POut.Long(medNumInto));
                string   strMedNumList      = "";
                foreach (string medNumStr in arrayMedNums)                  //for each mednum in the MedicationList for the current trigger.
                {
                    string medNumCur = medNumStr.Trim();
                    if (medNumCur == "")                        //because we use spaces as a buffer before and after mednums, this prevents empty spaces from being considered.
                    {
                        continue;
                    }
                    if (containsMedNumInto)                      //if the list already contains medNumInto,
                    {
                        if (medNumCur == POut.Long(medNumFrom))
                        {
                            continue;                                   //skip medNumFrom (remove it from the list)
                        }
                        else
                        {
                            strMedNumList += " " + medNumCur + " ";
                        }
                    }
                    else                       //if the list doesn't contain medNumInto
                    {
                        if (medNumCur == POut.Long(medNumFrom))
                        {
                            strMedNumList += " " + medNumInto + " ";                       //replace medNumFrom with medNumInto
                        }
                        else
                        {
                            strMedNumList += " " + medNumCur + " ";
                        }
                    }
                }                                      //end for each mednum
                ListEhrTrigger[i].MedicationNumList = strMedNumList;
                EhrTriggers.Update(ListEhrTrigger[i]); //update the ehrtrigger list.
            }                                          //end for each trigger
            Crud.MedicationCrud.Delete(medNumFrom);    //finally, delete the mednum.
            return(rowsChanged);
        }