Beispiel #1
0
        public void Reactivations_GetReactivationList_PatientMarkedDoNotContact()
        {
            string  name    = MethodBase.GetCurrentMethod().Name;
            Clinic  clinic  = ClinicT.CreateClinic(name);
            long    provNum = ProviderT.CreateProvider(name);
            Patient pat     = PatientT.CreatePatient(name, provNum, clinic.ClinicNum, TestEmaiAddress, TestPatPhone, ContactMethod.Mail);
            //Patient has not been seen since further in the past than the ReactivationDaysPast preference.
            Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50, procDate: DateTime.Now.AddYears(-3), provNum: provNum);   //3 year old proc
            //Patient has been contacted, and the ReactivationContactInterval has elapsed.
            Commlog comm = new Commlog()
            {
                PatNum         = pat.PatNum,
                CommDateTime   = DateTime.Now.AddYears(-1),
                CommType       = _reactivationCommLogType,
                Mode_          = CommItemMode.Email,
                SentOrReceived = CommSentOrReceived.Sent,
                CommSource     = CommItemSource.ApptReminder,
            };

            comm.CommlogNum = Commlogs.Insert(comm);
            //Patient has been marked "Do Not Contact"
            Reactivations.Insert(new Reactivation()
            {
                PatNum       = pat.PatNum,
                DoNotContact = true,
            });
            DateTime dateSince = DateTime.Today.AddDays(-PrefC.GetInt(PrefName.ReactivationDaysPast));
            DateTime dateStop  = dateSince.AddMonths(-36);
            //Confirm that the patient does not in the Reactivation List
            DataTable tbl = Reactivations.GetReactivationList(dateSince, dateStop, false, false, true, provNum, clinic.ClinicNum, 0, 0
                                                              , ReactivationListSort.LastContacted, RecallListShowNumberReminders.One);

            //No patients in the list
            Assert.AreEqual(0, tbl.Rows.Count);
        }
Beispiel #2
0
        public static Commlog CreateCommlog(long patNum, string text          = "", DateTime commDateTime = default(DateTime),
                                            CommSentOrReceived sentOrReceived = CommSentOrReceived.Sent, CommItemMode itemMode = CommItemMode.None)
        {
            Commlog commlog = new Commlog {
                CommDateTime   = commDateTime.Year > 1880 ? commDateTime : DateTime.Now,
                Mode_          = itemMode,
                Note           = text,
                PatNum         = patNum,
                SentOrReceived = sentOrReceived,
            };

            Commlogs.Insert(commlog);
            return(commlog);
        }
        private static void OnCreated(object source, FileSystemEventArgs e)
        {
            //MessageBox.Show("File created.  It will now be deleted.");
            Thread.Sleep(200);            //just to make sure the other process is done writing.
            string[] lines = File.ReadAllLines(e.FullPath);
            File.Delete(e.FullPath);
            if (lines.Length != 1)
            {
                MessageBox.Show(e.FullPath + " was supposed to have exactly one line.  Invalid file.");
                return;
            }
            string rawFieldNames = "PAT_PK,PAT_LOGFK,PAT_LANFK,PAT_TITLE,PAT_FNAME,PAT_MI,PAT_LNAME,PAT_CALLED,PAT_ADDR1,PAT_ADDR2,PAT_CITY,PAT_ST,PAT_ZIP,PAT_HPHN,PAT_WPHN,PAT_EXT,PAT_FAX,PAT_PAGER,PAT_CELL,PAT_EMAIL,PAT_SEX,PAT_EDOCS,PAT_STATUS,PAT_TYPE,PAT_BIRTH,PAT_SSN,PAT_NOCALL,PAT_NOCORR,PAT_DISRES,PAT_LSTUPD,PAT_INSNM,PAT_INSGPL,PAT_INSAD1,PAT_INSAD2,PAT_INSCIT,PAT_INSST,PAT_INSZIP,PAT_INSPHN,PAT_INSEXT,PAT_INSCON,PAT_INSGNO,PAT_EMPNM,PAT_EMPAD1,PAT_EMPAD2,PAT_EMPCIT,PAT_EMPST,PAT_EMPZIP,PAT_EMPPHN,PAT_REFLNM,PAT_REFFNM,PAT_REFMI,PAT_REFPHN,PAT_REFEML,PAT_REFSPE,PAT_NOTES,PAT_NOTE1,PAT_NOTE2,PAT_NOTE3,PAT_NOTE4,PAT_NOTE5,PAT_NOTE6,PAT_NOTE7,PAT_NOTE8,PAT_NOTE9,PAT_NOTE10,PAT_FPSCAN,PAT_PREMED,PAT_MEDS,PAT_FTSTUD,PAT_PTSTUD,PAT_COLLEG,PAT_CHRTNO,PAT_OTHID,PAT_RESPRT,PAT_POLHLD,PAT_CUSCD,PAT_PMPID";

            fieldNames = rawFieldNames.Split(',');
            fieldVals  = lines[0].Split(',');
            if (fieldNames.Length != fieldVals.Length)
            {
                MessageBox.Show(e.FullPath + " contains " + fieldNames.Length.ToString() + " field names, but " + fieldVals.Length.ToString() + " field values.  Invalid file.");
                return;
            }
            for (int i = 0; i < fieldVals.Length; i++)
            {
                fieldVals[i] = fieldVals[i].Replace("\"", "");             //remove quotes
            }
            long patNum = PIn.Long(GetVal("PAT_OTHID"));

            if (patNum == 0)
            {
                MessageBox.Show(patNum.ToString() + " is not a recognized PatNum.");
                return;
            }
            Family fam = Patients.GetFamily(patNum);

            if (fam == null)
            {
                MessageBox.Show("Could not find patient based on PatNum " + patNum.ToString());
                return;
            }
            Patient pat    = fam.GetPatient(patNum);
            Patient patOld = pat.Copy();
            string  txt;
            string  note = "PT Dental import processed.  Some information is shown below which was too complex to import automatically.\r\n";

            txt = GetVal("PAT_FNAME");
            if (txt != "")
            {
                pat.FName = txt;
            }
            txt = GetVal("PAT_MI");
            if (txt != "")
            {
                pat.MiddleI = txt;
            }
            txt = GetVal("PAT_LNAME");
            if (txt != "")
            {
                pat.LName = txt;
            }
            txt = GetVal("PAT_CALLED");
            if (txt != "")
            {
                pat.Preferred = txt;
            }
            txt = GetVal("PAT_ADDR1");
            if (txt != "")
            {
                pat.Address = txt;
            }
            txt = GetVal("PAT_ADDR2");
            if (txt != "")
            {
                pat.Address2 = txt;
            }
            txt = GetVal("PAT_CITY");
            if (txt != "")
            {
                pat.City = txt;
            }
            txt = GetVal("PAT_ST");
            if (txt != "")
            {
                pat.State = txt;
            }
            txt = GetVal("PAT_ZIP");
            if (txt != "")
            {
                pat.Zip = txt;
            }
            txt = GetVal("PAT_HPHN");          //No punct
            if (txt != "")
            {
                pat.HmPhone = TelephoneNumbers.ReFormat(txt);
            }
            txt = GetVal("PAT_WPHN");
            if (txt != "")
            {
                pat.WkPhone = TelephoneNumbers.ReFormat(txt);
            }
            //no matching fields for these three:
            txt = GetVal("PAT_EXT");
            if (txt != "")
            {
                note += "Ph extension: " + txt + "\r\n";
            }
            txt = GetVal("PAT_FAX");
            if (txt != "")
            {
                note += "Fax: " + txt + "\r\n";
            }
            txt = GetVal("PAT_PAGER");
            if (txt != "")
            {
                note += "Pager: " + txt + "\r\n";
            }
            txt = GetVal("PAT_CELL");
            if (txt != "")
            {
                pat.WirelessPhone = TelephoneNumbers.ReFormat(txt);
            }
            txt = GetVal("PAT_EMAIL");
            if (txt != "")
            {
                pat.Email = txt;
            }
            txt = GetVal("PAT_SEX");          //M or F
            if (txt == "M")
            {
                pat.Gender = PatientGender.Male;
            }
            if (txt == "F")
            {
                pat.Gender = PatientGender.Male;
            }
            txt = GetVal("PAT_STATUS");          //our patStatus, Any text allowed
            switch (txt)
            {
            case "Archived": pat.PatStatus = PatientStatus.Archived; break;

            case "Deceased": pat.PatStatus = PatientStatus.Deceased; break;

            //case "Archived": pat.PatStatus=PatientStatus.Deleted; break;
            case "Inactive": pat.PatStatus = PatientStatus.Inactive; break;

            case "NonPatient": pat.PatStatus = PatientStatus.NonPatient; break;

            case "Patient": pat.PatStatus = PatientStatus.Patient; break;
            }
            txt = GetVal("PAT_TYPE");          //our Position, Any text allowed
            switch (txt)
            {
            case "Child": pat.Position = PatientPosition.Child; break;

            case "Divorced": pat.Position = PatientPosition.Divorced; break;

            case "Married": pat.Position = PatientPosition.Married; break;

            case "Single": pat.Position = PatientPosition.Single; break;

            case "Widowed": pat.Position = PatientPosition.Widowed; break;
            }
            txt = GetVal("PAT_BIRTH");          // yyyyMMdd
            if (txt != "")
            {
                pat.Birthdate = PIn.Date(txt);
            }
            txt = GetVal("PAT_SSN");          // No punct
            if (txt != "")
            {
                pat.SSN = txt;
            }
            txt = GetVal("PAT_NOCALL");          // T if no call
            if (txt != "")
            {
                note += "No Call Patient: " + txt + "\r\n";
            }
            txt = GetVal("PAT_NOCORR");          // T/F
            if (txt != "")
            {
                note += "No Correspondence: " + txt + "\r\n";
            }
            txt = GetVal("PAT_NOTES");          // No limits.
            if (txt != "")
            {
                note += txt + "\r\n";
            }
            txt = GetVal("PAT_PREMED");          // F or T
            //I don't like giving the patient control of this field, but I guess the office has the option of not showing this on forms.
            if (txt == "T")
            {
                pat.Premed = true;
            }
            if (txt == "F")
            {
                pat.Premed = false;
            }
            txt = GetVal("PAT_MEDS");          // The meds that they must premedicate with.
            if (txt != "")
            {
                note += "Patient Meds: " + txt + "\r\n";
            }
            string ft = GetVal("PAT_FTSTUD");          // T/F
            string pt = GetVal("PAT_PTSTUD");          //parttime

            if (ft == "T")
            {
                pat.StudentStatus = "F";              //fulltime
            }
            else if (pt == "T")
            {
                pat.StudentStatus = "P";              //parttime
            }
            else if (ft == "F" && pt == "F")
            {
                pat.StudentStatus = "";              //nonstudent
            }
            else if (ft == "F" && pat.StudentStatus == "F")
            {
                pat.StudentStatus = "";
            }
            else if (pt == "F" && pat.StudentStatus == "P")
            {
                pat.StudentStatus = "";
            }
            txt = GetVal("PAT_COLLEG");
            if (txt != "")
            {
                pat.SchoolName = txt;
            }
            txt = GetVal("PAT_CHRTNO");
            //I don't think patient should have control of this field.
            if (txt != "")
            {
                pat.ChartNumber = txt;
            }
            txt = GetVal("PAT_RESPRT");          // Responsible party checkbox T/F
            if (txt == "T" && pat.PatNum != pat.Guarantor)
            {
                note += "Responsible party: True\r\n";
            }
            if (txt == "F" && pat.PatNum == pat.Guarantor)
            {
                note += "Responsible party: False\r\n";
            }
            txt = GetVal("PAT_POLHLD");          // Policy holder checkbox T/F
            if (txt == "T")
            {
                note += "Policy holder: True\r\n";
            }
            if (txt == "F")
            {
                note += "Policy holder: False\r\n";
            }
            txt = GetVal("PAT_INSNM");
            if (txt != "")
            {
                note += "Insurance name: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSGPL");
            if (txt != "")
            {
                note += "Ins group plan name: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSAD1");
            if (txt != "")
            {
                note += "Ins address: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSAD2");
            if (txt != "")
            {
                note += "Ins address2: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSCIT");
            if (txt != "")
            {
                note += "Ins city: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSST");
            if (txt != "")
            {
                note += "Ins state: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSZIP");
            if (txt != "")
            {
                note += "Ins zip: " + txt + "\r\n";
            }
            txt = GetVal("PAT_INSPHN");
            if (txt != "")
            {
                note += "Ins phone: " + TelephoneNumbers.ReFormat(txt) + "\r\n";
            }
            txt = GetVal("PAT_INSGNO");          // Ins group number
            if (txt != "")
            {
                note += "Ins group number: " + txt + "\r\n";
            }
            txt = GetVal("PAT_EMPNM");
            if (txt != "")
            {
                note += "Employer name: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFLNM");
            if (txt != "")
            {
                note += "Referral last name: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFFNM");
            if (txt != "")
            {
                note += "Referral first name: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFMI");
            if (txt != "")
            {
                note += "Referral middle init: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFPHN");
            if (txt != "")
            {
                note += "Referral phone: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFEML");          // Referral source email
            if (txt != "")
            {
                note += "Referral email: " + txt + "\r\n";
            }
            txt = GetVal("PAT_REFSPE");          // Referral specialty. Customizable, so any allowed
            if (txt != "")
            {
                note += "Referral specialty: " + txt + "\r\n";
            }
            Patients.Update(pat, patOld);
            if (File.Exists(dir + "\\" + importMedCsv))
            {
                lines = File.ReadAllLines(dir + "\\" + importMedCsv);
                File.Delete(dir + "\\" + importMedCsv);
                if (lines.Length < 1)
                {
                    MessageBox.Show(e.FullPath + " was supposed to have at least one line.  Invalid file.");
                    return;
                }
                fieldNames = lines[0].Split(',');
                long    diseaseDefNum;
                Disease disease;
                string  diseaseNote;
                for (int i = 1; i < lines.Length; i++)
                {
                    fieldVals   = lines[i].Split(',');
                    txt         = GetVal("PMA_MALDES");
                    diseaseNote = GetVal("PMA_NOTES");
                    if (txt == "")
                    {
                        continue;
                    }
                    diseaseDefNum = DiseaseDefs.GetNumFromName(txt);
                    if (diseaseDefNum == 0)
                    {
                        note += "Disease: " + txt + ", " + diseaseNote + "\r\n";
                    }
                    disease = Diseases.GetSpecificDiseaseForPatient(patNum, diseaseDefNum);
                    if (disease == null)
                    {
                        disease = new Disease();
                        disease.DiseaseDefNum = diseaseDefNum;
                        disease.PatNum        = patNum;
                        disease.PatNote       = diseaseNote;
                        Diseases.Insert(disease);
                    }
                    else
                    {
                        if (txt != "")
                        {
                            if (disease.PatNote != "")
                            {
                                disease.PatNote += "  ";
                            }
                            disease.PatNote += diseaseNote;
                            Diseases.Update(disease);
                        }
                    }
                }
            }
            Commlog comm = new Commlog();

            comm.PatNum         = patNum;
            comm.SentOrReceived = CommSentOrReceived.Received;
            comm.CommDateTime   = DateTime.Now;
            comm.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            comm.Mode_          = CommItemMode.None;
            comm.Note           = note;
            comm.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(comm);
            MessageBox.Show("PT Dental import complete.");
        }
        ///<summary>When sub is set, fills customer group box with various information.
        ///When null, clears all fields.</summary>
        private void SetCustomerInfo(BugSubmission sub, bool isCustomerGridRefresh = true)
        {
            try {
                labelCustomerNum.Text   = _patCur?.PatNum.ToString() ?? "";
                labelRegKey.Text        = sub.RegKey;
                labelCustomerState.Text = _patCur?.State ?? "";
                labelCustomerPhone.Text = _patCur?.WkPhone ?? "";
                labelSubNum.Text        = POut.Long(sub.BugSubmissionNum);
                labelLastCall.Text      = Commlogs.GetDateTimeOfLastEntryForPat(_patCur?.PatNum ?? 0).ToString();
            }
            catch (Exception ex) {
                ex.DoNothing();
            }
            butGoToAccount.Enabled = true;
            butBugTask.Enabled     = true;
            butCompare.Enabled     = true;
            if (!isCustomerGridRefresh || _groupSelection == -1 || _listSubs == null || !gridCustomerSubs.Visible)         //Just in case checks.
            {
                return;
            }
            switch (_groupSelection)
            {
            case 0:
                #region None
                gridCustomerSubs.Title = "Customer Submissions";
                gridCustomerSubs.BeginUpdate();
                gridCustomerSubs.ListGridColumns.Clear();
                gridCustomerSubs.ListGridColumns.Add(new GridColumn("Version", 100, HorizontalAlignment.Center));
                gridCustomerSubs.ListGridColumns.Add(new GridColumn("Count", 50, HorizontalAlignment.Center));
                gridCustomerSubs.ListGridRows.Clear();
                Dictionary <string, List <BugSubmission> > dictCustomerSubVersions = _listSubs
                                                                                     .Where(x => x.RegKey == sub.RegKey)
                                                                                     .GroupBy(x => x.TryGetPrefValue(PrefName.ProgramVersion, "0.0.0.0"))
                                                                                     .ToDictionary(x => x.Key, x => x.DistinctBy(y => y.ExceptionStackTrace).ToList());
                foreach (KeyValuePair <string, List <BugSubmission> > pair in dictCustomerSubVersions)
                {
                    gridCustomerSubs.ListGridRows.Add(new GridRow(pair.Key, pair.Value.Count.ToString()));
                }
                gridCustomerSubs.EndUpdate();
                #endregion
                break;

            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                #region RegKey/Ver/Stack, Stacktrace, 95%, StackSig
                gridCustomerSubs.Title = "Grouped Subs (" + _listSubs.DistinctBy(x => x.RegKey).Count() + " Reg)";
                if (_groupSelection.In(4, 5))                        //StackSig,StackSimple
                {
                    gridCustomerSubs.Title += " (" + _listSubs.DistinctBy(x => x.ExceptionStackTrace).Count() + " Stacks)";
                }
                gridCustomerSubs.BeginUpdate();
                gridCustomerSubs.ListGridColumns.Clear();
                gridCustomerSubs.ListGridColumns.Add(new GridColumn("Vers.", 55, HorizontalAlignment.Center));
                gridCustomerSubs.ListGridColumns.Add(new GridColumn("RegKey", 0, HorizontalAlignment.Center));
                gridCustomerSubs.ListGridRows.Clear();
                _listSubs.ForEach(x => {
                    Patient rowPat;
                    string patDescript = x.RegKey;
                    if (_dictPatients.TryGetValue(x.RegKey, out rowPat))
                    {
                        patDescript = rowPat.GetNameLF();
                    }
                    GridRow row = new GridRow(x.TryGetPrefValue(PrefName.ProgramVersion, "0.0.0.0"), patDescript);
                    row.Tag     = x;
                    gridCustomerSubs.ListGridRows.Add(row);
                });
                gridCustomerSubs.EndUpdate();
                #endregion
                break;
            }
        }