Beispiel #1
0
 //инициализация формы
 public formMain()
 {
     InitializeComponent();
     HidePanels();
     patientsList = new Patients();
     patientsList.currentPatient = -1;
     patientsList.patients = new List<Patient>();
     //загрузка из файлов
     if (File.Exists(screenFile))
         screenData = ClassesLib.Screen.Read(screenFile);
     if (File.Exists(file))
     {
         patientsList = Patients.Read(file);
         if (File.Exists(resultsFile))
             ResultsToPatients();
     }
     //обновление модели данных
     if (patientsList.patients.Count != 0)
     {
         if (patientsList.currentPatient == -1 && patientsList.currentPatient > patientsList.patients.Count)
             patientsList.currentPatient = 0;
         panelMain.Visible = true;
         MainPanelShowInfo(patientsList.patients[patientsList.currentPatient]);
     }
     else
     {
         panelPacients.Visible = true;
         PatientShowInfo(patientsList);
         ShowButtons();
         buttonPacients.Visible = false;
         buttonStart.Visible = false;
         buttonSessions.Visible = false;
         buttonLevels.Visible = false;
         buttonResults.Visible = false;
         buttonPalitre.Visible = false;
         buttonMain.Visible = false;
         MessageBox.Show("Выберите пациента или создайте нового", "Внимание");
     }
 }
Beispiel #2
0
        public IEnumerable <Patient> GetPatientsFromRoom(int roomNumber)
        {
            var numberOfPatientsToSkip = (roomNumber - 1) * 3;

            return(Patients.Skip(numberOfPatientsToSkip).Take(3));
        }
Beispiel #3
0
 public Department(string name)
 {
     this.Name     = name;
     this.Patients = new List <List <Patient> >(20);
     Patients.Add(new List <Patient>(3));
 }
Beispiel #4
0
        public static void ProcessMessage(MessageHL7 message, bool isStandalone, bool isVerboseLogging)
        {
            /*string triggerevent=message.Segments[0].GetFieldComponent(8,1);
             * switch(triggerevent) {
             *      case "A01"://Admit/Visit Information
             *
             *              break;
             *      case "A04"://New Patient Information
             *              ProcessNewPatient(message);
             *              break;
             *      case "A08"://Update Patient Information
             *
             *              break;
             *      case "A28"://Add Patient Information
             *
             *              break;
             *      case "A31"://Update Patient Information
             *
             *              break;
             * }*/
            //MSH-Ignore
            //EVN-Ignore
            //PID-------------------------------------
            SegmentHL7 seg    = message.GetSegment(SegmentNameHL7.PID, true);
            long       patNum = PIn.Long(seg.GetFieldFullText(2));
            Patient    pat    = null;

            if (isStandalone)
            {
                pat = Patients.GetPatByChartNumber(patNum.ToString());
                if (pat == null)
                {
                    //try to find the patient in question by using name and birthdate
                    string   lName        = seg.GetFieldComponent(5, 0);
                    string   fName        = seg.GetFieldComponent(5, 1);
                    DateTime birthdate    = EcwSegmentPID.DateParse(seg.GetFieldFullText(7));
                    long     patNumByName = Patients.GetPatNumByNameAndBirthday(lName, fName, birthdate);
                    if (patNumByName == 0)                   //patient does not exist in OD
                    //so pat will still be null, triggering creation of new patient further down.
                    {
                    }
                    else
                    {
                        pat             = Patients.GetPat(patNumByName);
                        pat.ChartNumber = patNum.ToString();                      //from now on, we will be able to find pat by chartNumber
                    }
                }
            }
            else
            {
                pat = Patients.GetPat(patNum);
            }
            Patient patOld   = null;
            bool    isNewPat = pat == null;

            if (isNewPat)
            {
                pat = new Patient();
                if (isStandalone)
                {
                    pat.ChartNumber = patNum.ToString();
                    //this line does not work if isStandalone, so moved to end
                    //pat.Guarantor=patNum;
                }
                else
                {
                    pat.PatNum    = patNum;
                    pat.Guarantor = patNum;
                }
                pat.PriProv     = PrefC.GetLong(PrefName.PracticeDefaultProv);
                pat.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            }
            else
            {
                patOld = pat.Copy();
            }
            EcwSegmentPID.ProcessPID(pat, seg, isStandalone);
            //PV1-patient visit---------------------------
            //seg=message.GetSegment(SegmentName.PV1,false);
            //if(seg!=null) {//this seg is optional
            //	SegmentPID.ProcessPV1(pat,seg);
            //}
            //PD1-additional patient demographics------------
            //seg=message.GetSegment(SegmentName.PD1,false);
            //if(seg!=null) {//this seg is optional
            //	ProcessPD1(pat,seg);
            //}
            //GT1-Guarantor-------------------------------------
            seg = message.GetSegment(SegmentNameHL7.GT1, true);
            EcwSegmentPID.ProcessGT1(pat, seg, isStandalone);
            //IN1-Insurance-------------------------------------
            //List<SegmentHL7> segments=message.GetSegments(SegmentName.IN1);
            //for(int i=0;i<segments.Count;i++) {
            //	ProcessIN1(pat,seg);
            //}
            if (pat.FName == "" || pat.LName == "")
            {
                EventLog.WriteEntry("OpenDentHL7", "Patient demographics not processed due to missing first or last name. PatNum:" + pat.PatNum.ToString()
                                    , EventLogEntryType.Information);
                return;
            }
            if (isNewPat)
            {
                if (isVerboseLogging)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Inserted patient: " + pat.FName + " " + pat.LName, EventLogEntryType.Information);
                }
                Patients.Insert(pat, true);
                if (pat.Guarantor == 0)
                {
                    patOld        = pat.Copy();
                    pat.Guarantor = pat.PatNum;
                    Patients.Update(pat, patOld);
                }
            }
            else
            {
                if (isVerboseLogging)
                {
                    EventLog.WriteEntry("OpenDentHL7", "Updated patient: " + pat.FName + " " + pat.LName, EventLogEntryType.Information);
                }
                Patients.Update(pat, patOld);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="patients"></param>
 /// <param name="templates"></param>
 /// <returns></returns>
 public ObservableCollection <Templates_Images> QueryTemplatesImagesImportDateAndReturnFullImagePath(Agencys agencys, Patients patients, Templates templates, DateTime templateImportDate)
 {
     using (var ide = new iDentalEntities())
     {
         ObservableCollection <Templates_Images> observableCollection;
         var queryTemplatesImages = (from iie in ide.Templates_Images
                                     where iie.Template_ID == templates.Template_ID &&
                                     iie.Patient_ID == patients.Patient_ID &&
                                     iie.Template_Image_ImportDate == templateImportDate.Date
                                     select new
         {
             Template_Image_ID = iie.Template_Image_ID,
             Template_Image_Number = iie.Template_Image_Number,
             Template_Image_ImportDate = iie.Template_Image_ImportDate,
             Template_ID = iie.Template_ID,
             Image_ID = iie.Image_ID,
             Image_FullPath = agencys.Agency_ImagePath + iie.Image_Path,
             Patient_ID = iie.Patient_ID
         }).ToList().Select(s => new Templates_Images
         {
             Template_Image_ID         = s.Template_Image_ID,
             Template_Image_Number     = s.Template_Image_Number,
             Template_Image_ImportDate = s.Template_Image_ImportDate,
             Template_ID = s.Template_ID,
             Image_ID    = s.Image_ID,
             Image_Path  = s.Image_FullPath,
             Patient_ID  = s.Patient_ID
         });
         observableCollection = new ObservableCollection <Templates_Images>(queryTemplatesImages);
         return(observableCollection);
     }
 }
Beispiel #6
0
        public Patient[] GetPatientsByName(string patientName)
        {
            var found = Patients.FindAll(p => p.Name == patientName && p.Registered);

            return(found.ToArray());
        }
Beispiel #7
0
 public IEnumerable <Patient> GetRegisteredPatients()
 {
     return(Patients.Where(p => p.Registered));
 }
Beispiel #8
0
        ///<summary>Launches the program if necessary.  Then passes patient.Cur data using DDE.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);
            List <ProgramProperty> ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;

            if (pat == null)
            {
                MessageBox.Show("Please select a patient first");
                return;
            }
            if (!File.Exists(path))
            {
                MessageBox.Show("Could not find " + path);
                return;
            }
            //Make sure the program is running
            //Documentation says to include the -nostartup command line switch (to avoid optional program preference startup command).
            if (Process.GetProcessesByName("Vipersoft").Length == 0)
            {
                Process.Start(path, "-nostartup");
                Thread.Sleep(TimeSpan.FromSeconds(4));
            }
            //Data is sent to the Vipersoft DDE Server by use of the XTYP_EXECUTE DDE message only.
            //The format ot the XTYP_EXECUTE DDE message is"
            //command="\004hwnd|name|ID|Lastname|Firstname|MI|Comments|Provider|Provider Phone|Addrs1|Addrs2|City|State|Zip|Patient Phone|Practice Name|Patient SSN|restore server|"
            //\004 is one byte code for version 4. 0x04 or Char(4)
            //hwnd is calling software's windows handle.
            //name is for name of calling software (Open Dental)
            //ID is patient ID.  Required and must be unique.
            //Provider field is for provider name.
            //hwnd, ID, Lastname, Firstname, and Provider fields are required.  All other fields are optional.
            //All vertical bars (|) are required, including the ending bar.
            //The restore server flag is for a future release's support of the specialized capture/view commands (default is '1')
            //Visual Basic pseudo code:
            //Chan = DDEInitiate("Vipersoft", "Advanced IntraOral")
            //DDE_String$ = "" //etc
            //DDEExecute Chan, DDE_String$ //send XTYP_EXECUTE DDE command:
            //DDETerminate Chan
            Char   char4   = Convert.ToChar(4);
            string command = char4.ToString();          //tested to make sure this is just one non-printable byte.
            IntPtr hwnd    = Application.OpenForms[0].Handle;

            command += hwnd.ToString() + "|"   //hwnd
                       + "OpenDental|";        //name
            ProgramProperty PPCur = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
            string          patID;

            if (PPCur.PropertyValue == "0")
            {
                patID = pat.PatNum.ToString();
            }
            else
            {
                if (pat.ChartNumber == "")
                {
                    MessageBox.Show("ChartNumber for this patient is blank.");
                    return;
                }
                patID = pat.ChartNumber;
            }
            command += patID + "|";       //ID
            command += pat.LName + "|";   //Lastname
            command += pat.FName + "|";   //Firstname
            command += pat.MiddleI + "|"; //
            command += "|";               //Comments: blank
            Provider prov = Providers.GetProv(Patients.GetProvNum(pat));

            command += prov.LName + ", " + prov.FName + "|"; //Provider
            command += "|";                                  //Provider phone
            command += "|";                                  //Addr
            command += "|";                                  //Addr2
            command += "|";                                  //City
            command += "|";                                  //State
            command += "|";                                  //Zip
            command += "|";                                  //Phone
            command += "|";                                  //Practice
            command += pat.SSN + "|";                        //SSN
            command += "1|";                                 //Restore Server
            //MessageBox.Show(command);
            try {
                //Create a context that uses a dedicated thread for DDE message pumping.
                using (DdeContext context = new DdeContext()){
                    //Create a client.
                    using (DdeClient client = new DdeClient("Vipersoft", "Advanced IntraOral", context)){
                        //Establish the conversation.
                        client.Connect();
                        //Select patient
                        client.Execute(command, 2000);                       //timeout 2 secs
                        client.Disconnect();
                    }
                }
            }
            catch {
                //MessageBox.Show(e.Message);
            }
        }
Beispiel #9
0
 ///<summary>LName, 'Preferred' FName M</summary>
 public string GetNameLF()
 {
     return(Patients.GetNameLF(LName, FName, Preferred, MiddleI));
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Patients ds = new Patients();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Beispiel #11
0
 //отмена сеансов
 private void buttonSessionsCancel_Click(object sender, EventArgs e)
 {
     saved = true;
     buttonSessionsSave.Enabled = false;
     buttonSessionsCancel.Enabled = false;
     patientsList = Patients.Read(file);
     SessionShowInfo(patientsList.patients[patientsList.currentPatient]);
 }
Beispiel #12
0
 //редактирование комментария
 private void buttonResultsComment_Click(object sender, EventArgs e)
 {
     if (resPatient.results.Count > 0)
     {
         //для текущего пациента
         ResultComment form = new ResultComment(resPatient.results[listViewResults.SelectedIndices[0]].Comment, this);
         form.ShowDialog(this);
         if (dRes == DialogResult.OK)
         {
             resPatient.results[listViewResults.SelectedIndices[0]].Comment = _com;
         }
         patientsList.patients[patientsList.currentPatient] = resPatient;
         Patients.Write(file, patientsList);
         patientsList = Patients.Read(file);
         ResultsShowInfo(patientsList.patients[patientsList.currentPatient]);
     }
 }
Beispiel #13
0
 //отмена состояния палитры
 private void buttonPalitreCancel_Click(object sender, EventArgs e)
 {
     patientsList = Patients.Read(file);
     PalitreShowInfo(patientsList.patients[patientsList.currentPatient].Palitre);
     saved = true;
     PalitreActivateSaving(false);
 }
Beispiel #14
0
 //отмена изменений пациента
 private void buttonPacientsCancel_Click(object sender, EventArgs e)
 {
     saved = true;
     buttonPacientsSave.Enabled = false;
     buttonPacientsCancel.Enabled = false;
     patientsList = Patients.Read(file);
     PatientShowInfo(patientsList);
 }
Beispiel #15
0
        /*
         * ///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
         * private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
         *      int startI=GetProvBarIndex(timeStart);
         *      int stopI=GetProvBarIndex(timeStop);
         *      for(int i=startI;i<=stopI;i++){
         *              provBarSched[i]=true;
         *      }
         * }
         *
         * private static int GetProvBarIndex(TimeSpan time) {
         *      return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr
         +(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement))
         *(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr)
         *              /ApptDrawing.LineH;//rounds down
         * }*/

        ///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
        public static Appointment CreateRecallApt(Patient patCur, List <InsPlan> planList, long recallNum, List <InsSub> subList
                                                  , DateTime aptDateTime = default(DateTime))
        {
            List <Recall> recallList = Recalls.GetList(patCur.PatNum);
            Recall        recallCur  = null;

            if (recallNum > 0)
            {
                recallCur = Recalls.GetRecall(recallNum);
            }
            else
            {
                for (int i = 0; i < recallList.Count; i++)
                {
                    if (recallList[i].RecallTypeNum == RecallTypes.PerioType || recallList[i].RecallTypeNum == RecallTypes.ProphyType)
                    {
                        if (!recallList[i].IsDisabled)
                        {
                            recallCur = recallList[i];
                        }
                        break;
                    }
                }
            }
            if (recallCur == null)
            {
                //Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
                throw new ApplicationException(Lan.g("AppointmentL", "No special type recall is due."));
            }
            if (recallCur.DateScheduled.Date > DateTime.Today)
            {
                throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString());
            }
            Appointment aptCur = new Appointment();

            aptCur.AptDateTime = aptDateTime;
            List <string>    procs     = RecallTypes.GetProcs(recallCur.RecallTypeNum);
            List <Procedure> listProcs = Appointments.FillAppointmentForRecall(aptCur, recallCur, recallList, patCur, procs, planList, subList);

            for (int i = 0; i < listProcs.Count; i++)
            {
                if (Programs.UsingOrion)
                {
                    FormProcEdit FormP = new FormProcEdit(listProcs[i], patCur.Copy(), Patients.GetFamily(patCur.PatNum));
                    FormP.IsNew = true;
                    FormP.ShowDialog();
                    if (FormP.DialogResult == DialogResult.Cancel)
                    {
                        //any created claimprocs are automatically deleted from within procEdit window.
                        try {
                            Procedures.Delete(listProcs[i].ProcNum);                            //also deletes the claimprocs
                        }
                        catch (Exception ex) {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        //Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
                        //Recalls.Synch(PatCur.PatNum);
                    }
                }
            }
            return(aptCur);
        }
Beispiel #16
0
 ///<summary>FName M LName</summary>
 public string GetNameFLnoPref()
 {
     return(Patients.GetNameFLnoPref(LName, FName, MiddleI));
 }
Beispiel #17
0
        ///<summary></summary>
        public static PlannedApptStatus CreatePlannedAppt(Patient pat, int itemOrder, List <long> listPreSelectedProcNums = null)
        {
            if (!Security.IsAuthorized(Permissions.AppointmentCreate))
            {
                return(PlannedApptStatus.Failure);
            }
            if (PatRestrictionL.IsRestricted(pat.PatNum, PatRestrict.ApptSchedule))
            {
                return(PlannedApptStatus.Failure);
            }
            if (PromptForMerge(pat, out pat))
            {
                FormOpenDental.S_Contr_PatientSelected(pat, true, false);
            }
            if (pat.PatStatus.In(PatientStatus.Archived, PatientStatus.Deceased))
            {
                MsgBox.Show("Appointments", "Appointments cannot be scheduled for " + pat.PatStatus.ToString().ToLower() + " patients.");
                return(PlannedApptStatus.Failure);
            }
            Appointment AptCur = new Appointment();

            AptCur.PatNum      = pat.PatNum;
            AptCur.ProvNum     = pat.PriProv;
            AptCur.ClinicNum   = pat.ClinicNum;
            AptCur.AptStatus   = ApptStatus.Planned;
            AptCur.AptDateTime = DateTimeOD.Today;
            List <Procedure> listProcs = Procedures.GetManyProc(listPreSelectedProcNums, false);        //Returns empty list if null.

            //If listProcs is empty then AptCur.Pattern defaults to PrefName.AppointmentWithoutProcsDefaultLength value.
            //See Appointments.GetApptTimePatternForNoProcs().
            AptCur.Pattern    = Appointments.CalculatePattern(pat, AptCur.ProvNum, AptCur.ProvHyg, listProcs, isMake5Minute: true);
            AptCur.TimeLocked = PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
            Appointments.Insert(AptCur);
            PlannedAppt plannedAppt = new PlannedAppt();

            plannedAppt.AptNum    = AptCur.AptNum;
            plannedAppt.PatNum    = pat.PatNum;
            plannedAppt.ItemOrder = itemOrder;
            PlannedAppts.Insert(plannedAppt);
            Procedures.UpdateAptNums(listPreSelectedProcNums, plannedAppt.AptNum, true);          //Simply returns if listPreSelectedProcNums is null
            FormApptEdit FormApptEdit = new FormApptEdit(AptCur.AptNum);

            FormApptEdit.IsNew = true;
            FormApptEdit.ShowDialog();
            if (FormApptEdit.DialogResult != DialogResult.OK)
            {
                Procedures.UpdateAptNums(listPreSelectedProcNums, 0, true);              //Simply returns if listPreSelectedProcNums is null
                return(PlannedApptStatus.FillGridNeeded);
            }
            //Only set the appointment hygienist to this patient's secondary provider if one was not manually set within the edit window.
            if (AptCur.ProvHyg < 1)
            {
                List <Procedure> myProcList  = Procedures.GetProcsForSingle(AptCur.AptNum, true);
                bool             allProcsHyg = (myProcList.Count > 0 && myProcList.Select(x => ProcedureCodes.GetProcCode(x.CodeNum)).ToList().All(x => x.IsHygiene));
                //Automatically set the appointments hygienist to the secondary provider of the patient if one is set.
                if (allProcsHyg && pat.SecProv != 0)
                {
                    Appointment aptOld = AptCur.Copy();
                    AptCur.ProvNum = pat.SecProv;
                    Appointments.Update(AptCur, aptOld);
                }
            }
            Patient patOld = pat.Copy();

            pat.PlannedIsDone = false;
            Patients.Update(pat, patOld);
            FormOpenDental.S_RefreshCurrentModule(isClinicRefresh: false);           //if procs were added in appt, then this will display them
            return(PlannedApptStatus.Success);
        }
Beispiel #18
0
 ///<summary>FName/Preferred M. LName</summary>
 public string GetNameFirstOrPrefML()
 {
     return(Patients.GetNameFirstOrPrefML(LName, FName, Preferred, MiddleI));
 }
Beispiel #19
0
 //отмена
 private void buttonLevelsCancel_Click(object sender, EventArgs e)
 {
     patientsList = Patients.Read(file);
     LevelShowInfo(patientsList.patients[patientsList.currentPatient]);
     saved = true;
     buttonLevelsSave.Enabled = false;
     buttonLevelsCancel.Enabled = false;
 }
Beispiel #20
0
 ///<summary>Title FName M LName</summary>
 public string GetNameFLFormal()
 {
     return(Patients.GetNameFLFormal(LName, FName, MiddleI, Title));
 }
Beispiel #21
0
 public void DeletePatient(string patientName)
 {
     Patients.Remove(Patients.Find(p => p.Name == patientName));
     SaveData();
 }
Beispiel #22
0
 ///<summary></summary>
 public string GetNameFirstOrPreferred()
 {
     return(Patients.GetNameFirstOrPreferred(FName, Preferred));
 }
Beispiel #23
0
        /// <summary>
        /// Method to register a new patient based on its condition
        /// </summary>
        /// <param name="patient"></param>
        public void PatientRegistration(Patient patient)
        {
            //Make sure two operators cannot call this method at the same time. Prevent double booking of the same resource
            lock (_thisLock)
            {
                if (patient.Registered)
                {
                    //this patient has already been registered
                    return;
                }

                Consultation consultation;
                patient.Registered = true;

                switch (patient.Condition)
                {
                case PatientCondition.Flu:
                    consultation = new Consultation
                    {
                        //Assign next day of last scheduled date to new consultation
                        ConsultationDate = _lastScheduledDate.AddDays(1),
                        //Randomly select a general practitioner.
                        Doctor          = _doctors.FindAll(d => d.Role.Contains(DoctorRolesEnum.GeneralPractioner)).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault(),
                        Patient         = patient,
                        RegistraionDate = DateTime.Now,
                        //Randomly select a treatment room that does not contain a machine. Free up the treatment rooms with machine for cancer patients
                        TreatmentRoom = _treatmentRooms.FindAll(tr => tr.TreatmentMachine == null).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault()
                    };
                    break;

                case PatientCondition.Breast:
                    consultation = new Consultation
                    {
                        ConsultationDate = _lastScheduledDate.AddDays(1),
                        //Randomly select an oncologist.
                        Doctor          = _doctors.FindAll(d => d.Role.Contains(DoctorRolesEnum.Oncologist)).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault(),
                        Patient         = patient,
                        RegistraionDate = DateTime.Now,
                        //Select a room with a treatment machine. Can be Advanced or Simple
                        TreatmentRoom = _treatmentRooms.FindAll(tr => tr.TreatmentMachine != null).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault()
                    };
                    break;

                case PatientCondition.HeadAndNeck:
                    consultation = new Consultation
                    {
                        ConsultationDate = _lastScheduledDate.AddDays(1),
                        Doctor           = _doctors.FindAll(d => d.Role.Contains(DoctorRolesEnum.Oncologist)).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault(),
                        Patient          = patient,
                        RegistraionDate  = DateTime.Now,
                        //Randomly select an advanced treatment machine
                        TreatmentRoom = _treatmentRooms.FindAll(tr => tr.TreatmentMachine != null && tr.TreatmentMachine.Capability == MachineCapabilityEnum.Advanced).OrderBy(r => _rnd.Next()).Take(1).FirstOrDefault()
                    };
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                _lastScheduledDate = consultation.ConsultationDate;
                Consultations.Add(consultation);
                Patients.Add(patient);
            }
            SaveData();
        }
Beispiel #24
0
 ///<summary>Dear __.  Does not include the "Dear" or the comma.</summary>
 public string GetSalutation()
 {
     return(Patients.GetSalutation(Salutation, Preferred, FName));
 }
Beispiel #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="agencys"></param>
 /// <param name="patients"></param>
 /// <param name="registrationDate"></param>
 /// <returns></returns>
 public ObservableCollection <ImageInfo> QueryRegistrationDateImageToImageInfo(Agencys agencys, Patients patients, DateTime registrationDate)
 {
     using (var ide = new iDentalEntities())
     {
         var qi = from i in ide.Images
                  where i.Registrations.Patient_ID == patients.Patient_ID &&
                  i.Registrations.Registration_Date == registrationDate.Date &&
                  i.Image_IsEnable == true
                  select i;
         ObservableCollection <ImageInfo> observableCollection = new ObservableCollection <ImageInfo>(qi.ToList().Select(s => new ImageInfo
         {
             Registration_Date = s.Registrations.Registration_Date,
             Image_ID          = s.Image_ID,
             Image_Path        = s.Image_Path,
             Image_FullPath    = agencys.Agency_ImagePath + s.Image_Path,
             Image_FileName    = s.Image_FileName,
             Image_Extension   = s.Image_Extension,
             Registration_ID   = s.Registration_ID,
             CreateDate        = s.CreateDate,
             IsSelected        = false
         }));
         return(observableCollection);
     }
 }
Beispiel #26
0
        ///<summary>The insplan that's passed in need not be properly updated to the database first.</summary>
        public static void RequestBenefits(Clearinghouse clearhouse, InsPlan plan, long patNum, Carrier carrier, List <Benefit> benList, long patPlanNum, InsSub insSub)
        {
            Patient  pat      = Patients.GetPat(patNum);
            Patient  subsc    = Patients.GetPat(insSub.Subscriber);
            Clinic   clinic   = Clinics.GetClinic(pat.ClinicNum);
            Provider billProv = Providers.GetProv(Providers.GetBillingProvNum(pat.PriProv, pat.ClinicNum));
            //validation.  Throw exception if missing info----------------------------------------
            string validationResult = X270.Validate(clearhouse, carrier, billProv, clinic, plan, subsc, insSub);

            if (validationResult != "")
            {
                throw new Exception(Lan.g("FormInsPlan", "Please fix the following errors first:") + "\r\n" + validationResult);
            }
            //create a 270 message---------------------------------------------------------------
            string            x12message        = X270.GenerateMessageText(clearhouse, carrier, billProv, clinic, plan, subsc, insSub);
            EtransMessageText etransMessageText = new EtransMessageText();

            etransMessageText.MessageText = x12message;
            EtransMessageTexts.Insert(etransMessageText);
            //attach it to an etrans-------------------------------------------------------------
            Etrans etrans = new Etrans();

            etrans.DateTimeTrans        = DateTime.Now;
            etrans.ClearingHouseNum     = clearhouse.ClearinghouseNum;
            etrans.Etype                = EtransType.BenefitInquiry270;
            etrans.PlanNum              = plan.PlanNum;
            etrans.InsSubNum            = insSub.InsSubNum;
            etrans.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans);
            //send the 270----------------------------------------------------------------------
            string x12response = "";

            //a connection error here needs to bubble up
            try {
                if (clearhouse.CommBridge == EclaimsCommBridge.ClaimConnect)
                {
                    x12response = ClaimConnect.Benefits270(clearhouse, x12message);
                }
            }
            catch (Exception ex) {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lan.g("FormInsPlan", "Connection Error:") + "\r\n" + ex.GetType().Name + "\r\n" + ex.Message);
            }
            //start to process the 271----------------------------------------------------------
            X271 x271 = null;

            if (X12object.IsX12(x12response))
            {
                X12object x12obj = new X12object(x12response);
                if (x12obj.Is271())
                {
                    x271 = new X271(x12response);
                }
            }
            else              //neither a 997 nor a 271
            {
                EtransMessageTexts.Delete(etrans.EtransMessageTextNum);
                Etranss.Delete(etrans.EtransNum);
                throw new ApplicationException(Lan.g("FormInsPlan", "Error:") + "\r\n" + x12response);
            }

            /*
             * //In realtime mode, X12 limits the request to one patient.
             * //We will always use the subscriber.
             * //So all EB segments are for the subscriber.
             * List<EB271> listEB=new List<EB271>();
             * EB271 eb;
             * if(x271 != null) {
             *      for(int i=0;i<x271.Segments.Count;i++) {
             *              if(x271.Segments[i].SegmentID != "EB") {
             *                      continue;
             *              }
             *              eb=new EB271(x271.Segments[i]);
             *              listEB.Add(eb);
             *      }
             * }*/
            //create an etrans for the 271------------------------------------------------------
            etransMessageText             = new EtransMessageText();
            etransMessageText.MessageText = x12response;
            EtransMessageTexts.Insert(etransMessageText);
            Etrans etrans271 = new Etrans();

            etrans271.DateTimeTrans    = DateTime.Now;
            etrans271.ClearingHouseNum = clearhouse.ClearinghouseNum;
            etrans271.Etype            = EtransType.TextReport;
            if (X12object.IsX12(x12response))             //this shouldn't need to be tested because it was tested above.
            {
                if (x271 == null)
                {
                    etrans271.Etype = EtransType.Acknowledge_997;
                }
                else
                {
                    etrans271.Etype = EtransType.BenefitResponse271;
                }
            }
            etrans271.PlanNum              = plan.PlanNum;
            etrans271.InsSubNum            = insSub.InsSubNum;
            etrans271.EtransMessageTextNum = etransMessageText.EtransMessageTextNum;
            Etranss.Insert(etrans271);
            etrans.AckEtransNum = etrans271.EtransNum;
            if (etrans271.Etype == EtransType.Acknowledge_997)
            {
                X997   x997     = new X997(x12response);
                string error997 = x997.GetHumanReadable();
                etrans.Note = "Error: " + error997;            //"Malformed document sent.  997 error returned.";
                Etranss.Update(etrans);
                MessageBox.Show(etrans.Note);
                //CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
                //msgbox.ShowDialog();
                //don't show the 270 interface.
                return;
            }
            else
            {
                string processingerror = x271.GetProcessingError();
                if (processingerror != "")
                {
                    etrans.Note = processingerror;
                    Etranss.Update(etrans);
                    MessageBox.Show(etrans.Note);
                    //CodeBase.MsgBoxCopyPaste msgbox=new CodeBase.MsgBoxCopyPaste(etrans.Note);
                    //msgbox.ShowDialog();
                    //don't show the 270 interface.
                    return;
                }
                else
                {
                    etrans.Note = "Normal 271 response.";                  //change this later to be explanatory of content.
                }
            }
            Etranss.Update(etrans);
            //show the user a list of benefits to pick from for import--------------------------
            FormEtrans270Edit formE = new FormEtrans270Edit(patPlanNum, plan.PlanNum, insSub.InsSubNum);

            formE.EtransCur         = etrans;
            formE.IsInitialResponse = true;
            formE.benList           = benList;
            formE.ShowDialog();
        }
        ///<summary></summary>
        public void butOK_Click(object sender, System.EventArgs e)          //this is public for NewPatientForm bridge
        {
            if (textMain.Text == "")
            {
                MsgBox.Show(this, "Please paste the text generated by the other program into the large box first.");
                return;
            }
            pat               = new Patient();
            pat.PriProv       = PrefB.GetInt("PracticeDefaultProv");
            pat.BillingType   = PrefB.GetInt("PracticeDefaultBillType");
            guar              = new Patient();
            guar.PriProv      = PrefB.GetInt("PracticeDefaultProv");
            guar.BillingType  = PrefB.GetInt("PracticeDefaultBillType");
            subsc             = new Patient();
            subsc.PriProv     = PrefB.GetInt("PracticeDefaultProv");
            subsc.BillingType = PrefB.GetInt("PracticeDefaultBillType");
            plan              = new InsPlan();
            plan.ReleaseInfo  = true;
            plan.AssignBen    = true;
            carrier           = new Carrier();
            insRelat          = "self"; //this is the default if not included
            guarRelat         = "self";
            InsEmp            = "";
            GuarEmp           = "";
            NoteMedicalComp   = "";
            insPresent        = false;
            annualMax         = -1;
            deductible        = -1;
            XmlTextReader reader = new XmlTextReader(new StringReader(textMain.Text));

            reader.WhitespaceHandling = WhitespaceHandling.None;
            string element     = "";
            string textValue   = "";
            string rootElement = "";
            string segment     = "";    //eg PatientIdentification
            string field       = "";    //eg NameLast
            string endelement  = "";

            warnings = "";
            try{
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        element = reader.Name;
                        if (rootElement == "")                              //should be the first node
                        {
                            if (element == "Message")
                            {
                                rootElement = "Message";
                            }
                            else
                            {
                                throw new Exception(element + " should not be the first element.");
                            }
                        }
                        else if (segment == "")                              //expecting a new segment
                        {
                            segment = element;
                            if (segment != "MessageHeader" &&
                                segment != "PatientIdentification" &&
                                segment != "Guarantor" &&
                                segment != "Insurance")
                            {
                                throw new Exception(segment + " is not a recognized segment.");
                            }
                        }
                        else                                 //expecting a new field
                        {
                            field = element;
                        }
                        if (segment == "Insurance")
                        {
                            insPresent = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        textValue = reader.Value;
                        if (field == "")
                        {
                            throw new Exception("Unexpected text: " + textValue);
                        }
                        break;

                    case XmlNodeType.EndElement:
                        endelement = reader.Name;
                        if (field == "")                              //we're not in a field, so we must be closing a segment or rootelement
                        {
                            if (segment == "")                        //we're not in a segment, so we must be closing the rootelement
                            {
                                if (rootElement == "Message")
                                {
                                    rootElement = "";
                                }
                                else
                                {
                                    throw new Exception("Message closing element expected.");
                                }
                            }
                            else                                     //must be closing a segment
                            {
                                segment = "";
                            }
                        }
                        else                                 //closing a field
                        {
                            field     = "";
                            textValue = "";
                        }
                        break;
                    }                    //switch
                    if (rootElement == "")
                    {
                        break;                        //this will ignore anything after the message endelement
                    }
                    if (field != "" && textValue != "")
                    {
                        if (segment == "MessageHeader")
                        {
                            ProcessMSH(field, textValue);
                        }
                        else if (segment == "PatientIdentification")
                        {
                            ProcessPID(field, textValue);
                        }
                        else if (segment == "Guarantor")
                        {
                            ProcessGT(field, textValue);
                        }
                        else if (segment == "Insurance")
                        {
                            ProcessINS(field, textValue);
                        }
                    }
                }                //while
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                //MsgBox.Show(this,"Error in the XML format.");
                reader.Close();
                return;
            }
            finally{
                reader.Close();
            }
            //Warnings and errors-----------------------------------------------------------------------------
            if (pat.LName == "" || pat.FName == "" || pat.Birthdate.Year < 1880)
            {
                MsgBox.Show(this, "Patient first and last name and birthdate are required.  Could not import.");
                return;
            }
            //if guarRelat is not self, and name and birthdate not supplied, no error.  Just make guar self.
            if (guarRelat != "self")
            {
                if (guar.LName == "" || guar.FName == "" || guar.Birthdate.Year < 1880)
                {
                    warnings += "Guarantor information incomplete.  Guarantor will be self.\r\n";
                    guarRelat = "self";
                }
            }
            if (insPresent)
            {
                if (carrier.CarrierName == "")
                {
                    warnings  += "Insurance CompanyName is missing. No insurance info will be imported.\r\n";
                    insPresent = false;
                }
                else if (insRelat != "self")
                {
                    if (subsc.LName == "" || subsc.FName == "" || subsc.Birthdate.Year < 1880)
                    {
                        warnings  += "Subscriber name or birthdate is missing. No insurance info will be imported.\r\n";
                        insPresent = false;
                    }
                }
                else if (plan.SubscriberID == "")
                {
                    warnings         += "PolicyNumber/SubscriberID missing.\r\n";
                    plan.SubscriberID = " ";
                }
            }
            if (warnings != "")
            {
                if (MessageBox.Show("It's safe to import, but you should be aware of the following issues:\r\n" + warnings + "\r\nContinue with Import?", "Warnings", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }

            //Patient-------------------------------------------------------------------------------------
            string    command;
            DataTable table;

            command = "SELECT PatNum FROM patient WHERE "
                      + "LName='" + POut.PString(pat.LName) + "' "
                      + "AND FName='" + POut.PString(pat.FName) + "' "
                      + "AND Birthdate=" + POut.PDate(pat.Birthdate) + " "
                      + "AND PatStatus!=4";         //not deleted
            table = General.GetTable(command);
            Patient existingPat = null;

            existingPatOld = null;          //we will need this to do an update.
            if (table.Rows.Count > 0)       //a patient already exists, so only add missing fields
            {
                existingPat    = Patients.GetPat(PIn.PInt(table.Rows[0][0].ToString()));
                existingPatOld = existingPat.Copy();
                if (existingPat.MiddleI == "")              //only alter existing if blank
                {
                    existingPat.MiddleI = pat.MiddleI;
                }
                if (pat.Gender != PatientGender.Unknown)
                {
                    existingPat.Gender = pat.Gender;
                }
                if (existingPat.Preferred == "")
                {
                    existingPat.Preferred = pat.Preferred;
                }
                if (existingPat.Address == "")
                {
                    existingPat.Address = pat.Address;
                }
                if (existingPat.Address2 == "")
                {
                    existingPat.Address2 = pat.Address2;
                }
                if (existingPat.City == "")
                {
                    existingPat.City = pat.City;
                }
                if (existingPat.State == "")
                {
                    existingPat.State = pat.State;
                }
                if (existingPat.Zip == "")
                {
                    existingPat.Zip = pat.Zip;
                }
                if (existingPat.HmPhone == "")
                {
                    existingPat.HmPhone = pat.HmPhone;
                }
                if (existingPat.Email == "")
                {
                    existingPat.Email = pat.Email;
                }
                if (existingPat.WkPhone == "")
                {
                    existingPat.WkPhone = pat.WkPhone;
                }
                if (existingPat.Position == PatientPosition.Single)
                {
                    existingPat.Position = pat.Position;
                }
                if (existingPat.SSN == "")
                {
                    existingPat.SSN = pat.SSN;
                }
                existingPat.AddrNote += pat.AddrNote;              //concat
                Patients.Update(existingPat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(existingPat.PatNum, existingPat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, existingPat.Guarantor);
                //guarantor will not be altered in any way
            }            //if patient already exists
            else         //patient is new, so insert
            {
                Patients.Insert(pat, false);
                existingPatOld = pat.Copy();
                pat.Guarantor  = pat.PatNum;             //this can be changed later.
                Patients.Update(pat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(pat.PatNum, pat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, pat.Guarantor);
            }
            //guar-----------------------------------------------------------------------------------------------------
            if (existingPat == null)          //only add or alter guarantor for new patients
            {
                if (guarRelat == "self")
                {
                    //pat is already set with guar as self
                    //ignore all guar fields except EmployerName
                    existingPatOld  = pat.Copy();
                    pat.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                    Patients.Update(pat, existingPatOld);
                }
                else
                {
                    //if guarRelat is not self, and name and birthdate not supplied, a warning was issued, and relat was changed to self.
                    //add guarantor or attach to an existing guarantor
                    command = "SELECT PatNum FROM patient WHERE "
                              + "LName='" + POut.PString(guar.LName) + "' "
                              + "AND FName='" + POut.PString(guar.FName) + "' "
                              + "AND Birthdate=" + POut.PDate(guar.Birthdate) + " "
                              + "AND PatStatus!=4";            //not deleted
                    table = General.GetTable(command);
                    if (table.Rows.Count > 0)                  //a guar already exists, so simply attach. Make no other changes
                    {
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = PIn.PInt(table.Rows[0][0].ToString());
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                    else                     //we need to completely create guar, then attach
                    {
                        Patients.Insert(guar, false);
                        //set guar for guar
                        existingPatOld   = guar.Copy();
                        guar.Guarantor   = guar.PatNum;
                        guar.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                        Patients.Update(guar, existingPatOld);
                        //set guar for pat
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = guar.PatNum;
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                }
            }
            //subsc--------------------------------------------------------------------------------------------------
            if (!insPresent)
            {
                //this takes care of missing carrier name or subscriber info.
                MsgBox.Show(this, "Done");
                DialogResult = DialogResult.OK;
            }
            if (insRelat == "self")
            {
                plan.Subscriber = pat.PatNum;
            }
            else             //we need to find or add the subscriber
            {
                command = "SELECT PatNum FROM patient WHERE "
                          + "LName='" + POut.PString(subsc.LName) + "' "
                          + "AND FName='" + POut.PString(subsc.FName) + "' "
                          + "AND Birthdate=" + POut.PDate(subsc.Birthdate) + " "
                          + "AND PatStatus!=4";        //not deleted
                table = General.GetTable(command);
                if (table.Rows.Count > 0)              //a subsc already exists, so simply attach. Make no other changes
                {
                    plan.Subscriber = PIn.PInt(table.Rows[0][0].ToString());
                }
                else                 //need to create and attach a subscriber
                {
                    Patients.Insert(subsc, false);
                    //set guar to same guar as patient
                    existingPatOld  = subsc.Copy();
                    subsc.Guarantor = pat.Guarantor;
                    Patients.Update(subsc, existingPatOld);
                    plan.Subscriber = subsc.PatNum;
                }
            }
            //carrier-------------------------------------------------------------------------------------------------
            //Carriers.Cur=carrier;
            Carriers.GetCurSame(carrier);            //this automatically finds or creates a carrier
            //plan------------------------------------------------------------------------------------------------------
            plan.EmployerNum = Employers.GetEmployerNum(InsEmp);
            plan.CarrierNum  = carrier.CarrierNum;
            InsPlans.Insert(plan);
            //Then attach plan
            PatPlan[] PatPlanList = PatPlans.Refresh(pat.PatNum);
            PatPlan   patplan     = new PatPlan();

            patplan.Ordinal = PatPlanList.Length + 1;        //so the ordinal of the first entry will be 1, NOT 0.
            patplan.PatNum  = pat.PatNum;
            patplan.PlanNum = plan.PlanNum;
            switch (insRelat)
            {
            case "self":
                patplan.Relationship = Relat.Self;
                break;

            case "parent":
                patplan.Relationship = Relat.Child;
                break;

            case "spouse":
                patplan.Relationship = Relat.Spouse;
                break;

            case "guardian":
                patplan.Relationship = Relat.Dependent;
                break;
            }
            PatPlans.Insert(patplan);
            //benefits
            if (annualMax != -1 && CovCatB.ListShort.Length > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Limitations;
                ben.CovCatNum   = CovCatB.ListShort[0].CovCatNum;
                ben.MonetaryAmt = annualMax;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            if (deductible != -1 && CovCatB.ListShort.Length > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Deductible;
                ben.CovCatNum   = CovCatB.ListShort[0].CovCatNum;
                ben.MonetaryAmt = deductible;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            MsgBox.Show(this, "Done");
            DialogResult = DialogResult.OK;
        }
Beispiel #28
0
        private void FormReqStudentEdit_Load(object sender, System.EventArgs e)
        {
            //There should only be two types of users who are allowed to get this far:
            //Students editing their own req, and users with setup perm.  But we will double check.
            Provider provUser = Providers.GetProv(Security.CurUser.ProvNum);

            if (provUser != null && !provUser.IsInstructor)           //A student is logged in
            //the student only has permission to view/attach/detach their own requirements
            {
                if (provUser.ProvNum != ReqCur.ProvNum)
                {
                    //but this should never happen
                    MsgBox.Show(this, "Students may only edit their own requirements.");
                    butDelete.Enabled = false;
                    butOK.Enabled     = false;
                }
                else                 //the student matches
                {
                    butDelete.Enabled         = false;
                    textDateCompleted.Enabled = false;
                    butNow.Enabled            = false;
                    comboInstructor.Enabled   = false;
                    //a student is only allowed to change the patient and appointment.
                }
            }
            else                                               //A student is not logged in
            {
                if (provUser != null && provUser.IsInstructor) //suppress message
                {
                    butDelete.Enabled = false;
                    butOK.Enabled     = false;
                }
            }
            textStudent.Text     = Providers.GetLongDesc(ReqCur.ProvNum);
            textCourse.Text      = SchoolCourses.GetDescript(ReqCur.SchoolCourseNum);
            textDescription.Text = ReqCur.Descript;
            if (ReqCur.DateCompleted.Year > 1880)
            {
                textDateCompleted.Text = ReqCur.DateCompleted.ToShortDateString();
            }
            //if an apt is attached, then the same pat must be attached.
            Patient pat = Patients.GetPat(ReqCur.PatNum);

            if (pat != null)
            {
                textPatient.Text = pat.GetNameFL();
            }
            Appointment apt = Appointments.GetOneApt(ReqCur.AptNum);

            if (apt != null)
            {
                if (apt.AptStatus == ApptStatus.UnschedList)
                {
                    textAppointment.Text = Lan.g(this, "Unscheduled");
                }
                else
                {
                    textAppointment.Text = apt.AptDateTime.ToShortDateString() + " " + apt.AptDateTime.ToShortTimeString();
                }
                textAppointment.Text += ", " + apt.ProcDescript;
            }
            comboInstructor.Items.Add(Lan.g(this, "None"));
            comboInstructor.SelectedIndex = 0;
            _listProviders = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                comboInstructor.Items.Add(_listProviders[i].GetLongDesc());
                if (_listProviders[i].ProvNum == ReqCur.InstructorNum)
                {
                    comboInstructor.SelectedIndex = i + 1;
                }
            }
        }
Beispiel #29
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            List <Procedure> listProcedures = new List <Procedure>();
            //splits should only exist on procs if they are using tp pre-payments
            List <PaySplit> listSplitsForApptProcs = new List <PaySplit>();
            bool            isNonRefundable        = false;
            double          brokenProcAmount       = 0;
            Procedure       brokenProcedure        = new Procedure();
            bool            wasBrokenProcDeleted   = false;
            if (PrefC.GetYN(PrefName.PrePayAllowedForTpProcs))
            {
                listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false);
                if (listProcedures.Count > 0)
                {
                    listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList());
                }
            }
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                brokenProcedure.PatNum       = pat.PatNum;
                brokenProcedure.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                brokenProcedure.CodeNum      = procCode.CodeNum;
                brokenProcedure.ProcDate     = DateTime.Today;
                brokenProcedure.DateEntryC   = DateTime.Now;
                brokenProcedure.ProcStatus   = ProcStat.C;
                brokenProcedure.ClinicNum    = appt.ClinicNum;
                brokenProcedure.UserNum      = Security.CurUser.UserNum;
                brokenProcedure.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum);
                }
                procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum,
                                                     brokenProcedure.ProvNum);
                    brokenProcedure.ProcFee = Math.Max(provFee, procFee);
                }
                else if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986")
                {
                    //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill
                    //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user.
                    brokenProcedure.ProcFee = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                    isNonRefundable         = true;
                }
                else
                {
                    brokenProcedure.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    brokenProcedure.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(brokenProcedure);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum);
                Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(brokenProcedure, isNonRefundable);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
                brokenProcAmount     = FormPB.AmountTotal;
                wasBrokenProcDeleted = FormPB.IsProcDeleted;
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog commlogCur = new Commlog();
                commlogCur.PatNum       = pat.PatNum;
                commlogCur.CommDateTime = DateTime.Now;
                commlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                commlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                commlogCur.Mode_        = CommItemMode.None;
                commlogCur.UserNum      = Security.CurUser.UserNum;
                commlogCur.IsNew        = true;
                FormCommItem FormCI = new FormCommItem(commlogCur);
                FormCI.ShowDialog();
            }
            #endregion
            #region Transfer money from TP Procedures if necessary
            //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure.
            if (isNonRefundable && !wasBrokenProcDeleted && listSplitsForApptProcs.Count > 0)
            {
                //transfer what the user specified in the broken appointment window.
                //transfer up to the amount specified by the user
                foreach (Procedure proc in listProcedures)
                {
                    if (brokenProcAmount == 0)
                    {
                        break;
                    }
                    List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum);
                    foreach (PaySplit split in listSplitsForAppointmentProcedure)
                    {
                        if (brokenProcAmount == 0)
                        {
                            break;
                        }
                        double amt = Math.Min(brokenProcAmount, split.SplitAmt);
                        Payments.CreateTransferForTpProcs(proc, new List <PaySplit> {
                            split
                        }, brokenProcedure, amt);
                        double amtPaidOnApt = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                        if (amtPaidOnApt > amt)
                        {
                            //If the original prepayment amount is greater than the amt being specified for the appointment break, transfer
                            //the difference to an Unallocated Unearned Paysplit on the account.
                            double remainingAmt = amtPaidOnApt - amt;
                            //We have to create a new transfer payment here to correlate to the split.
                            Payment txfrPayment = new Payment();
                            txfrPayment.PayAmt    = 0;
                            txfrPayment.PayDate   = DateTime.Today;
                            txfrPayment.ClinicNum = split.ClinicNum;
                            txfrPayment.PayNote   = "Automatic transfer from treatment planned procedure prepayment.";
                            txfrPayment.PatNum    = split.PatNum;                       //ultimately where the payment ends up.
                            txfrPayment.PayType   = 0;
                            Payments.Insert(txfrPayment);
                            PaymentEdit.IncomeTransferData transferData = PaymentEdit.IncomeTransferData.CreateTransfer(split, txfrPayment.PayNum, true, remainingAmt);
                            PaySplit offset         = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum != 0);
                            long     offsetSplitNum = PaySplits.Insert(offset);                      //Get the FSplitNum from the offset
                            PaySplit allocation     = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum == 0);
                            allocation.FSplitNum = offsetSplitNum;
                            PaySplits.Insert(allocation);                            //Insert so the split is now up to date
                            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, txfrPayment.PatNum, "Automatic transfer of funds for treatment plan procedure pre-payments.");
                        }
                        brokenProcAmount -= amt;
                    }
                }
            }
            //if broken appointment procedure was deleted (user cancelled out of the window) just keep money on the original procedure.
            #endregion
            AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt);
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Beispiel #30
0
        ///<summary>Gets the data necessary to load the Family Module.</summary>
        public static LoadData GetLoadData(long patNum, bool doCreateSecLog)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), patNum, doCreateSecLog));
            }
            LoadData data = new LoadData();

            data.Fam          = Patients.GetFamily(patNum);
            data.Pat          = data.Fam.GetPatient(patNum);
            data.ListPatPlans = PatPlans.Refresh(patNum);
            if (!PatPlans.IsPatPlanListValid(data.ListPatPlans))             //PatPlans had invalid references and need to be refreshed.
            {
                data.ListPatPlans = PatPlans.Refresh(patNum);
            }
            data.PatNote               = PatientNotes.Refresh(patNum, data.Pat.Guarantor);
            data.ListInsSubs           = InsSubs.RefreshForFam(data.Fam);
            data.ListInsPlans          = InsPlans.RefreshForSubList(data.ListInsSubs);
            data.ListBenefits          = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs);
            data.ListRecalls           = Recalls.GetList(data.Fam.ListPats.Select(x => x.PatNum).ToList());
            data.ArrPatFields          = PatFields.Refresh(patNum);
            data.SuperFamilyMembers    = Patients.GetBySuperFamily(data.Pat.SuperFamily);
            data.SuperFamilyGuarantors = Patients.GetSuperFamilyGuarantors(data.Pat.SuperFamily);
            data.DictCloneSpecialities = Patients.GetClonesAndSpecialties(patNum);
            data.PatPict               = Documents.GetPatPictFromDb(patNum);
            data.HasPatPict            = (data.PatPict == null ? YN.No : YN.Yes);
            List <DisplayField> listDisplayFields = DisplayFields.GetForCategory(DisplayFieldCategory.PatientInformation);

            foreach (DisplayField field in listDisplayFields)
            {
                switch (field.InternalName)
                {
                case "Guardians":
                    data.ListGuardians = Guardians.Refresh(patNum);
                    break;

                case "Pat Restrictions":
                    data.ListPatRestricts = PatRestrictions.GetAllForPat(patNum);
                    break;

                case "Payor Types":
                    data.PayorTypeDesc = PayorTypes.GetCurrentDescription(patNum);
                    break;

                case "PatFields":
                    data.ListPatFieldDefLinks = FieldDefLinks.GetForLocation(FieldLocations.Family);
                    break;

                case "References":
                    data.ListCustRefEntries = CustRefEntries.GetEntryListForCustomer(patNum);
                    break;

                case "Referrals":
                    data.ListRefAttaches = RefAttaches.Refresh(patNum);
                    break;

                case "ResponsParty":
                    if (data.Pat.ResponsParty != 0)
                    {
                        data.ResponsibleParty = Patients.GetLim(data.Pat.ResponsParty);
                    }
                    break;
                }
            }
            if (data.Pat.DiscountPlanNum != 0)
            {
                data.DiscountPlan = DiscountPlans.GetPlan(data.Pat.DiscountPlanNum);
            }
            data.ListMergeLinks = PatientLinks.GetLinks(data.Fam.ListPats.Select(x => x.PatNum).ToList(), PatientLinkType.Merge);
            if (doCreateSecLog)
            {
                SecurityLogs.MakeLogEntry(Permissions.FamilyModule, patNum, "");
            }
            return(data);
        }
Beispiel #31
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (Defs.IsHidable(DefCur.Category) && checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (DefCur.DefNum == PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeArrivedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeSeatedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeDismissedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.BillingChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PrepaymentUnearnedType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.SalesTaxAdjustmentType))
                    {
                        MsgBox.Show(this, "You cannot hide a definition if it is in use within Module Preferences.");
                        return;
                    }
                    else if (DefCur.DefNum.In(
                                 PrefC.GetLong(PrefName.RecallStatusMailed),
                                 PrefC.GetLong(PrefName.RecallStatusTexted),
                                 PrefC.GetLong(PrefName.RecallStatusEmailed),
                                 PrefC.GetLong(PrefName.RecallStatusEmailedTexted)))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as a status in the Setup Recall window.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedNewPatConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched New Pat Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedRecallConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched Recall Appt.");
                        return;
                    }
                    else
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                        {
                            return;
                        }
                    }
                }
                //Stop users from hiding the last definition in categories that must have at least one def in them.
                if (!_defsList.Any(x => x.DefNum != DefCur.DefNum && !x.IsHidden))
                {
                    MsgBox.Show(this, "You cannot hide the last definition in this category.");
                    return;
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch (DefCur.Category)
            {
            case DefCat.AccountQuickCharge:
            case DefCat.ApptProcsQuickAdd:
                string[]      procCodes     = textValue.Text.Split(',');
                List <string> listProcCodes = new List <string>();
                for (int i = 0; i < procCodes.Length; i++)
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(procCodes[i]);
                    if (procCode.CodeNum == 0)
                    {
                        //Now check to see if the trimmed version of the code does not exist either.
                        procCode = ProcedureCodes.GetProcCode(procCodes[i].Trim());
                        if (procCode.CodeNum == 0)
                        {
                            MessageBox.Show(Lan.g(this, "Invalid procedure code entered") + ": " + procCodes[i]);
                            return;
                        }
                    }
                    listProcCodes.Add(procCode.ProcCode);
                }
                textValue.Text = String.Join(",", listProcCodes);
                break;

            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-" && textValue.Text != "dp")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are +, -, or dp."));
                    return;
                }
                break;

            case DefCat.BillingTypes:
                if (textValue.Text != "" && textValue.Text != "E" && textValue.Text != "C")
                {
                    MsgBox.Show(this, "Valid values are blank, E, or C.");
                    return;
                }
                if (checkHidden.Checked && Patients.IsBillingTypeInUse(DefCur.DefNum))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients, insurance plans, or preferences."))
                    {
                        return;
                    }
                }
                break;

            case DefCat.ClaimCustomTracking:
                int value = 0;
                if (!Int32.TryParse(textValue.Text, out value) || value < 0)
                {
                    MsgBox.Show(this, "Days Suppressed must be a valid non-negative number.");
                    return;
                }
                break;

            case DefCat.CommLogTypes:
                if (textValue.Text != "" && textValue.Text != "MISC" && textValue.Text != "APPT" &&
                    textValue.Text != "FIN" && textValue.Text != "RECALL" && textValue.Text != "TEXT")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are blank,APPT,FIN,RECALL,MISC,or TEXT."));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try {
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            /*case DefCat.FeeSchedNames:
             *      if(textValue.Text=="C" || textValue.Text=="c") {
             *              textValue.Text="C";
             *      }
             *      else if(textValue.Text=="A" || textValue.Text=="a") {
             *              textValue.Text="A";
             *      }
             *      else textValue.Text="";
             *      break;*/
            case DefCat.ImageCats:
                textValue.Text = textValue.Text.ToUpper().Replace(",", "");
                if (!Regex.IsMatch(textValue.Text, @"^[XPS]*$"))
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.InsurancePaymentType:
                if (textValue.Text != "" && textValue.Text != "N")
                {
                    MsgBox.Show(this, "Valid values are blank or N.");
                    return;
                }
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.ProcCodeCats:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "At least one procedure code category must be enabled.");
                        return;
                    }
                }
                break;

            case DefCat.ProviderSpecialties:
                if (checkHidden.Checked &&
                    (Providers.IsSpecialtyInUse(DefCur.DefNum) ||
                     Referrals.IsSpecialtyInUse(DefCur.DefNum)))
                {
                    MsgBox.Show(this, "You cannot hide a specialty if it is in use by a provider or a referral source.");
                    checkHidden.Checked = false;
                    return;
                }
                break;

            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.TaskPriorities:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "You cannot hide the last priority.");
                        return;
                    }
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            default:
                break;
            }            //end switch DefCur.Category
            DefCur.ItemName  = textName.Text;
            DefCur.ItemValue = _selectedValueString;
            if (_defCatOptions.EnableValue && !_defCatOptions.IsValueDefNum)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (_defCatOptions.EnableColor)
            {
                DefCur.ItemColor = butColor.BackColor;
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            //Must be after the upsert so that we have access to the DefNum for new Defs.
            if (DefCur.Category == DefCat.ApptConfirmed)
            {
                //==================== EXCLUDE SEND ====================
                if (checkExcludeSend.Checked)
                {
                    _listExcludeSendNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeSendNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string sendString = string.Join(",", _listExcludeSendNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeESend, sendString);
                //==================== EXCLUDE CONFIRM ====================
                if (checkExcludeConfirm.Checked)
                {
                    _listExcludeConfirmNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeConfirmNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string confirmString = string.Join(",", _listExcludeConfirmNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeEConfirm, confirmString);
                //==================== EXCLUDE REMIND ====================
                if (checkExcludeRemind.Checked)
                {
                    _listExcludeRemindNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeRemindNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string remindString = string.Join(",", _listExcludeRemindNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeERemind, remindString);
                Signalods.SetInvalid(InvalidType.Prefs);
            }
            DialogResult = DialogResult.OK;
        }
Beispiel #32
0
        ///<summary>If relationship is self, this loop does nothing.  A new pat will later change guarantor to be same as patnum. </summary>
        public static void ProcessGT1(Patient pat, SegmentHL7 seg, bool useChartNumber)
        {
            long guarNum = PIn.Long(seg.GetFieldFullText(2));

            if (guarNum == 0)           //because we have an example where they sent us this (position 2 is empty): GT1|1||^^||^^^^||||||||
            {
                return;
            }
            if (seg.GetFieldFullText(11) == "1")           //if relationship is self (according to some of their documentation)
            {
                return;
            }
            if (seg.GetFieldComponent(3, 0) == "" ||     //lname
                seg.GetFieldComponent(3, 1) == "")                //fname
            {
                EventLog.WriteEntry("OpenDentHL7", "Guarantor not processed due to missing first or last name. PatNum of patient:" + pat.PatNum.ToString()
                                    , EventLogEntryType.Information);
                return;
            }
            Patient guar    = null;
            Patient guarOld = null;

            //So guarantor is someone else
            if (useChartNumber)
            {
                //try to find guarantor by using chartNumber
                guar = Patients.GetPatByChartNumber(guarNum.ToString());
                if (guar == null)
                {
                    //try to find the guarantor by using name and birthdate
                    string   lName         = seg.GetFieldComponent(3, 0);
                    string   fName         = seg.GetFieldComponent(3, 1);
                    DateTime birthdate     = EcwSegmentPID.DateParse(seg.GetFieldFullText(8));
                    long     guarNumByName = Patients.GetPatNumByNameAndBirthday(lName, fName, birthdate);
                    if (guarNumByName == 0)                   //guarantor does not exist in OD
                    //so guar will still be null, triggering creation of new guarantor further down.
                    {
                    }
                    else
                    {
                        guar             = Patients.GetPat(guarNumByName);
                        guar.ChartNumber = guarNum.ToString();                      //from now on, we will be able to find guar by chartNumber
                    }
                }
            }
            else
            {
                guar = Patients.GetPat(guarNum);
            }
            //we can't necessarily set pat.Guarantor yet, because in Standalone mode, we might not know it yet.
            bool isNewGuar = guar == null;

            if (isNewGuar)             //then we need to add guarantor to db
            {
                guar = new Patient();
                if (useChartNumber)
                {
                    guar.ChartNumber = guarNum.ToString();
                }
                else
                {
                    guar.PatNum = guarNum;
                }
                guar.PriProv     = PrefC.GetLong(PrefName.PracticeDefaultProv);
                guar.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            }
            else
            {
                guarOld = guar.Copy();
            }
            //guar.Guarantor=guarNum;
            guar.LName     = seg.GetFieldComponent(3, 0);
            guar.FName     = seg.GetFieldComponent(3, 1);
            guar.MiddleI   = seg.GetFieldComponent(3, 2);
            guar.Address   = seg.GetFieldComponent(5, 0);
            guar.Address2  = seg.GetFieldComponent(5, 1);
            guar.City      = seg.GetFieldComponent(5, 2);
            guar.State     = seg.GetFieldComponent(5, 3);
            guar.Zip       = seg.GetFieldComponent(5, 4);
            guar.HmPhone   = PhoneParse(seg.GetFieldFullText(6));
            guar.WkPhone   = PhoneParse(seg.GetFieldFullText(7));
            guar.Birthdate = DateParse(seg.GetFieldFullText(8));
            guar.Gender    = GenderParse(seg.GetFieldFullText(9));
            //11. Guarantor relationship to patient.  We can't really do anything with this value
            guar.SSN = seg.GetFieldFullText(12);
            if (isNewGuar)
            {
                Patients.Insert(guar, !useChartNumber);               //if using chartnumber (standalone mode), then can't insert using existing PK
                SecurityLogs.MakeLogEntry(Permissions.PatientCreate, guar.PatNum, "Created from HL7 for eCW.", LogSources.HL7);
                guarOld        = guar.Copy();
                guar.Guarantor = guar.PatNum;
                Patients.Update(guar, guarOld);
            }
            else
            {
                Patients.Update(guar, guarOld);
            }
            pat.Guarantor = guar.PatNum;
        }
Beispiel #33
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                Procedure procedureCur = new Procedure();
                procedureCur.PatNum       = pat.PatNum;
                procedureCur.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                procedureCur.CodeNum      = procCode.CodeNum;
                procedureCur.ProcDate     = DateTime.Today;
                procedureCur.DateEntryC   = DateTime.Now;
                procedureCur.ProcStatus   = ProcStat.C;
                procedureCur.ClinicNum    = appt.ClinicNum;
                procedureCur.UserNum      = Security.CurUser.UserNum;
                procedureCur.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                procedureCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, procedureCur.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, procedureCur.ProvNum);
                }
                procFee = Fees.GetAmount0(procedureCur.CodeNum, feeSch, procedureCur.ClinicNum, procedureCur.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(procedureCur.CodeNum, Providers.GetProv(procedureCur.ProvNum).FeeSched, procedureCur.ClinicNum,
                                                     procedureCur.ProvNum);
                    procedureCur.ProcFee = Math.Max(provFee, procFee);
                }
                else
                {
                    procedureCur.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    procedureCur.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(procedureCur);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(procedureCur.ProcNum);
                Procedures.ComputeEstimates(procedureCur, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(procedureCur);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog CommlogCur = new Commlog();
                CommlogCur.PatNum       = pat.PatNum;
                CommlogCur.CommDateTime = DateTime.Now;
                CommlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                CommlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                CommlogCur.Mode_        = CommItemMode.None;
                CommlogCur.UserNum      = Security.CurUser.UserNum;
                FormCommItem FormCI = new FormCommItem();
                FormCI.ShowDialog(new CommItemModel()
                {
                    CommlogCur = CommlogCur
                }, new CommItemController(FormCI)
                {
                    IsNew = true
                });
            }
            #endregion
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Beispiel #34
0
        private void FormReferralEdit_Load(object sender, System.EventArgs e)
        {
            listSpecialty.Items.Clear();
            for (int i = 0; i < Enum.GetNames(typeof(DentalSpecialty)).Length; i++)
            {
                listSpecialty.Items.Add(Lan.g("enumDentalSpecialty", Enum.GetNames(typeof(DentalSpecialty))[i]));
            }
            if (IsPatient)
            {
                if (IsNew)
                {
                    Text = Lan.g(this, "Add Referral");
                    Family  FamCur = Patients.GetFamily(RefCur.PatNum);
                    Patient PatCur = FamCur.GetPatient(RefCur.PatNum);
                    RefCur.Address  = PatCur.Address;
                    RefCur.Address2 = PatCur.Address2;
                    RefCur.City     = PatCur.City;
                    RefCur.EMail    = PatCur.Email;
                    RefCur.FName    = PatCur.FName;
                    RefCur.LName    = PatCur.LName;
                    RefCur.MName    = PatCur.MiddleI;
                    //RefCur.PatNum=Patients.Cur.PatNum;//already handled
                    RefCur.SSN       = PatCur.SSN;
                    RefCur.Telephone = TelephoneNumbers.FormatNumbersExactTen(PatCur.HmPhone);
                    if (PatCur.WkPhone == "")
                    {
                        RefCur.Phone2 = PatCur.WirelessPhone;
                    }
                    else
                    {
                        RefCur.Phone2 = PatCur.WkPhone;
                    }
                    RefCur.ST  = PatCur.State;
                    RefCur.Zip = PatCur.Zip;
                }
                labelPatient.Visible        = true;
                textLName.ReadOnly          = true;
                textFName.ReadOnly          = true;
                textMName.ReadOnly          = true;
                textTitle.ReadOnly          = true;
                textAddress.ReadOnly        = true;
                textAddress2.ReadOnly       = true;
                textCity.ReadOnly           = true;
                textST.ReadOnly             = true;
                textZip.ReadOnly            = true;
                checkNotPerson.Enabled      = false;
                textPhone1.ReadOnly         = true;
                textPhone2.ReadOnly         = true;
                textPhone3.ReadOnly         = true;
                textSSN.ReadOnly            = true;
                radioTIN.Enabled            = false;
                textEmail.ReadOnly          = true;
                listSpecialty.Enabled       = false;
                listSpecialty.SelectedIndex = -1;
                checkIsDoctor.Enabled       = false;
                textNotes.Select();
            }
            else             //non patient
            {
                if (IsNew)
                {
                    this.Text        = Lan.g(this, "Add Referral");
                    RefCur           = new Referral();
                    RefCur.Specialty = DentalSpecialty.General;
                }
                listSpecialty.SelectedIndex = (int)RefCur.Specialty;
                textLName.Select();
            }
            checkIsDoctor.Checked  = RefCur.IsDoctor;
            checkNotPerson.Checked = RefCur.NotPerson;
            checkHidden.Checked    = RefCur.IsHidden;
            textLName.Text         = RefCur.LName;
            textFName.Text         = RefCur.FName;
            textMName.Text         = RefCur.MName;
            textTitle.Text         = RefCur.Title;
            textAddress.Text       = RefCur.Address;
            textAddress2.Text      = RefCur.Address2;
            textCity.Text          = RefCur.City;
            textST.Text            = RefCur.ST;
            textZip.Text           = RefCur.Zip;
            string phone = RefCur.Telephone;

            if (phone != null && phone.Length == 10)
            {
                textPhone1.Text = phone.Substring(0, 3);
                textPhone2.Text = phone.Substring(3, 3);
                textPhone3.Text = phone.Substring(6);
            }
            textSSN.Text = RefCur.SSN;
            if (RefCur.UsingTIN)
            {
                radioTIN.Checked = true;
            }
            else
            {
                radioSSN.Checked = true;
            }
            textNationalProvID.Text = RefCur.NationalProvID;
            textOtherPhone.Text     = RefCur.Phone2;
            textEmail.Text          = RefCur.EMail;
            textNotes.Text          = RefCur.Note;
            //Patients using:
            string[] patsTo   = RefAttaches.GetPats(RefCur.ReferralNum, false);
            string[] patsFrom = RefAttaches.GetPats(RefCur.ReferralNum, true);
            textPatientsNumTo.Text   = patsTo.Length.ToString();
            textPatientsNumFrom.Text = patsFrom.Length.ToString();
            comboPatientsTo.Items.Clear();
            comboPatientsFrom.Items.Clear();
            for (int i = 0; i < patsTo.Length; i++)
            {
                comboPatientsTo.Items.Add(patsTo[i]);
            }
            for (int i = 0; i < patsFrom.Length; i++)
            {
                comboPatientsFrom.Items.Add(patsFrom[i]);
            }
            if (patsTo.Length > 0)
            {
                comboPatientsTo.SelectedIndex = 0;
            }
            if (patsFrom.Length > 0)
            {
                comboPatientsFrom.SelectedIndex = 0;
            }
            comboSlip.Items.Add(Lan.g(this, "Default"));
            comboSlip.SelectedIndex = 0;
            SlipList = SheetDefs.GetCustomForType(SheetTypeEnum.ReferralSlip);
            for (int i = 0; i < SlipList.Count; i++)
            {
                comboSlip.Items.Add(SlipList[i].Description);
                if (RefCur.Slip == SlipList[i].SheetDefNum)
                {
                    comboSlip.SelectedIndex = i + 1;
                }
            }
        }
Beispiel #35
0
        ///<summary>Used when viewing securityLog from the security admin window.  PermTypes can be length 0 to get all types.</summary>
        public static SecurityLog[] Refresh(DateTime dateFrom, DateTime dateTo, Permissions permType, long patNum, long userNum,
                                            DateTime datePreviousFrom, DateTime datePreviousTo, bool includeArchived, int limit = 0)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <SecurityLog[]>(MethodBase.GetCurrentMethod(), dateFrom, dateTo, permType, patNum, userNum, datePreviousFrom, datePreviousTo, includeArchived, limit));
            }
            string command = "SELECT securitylog.*,LName,FName,Preferred,MiddleI,LogHash FROM securitylog "
                             + "LEFT JOIN patient ON patient.PatNum=securitylog.PatNum "
                             + "LEFT JOIN securityloghash ON securityloghash.SecurityLogNum=securitylog.SecurityLogNum "
                             + "WHERE LogDateTime >= " + POut.Date(dateFrom) + " "
                             + "AND LogDateTime <= " + POut.Date(dateTo.AddDays(1)) + " "
                             + "AND DateTPrevious >= " + POut.Date(datePreviousFrom) + " "
                             + "AND DateTPrevious <= " + POut.Date(datePreviousTo.AddDays(1));

            if (patNum != 0)
            {
                command += " AND securitylog.PatNum IN (" + string.Join(",",
                                                                        PatientLinks.GetPatNumsLinkedToRecursive(patNum, PatientLinkType.Merge).Select(x => POut.Long(x))) + ")";
            }
            if (permType != Permissions.None)
            {
                command += " AND PermType=" + POut.Long((int)permType);
            }
            if (userNum != 0)
            {
                command += " AND UserNum=" + POut.Long(userNum);
            }
            command += " ORDER BY LogDateTime DESC";          //Using DESC so that the most recent ones appear in the list
            if (limit > 0)
            {
                command = DbHelper.LimitOrderBy(command, limit);
            }
            DataTable          table    = Db.GetTable(command);
            List <SecurityLog> listLogs = Crud.SecurityLogCrud.TableToList(table);

            for (int i = 0; i < listLogs.Count; i++)
            {
                if (table.Rows[i]["PatNum"].ToString() == "0")
                {
                    listLogs[i].PatientName = "";
                }
                else
                {
                    listLogs[i].PatientName = table.Rows[i]["PatNum"].ToString() + "-"
                                              + Patients.GetNameLF(table.Rows[i]["LName"].ToString()
                                                                   , table.Rows[i]["FName"].ToString()
                                                                   , table.Rows[i]["Preferred"].ToString()
                                                                   , table.Rows[i]["MiddleI"].ToString());
                }
                listLogs[i].LogHash = table.Rows[i]["LogHash"].ToString();
            }
            if (includeArchived && dateFrom <= PrefC.GetDate(PrefName.ArchiveDate))           //They are attempting to find security logs that are prior to archived date.
            {
                string decryptedPass;
                CDT.Class1.Decrypt(PrefC.GetString(PrefName.ArchivePassHash), out decryptedPass);
                string         connectionStrOrig = DataConnection.GetCurrentConnectionString();
                DatabaseType   dbTypeOrig        = DataConnection.DBtype;
                DataConnection dcon = new DataConnection();
                //Connect to archive database
                dcon.SetDb(PrefC.GetString(PrefName.ArchiveServerName) == ""?PrefC.GetString(PrefName.ArchiveServerURI):PrefC.GetString(PrefName.ArchiveServerName),
                           "opendentalarchive", PrefC.GetString(PrefName.ArchiveUserName), decryptedPass, "", "", dbTypeOrig);
                DataTable          tableArchive    = Db.GetTable(command);  //Query the archive
                List <SecurityLog> listLogsArchive = Crud.SecurityLogCrud.TableToList(tableArchive);
                dcon.SetDb(connectionStrOrig, "", dbTypeOrig);              //Reconnect to initial db
                Dictionary <long, Patient> dictPats = Patients.GetMultPats(listLogsArchive.Select(x => x.PatNum).Distinct().ToList())
                                                      .ToDictionary(x => x.PatNum);
                for (int i = 0; i < listLogsArchive.Count; i++)
                {
                    Patient pat;
                    if (listLogsArchive[i].PatNum == 0 || !dictPats.TryGetValue(listLogsArchive[i].PatNum, out pat))
                    {
                        listLogsArchive[i].PatientName = "";
                    }
                    else
                    {
                        listLogsArchive[i].PatientName = listLogsArchive[i].PatNum + "-" + pat.GetNameLF();
                    }
                    listLogsArchive[i].LogHash = tableArchive.Rows[i]["LogHash"].ToString();
                }
                listLogs.AddRange(listLogsArchive);                //Add archived entries to returned list.
            }
            return(listLogs.OrderBy(x => x.LogDateTime).ToArray());
        }
Beispiel #36
0
        ///<summary>Uses a VB dll to launch.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            if (pat == null)
            {
                MessageBox.Show("Please select a patient first.");
                return;
            }
            //js This was originally added on 9/2/09, probably due to race affecting ceph proportions.  But since we can't find any documentation, and since a customer is complaining, we are removing it for now.  If we add it back, we will document exactly why.
            //if(pat.Race==PatientRace.Unknown) {
            //  MessageBox.Show("Race must be entered first.");
            //  return;
            //}
            //Make sure the program is running
            if (Process.GetProcessesByName("DrCeph").Length == 0)
            {
                try{
                    Process.Start(path);
                }
                catch {
                    MsgBox.Show("DrCeph", "Program path not set properly.");
                    return;
                }
                Thread.Sleep(TimeSpan.FromSeconds(4));
            }
            ArrayList       ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;
            ProgramProperty PPCur      = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
            string          patID      = "";

            if (PPCur.PropertyValue == "0")
            {
                patID = pat.PatNum.ToString();
            }
            else
            {
                patID = pat.ChartNumber;
            }
            try{
                List <RefAttach> referalList = RefAttaches.Refresh(pat.PatNum);
                Provider         prov        = Providers.GetProv(Patients.GetProvNum(pat));
                string           provName    = prov.FName + " " + prov.MI + " " + prov.LName + " " + prov.Suffix;
                Family           fam         = Patients.GetFamily(pat.PatNum);
                Patient          guar        = fam.ListPats[0];
                string           relat       = "";
                if (guar.PatNum == pat.PatNum)
                {
                    relat = "Self";
                }
                else if (guar.Gender == PatientGender.Male && pat.Position == PatientPosition.Child)
                {
                    relat = "Father";
                }
                else if (guar.Gender == PatientGender.Female && pat.Position == PatientPosition.Child)
                {
                    relat = "Mother";
                }
                else
                {
                    relat = "Unknown";
                }
                VBbridges.DrCephNew.Launch(patID, pat.FName, pat.MiddleI, pat.LName, pat.Address, pat.Address2, pat.City,
                                           pat.State, pat.Zip, pat.HmPhone, pat.SSN, pat.Gender.ToString(), pat.Race.ToString(), "", pat.Birthdate.ToString(),
                                           DateTime.Today.ToShortDateString(), RefAttachL.GetReferringDr(referalList), provName,
                                           guar.GetNameFL(), guar.Address, guar.Address2, guar.City, guar.State, guar.Zip, guar.HmPhone, relat);
            }
            catch {
                MessageBox.Show("DrCeph not responding.  It might not be installed properly.");
            }
        }
Beispiel #37
0
        public void TestaSeConsegueExecutarGetNoServidor()
        {
            Patient patient = Patients.Get("00000000000");

            Assert.IsNull(patient);
        }
Beispiel #38
0
 //загрузка информации о пациенте
 private void PatientShowInfo(Patients patients)
 {
     bufferPatients = new List<Patient>(patients.patients);
     currentPatient = patients.currentPatient;
     UpdateComboBoxList();
     FillPatient();
     saved = true;
     buttonPacientsSave.Enabled = false;
     buttonPacientsCancel.Enabled = false;
 }