Esempio n. 1
0
        ///<summary></summary>
        public static List <EduResource> GenerateForPatient(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <EduResource> >(MethodBase.GetCurrentMethod(), patNum));
            }
            List <Disease>       diseaseList        = Diseases.Refresh(patNum);
            List <MedicationPat> medicationPatList  = MedicationPats.Refresh(patNum, false);
            List <LabResult>     labResultList      = LabResults.GetAllForPatient(patNum);
            List <EduResource>   eduResourceListAll = Crud.EduResourceCrud.SelectMany("SELECT * FROM eduresource");
            List <EduResource>   retVal             = new List <EduResource>();

            for (int i = 0; i < eduResourceListAll.Count; i++)
            {
                if (eduResourceListAll[i].DiseaseDefNum != 0)
                {
                    for (int j = 0; j < diseaseList.Count; j++)
                    {
                        if (eduResourceListAll[i].DiseaseDefNum == diseaseList[j].DiseaseDefNum)
                        {
                            retVal.Add(eduResourceListAll[i]);
                        }
                    }
                }
                else if (eduResourceListAll[i].Icd9Num != 0)               //checks against same list as Diseases/Problems
                {
                    for (int j = 0; j < diseaseList.Count; j++)
                    {
                        if (eduResourceListAll[i].Icd9Num == diseaseList[j].ICD9Num)
                        {
                            retVal.Add(eduResourceListAll[i]);
                        }
                    }
                }
                else if (eduResourceListAll[i].MedicationNum != 0)
                {
                    for (int j = 0; j < medicationPatList.Count; j++)
                    {
                        if (eduResourceListAll[i].MedicationNum == medicationPatList[j].MedicationNum)
                        {
                            retVal.Add(eduResourceListAll[i]);
                        }
                    }
                }
                else if (eduResourceListAll[i].LabResultID != "")
                {
                    for (int j = 0; j < labResultList.Count; j++)
                    {
                        if (eduResourceListAll[i].LabResultID != labResultList[j].TestID)
                        {
                            continue;
                        }
                        if (eduResourceListAll[i].LabResultCompare.StartsWith("<"))
                        {
                            //PIn.Int not used because blank not allowed.
                            try{
                                if (int.Parse(labResultList[j].ObsValue) < int.Parse(eduResourceListAll[i].LabResultCompare.Substring(1)))
                                {
                                    retVal.Add(eduResourceListAll[i]);
                                }
                            }
                            catch {
                                //This could only happen if the validation in either input didn't work.
                            }
                        }
                        else if (eduResourceListAll[i].LabResultCompare.StartsWith(">"))
                        {
                            try {
                                if (int.Parse(labResultList[j].ObsValue) > int.Parse(eduResourceListAll[i].LabResultCompare.Substring(1)))
                                {
                                    retVal.Add(eduResourceListAll[i]);
                                }
                            }
                            catch {
                                //This could only happen if the validation in either input didn't work.
                            }
                        }
                    }
                }
            }
            return(retVal);
        }
Esempio n. 2
0
        public static List <ReminderRule> GetRemindersForPatient(Patient PatCur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <ReminderRule> >(MethodBase.GetCurrentMethod(), PatCur));
            }
            //Problem,Medication,Allergy,Age,Gender,LabResult
            List <ReminderRule> fullListReminders = Crud.ReminderRuleCrud.SelectMany("SELECT * FROM reminderrule");
            List <ReminderRule> retVal            = new List <ReminderRule>();
            List <Disease>      listProblems      = Diseases.Refresh(PatCur.PatNum);
            List <Medication>   listMedications   = Medications.GetMedicationsByPat(PatCur.PatNum);
            List <Allergy>      listAllergies     = Allergies.Refresh(PatCur.PatNum);
            List <LabResult>    listLabResults    = LabResults.GetAllForPatient(PatCur.PatNum);

            for (int i = 0; i < fullListReminders.Count; i++)
            {
                switch (fullListReminders[i].ReminderCriterion)
                {
                case EhrCriterion.Problem:
                    for (int j = 0; j < listProblems.Count; j++)
                    {
                        if (fullListReminders[i].CriterionFK == listProblems[j].DiseaseDefNum)
                        {
                            retVal.Add(fullListReminders[i]);
                            break;
                        }
                    }
                    break;

                case EhrCriterion.Medication:
                    for (int j = 0; j < listMedications.Count; j++)
                    {
                        if (fullListReminders[i].CriterionFK == listMedications[j].MedicationNum)
                        {
                            retVal.Add(fullListReminders[i]);
                            break;
                        }
                    }
                    break;

                case EhrCriterion.Allergy:
                    for (int j = 0; j < listAllergies.Count; j++)
                    {
                        if (fullListReminders[i].CriterionFK == listAllergies[j].AllergyDefNum)
                        {
                            retVal.Add(fullListReminders[i]);
                            break;
                        }
                    }
                    break;

                case EhrCriterion.Age:
                    if (fullListReminders[i].CriterionValue[0] == '<')
                    {
                        if (PatCur.Age < int.Parse(fullListReminders[i].CriterionValue.Substring(1, fullListReminders[i].CriterionValue.Length - 1)))
                        {
                            retVal.Add(fullListReminders[i]);
                        }
                    }
                    else if (fullListReminders[i].CriterionValue[0] == '>')
                    {
                        if (PatCur.Age > int.Parse(fullListReminders[i].CriterionValue.Substring(1, fullListReminders[i].CriterionValue.Length - 1)))
                        {
                            retVal.Add(fullListReminders[i]);
                        }
                    }
                    else
                    {
                        //This section should never be reached
                    }
                    break;

                case EhrCriterion.Gender:
                    if (PatCur.Gender.ToString().ToLower() == fullListReminders[i].CriterionValue.ToLower())
                    {
                        retVal.Add(fullListReminders[i]);
                    }
                    break;

                case EhrCriterion.LabResult:
                    for (int j = 0; j < listLabResults.Count; j++)
                    {
                        if (listLabResults[j].TestName.ToLower().Contains(fullListReminders[i].CriterionValue.ToLower()))
                        {
                            retVal.Add(fullListReminders[i]);
                            break;
                        }
                    }
                    break;
                    //case EhrCriterion.ICD9:
                    //  for(int j=0;j<listProblems.Count;j++) {
                    //    if(fullListReminders[i].CriterionFK==listProblems[j].DiseaseDefNum) {
                    //      retVal.Add(fullListReminders[i]);
                    //      break;
                    //    }
                    //  }
                    //  break;
                }
            }
            return(retVal);
        }
Esempio n. 3
0
        ///<summary></summary>
        public static List <EduResource> GenerateForPatient(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <EduResource> >(MethodBase.GetCurrentMethod(), patNum));
            }
            List <Disease>         diseaseList        = Diseases.Refresh(patNum);
            List <MedicationPat>   medicationPatList  = MedicationPats.Refresh(patNum, false);
            List <LabResult>       labResultList      = LabResults.GetAllForPatient(patNum);
            List <EhrLabResult>    listEhrLabResults  = EhrLabResults.GetAllForPatient(patNum);
            List <EduResource>     eduResourceListAll = Crud.EduResourceCrud.SelectMany("SELECT * FROM eduresource");
            List <EhrMeasureEvent> listTobaccoEvents  = EhrMeasureEvents.RefreshByType(patNum, EhrMeasureEventType.TobaccoUseAssessed)
                                                        .FindAll(x => x.CodeSystemResult == "SNOMEDCT");
            List <EduResource> retVal = new List <EduResource>();

            eduResourceListAll.FindAll(x => x.DiseaseDefNum != 0 && diseaseList.Any(y => y.DiseaseDefNum == x.DiseaseDefNum)).ForEach(x => retVal.Add(x));
            eduResourceListAll.FindAll(x => x.MedicationNum != 0 &&
                                       medicationPatList.Any(y => y.MedicationNum == x.MedicationNum ||
                                                             (y.MedicationNum == 0 && Medications.GetMedication(x.MedicationNum).RxCui == y.RxCui)))
            .ForEach(x => retVal.Add(x));
            eduResourceListAll.FindAll(x => x.SmokingSnoMed != "" && listTobaccoEvents.Any(y => y.CodeValueResult == x.SmokingSnoMed)).ForEach(x => retVal.Add(x));
            foreach (EduResource resourceCur in eduResourceListAll.Where(x => x.LabResultID != ""))
            {
                foreach (LabResult labResult in labResultList.Where(x => x.TestID == resourceCur.LabResultID))
                {
                    if (resourceCur.LabResultCompare.StartsWith("<"))
                    {
                        //PIn.Int not used because blank not allowed.
                        try{
                            if (int.Parse(labResult.ObsValue) < int.Parse(resourceCur.LabResultCompare.Substring(1)))
                            {
                                retVal.Add(resourceCur);
                            }
                        }
                        catch {
                            //This could only happen if the validation in either input didn't work.
                        }
                    }
                    else if (resourceCur.LabResultCompare.StartsWith(">"))
                    {
                        try {
                            if (int.Parse(labResult.ObsValue) > int.Parse(resourceCur.LabResultCompare.Substring(1)))
                            {
                                retVal.Add(resourceCur);
                            }
                        }
                        catch {
                            //This could only happen if the validation in either input didn't work.
                        }
                    }
                }                                                                                                                         //end LabResultList
                foreach (EhrLabResult ehrLabResult in listEhrLabResults.Where(x => x.ObservationIdentifierID == resourceCur.LabResultID)) //matches loinc only.
                {
                    if (retVal.Contains(resourceCur))
                    {
                        continue;                        //already added from loop above.
                    }
                    retVal.Add(resourceCur);
                }                //end EhrLabResults
            }
            return(retVal);
        }