示例#1
0
        ///<summary>Updates password info in db for given inputs if PlainTextPassword (Item2) is not empty.
        ///Insert EhrMeasureEvent OnlineAccessProvided if previous db version of UserWeb had no PasswordHash (access has now been granted to portal).
        ///Returns true if UserWeb row was updated. Otherwise returns false.</summary>
        public static bool UpdateNewPatientPortalCredentials(Tuple <UserWeb, string, PasswordContainer> args)
        {
            //No need to check RemotingRole; no call to db.
            if (args == null)
            {
                return(false);
            }
            UserWeb userWeb = args.Item1; string passwordPlainText = args.Item2; PasswordContainer loginDetails = args.Item3;

            if (userWeb != null && !string.IsNullOrEmpty(passwordPlainText))
            {
                //Only insert an EHR event if the password was previously blank (meaning they don't currently have access).
                if (string.IsNullOrEmpty(userWeb.PasswordHash))
                {
                    EhrMeasureEvents.Insert(new EhrMeasureEvent()
                    {
                        DateTEvent = DateTime.Now,
                        EventType  = EhrMeasureEventType.OnlineAccessProvided,
                        PatNum     = userWeb.FKey,                   //PatNum.
                        MoreInfo   = "",
                    });
                }
                //New password was created so set the flag for the user to change on next login and update the db accordingly.
                userWeb.RequirePasswordChange = true;
                userWeb.LoginDetails          = loginDetails;
                UserWebs.Update(userWeb);
                return(true);
            }
            return(false);
        }
示例#2
0
        ///<summary>Returns EhrCodes for the specified EhrMeasureEventType ordered by how often and how recently they have been used.  Results are
        ///ordered by applying a weight based on the date diff from current date to DateTEvent of the EhrMeasureEvents.  EhrCodes used most
        ///recently will have the largest weight and help move the EhrCode to the top of the list.  Specify a limit amount if the result set should only
        ///be a certain number of EhrCodes at most.</summary>
        public static List <EhrCode> GetForEventTypeByUse(EhrMeasureEventType ehrMeasureEventTypes)
        {
            List <EhrCode> retVal = new List <EhrCode>();
            //list of CodeValueResults of the specified type ordered by a weight calculated by summing values based on how recently the codes were used
            List <string> listCodes = EhrMeasureEvents.GetListCodesUsedForType(ehrMeasureEventTypes);

            foreach (string codeStr in listCodes)
            {
                EhrCode codeCur = Listt.FirstOrDefault(x => x.CodeValue == codeStr);
                Snomed  sCur    = null;
                if (codeCur == null)
                {
                    sCur = Snomeds.GetByCode(codeStr);
                    if (sCur == null)
                    {
                        continue;
                    }
                    codeCur = new EhrCode {
                        CodeValue = sCur.SnomedCode, Description = sCur.Description
                    };
                }
                retVal.Add(codeCur);
            }
            return(retVal.OrderBy(x => x.Description).ToList());
        }
示例#3
0
        ///<summary>Generates a username and password if necessary for this patient. If the patient already has access to the Patient Portal or if they
        ///are not eligible to be given access, this will return null.</summary>
        public static UserWeb GetNewPatientPortalCredentials(Patient pat, bool doUpdateDatabase, out string passwordGenerated)
        {
            //No need to check RemotingRole; no call to db.
            passwordGenerated = "";
            if (string.IsNullOrEmpty(PrefC.GetString(PrefName.PatientPortalURL)))
            {
                return(null);               //Haven't set up patient portal yet.
            }
            string errors;

            if (!UserWebs.ValidatePatientAccess(pat, out errors))
            {
                return(null);               //Patient is missing necessary fields.
            }
            UserWeb userWeb = UserWebs.GetByFKeyAndType(pat.PatNum, UserWebFKeyType.PatientPortal);

            if (userWeb == null)
            {
                userWeb          = new UserWeb();
                userWeb.UserName = UserWebs.CreateUserNameFromPat(pat, UserWebFKeyType.PatientPortal);
                userWeb.FKey     = pat.PatNum;
                userWeb.FKeyType = UserWebFKeyType.PatientPortal;
                userWeb.RequireUserNameChange = true;
                userWeb.Password = "";
                userWeb.IsNew    = true;
                if (doUpdateDatabase)
                {
                    UserWebs.Insert(userWeb);
                }
            }
            if (!string.IsNullOrEmpty(userWeb.Password) &&         //If they already have access to the Patient Portal, return.
                !userWeb.RequirePasswordChange)                    //If they need to change their password, we are going to generate another password for them.
            {
                return(null);
            }
            if (string.IsNullOrEmpty(userWeb.Password) &&        //Only insert an EHR event if their password is blank (meaning they don't currently have access).
                doUpdateDatabase)
            {
                EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
                newMeasureEvent.DateTEvent = DateTime.Now;
                newMeasureEvent.EventType  = EhrMeasureEventType.OnlineAccessProvided;
                newMeasureEvent.PatNum     = pat.PatNum;
                newMeasureEvent.MoreInfo   = "";
                EhrMeasureEvents.Insert(newMeasureEvent);
            }
            passwordGenerated             = UserWebs.GenerateRandomPassword(8);
            userWeb.Password              = Userods.HashPassword(passwordGenerated, false);
            userWeb.RequirePasswordChange = true;
            if (doUpdateDatabase)
            {
                UserWebs.Update(userWeb);
            }
            return(userWeb);
        }
示例#4
0
        ///<summary>Used when printing or emailing recall to make a commlog entry without any display.
        ///Set commSource to the corresponding entity that is making this recall.  E.g. Web Sched.
        ///If the commSource is a 3rd party, set it to ProgramLink and make an overload that accepts the ProgramNum.</summary>
        public static Commlog InsertForRecall(long patNum, CommItemMode _mode, int numberOfReminders, long defNumNewStatus, CommItemSource commSource,
                                              long userNum, DateTime dateTimeNow)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Commlog>(MethodBase.GetCurrentMethod(), patNum, _mode, numberOfReminders, defNumNewStatus, commSource, userNum, dateTimeNow));
            }
            long   recallType = Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL);
            string command;
            string datesql = "CURDATE()";

            if (DataConnection.DBtype == DatabaseType.Oracle)
            {
                datesql = "(SELECT CURRENT_DATE FROM dual)";
            }
            if (recallType != 0)
            {
                command  = "SELECT * FROM commlog WHERE ";
                command += DbHelper.DtimeToDate("CommDateTime") + " = " + datesql;
                command += " AND PatNum=" + POut.Long(patNum) + " AND CommType=" + POut.Long(recallType)
                           + " AND Mode_=" + POut.Long((int)_mode)
                           + " AND SentOrReceived=1";
                List <Commlog> listComms = Crud.CommlogCrud.SelectMany(command).OrderByDescending(x => x.CommDateTime).ToList();
                if (listComms.Count > 0)
                {
                    return(listComms[0]);
                }
            }
            Commlog com = new Commlog();

            com.PatNum         = patNum;
            com.CommDateTime   = dateTimeNow;
            com.CommType       = recallType;
            com.Mode_          = _mode;
            com.SentOrReceived = CommSentOrReceived.Sent;
            com.Note           = "";
            if (numberOfReminders == 0)
            {
                com.Note = Lans.g("FormRecallList", "Recall reminder.");
            }
            else if (numberOfReminders == 1)
            {
                com.Note = Lans.g("FormRecallList", "Second recall reminder.");
            }
            else if (numberOfReminders == 2)
            {
                com.Note = Lans.g("FormRecallList", "Third recall reminder.");
            }
            else
            {
                com.Note = Lans.g("FormRecallList", "Recall reminder:") + " " + (numberOfReminders + 1).ToString();
            }
            if (defNumNewStatus == 0)
            {
                com.Note += "  " + Lans.g("Commlogs", "Status None");
            }
            else
            {
                com.Note += "  " + Defs.GetName(DefCat.RecallUnschedStatus, defNumNewStatus);
            }
            com.UserNum    = userNum;
            com.CommSource = commSource;
            com.CommlogNum = Insert(com);
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = com.CommDateTime;
            newMeasureEvent.EventType  = EhrMeasureEventType.ReminderSent;
            newMeasureEvent.PatNum     = com.PatNum;
            newMeasureEvent.MoreInfo   = com.Note;
            EhrMeasureEvents.Insert(newMeasureEvent);
            return(com);
        }
示例#5
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);
        }