示例#1
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g("TableRecallMsgs", "Remind#"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallMsgs", "Mode"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("", 300);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallMsgs", "Message"), 500);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //
            row = new ODGridRow();
            row.Cells.Add("1");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Subject line"));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailSubject));            //old
            row.Tag = "RecallEmailSubject";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("1");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailMessage));
            row.Tag = "RecallEmailMessage";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("1");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList] where the list of family members should show."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailFamMsg));
            row.Tag = "RecallEmailFamMsg";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("1");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardMessage));            //old
            row.Tag = "RecallPostcardMessage";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("1");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList] where the list of family members should show."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardFamMsg));            //old
            row.Tag = "RecallPostcardFamMsg";
            gridMain.Rows.Add(row);
            //2---------------------------------------------------------------------------------------------
            //
            row = new ODGridRow();
            row.Cells.Add("2");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Subject line"));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailSubject2));
            row.Tag = "RecallEmailSubject2";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("2");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailMessage2));
            row.Tag = "RecallEmailMessage2";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("2");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailFamMsg2));
            row.Tag = "RecallEmailFamMsg2";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("2");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardMessage2));
            row.Tag = "RecallPostcardMessage2";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("2");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardFamMsg2));
            row.Tag = "RecallPostcardFamMsg2";
            gridMain.Rows.Add(row);
            //3---------------------------------------------------------------------------------------------
            //
            row = new ODGridRow();
            row.Cells.Add("3");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Subject line"));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailSubject3));
            row.Tag = "RecallEmailSubject3";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("3");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailMessage3));
            row.Tag = "RecallEmailMessage3";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("3");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallEmailFamMsg3));
            row.Tag = "RecallEmailFamMsg3";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("3");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "Available variables: [DueDate], [NameFL], [NameF]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardMessage3));
            row.Tag = "RecallPostcardMessage3";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("3");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "For multiple patients in one family.  Use [FamilyList]."));
            row.Cells.Add(PrefC.GetString(PrefName.RecallPostcardFamMsg3));
            row.Tag = "RecallPostcardFamMsg3";
            gridMain.Rows.Add(row);
            //Confirmation---------------------------------------------------------------------------------------------
            row = new ODGridRow();
            row.Cells.Add("");
            row.Cells.Add(Lan.g(this, "Postcard"));
            row.Cells.Add(Lan.g(this, "Confirmation message.  Use [date]  and [time] where you want those values to be inserted"));
            row.Cells.Add(PrefC.GetString(PrefName.ConfirmPostcardMessage));
            row.Tag = "ConfirmPostcardMessage";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Confirmation subject line."));
            row.Cells.Add(PrefC.GetString(PrefName.ConfirmEmailSubject));
            row.Tag = "ConfirmEmailSubject";
            gridMain.Rows.Add(row);
            //
            row = new ODGridRow();
            row.Cells.Add("");
            row.Cells.Add(Lan.g(this, "E-mail"));
            row.Cells.Add(Lan.g(this, "Confirmation message.  Available variables: [NameF], [NameFL], [date], and [time]."));
            row.Cells.Add(PrefC.GetString(PrefName.ConfirmEmailMessage));
            row.Tag = "ConfirmEmailMessage";
            gridMain.Rows.Add(row);
            //Text Messaging----------------------------------------------------------------------------------------------
            row = new ODGridRow();
            row.Cells.Add("");
            row.Cells.Add(Lan.g(this, "Text"));
            row.Cells.Add(Lan.g(this, "Confirmation message.  Available variables: [NameF], [NameFL], [date], and [time]."));
            row.Cells.Add(PrefC.GetString(PrefName.ConfirmTextMessage));
            row.Tag = "ConfirmTextMessage";
            gridMain.Rows.Add(row);
            gridMain.EndUpdate();
        }
示例#2
0
        ///<summary>This is the function that the worker thread uses to actually perform the upload.  Can also call this method in the ordinary way if the data to be transferred is small.  The timeSynchStarted must be passed in to ensure that no records are skipped due to small time differences.</summary>
        private static void UploadWorker(DateTime changedSince, DateTime timeSynchStarted)
        {
            int totalCount = 100;

            try {            //Dennis: try catch may not work: Does not work in threads, not sure about this. Note that all methods inside this try catch block are without exception handling. This is done on purpose so that when an exception does occur it does not update PrefName.MobileSyncDateTimeLastRun
                //The handling of PrefName.MobileSynchNewTables79 should never be removed in future versions
                DateTime changedProv      = changedSince;
                DateTime changedDeleted   = changedSince;
                DateTime changedPat       = changedSince;
                DateTime changedStatement = changedSince;
                DateTime changedDocument  = changedSince;
                DateTime changedRecall    = changedSince;
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables79Done, false))
                {
                    changedProv    = DateTime.MinValue;
                    changedDeleted = DateTime.MinValue;
                }
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables112Done, false))
                {
                    changedPat       = DateTime.MinValue;
                    changedStatement = DateTime.MinValue;
                    changedDocument  = DateTime.MinValue;
                }
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables121Done, false))
                {
                    changedRecall = DateTime.MinValue;
                    UploadPreference(PrefName.PracticeTitle);                     //done again because the previous upload did not include the prefnum
                }
                bool synchDelPat = true;
                if (PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).Hour == timeSynchStarted.Hour)
                {
                    synchDelPat = false;                  // synching delPatNumList is timeconsuming (15 seconds) for a dental office with around 5000 patients and it's mostly the same records that have to be deleted every time a synch happens. So it's done only once hourly.
                }
                //MobileWeb
                List <long> patNumList        = Patientms.GetChangedSincePatNums(changedPat);
                List <long> aptNumList        = Appointmentms.GetChangedSinceAptNums(changedSince, PrefC.GetDate(PrefName.MobileExcludeApptsBeforeDate));
                List <long> rxNumList         = RxPatms.GetChangedSinceRxNums(changedSince);
                List <long> provNumList       = Providerms.GetChangedSinceProvNums(changedProv);
                List <long> pharNumList       = Pharmacyms.GetChangedSincePharmacyNums(changedSince);
                List <long> allergyDefNumList = AllergyDefms.GetChangedSinceAllergyDefNums(changedSince);
                List <long> allergyNumList    = Allergyms.GetChangedSinceAllergyNums(changedSince);
                //exclusively Patient Portal

                /*
                 * List<long> eligibleForUploadPatNumList=Patientms.GetPatNumsEligibleForSynch();
                 * List<long> labPanelNumList=LabPanelms.GetChangedSinceLabPanelNums(changedSince,eligibleForUploadPatNumList);
                 * List<long> labResultNumList=LabResultms.GetChangedSinceLabResultNums(changedSince);
                 * List<long> medicationNumList=Medicationms.GetChangedSinceMedicationNums(changedSince);
                 * List<long> medicationPatNumList=MedicationPatms.GetChangedSinceMedicationPatNums(changedSince,eligibleForUploadPatNumList);
                 * List<long> diseaseDefNumList=DiseaseDefms.GetChangedSinceDiseaseDefNums(changedSince);
                 * List<long> diseaseNumList=Diseasems.GetChangedSinceDiseaseNums(changedSince,eligibleForUploadPatNumList);
                 * List<long> icd9NumList=ICD9ms.GetChangedSinceICD9Nums(changedSince);
                 * List<long> statementNumList=Statementms.GetChangedSinceStatementNums(changedStatement,eligibleForUploadPatNumList,statementLimitPerPatient);
                 * List<long> documentNumList=Documentms.GetChangedSinceDocumentNums(changedDocument,statementNumList);
                 * List<long> recallNumList=Recallms.GetChangedSinceRecallNums(changedRecall);*/
                List <long> delPatNumList = Patientms.GetPatNumsForDeletion();
                //List<DeletedObject> dO=DeletedObjects.GetDeletedSince(changedDeleted);dennis: delete this line later
                List <long> deletedObjectNumList = DeletedObjects.GetChangedSinceDeletedObjectNums(changedDeleted); //to delete appointments from mobile
                totalCount = patNumList.Count + aptNumList.Count + rxNumList.Count + provNumList.Count + pharNumList.Count
                                                                                                                    //+labPanelNumList.Count+labResultNumList.Count+medicationNumList.Count+medicationPatNumList.Count
                                                                                                                    //+allergyDefNumList.Count//+allergyNumList.Count+diseaseDefNumList.Count+diseaseNumList.Count+icd9NumList.Count
                                                                                                                    //+statementNumList.Count+documentNumList.Count+recallNumList.Count
                             + deletedObjectNumList.Count;
                if (synchDelPat)
                {
                    totalCount += delPatNumList.Count;
                }
                double currentVal = 0;
                if (Application.OpenForms["FormProgress"] != null)               // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system.
                {
                    FormP.Invoke(new PassProgressDelegate(PassProgressToDialog),
                                 new object[] { currentVal, "?currentVal of ?maxVal records uploaded", totalCount, "" });
                }
                IsSynching = true;
                SynchGeneric(patNumList, SynchEntity.patient, totalCount, ref currentVal);
                SynchGeneric(aptNumList, SynchEntity.appointment, totalCount, ref currentVal);
                SynchGeneric(rxNumList, SynchEntity.prescription, totalCount, ref currentVal);
                SynchGeneric(provNumList, SynchEntity.provider, totalCount, ref currentVal);
                SynchGeneric(pharNumList, SynchEntity.pharmacy, totalCount, ref currentVal);
                //pat portal

                /*
                 * SynchGeneric(labPanelNumList,SynchEntity.labpanel,totalCount,ref currentVal);
                 * SynchGeneric(labResultNumList,SynchEntity.labresult,totalCount,ref currentVal);
                 * SynchGeneric(medicationNumList,SynchEntity.medication,totalCount,ref currentVal);
                 * SynchGeneric(medicationPatNumList,SynchEntity.medicationpat,totalCount,ref currentVal);
                 * SynchGeneric(allergyDefNumList,SynchEntity.allergydef,totalCount,ref currentVal);
                 * SynchGeneric(allergyNumList,SynchEntity.allergy,totalCount,ref currentVal);
                 * SynchGeneric(diseaseDefNumList,SynchEntity.diseasedef,totalCount,ref currentVal);
                 * SynchGeneric(diseaseNumList,SynchEntity.disease,totalCount,ref currentVal);
                 * SynchGeneric(icd9NumList,SynchEntity.icd9,totalCount,ref currentVal);
                 * SynchGeneric(statementNumList,SynchEntity.statement,totalCount,ref currentVal);
                 * SynchGeneric(documentNumList,SynchEntity.document,totalCount,ref currentVal);
                 * SynchGeneric(recallNumList,SynchEntity.recall,totalCount,ref currentVal);*/
                if (synchDelPat)
                {
                    SynchGeneric(delPatNumList, SynchEntity.patientdel, totalCount, ref currentVal);
                }
                //DeleteObjects(dO,totalCount,ref currentVal);// this has to be done at this end because objects may have been created and deleted between synchs. If this function is place above then the such a deleted object will not be deleted from the server.
                SynchGeneric(deletedObjectNumList, SynchEntity.deletedobject, totalCount, ref currentVal);             // this has to be done at this end because objects may have been created and deleted between synchs. If this function is place above then the such a deleted object will not be deleted from the server.
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables79Done, true))
                {
                    Prefs.UpdateBool(PrefName.MobileSynchNewTables79Done, true);
                }
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables112Done, true))
                {
                    Prefs.UpdateBool(PrefName.MobileSynchNewTables112Done, true);
                }
                if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables121Done, true))
                {
                    Prefs.UpdateBool(PrefName.MobileSynchNewTables121Done, true);
                }
                Prefs.UpdateDateT(PrefName.MobileSyncDateTimeLastRun, timeSynchStarted);
                IsSynching = false;
            }
            catch (Exception e) {
                IsSynching = false;                                // this will ensure that the synch can start again. If this variable remains true due to an exception then a synch will never take place automatically.
                if (Application.OpenForms["FormProgress"] != null) // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system.
                {
                    FormP.Invoke(new PassProgressDelegate(PassProgressToDialog),
                                 new object[] { 0, "?currentVal of ?maxVal records uploaded", totalCount, e.Message });
                }
            }
        }
示例#3
0
        ///<summary>Called from FormOpenDental and from FormEhrOnlineAccess.  doForce is set to false to follow regular synching interval.</summary>
        public static void SynchFromMain(bool doForce)
        {
            if (Application.OpenForms["FormMobile"] != null)           //tested.  This prevents main synch whenever this form is open.
            {
                return;
            }
            if (IsSynching)
            {
                return;
            }
            DateTime timeSynchStarted = MiscData.GetNowDateTime();

            if (!doForce)             //if doForce, we skip checking the interval
            {
                if (timeSynchStarted < PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).AddMinutes(PrefC.GetInt(PrefName.MobileSyncIntervalMinutes)))
                {
                    return;
                }
            }
            //if(PrefC.GetString(PrefName.MobileSyncServerURL).Contains("192.168.0.196") || PrefC.GetString(PrefName.MobileSyncServerURL).Contains("localhost")) {
            if (PrefC.GetString(PrefName.MobileSyncServerURL).Contains("10.10.1.196") || PrefC.GetString(PrefName.MobileSyncServerURL).Contains("localhost"))
            {
                IgnoreCertificateErrors();
            }
            if (!TestWebServiceExists())
            {
                if (!doForce)                 //if being used from FormOpenDental as part of timer
                {
                    if (IsServerAvail)        //this will only happen the first time to prevent multiple windows.
                    {
                        IsServerAvail = false;
                        DialogResult res = MessageBox.Show("Mobile synch server not available.  Synch failed.  Turn off synch?", "", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            Prefs.UpdateInt(PrefName.MobileSyncIntervalMinutes, 0);
                        }
                    }
                }
                return;
            }
            else
            {
                IsServerAvail = true;
            }
            DateTime changedSince = PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun);
            //FormProgress FormP=new FormProgress();//but we won't display it.
            //FormP.NumberFormat="";
            //FormP.DisplayText="";
            //start the thread that will perform the upload
            ThreadStart uploadDelegate = delegate { UploadWorker(changedSince, timeSynchStarted); };
            Thread      workerThread   = new Thread(uploadDelegate);

            workerThread.Start();
        }
示例#4
0
        private void FillAvailable()
        {
            _listReqFields = RequiredFields.GetDeepCopy();
            listAvailableFields.Items.Clear();
            _listFieldNames = new List <RequiredFieldName>();
            if (comboFieldTypes.SelectedIndex >= 0)           //if a selection
            {
                switch (comboFieldTypes.SelectedIndex)
                {
                case 0:
                    _listFieldNames = RequiredFields.GetFieldNamesForType(RequiredFieldType.PatientInfo);
                    break;

                case 1:
                    _listFieldNames = RequiredFields.GetFieldNamesForType(RequiredFieldType.InsPayEdit);
                    break;
                }
            }
            RequiredFieldName[] arrayRequiredFieldNames = (RequiredFieldName[])Enum.GetValues(typeof(RequiredFieldName));
            for (int i = 0; i < arrayRequiredFieldNames.Length; i++)
            {
                switch (arrayRequiredFieldNames[i])
                {
                case RequiredFieldName.AdmitDate:
                    if (PrefC.GetBool(PrefName.EasyHideHospitals))
                    {
                        continue;                                //Don't include AdmitDate in the list if hospitals is not enabled
                    }
                    break;

                case RequiredFieldName.TrophyFolder:
                    if (!Programs.IsEnabled(Programs.GetProgramNum(ProgramName.TrophyEnhanced)))
                    {
                        continue;                                //Don't include TrophyFolder in the list if TrophyEnhanced is not enabled
                    }
                    break;

                case RequiredFieldName.Ward:
                    if (PrefC.GetBool(PrefName.EasyHideHospitals))
                    {
                        continue;                                //Don't include Ward in the list if hospitals is not enabled
                    }
                    break;

                case RequiredFieldName.Clinic:
                    if (!PrefC.HasClinicsEnabled)
                    {
                        continue;                                //Don't include Clinic in the list if clinics is not enabled
                    }
                    break;

                case RequiredFieldName.PatientStatus:
                case RequiredFieldName.Position:
                    continue;                            //There is no way to not select these.

                case RequiredFieldName.MothersMaidenFirstName:
                case RequiredFieldName.MothersMaidenLastName:
                case RequiredFieldName.DateTimeDeceased:
                    if (!PrefC.GetBool(PrefName.ShowFeatureEhr))
                    {
                        continue;                                //EHR features
                    }
                    break;

                case RequiredFieldName.StudentStatus:
                    if (CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA
                    {
                        continue;                                       //Canada uses Eligibility Excep. Code instead of Student Status radio buttons
                    }
                    break;

                case RequiredFieldName.EligibilityExceptCode:
                    if (!CultureInfo.CurrentCulture.Name.EndsWith("CA")) // Not Canadian. en-CA or fr-CA
                    {
                        continue;                                        //Don't show EligibilityExceptCode
                    }
                    break;

                case RequiredFieldName.MedicaidID:
                case RequiredFieldName.MedicaidState:
                    if (PrefC.GetBool(PrefName.EasyHideMedicaid))
                    {
                        continue;                                //Don't show Medicaid fields
                    }
                    break;

                case RequiredFieldName.Race:
                case RequiredFieldName.County:
                case RequiredFieldName.Site:
                case RequiredFieldName.GradeLevel:
                case RequiredFieldName.TreatmentUrgency:
                case RequiredFieldName.ResponsibleParty:
                    if (PrefC.GetBool(PrefName.EasyHidePublicHealth))
                    {
                        continue;                                //Don't show Public Health fields
                    }
                    break;

                case RequiredFieldName.Ethnicity:
                    if (PrefC.GetBool(PrefName.EasyHidePublicHealth) ||
                        !PrefC.GetBool(PrefName.ShowFeatureEhr))
                    {
                        continue;                                //Don't show Ethnicity
                    }
                    break;

                default:
                    break;
                }
            }
            List <RequiredFieldName> listReqFieldNames = _listReqFields.Select(y => y.FieldName).Distinct().ToList();

            _listFieldNames = _listFieldNames.FindAll(x => !listReqFieldNames.Any(y => y == x));
            listAvailableFields.Items.AddRange(_listFieldNames.Select(x => x.ToString()).ToArray());
        }
示例#5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" ||
                textDateTo.errorProvider1.GetError(textDateTo) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            DateTime dateFrom = PIn.Date(textDateFrom.Text);
            DateTime dateTo   = PIn.Date(textDateTo.Text);

            if (dateTo < dateFrom)
            {
                MsgBox.Show(this, "To date cannot be before From date.");
                return;
            }
            ReportComplex report       = new ReportComplex(true, false);
            List <long>   listProvNums = new List <long>();

            if (!checkAllProv.Checked)
            {
                listProvNums.AddRange(listProv.SelectedIndices.OfType <int>().Select(x => _listProviders[x].ProvNum).ToList());
            }
            List <long> listBillingDefNums = new List <long>();

            if (!checkAllBilling.Checked)
            {
                listBillingDefNums.AddRange(listBillingType.SelectedIndices.OfType <int>().Select(x => _listBillingTypeDefs[x].DefNum).ToList());
            }
            DataTable table        = RpFinanceCharge.GetFinanceChargeTable(dateFrom, dateTo, PrefC.GetLong(PrefName.FinanceChargeAdjustmentType), listProvNums, listBillingDefNums);
            Font      font         = new Font("Tahoma", 9);
            Font      fontTitle    = new Font("Tahoma", 17, FontStyle.Bold);
            Font      fontSubTitle = new Font("Tahoma", 10, FontStyle.Bold);

            report.ReportName = Lan.g(this, "Finance Charge Report");
            report.AddTitle("Title", Lan.g(this, "Finance Charge Report"), fontTitle);
            report.AddSubTitle("PracticeTitle", PrefC.GetString(PrefName.PracticeTitle), fontSubTitle);
            report.AddSubTitle("Date SubTitle", dateFrom.ToString("d") + " - " + dateTo.ToString("d"), fontSubTitle);
            string subtitleProvs = "";

            if (listProvNums.Count > 0)
            {
                subtitleProvs += string.Join(", ", listProv.SelectedIndices.OfType <int>().ToList().Select(x => _listProviders[x].Abbr));
            }
            else
            {
                subtitleProvs = Lan.g(this, "All Providers");
            }
            report.AddSubTitle("Provider Subtitle", subtitleProvs);
            string subtBillingTypes = "";

            if (listBillingDefNums.Count > 0)
            {
                subtBillingTypes += string.Join(", ", listBillingType.SelectedIndices.OfType <int>().Select(x => _listBillingTypeDefs[x].ItemName));
            }
            else
            {
                subtBillingTypes = Lan.g(this, "All Billing Types");
            }
            report.AddSubTitle("Billing Subtitle", subtBillingTypes);
            QueryObject query = report.AddQuery(table, Lan.g(this, "Date") + ": " + DateTimeOD.Today.ToString("d"));

            query.AddColumn("PatNum", 75);
            query.AddColumn("Patient Name", 180);
            query.AddColumn("Preferred Name", 130);
            query.AddColumn("Amount", 100, FieldValueType.Number);
            query.GetColumnDetail("Amount").ContentAlignment = ContentAlignment.MiddleRight;
            report.AddPageNum(font);
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
            DialogResult = DialogResult.OK;
        }
示例#6
0
        private void ButOK_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }
            ReportComplex report                  = new ReportComplex(true, false);
            List <long>   listProvNums            = new List <long>();
            List <long>   listClinicNums          = new List <long>();
            List <long>   listUnearnedTypeDefNums = new List <long>();
            string        subtitleProvs           = "";
            string        subtitleClinics         = "";
            string        subtitleUnearned        = "";

            if (checkAllProv.Checked)
            {
                subtitleProvs = "All Providers";
                listProvNums  = _listProviders.Select(x => x.ProvNum).ToList();
            }
            else
            {
                subtitleProvs = string.Join(", ", listBoxProv.GetListSelected <Provider>().Select(x => x.Abbr));
                listProvNums  = listBoxProv.GetListSelected <Provider>().Select(x => x.ProvNum).ToList();
            }
            if (checkAllUnearnedTypes.Checked)
            {
                subtitleUnearned        = "All Hidden Unearned";
                listUnearnedTypeDefNums = _listUnearnedTypes.Select(x => x.DefNum).ToList();
            }
            else
            {
                subtitleUnearned        = string.Join(", ", listBoxUnearnedTypes.GetListSelected <Def>().Select(x => x.ItemName));
                listUnearnedTypeDefNums = listBoxUnearnedTypes.GetListSelected <Def>().Select(x => x.DefNum).ToList();
            }
            if (PrefC.HasClinicsEnabled && checkAllClinics.Checked)
            {
                subtitleClinics = "All Clinics";
                listClinicNums  = listBoxClinic.AllTags <Clinic>().Select(x => x.ClinicNum).ToList();
            }
            else if (PrefC.HasClinicsEnabled && !checkAllClinics.Checked)
            {
                subtitleClinics = string.Join(", ", listBoxClinic.GetListSelected <Clinic>().Select(x => x.Abbr).ToList());
                listClinicNums  = listBoxClinic.GetListSelected <Clinic>().Select(x => x.ClinicNum).ToList();
            }
            DataTable table = new DataTable();

            table = RpHiddenPaySplits.GetReportData(listProvNums, listUnearnedTypeDefNums, listClinicNums, PrefC.HasClinicsEnabled
                                                    , odDateRangePicker.GetDateTimeFrom(), odDateRangePicker.GetDateTimeTo());
            Font font         = new Font("Tahoma", 9);
            Font fontBold     = new Font("Tahoma", 9, FontStyle.Bold);
            Font fontTitle    = new Font("Tahoma", 17, FontStyle.Bold);
            Font fontSubTitle = new Font("Tahoma", 10, FontStyle.Bold);

            report.ReportName = Lan.g(this, "Hidden Payment Splits");
            report.AddTitle("Title", Lan.g(this, "Hidden Payment Splits"), fontTitle);
            report.AddSubTitle("PracTitle", PrefC.GetString(PrefName.PracticeTitle), fontSubTitle);
            report.AddSubTitle("Providers", subtitleProvs, fontSubTitle);
            report.AddSubTitle("UnearnedTypes", subtitleUnearned, fontSubTitle);
            if (PrefC.HasClinicsEnabled)
            {
                report.AddSubTitle("Clinics", subtitleClinics, fontSubTitle);
            }
            QueryObject query = report.AddQuery(table, "Hidden PaySplits");

            query.AddColumn("Date", 90, FieldValueType.Date, font);
            query.AddColumn("Patient", 140, FieldValueType.String, font);
            query.AddColumn("Provider", 90, FieldValueType.String, font);
            if (PrefC.HasClinicsEnabled)
            {
                query.AddColumn("Clinic", 50, FieldValueType.String, font);
            }
            query.AddColumn("Code", 65, FieldValueType.String, font);
            query.AddColumn("Description", 220, FieldValueType.String, font);
            query.AddColumn("Amount", 80, FieldValueType.Number, font);
            report.AddPageNum(font);
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex formComplex = new FormReportComplex(report);

            formComplex.ShowDialog();
            DialogResult = DialogResult.OK;
        }
示例#7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!checkBillTypesAll.Checked && listBillType.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one billing type must be selected.");
                return;
            }
            if (!checkProvAll.Checked && listProv.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one provider must be selected.");
                return;
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Invalid date.");
                return;
            }
            DateTime asOfDate = PIn.Date(textDate.Text);

            //The aging report always show historical numbers based on the date entered.
            Ledgers.ComputeAging(0, asOfDate, true);
            ReportSimpleGrid report = new ReportSimpleGrid();
            string           cmd    = "SELECT ";

            if (PrefC.GetBool(PrefName.ReportsShowPatNum))
            {
                cmd += DbHelper.Concat("Cast(PatNum AS CHAR)", "'-'", "LName", "', '", "FName", "' '", "MiddleI");
            }
            else
            {
                cmd += DbHelper.Concat("LName", "', '", "FName", "' '", "MiddleI");
            }
            cmd += ",Bal_0_30,Bal_31_60,Bal_61_90,BalOver90"
                   + ",BalTotal "
                   + ",InsEst"
                   + ",BalTotal-InsEst AS ";            //\"$pat\" ";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                cmd += "$pat ";
            }
            else               //Oracle needs quotes.
            {
                cmd += "\"$pat\" ";
            }
            cmd += "FROM patient "
                   + "WHERE ";
            if (checkExcludeInactive.Checked)
            {
                cmd += "(patstatus != 2) AND ";
            }
            if (checkBadAddress.Checked)
            {
                cmd += "(zip !='') AND ";
            }
            if (checkOnlyNeg.Checked)
            {
                cmd += "BalTotal < '-.005' ";
            }
            else
            {
                if (radioAny.Checked)
                {
                    cmd +=
                        "(Bal_0_30 > '.005' OR Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio30.Checked)
                {
                    cmd +=
                        "(Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio60.Checked)
                {
                    cmd +=
                        "(Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio90.Checked)
                {
                    cmd +=
                        "(BalOver90 > '.005'";
                }
                if (checkIncludeNeg.Checked)
                {
                    cmd += " OR BalTotal < '-.005'";
                }
                cmd += ") ";
            }
            if (!checkBillTypesAll.Checked)
            {
                for (int i = 0; i < listBillType.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (billingtype = ";
                    }
                    else
                    {
                        cmd += " OR billingtype = ";
                    }
                    cmd += POut.Long(DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].DefNum);
                }
                cmd += ") ";
            }
            if (!checkProvAll.Checked)
            {
                for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (PriProv = ";
                    }
                    else
                    {
                        cmd += " OR PriProv = ";
                    }
                    cmd += POut.Long(ProviderC.ListShort[listProv.SelectedIndices[i]].ProvNum);
                }
                cmd += ") ";
            }
            cmd                += "ORDER BY LName,FName";
            report.Query        = cmd;
            FormQuery2          = new FormQuery(report);
            FormQuery2.IsReport = true;
            FormQuery2.SubmitReportQuery();
            //Recompute aging in a non-historical way, so that the numbers are returned to the way they
            //are normally used in other parts of the program.
            Ledgers.RunAging();
            //if(Prefs.UpdateString(PrefName.DateLastAging",POut.PDate(asOfDate,false))) {
            //	DataValid.SetInvalid(InvalidType.Prefs);
            //}
            report.Title = "AGING OF ACCOUNTS RECEIVABLE REPORT";
            report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle));
            report.SubTitle.Add("As of " + textDate.Text);
            if (radioAny.Checked)
            {
                report.SubTitle.Add("Any Balance");
            }
            if (radio30.Checked)
            {
                report.SubTitle.Add("Over 30 Days");
            }
            if (radio60.Checked)
            {
                report.SubTitle.Add("Over 60 Days");
            }
            if (radio90.Checked)
            {
                report.SubTitle.Add("Over 90 Days");
            }
            if (checkBillTypesAll.Checked)
            {
                report.SubTitle.Add("All Billing Types");
            }
            else
            {
                string subt = DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[0]].ItemName;
                for (int i = 1; i < listBillType.SelectedIndices.Count; i++)
                {
                    subt += ", " + DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].ItemName;
                }
                report.SubTitle.Add(subt);
            }
            //report.InitializeColumns(8);
            report.SetColumn(this, 0, "GUARANTOR", 160);
            report.SetColumn(this, 1, "0-30 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 2, "30-60 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 3, "60-90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 4, "> 90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 5, "TOTAL", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 6, "-INS EST", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 7, "=PATIENT", 85, HorizontalAlignment.Right);
            FormQuery2.ShowDialog();
            DialogResult = DialogResult.OK;
        }
示例#8
0
        private static void ShowPendingDeletionReportForTrojan(FormPrintReport fpr)
        {
            //Print the header on the report.
            Font   font = new Font(FontFamily.GenericMonospace, 12);
            string text = PrefC.GetString(PrefName.PracticeTitle);
            SizeF  size = fpr.Graph.MeasureString(text, font);
            float  y    = 20;

            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth / 2 - size.Width / 2, y);
            text = DateTime.Today.ToShortDateString();
            size = fpr.Graph.MeasureString(text, font);
            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth - size.Width, y);
            y   += size.Height;
            text = "PLANS PENDING DELETION: Please Fax or Mail to Trojan";
            size = fpr.Graph.MeasureString(text, font);
            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth / 2 - fpr.Graph.MeasureString(text, font).Width / 2, y);
            y   += size.Height;
            text = "Fax: 800-232-9788";
            size = fpr.Graph.MeasureString(text, font);
            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth / 2 - fpr.Graph.MeasureString(text, font).Width / 2, y);
            y   += size.Height;
            y   += 20;        //Skip a line or so.
            text = "INSTRUCTIONS: Please complete the information requested below to help Trojan research these plans.\n" +
                   "Active Patient: \"Yes\" means the patient has been in the office within the past 6 to 8 months.\n" +
                   "Correct Employer: \"Yes\" means the insured currently is insured through this employer.\n" +
                   "Correct Carrier: \"Yes\" means the insured currently has coverage with this carrier.";
            fpr.Graph.DrawString(text, new Font(new Font(font.FontFamily, 10), FontStyle.Bold), Brushes.Black, new RectangleF(0, y, 900, 500));
            y   += 85;        //Skip a line or so.
            font = new Font(font.FontFamily, 9);
            text = "Active\nPatient?";
            fpr.Graph.DrawString(text, font, Brushes.Black, 5, y);
            text = "\nPatient&Insured";
            fpr.Graph.DrawString(text, font, Brushes.Black, 80, y);
            text = "\nTrojanID";
            fpr.Graph.DrawString(text, font, Brushes.Black, 265, y);
            text = "Correct\nEmployer?";
            fpr.Graph.DrawString(text, font, Brushes.Black, 345, y);
            text = "\nEmployer";
            fpr.Graph.DrawString(text, font, Brushes.Black, 420, y);
            text = "Correct\nCarrier?";
            fpr.Graph.DrawString(text, font, Brushes.Black, 600, y);
            text = "\nCarrier";
            fpr.Graph.DrawString(text, font, Brushes.Black, 670, y);
            y += 30;
            //Use a static height for the records, to keep the math simple.
            float recordHeight  = 200;
            float recordSpacing = 10;

            //Calculate the total number of pages in the report the first time this function is called only.
            if (fpr.TotalPages == 0)
            {
                fpr.TotalPages = (int)Math.Ceiling((y + recordHeight * pendingDeletionTableTrojan.Rows.Count +
                                                    ((pendingDeletionTableTrojan.Rows.Count > 1)?pendingDeletionTableTrojan.Rows.Count - 1:0) * recordSpacing) / fpr.PageHeight);
            }
            float pageBoundry = fpr.PageHeight;

            for (int i = 0; i < pendingDeletionTableTrojan.Rows.Count; i++)
            {
                //Draw the outlines around this record.
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y), new PointF(fpr.GraphWidth - 1, y));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y + recordHeight), new PointF(fpr.GraphWidth - 1, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y), new PointF(0, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(fpr.GraphWidth - 1, y), new PointF(fpr.GraphWidth - 1, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y + recordHeight - 40), new PointF(fpr.GraphWidth - 1, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(260, y), new PointF(260, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(340, y), new PointF(340, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(595, y), new PointF(595, y + recordHeight - 40));
                //Patient active boxes.
                text = "Yes No";
                fpr.Graph.DrawString(text, font, Brushes.Black, 10, y);
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(15, (int)(y + 15), 15, 15));
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(40, (int)(y + 15), 15, 15));
                //Install the information for the record into the outline box.
                //Patient name, Guarantor name, guarantor SSN, guarantor birthdate, insurance plan group number,
                //and reason for pending deletion.
                fpr.Graph.DrawString(
                    PIn.String(pendingDeletionTableTrojan.Rows[i][0].ToString()) + " " + PIn.String(pendingDeletionTableTrojan.Rows[i][1].ToString()) + Environment.NewLine +
                    PIn.String(pendingDeletionTableTrojan.Rows[i][2].ToString()) + " " + PIn.String(pendingDeletionTableTrojan.Rows[i][3].ToString()) + Environment.NewLine +
                    " SSN: " + PIn.String(pendingDeletionTableTrojan.Rows[i][4].ToString()) + Environment.NewLine +
                    " Birth: " + PIn.Date(pendingDeletionTableTrojan.Rows[i][5].ToString()).ToShortDateString() + Environment.NewLine +
                    " Group: " + PIn.String(pendingDeletionTableTrojan.Rows[i][6].ToString()), font, Brushes.Black,
                    new RectangleF(80, y + 5, 185, 95));
                //Pending deletion reason.
                for (int j = 0; j < deleteTrojanRecords.Count; j++)
                {
                    if (deleteTrojanRecords[j][0] == PIn.String(pendingDeletionTableTrojan.Rows[i][8].ToString()))
                    {
                        text = "REASON FOR DELETION: " + deleteTrojanRecords[j][7];
                        if (deleteTrojanRecords[j][1].ToUpper() == "F")
                        {
                            text = "FINALLY DELETED" + Environment.NewLine + text;
                        }
                        fpr.Graph.DrawString(text, font, Brushes.Black,
                                             new RectangleF(5, y + recordHeight - 40, fpr.GraphWidth - 10, 40));
                        break;
                    }
                }
                //Trojan ID.
                fpr.Graph.DrawString(PIn.String(pendingDeletionTableTrojan.Rows[i][8].ToString()), font, Brushes.Black, new RectangleF(265, y + 5, 85, 95));
                //Correct Employer boxes and arrow.
                text = "Yes No";
                fpr.Graph.DrawString(text, font, Brushes.Black, 345, y);
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(350, (int)(y + 15), 15, 15));
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(375, (int)(y + 15), 15, 15));
                //Employer Name and Phone.
                fpr.Graph.DrawString(PIn.String(pendingDeletionTableTrojan.Rows[i][9].ToString()) + Environment.NewLine +
                                     PIn.String(pendingDeletionTableTrojan.Rows[i][10].ToString()), font, Brushes.Black, new RectangleF(420, y + 5, 175, 95));
                //New employer information if necessary.
                text = "New\nEmployer:";
                fpr.Graph.DrawString(text, font, Brushes.Black, 345, y + 85);
                fpr.Graph.DrawLine(Pens.Black, 415, y + 110, 590, y + 110);
                fpr.Graph.DrawLine(Pens.Black, 415, y + 125, 590, y + 125);
                text = "Phone:";
                fpr.Graph.DrawString(text, font, Brushes.Black, 345, y + 130);
                fpr.Graph.DrawLine(Pens.Black, 415, y + 140, 590, y + 140);
                //Correct Carrier boxes and arrow.
                text = "Yes No";
                fpr.Graph.DrawString(text, font, Brushes.Black, 600, y);
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(605, (int)(y + 15), 15, 15));
                fpr.Graph.DrawRectangle(Pens.Black, new Rectangle(630, (int)(y + 15), 15, 15));
                //Carrier Name and Phone
                fpr.Graph.DrawString(PIn.String(pendingDeletionTableTrojan.Rows[i][11].ToString()) + Environment.NewLine +
                                     PIn.String(pendingDeletionTableTrojan.Rows[i][12].ToString()), font, Brushes.Black,
                                     new RectangleF(670, y + 5, 225, 95));
                //New carrier information if necessary.
                text = "New\nCarrier:";
                fpr.Graph.DrawString(text, font, Brushes.Black, 600, y + 85);
                fpr.Graph.DrawLine(Pens.Black, 670, y + 110, 895, y + 110);
                fpr.Graph.DrawLine(Pens.Black, 670, y + 125, 895, y + 125);
                text = "Phone:";
                fpr.Graph.DrawString(text, font, Brushes.Black, 600, y + 130);
                fpr.Graph.DrawLine(Pens.Black, 670, y + 140, 895, y + 140);
                //Leave space between records.
                y += recordHeight + recordSpacing;
                //Watch out for the bottom of each page for the next record.
                if (y + recordHeight > pageBoundry)
                {
                    y            = pageBoundry + fpr.MarginBottom + 20;
                    pageBoundry += fpr.PageHeight + fpr.MarginBottom;
                    text         = "Active\nPatient?";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 5, y);
                    text = "\nPatient&Insured";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 80, y);
                    text = "\nTrojanID";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 265, y);
                    text = "Correct\nEmployer?";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 345, y);
                    text = "\nEmployer";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 420, y);
                    text = "Correct\nCarrier?";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 600, y);
                    text = "\nCarrier";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 670, y);
                    y += 30;
                }
            }
        }
示例#9
0
        private void FormAging_Load(object sender, System.EventArgs e)
        {
            _listProviders = Providers.GetListReports();
            DateTime lastAgingDate = PrefC.GetDate(PrefName.DateLastAging);

            if (lastAgingDate.Year < 1880)
            {
                textDate.Text = "";
            }
            else if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily))
            {
                textDate.Text = lastAgingDate.ToShortDateString();
            }
            else
            {
                textDate.Text = DateTime.Today.ToShortDateString();
            }
            _listBillingTypeDefs = Defs.GetDefsForCategory(DefCat.BillingTypes, true);
            for (int i = 0; i < _listBillingTypeDefs.Count; i++)
            {
                listBillType.Items.Add(_listBillingTypeDefs[i].ItemName);
            }
            if (listBillType.Items.Count > 0)
            {
                listBillType.SelectedIndex = 0;
            }
            listBillType.Visible      = false;
            checkBillTypesAll.Checked = true;
            for (int i = 0; i < _listProviders.Count; i++)
            {
                listProv.Items.Add(_listProviders[i].GetLongDesc());
            }
            if (listProv.Items.Count > 0)
            {
                listProv.SelectedIndex = 0;
            }
            checkProvAll.Checked = true;
            listProv.Visible     = false;
            if (!PrefC.HasClinicsEnabled)
            {
                listClin.Visible     = false;
                labelClin.Visible    = false;
                checkAllClin.Visible = false;
            }
            else
            {
                List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser, true, "Unassigned").ToList();
                if (!listClinics.Exists(x => x.ClinicNum == Clinics.ClinicNum))               //Could have a hidden clinic selected
                {
                    listClinics.Add(Clinics.GetClinic(Clinics.ClinicNum));
                }
                listClin.Items.AddRange(listClinics.Select(x => new ODBoxItem <Clinic>(x.Abbr + (x.IsHidden?(" " + Lan.g(this, "(hidden)")):""), x)).ToArray());
                listClin.SelectedIndex = listClinics.FindIndex(x => x.ClinicNum == Clinics.ClinicNum);            //FindIndex could return -1, which is fine
                if (Clinics.ClinicNum == 0)
                {
                    checkAllClin.Checked = true;
                    listClin.Visible     = false;
                }
            }
            checkAgeNegAdjs.Checked = PrefC.GetBool(PrefName.AgingNegativeAdjsByAdjDate);
            if (PrefC.GetBool(PrefName.AgingReportShowAgePatPayplanPayments))
            {
                //Visibility set to false in designer, only set to visible here.  No UI for pref, only set true via query for specific customer.
                checkAgePatPayPlanPayments.Visible = true;
            }
            if (PrefC.GetBool(PrefName.FutureTransDatesAllowed) || PrefC.GetBool(PrefName.AccountAllowFutureDebits) ||
                PrefC.GetBool(PrefName.AllowFutureInsPayments))
            {
                labelFutureTrans.Visible = true;              //Set to false in designer
            }
        }
示例#10
0
        private void FormUserEdit_Load(object sender, System.EventArgs e)
        {
            checkIsHidden.Checked = UserCur.IsHidden;
            if (UserCur.UserNum != 0)
            {
                textUserNum.Text = UserCur.UserNum.ToString();
            }
            textUserName.Text   = UserCur.UserName;
            textDomainUser.Text = UserCur.DomainUser;
            if (!PrefC.GetBool(PrefName.DomainLoginEnabled))
            {
                labelDomainUser.Visible   = false;
                textDomainUser.Visible    = false;
                butPickDomainUser.Visible = false;
            }
            checkRequireReset.Checked = UserCur.IsPasswordResetRequired;
            _listUserGroups           = UserGroups.GetList();
            _isFillingList            = true;
            for (int i = 0; i < _listUserGroups.Count; i++)
            {
                listUserGroup.Items.Add(new ODBoxItem <UserGroup>(_listUserGroups[i].Description, _listUserGroups[i]));
                if (!_isFromAddUser && UserCur.IsInUserGroup(_listUserGroups[i].UserGroupNum))
                {
                    listUserGroup.SetSelected(i, true);
                }
                if (_isFromAddUser && _listUserGroups[i].UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup))
                {
                    listUserGroup.SetSelected(i, true);
                }
            }
            if (listUserGroup.SelectedIndex == -1)          //never allowed to delete last group, so this won't fail
            {
                listUserGroup.SelectedIndex = 0;
            }
            _isFillingList = false;
            securityTreeUser.FillTreePermissionsInitial();
            RefreshUserTree();
            listEmployee.Items.Clear();
            listEmployee.Items.Add(Lan.g(this, "none"));
            listEmployee.SelectedIndex = 0;
            _listEmployees             = Employees.GetDeepCopy(true);
            for (int i = 0; i < _listEmployees.Count; i++)
            {
                listEmployee.Items.Add(Employees.GetNameFL(_listEmployees[i]));
                if (UserCur.EmployeeNum == _listEmployees[i].EmployeeNum)
                {
                    listEmployee.SelectedIndex = i + 1;
                }
            }
            listProv.Items.Clear();
            listProv.Items.Add(Lan.g(this, "none"));
            listProv.SelectedIndex = 0;
            _listProviders         = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                listProv.Items.Add(_listProviders[i].GetLongDesc());
                if (UserCur.ProvNum == _listProviders[i].ProvNum)
                {
                    listProv.SelectedIndex = i + 1;
                }
            }
            _listClinics           = Clinics.GetDeepCopy(true);
            _listUserAlertTypesOld = AlertSubs.GetAllForUser(UserCur.UserNum);
            List <long> listSubscribedClinics;
            bool        isAllClinicsSubscribed = false;

            if (_listUserAlertTypesOld.Select(x => x.ClinicNum).Contains(-1))             //User subscribed to all clinics
            {
                isAllClinicsSubscribed = true;
                listSubscribedClinics  = _listClinics.Select(x => x.ClinicNum).Distinct().ToList();
            }
            else
            {
                listSubscribedClinics = _listUserAlertTypesOld.Select(x => x.ClinicNum).Distinct().ToList();
            }
            List <long> listAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).Distinct().ToList();

            listAlertSubMulti.Items.Clear();
            _listAlertCategories = AlertCategories.GetDeepCopy();
            List <long> listUserAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).ToList();

            foreach (AlertCategory cat in _listAlertCategories)
            {
                int index = listAlertSubMulti.Items.Add(Lan.g(this, cat.Description));
                listAlertSubMulti.SetSelected(index, listUserAlertCatNums.Contains(cat.AlertCategoryNum));
            }
            if (!PrefC.HasClinicsEnabled)
            {
                tabClinics.Enabled = false;              //Disables all controls in the clinics tab.  Tab is still selectable.
                listAlertSubsClinicsMulti.Visible = false;
                labelAlertClinic.Visible          = false;
            }
            else
            {
                listClinic.Items.Clear();
                listClinic.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "Headquarters"));
                if (UserCur.ClinicNum == 0)               //Unrestricted
                {
                    listClinic.SetSelected(0, true);
                    checkClinicIsRestricted.Enabled = false; //We don't really need this checkbox any more but it's probably better for users to keep it....
                }
                if (isAllClinicsSubscribed)                  //They are subscribed to all clinics
                {
                    listAlertSubsClinicsMulti.SetSelected(0, true);
                }
                else if (listSubscribedClinics.Contains(0))                 //They are subscribed to Headquarters
                {
                    listAlertSubsClinicsMulti.SetSelected(1, true);
                }
                List <UserClinic> listUserClinics = UserClinics.GetForUser(UserCur.UserNum);
                for (int i = 0; i < _listClinics.Count; i++)
                {
                    listClinic.Items.Add(_listClinics[i].Abbr);
                    listClinicMulti.Items.Add(_listClinics[i].Abbr);
                    listAlertSubsClinicsMulti.Items.Add(_listClinics[i].Abbr);
                    if (UserCur.ClinicNum == _listClinics[i].ClinicNum)
                    {
                        listClinic.SetSelected(i + 1, true);
                    }
                    if (UserCur.ClinicNum != 0 && listUserClinics.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listClinicMulti.SetSelected(i, true);                       //No "All" option, don't select i+1
                    }
                    if (!isAllClinicsSubscribed && _listUserAlertTypesOld.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listAlertSubsClinicsMulti.SetSelected(i + 2, true);                     //All+HQ
                    }
                }
                checkClinicIsRestricted.Checked = UserCur.ClinicIsRestricted;
            }
            if (string.IsNullOrEmpty(UserCur.PasswordHash))
            {
                butPassword.Text = Lan.g(this, "Create Password");
            }
            if (!PrefC.IsODHQ)
            {
                butJobRoles.Visible = false;
            }
            if (IsNew)
            {
                butUnlock.Visible = false;
            }
            _listDoseSpotUserPrefOld = UserOdPrefs.GetByUserAndFkeyAndFkeyType(UserCur.UserNum,
                                                                               Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program,
                                                                               Clinics.GetForUserod(Security.CurUser, true).Select(x => x.ClinicNum)
                                                                               .Union(new List <long>()
            {
                0
            })                                                //Always include 0 clinic, this is the default, NOT a headquarters only value.
                                                                               .Distinct()
                                                                               .ToList());
            _listDoseSpotUserPrefNew = _listDoseSpotUserPrefOld.Select(x => x.Clone()).ToList();
            _doseSpotUserPrefDefault = _listDoseSpotUserPrefNew.Find(x => x.ClinicNum == 0);
            if (_doseSpotUserPrefDefault == null)
            {
                _doseSpotUserPrefDefault = DoseSpot.GetDoseSpotUserIdFromPref(UserCur.UserNum, 0);
                _listDoseSpotUserPrefNew.Add(_doseSpotUserPrefDefault);
            }
            textDoseSpotUserID.Text = _doseSpotUserPrefDefault.ValueString;
            if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true))
            {
                butPassword.Visible       = false;
                checkRequireReset.Checked = true;
                checkRequireReset.Enabled = false;
                butUnlock.Visible         = false;
                butJobRoles.Visible       = false;
            }
            if (!PrefC.HasClinicsEnabled)
            {
                butDoseSpotAdditional.Visible = false;
            }
        }
示例#11
0
        private static void ShowPendingDeletionReportForPatients(FormPrintReport fpr)
        {
            //Print the header on the report.
            Font   font = new Font(FontFamily.GenericMonospace, 12);
            string text = PrefC.GetString(PrefName.PracticeTitle);
            SizeF  size = fpr.Graph.MeasureString(text, font);
            float  y    = 20;

            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth / 2 - size.Width / 2, y);
            text = DateTime.Today.ToShortDateString();
            size = fpr.Graph.MeasureString(text, font);
            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth - size.Width, y);
            y   += size.Height;
            text = "PLANS PENDING DELETION WHICH REQUIRE YOUR ATTENTION";
            size = fpr.Graph.MeasureString(text, font);
            fpr.Graph.DrawString(text, font, Brushes.Black, fpr.GraphWidth / 2 - fpr.Graph.MeasureString(text, font).Width / 2, y);
            y   += size.Height;
            y   += 20;        //Skip a line or so.
            text = "INSTRUCTIONS: These plans no longer exist, please do not contact Trojan. Please contact your patient for current benefit information.";
            fpr.Graph.DrawString(text, new Font(font, FontStyle.Bold), Brushes.Black, new RectangleF(0, y, 650, 500));
            y   += 70;        //Skip a line or so.
            text = "Patient&Insured";
            font = new Font(font.FontFamily, 9);
            fpr.Graph.DrawString(text, font, Brushes.Black, 20, y);
            text = "TrojanID";
            fpr.Graph.DrawString(text, font, Brushes.Black, 240, y);
            text = "Employer";
            fpr.Graph.DrawString(text, font, Brushes.Black, 330, y);
            text = "Carrier";
            fpr.Graph.DrawString(text, font, Brushes.Black, 500, y);
            y += 20;
            //Use a static height for the records, to keep the math simple.
            float recordHeight  = 140;
            float recordSpacing = 10;

            //Calculate the total number of pages in the report the first time this function is called only.
            if (fpr.TotalPages == 0)
            {
                fpr.TotalPages = (int)Math.Ceiling((y + recordHeight * pendingDeletionTable.Rows.Count +
                                                    ((pendingDeletionTable.Rows.Count > 1)?pendingDeletionTable.Rows.Count - 1:0) * recordSpacing) / fpr.PageHeight);
            }
            float pageBoundry = fpr.PageHeight;

            for (int i = 0; i < pendingDeletionTable.Rows.Count; i++)
            {
                //Draw the outlines around this record.
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y), new PointF(fpr.GraphWidth - 1, y));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y + recordHeight), new PointF(fpr.GraphWidth - 1, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y), new PointF(0, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(fpr.GraphWidth - 1, y), new PointF(fpr.GraphWidth - 1, y + recordHeight));
                fpr.Graph.DrawLine(Pens.Black, new PointF(0, y + recordHeight - 40), new PointF(fpr.GraphWidth - 1, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(235, y), new PointF(235, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(325, y), new PointF(325, y + recordHeight - 40));
                fpr.Graph.DrawLine(Pens.Black, new PointF(500, y), new PointF(500, y + recordHeight - 40));
                //Install the information for the record into the outline box.
                //Patient name, Guarantor name, guarantor SSN, guarantor birthdate, insurance plan group number,
                //and reason for pending deletion.
                fpr.Graph.DrawString(
                    PIn.String(pendingDeletionTable.Rows[i][0].ToString()) + " " + PIn.String(pendingDeletionTable.Rows[i][1].ToString()) + Environment.NewLine +
                    PIn.String(pendingDeletionTable.Rows[i][2].ToString()) + " " + PIn.String(pendingDeletionTable.Rows[i][3].ToString()) + Environment.NewLine +
                    " SSN: " + PIn.String(pendingDeletionTable.Rows[i][4].ToString()) + Environment.NewLine +
                    " Birth: " + PIn.Date(pendingDeletionTable.Rows[i][5].ToString()).ToShortDateString() + Environment.NewLine +
                    " Group: " + PIn.String(pendingDeletionTable.Rows[i][6].ToString()), font, Brushes.Black,
                    new RectangleF(20, y + 5, 215, 95));
                //Pending deletion reason.
                for (int j = 0; j < deletePatientRecords.Count; j++)
                {
                    if (deletePatientRecords[j][0] == PIn.String(pendingDeletionTable.Rows[i][8].ToString()))
                    {
                        text = "REASON FOR DELETION: " + deletePatientRecords[j][7];
                        if (deletePatientRecords[j][1].ToUpper() == "F")
                        {
                            text = "FINALLY DELETED" + Environment.NewLine + text;
                        }
                        fpr.Graph.DrawString(text, font, Brushes.Black,
                                             new RectangleF(20, y + 100, fpr.GraphWidth - 40, 40));
                        break;
                    }
                }
                //Trojan ID.
                fpr.Graph.DrawString(PIn.String(pendingDeletionTable.Rows[i][8].ToString()), font, Brushes.Black, new RectangleF(240, y + 5, 85, 95));
                //Employer Name and Phone.
                fpr.Graph.DrawString(PIn.String(pendingDeletionTable.Rows[i][9].ToString()) + Environment.NewLine +
                                     PIn.String(pendingDeletionTable.Rows[i][10].ToString()), font, Brushes.Black, new RectangleF(330, y + 5, 170, 95));
                //Carrier Name and Phone
                fpr.Graph.DrawString(PIn.String(pendingDeletionTable.Rows[i][11].ToString()) + Environment.NewLine +
                                     PIn.String(pendingDeletionTable.Rows[i][12].ToString()), font, Brushes.Black,
                                     new RectangleF(500, y + 5, 150, 95));
                //Leave space between records.
                y += recordHeight + recordSpacing;
                //Watch out for the bottom of each page for the next record.
                if (y + recordHeight > pageBoundry)
                {
                    y            = pageBoundry + fpr.MarginBottom + 20;
                    pageBoundry += fpr.PageHeight + fpr.MarginBottom;
                    text         = "Patient&Insured";
                    font         = new Font(font.FontFamily, 9);
                    fpr.Graph.DrawString(text, font, Brushes.Black, 20, y);
                    text = "TrojanID";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 240, y);
                    text = "Employer";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 330, y);
                    text = "Carrier";
                    fpr.Graph.DrawString(text, font, Brushes.Black, 500, y);
                    y += 20;
                }
            }
        }
示例#12
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textUserName.Text == "")
            {
                MsgBox.Show(this, "Please enter a username.");
                return;
            }
            if (!_isFromAddUser && IsNew && PrefC.GetBool(PrefName.PasswordsMustBeStrong) && string.IsNullOrWhiteSpace(_passwordTyped))
            {
                MsgBox.Show(this, "Password may not be blank when the strong password feature is turned on.");
                return;
            }
            if (PrefC.HasClinicsEnabled && listClinic.SelectedIndex == -1)
            {
                MsgBox.Show(this, "This user does not have a User Default Clinic set.  Please choose one to continue.");
                return;
            }
            if (listUserGroup.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "Users must have at least one user group associated. Please select a user group to continue.");
                return;
            }
            if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true) &&
                (listUserGroup.SelectedItems.Count != 1 || listUserGroup.GetSelected <UserGroup>().UserGroupNum != PrefC.GetLong(PrefName.DefaultUserGroup)))
            {
                MsgBox.Show(this, "This user must be assigned to the default user group.");
                for (int i = 0; i < listUserGroup.Items.Count; i++)
                {
                    if (((ODBoxItem <UserGroup>)listUserGroup.Items[i]).Tag.UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup))
                    {
                        listUserGroup.SetSelected(i, true);
                    }
                    else
                    {
                        listUserGroup.SetSelected(i, false);
                    }
                }
                return;
            }
            List <UserClinic> listUserClinics = new List <UserClinic>();

            if (PrefC.HasClinicsEnabled && checkClinicIsRestricted.Checked)             //They want to restrict the user to certain clinics or clinics are enabled.
            {
                for (int i = 0; i < listClinicMulti.SelectedIndices.Count; i++)
                {
                    listUserClinics.Add(new UserClinic(_listClinics[listClinicMulti.SelectedIndices[i]].ClinicNum, UserCur.UserNum));
                }
                //If they set the user up with a default clinic and it's not in the restricted list, return.
                if (!listUserClinics.Exists(x => x.ClinicNum == _listClinics[listClinic.SelectedIndex - 1].ClinicNum))
                {
                    MsgBox.Show(this, "User cannot have a default clinic that they are not restricted to.");
                    return;
                }
            }
            if (!PrefC.HasClinicsEnabled || listClinic.SelectedIndex == 0)
            {
                UserCur.ClinicNum = 0;
            }
            else
            {
                UserCur.ClinicNum = _listClinics[listClinic.SelectedIndex - 1].ClinicNum;
            }
            UserCur.ClinicIsRestricted      = checkClinicIsRestricted.Checked;     //This is kept in sync with their choice of "All".
            UserCur.IsHidden                = checkIsHidden.Checked;
            UserCur.IsPasswordResetRequired = checkRequireReset.Checked;
            UserCur.UserName                = textUserName.Text;
            if (listEmployee.SelectedIndex == 0)
            {
                UserCur.EmployeeNum = 0;
            }
            else
            {
                UserCur.EmployeeNum = _listEmployees[listEmployee.SelectedIndex - 1].EmployeeNum;
            }
            if (listProv.SelectedIndex == 0)
            {
                Provider prov = Providers.GetProv(UserCur.ProvNum);
                if (prov != null)
                {
                    prov.IsInstructor = false;                  //If there are more than 1 users associated to this provider, they will no longer be an instructor.
                    Providers.Update(prov);
                }
                UserCur.ProvNum = 0;
            }
            else
            {
                Provider prov = Providers.GetProv(UserCur.ProvNum);
                if (prov != null)
                {
                    if (prov.ProvNum != _listProviders[listProv.SelectedIndex - 1].ProvNum)
                    {
                        prov.IsInstructor = false;                      //If there are more than 1 users associated to this provider, they will no longer be an instructor.
                    }
                    Providers.Update(prov);
                }
                UserCur.ProvNum = _listProviders[listProv.SelectedIndex - 1].ProvNum;
            }
            try{
                if (IsNew)
                {
                    Userods.Insert(UserCur, listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag.UserGroupNum).ToList());
                    //Set the userodprefs to the new user's UserNum that was just retreived from the database.
                    _listDoseSpotUserPrefNew.ForEach(x => x.UserNum = UserCur.UserNum);
                    listUserClinics.ForEach(x => x.UserNum          = UserCur.UserNum);         //Set the user clinic's UserNum to the one we just inserted.
                    SecurityLogs.MakeLogEntry(Permissions.AddNewUser, 0, "New user '" + UserCur.UserName + "' added");
                }
                else
                {
                    List <UserGroup> listNewUserGroups = listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag).ToList();
                    List <UserGroup> listOldUserGroups = UserCur.GetGroups();
                    Userods.Update(UserCur, listNewUserGroups.Select(x => x.UserGroupNum).ToList());
                    //if this is the current user, update the user, credentials, etc.
                    if (UserCur.UserNum == Security.CurUser.UserNum)
                    {
                        Security.CurUser = UserCur.Copy();
                        if (_passwordTyped != null)
                        {
                            Security.PasswordTyped = _passwordTyped;                           //update the password typed for middle tier refresh
                        }
                    }
                    //Log changes to the User's UserGroups.
                    Func <List <UserGroup>, List <UserGroup>, List <UserGroup> > funcGetMissing = (listCur, listCompare) => {
                        List <UserGroup> retVal = new List <UserGroup>();
                        foreach (UserGroup group in listCur)
                        {
                            if (listCompare.Exists(x => x.UserGroupNum == group.UserGroupNum))
                            {
                                continue;
                            }
                            retVal.Add(group);
                        }
                        return(retVal);
                    };
                    List <UserGroup> listRemovedGroups = funcGetMissing(listOldUserGroups, listNewUserGroups);
                    List <UserGroup> listAddedGroups   = funcGetMissing(listNewUserGroups, listOldUserGroups);
                    if (listRemovedGroups.Count > 0)                   //Only log if there are items in the list
                    {
                        SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "User " + UserCur.UserName +
                                                  " removed from User group(s): " + string.Join(", ", listRemovedGroups.Select(x => x.Description).ToArray()) + " by: " + Security.CurUser.UserName);
                    }
                    if (listAddedGroups.Count > 0)                   //Only log if there are items in the list.
                    {
                        SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, "User " + UserCur.UserName +
                                                  " added to User group(s): " + string.Join(", ", listAddedGroups.Select(x => x.Description).ToArray()) + " by: " + Security.CurUser.UserName);
                    }
                }
                if (UserClinics.Sync(listUserClinics, UserCur.UserNum))                //Either syncs new list, or clears old list if no longer restricted.
                {
                    DataValid.SetInvalid(InvalidType.UserClinics);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //DoseSpot User ID Insert/Update/Delete
            if (_doseSpotUserPrefDefault.ValueString != textDoseSpotUserID.Text)
            {
                if (string.IsNullOrWhiteSpace(textDoseSpotUserID.Text))
                {
                    UserOdPrefs.DeleteMany(_doseSpotUserPrefDefault.UserNum, _doseSpotUserPrefDefault.Fkey, UserOdFkeyType.Program);
                }
                else
                {
                    _doseSpotUserPrefDefault.ValueString = textDoseSpotUserID.Text.Trim();
                    UserOdPrefs.Upsert(_doseSpotUserPrefDefault);
                }
            }
            DataValid.SetInvalid(InvalidType.Security);
            //List of AlertTypes that are selected.
            List <long> listUserAlertCats = new List <long>();

            foreach (int index in listAlertSubMulti.SelectedIndices)
            {
                listUserAlertCats.Add(_listAlertCategories[index].AlertCategoryNum);
            }
            List <long> listClinics = new List <long>();

            foreach (int index in listAlertSubsClinicsMulti.SelectedIndices)
            {
                if (index == 0)               //All
                {
                    listClinics.Add(-1);      //Add All
                    break;
                }
                if (index == 1)               //HQ
                {
                    listClinics.Add(0);
                    continue;
                }
                Clinic clinic = _listClinics[index - 2];            //Subtract 2 for 'All' and 'HQ'
                listClinics.Add(clinic.ClinicNum);
            }
            List <AlertSub> _listUserAlertTypesNew = _listUserAlertTypesOld.Select(x => x.Copy()).ToList();

            //Remove AlertTypes that have been deselected through either deslecting the type or clinic.
            _listUserAlertTypesNew.RemoveAll(x => !listUserAlertCats.Contains(x.AlertCategoryNum));
            if (PrefC.HasClinicsEnabled)
            {
                _listUserAlertTypesNew.RemoveAll(x => !listClinics.Contains(x.ClinicNum));
            }
            foreach (long alertCatNum in listUserAlertCats)
            {
                if (!PrefC.HasClinicsEnabled)
                {
                    if (!_listUserAlertTypesOld.Exists(x => x.AlertCategoryNum == alertCatNum))                   //Was not subscribed to type.
                    {
                        _listUserAlertTypesNew.Add(new AlertSub(UserCur.UserNum, 0, alertCatNum));
                    }
                }
                else                  //Clinics enabled.
                {
                    foreach (long clinicNumCur in listClinics)
                    {
                        if (!_listUserAlertTypesOld.Exists(x => x.ClinicNum == clinicNumCur && x.AlertCategoryNum == alertCatNum))                     //Was not subscribed to type.
                        {
                            _listUserAlertTypesNew.Add(new AlertSub(UserCur.UserNum, clinicNumCur, alertCatNum));
                            continue;
                        }
                    }
                }
            }
            AlertSubs.Sync(_listUserAlertTypesNew, _listUserAlertTypesOld);
            UserOdPrefs.Sync(_listDoseSpotUserPrefNew, _listDoseSpotUserPrefOld);
            DialogResult = DialogResult.OK;
        }
示例#13
0
        ///<summary>Most of the logic for breaking an appointment. Pass in the brokenFee (the number the user enters in the brokenAppointment window),
        ///Optionally pass in if the brokenappointment procedure is being deleted. Returns the broken procedure that was created.</summary>
        public static Procedure BreakAppointment(Appointment appt, Patient pat, ProcedureCode procCode, double feeOverride, bool isDeleteBrokenProc = false)
        {
            //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 == "D9986" || procCode.ProcCode == "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);
            }
            List <Procedure> listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false);
            //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;

            if (listProcedures.Count > 0)
            {
                listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList());
            }
            Procedure brokenProcedure = new Procedure();

            #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
                {
                    brokenProcedure.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    brokenProcedure.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(brokenProcedure);
                Procedure procOld = brokenProcedure.Copy();
                //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);
                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.
                    //normally goes to the form to let the user speficy, this is the auto filled amount for the form.
                    brokenProcedure.ProcFee = feeOverride;                  //listSplitsForApptProcs.Sum(x => x.SplitAmt);
                    isNonRefundable         = true;
                }
                if (isDeleteBrokenProc)
                {
                    brokenProcedure.ProcStatus = ProcStat.D;
                }
                brokenProcedure.ProcFee = feeOverride;
                brokenProcAmount        = feeOverride;
                Procedures.Update(brokenProcedure, procOld);
            }
            #endregion
            //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure.
            if (isNonRefundable && !isDeleteBrokenProc && 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);
                        brokenProcAmount -= amt;
                    }
                }
            }
            return(brokenProcedure);
        }
示例#14
0
        ///<summary>Creates a patient.  Practice default provider and billing type.</summary>
        public static Patient CreatePatient(string suffix = "", long priProvNum = 0, long clinicNum = 0, string email = "", string phone = "",
                                            ContactMethod contactMethod = ContactMethod.Email, string lName = "", string fName = "", string preferredName  = "", DateTime birthDate                   = default(DateTime)
                                            , long secProvNum           = 0, long guarantor = 0, bool setPortalAccessInfo = false, PatientStatus patStatus = PatientStatus.Patient, bool hasSignedTil = false)
        {
            Patient pat = new Patient {
                Email = email,
                PreferConfirmMethod       = contactMethod,
                PreferContactConfidential = contactMethod,
                PreferContactMethod       = contactMethod,
                PreferRecallMethod        = contactMethod,
                HmPhone       = phone,
                WirelessPhone = phone,
                IsNew         = true,
                LName         = lName + suffix,
                FName         = fName + suffix,
                BillingType   = PrefC.GetLong(PrefName.PracticeDefaultBillType),
                ClinicNum     = clinicNum,
                Preferred     = preferredName,
                Birthdate     = birthDate,
                SecProv       = secProvNum,
                PatStatus     = patStatus,
                HasSignedTil  = hasSignedTil,
            };

            if (priProvNum != 0)
            {
                pat.PriProv = priProvNum;
            }
            else
            {
                long practiceProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv);
                //Check the provider cache to see if the ProvNum set for the PracticeDefaultProv pref actually exists.
                if (!Providers.GetExists(x => x.ProvNum == practiceProvNum))
                {
                    practiceProvNum = Providers.GetFirst().ProvNum;
                    //Update the preference in the database NOT the unit test preference cache to a valid provider if the current pref value is invalid.
                    Prefs.UpdateLong(PrefName.PracticeDefaultProv, practiceProvNum);
                }
                pat.PriProv = practiceProvNum;
            }
            if (setPortalAccessInfo)
            {
                pat.Address = "666 Church St NE";
                pat.City    = "Salem";
                pat.State   = "OR";
                pat.Zip     = "97301";
                if (pat.Birthdate.Year < 1880)
                {
                    pat.Birthdate = new DateTime(1970, 1, 1);
                }
                if (string.IsNullOrEmpty(pat.WirelessPhone))
                {
                    pat.WirelessPhone = "5555555555";
                }
            }
            Patients.Insert(pat, false);
            Patient oldPatient = pat.Copy();

            pat.Guarantor = pat.PatNum;
            if (guarantor > 0)
            {
                pat.Guarantor = guarantor;
            }
            if (lName == "")
            {
                pat.LName = pat.PatNum.ToString() + "L";
            }
            if (fName == "")
            {
                pat.FName = pat.PatNum.ToString() + "F";
            }
            Patients.Update(pat, oldPatient);
            return(pat);
        }
示例#15
0
        private void listLetters_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (listLetters.SelectedIndex == -1)
            {
                return;
            }
            if (!WarnOK())
            {
                return;
            }
            LetterCur = _listLetters[listLetters.SelectedIndex];
            StringBuilder str = new StringBuilder();

            //return address
            //if (checkIncludeRet.Checked) {
            str.Append(PrefC.GetString(PrefName.PracticeTitle) + "\r\n");
            str.Append(PrefC.GetString(PrefName.PracticeAddress) + "\r\n");
            if (PrefC.GetString(PrefName.PracticeAddress2) != "")
            {
                str.Append(PrefC.GetString(PrefName.PracticeAddress2) + "\r\n");
            }
            str.Append(PrefC.GetString(PrefName.PracticeCity) + ", ");
            str.Append(PrefC.GetString(PrefName.PracticeST) + "  ");
            str.Append(PrefC.GetString(PrefName.PracticeZip) + "\r\n");
            //}
            //else {
            //	str.Append("\r\n\r\n\r\n\r\n");
            //}
            str.Append("\r\n\r\n");
            //address
            if (ReferralCur == null)
            {
                str.Append(PatCur.FName + " " + PatCur.MiddleI + " " + PatCur.LName + "\r\n");
                str.Append(PatCur.Address + "\r\n");
                if (PatCur.Address2 != "")
                {
                    str.Append(PatCur.Address2 + "\r\n");
                }
                str.Append(PatCur.City + ", " + PatCur.State + "  " + PatCur.Zip);
            }
            else
            {
                str.Append(Referrals.GetNameFL(ReferralCur.ReferralNum) + "\r\n");
                str.Append(ReferralCur.Address + "\r\n");
                if (ReferralCur.Address2 != "")
                {
                    str.Append(ReferralCur.Address2 + "\r\n");
                }
                str.Append(ReferralCur.City + ", " + ReferralCur.ST + "  " + ReferralCur.Zip);
            }
            str.Append("\r\n\r\n\r\n\r\n");
            //date
            str.Append(DateTimeOD.Today.ToLongDateString() + "\r\n");
            //referral RE
            if (ReferralCur != null)
            {
                str.Append(Lan.g(this, "RE Patient: ") + PatCur.GetNameFL() + "\r\n");
            }
            str.Append("\r\n");
            //greeting
            str.Append(Lan.g(this, "Dear "));
            if (ReferralCur == null)
            {
                if (CultureInfo.CurrentCulture.Name == "en-GB")
                {
                    if (PatCur.Salutation != "")
                    {
                        str.Append(PatCur.Salutation);
                    }
                    else
                    {
                        if (PatCur.Gender == PatientGender.Female)
                        {
                            str.Append("Ms. " + PatCur.LName);
                        }
                        else
                        {
                            str.Append("Mr. " + PatCur.LName);
                        }
                    }
                }
                else
                {
                    if (PatCur.Salutation != "")
                    {
                        str.Append(PatCur.Salutation);
                    }
                    else if (PatCur.Preferred != "")
                    {
                        str.Append(PatCur.Preferred);
                    }
                    else
                    {
                        str.Append(PatCur.FName);
                    }
                }
            }
            else              //referral
            {
                str.Append(ReferralCur.FName);
            }
            str.Append(",\r\n\r\n");
            //body text
            str.Append(LetterCur.BodyText);
            //closing
            if (CultureInfo.CurrentCulture.Name == "en-GB")
            {
                str.Append("\r\n\r\nYours sincerely,\r\n\r\n\r\n\r\n");
            }
            else
            {
                str.Append("\r\n\r\n" + Lan.g(this, "Sincerely,") + "\r\n\r\n\r\n\r\n");
            }
            if (PrefC.GetBool(PrefName.FuchsOptionsOn))
            {
                str.Append("Dr. Fuchs");
            }
            else
            {
                str.Append(PrefC.GetString(PrefName.PracticeTitle));
            }
            textBody.Text = str.ToString();
            //bodyChanged = false;
        }
示例#16
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!Validation())
            {
                return;
            }
            ReportComplex report     = new ReportComplex(true, false);
            DataTable     tableAging = RpAging.GetAgingTable(GetParamsFromForm());

            report.IsLandscape = checkHasDateLastPay.Checked;
            report.ReportName  = Lan.g(this, "AGING OF ACCOUNTS RECEIVABLE REPORT");
            report.AddTitle("Aging Report", Lan.g(this, "AGING OF ACCOUNTS RECEIVABLE"));
            report.AddSubTitle("PracTitle", PrefC.GetString(PrefName.PracticeTitle));
            report.AddSubTitle("AsOf", Lan.g(this, "As of ") + textDate.Text);
            if (radioAny.Checked)
            {
                report.AddSubTitle("Balance", Lan.g(this, "Any Balance"));
            }
            if (radio30.Checked)
            {
                report.AddSubTitle("Over30", Lan.g(this, "Over 30 Days"));
            }
            if (radio60.Checked)
            {
                report.AddSubTitle("Over60", Lan.g(this, "Over 60 Days"));
            }
            if (radio90.Checked)
            {
                report.AddSubTitle("Over90", Lan.g(this, "Over 90 Days"));
            }
            if (checkBillTypesAll.Checked)
            {
                report.AddSubTitle("AllBillingTypes", Lan.g(this, "All Billing Types"));
            }
            else
            {
                report.AddSubTitle("", string.Join(", ", listBillType.SelectedIndices.OfType <int>().Select(x => _listBillingTypeDefs[x].ItemName)));
            }
            if (checkProvAll.Checked)
            {
                report.AddSubTitle("Providers", Lan.g(this, "All Providers"));
            }
            else
            {
                report.AddSubTitle("Providers", string.Join(", ", listProv.SelectedIndices.OfType <int>().Select(x => _listProviders[x].Abbr)));
            }
            if (checkAllClin.Checked)
            {
                report.AddSubTitle("Clinics", Lan.g(this, "All Clinics"));
            }
            else
            {
                report.AddSubTitle("Clinics", string.Join(", ", listClin.SelectedTags <Clinic>().Select(x => x.Abbr)));
            }
            //Patient Account Aging Query-----------------------------------------------
            bool isWoEstIncluded = true;

            if (checkAgeWriteoffs.Checked && tableAging.Select().All(x => Math.Abs(PIn.Double(x["InsWoEst"].ToString())) <= 0.005))
            {
                tableAging.Columns.Remove("InsWoEst");
                isWoEstIncluded = false;
            }
            QueryObject query = report.AddQuery(tableAging, "Date " + DateTime.Today.ToShortDateString());

            query.AddColumn((radioGroupByFam.Checked?"Guarantor":"Patient"), 160, FieldValueType.String);
            query.AddColumn("0-30 Days", 75, FieldValueType.Number);
            query.AddColumn("31-60 Days", 75, FieldValueType.Number);
            query.AddColumn("61-90 Days", 75, FieldValueType.Number);
            query.AddColumn("> 90 Days", 75, FieldValueType.Number);
            query.AddColumn("Total", 80, FieldValueType.Number);
            if (isWoEstIncluded)
            {
                query.AddColumn("-W/O " + (checkAgeWriteoffs.Checked?"Change":"Est"), 85, FieldValueType.Number);
            }
            query.AddColumn("-Ins Est", 75, FieldValueType.Number);
            query.AddColumn("=Patient", 80, FieldValueType.Number);
            if (checkHasDateLastPay.Checked)
            {
                query.AddColumn("", 10);               //add some space between the right alligned amounts and the left alligned date
                query.AddColumn("Last Pay Date", 90, FieldValueType.Date);
            }
            report.AddPageNum();
            report.AddGridLines();
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
            DialogResult = DialogResult.OK;
        }
        //Copied from FormRpOutstandingIns.cs
        private void butExport_Click(object sender, System.EventArgs e)
        {
            string fileName = Lan.g(this, "Unfinalized Insurance Payments");
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
                filePath += ".txt";              //Provide the filepath an extension so that Thinfinity can offer as a download.
            }
            else
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.AddExtension = true;
                saveFileDialog.FileName     = fileName;
                if (!Directory.Exists(PrefC.GetString(PrefName.ExportPath)))
                {
                    try {
                        Directory.CreateDirectory(PrefC.GetString(PrefName.ExportPath));
                        saveFileDialog.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                    }
                    catch {
                        //initialDirectory will be blank
                    }
                }
                else
                {
                    saveFileDialog.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                }
                saveFileDialog.Filter      = "Text files(*.txt)|*.txt|Excel Files(*.xls)|*.xls|All files(*.*)|*.*";
                saveFileDialog.FilterIndex = 0;
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog.FileName;
            }
            try {
                using (StreamWriter sw = new StreamWriter(filePath, false))
                {
                    String line = "";
                    for (int i = 0; i < gridMain.ListGridColumns.Count; i++)
                    {
                        line += gridMain.ListGridColumns[i].Heading + "\t";
                    }
                    sw.WriteLine(line);
                    for (int i = 0; i < gridMain.ListGridRows.Count; i++)
                    {
                        line = "";
                        for (int j = 0; j < gridMain.ListGridColumns.Count; j++)
                        {
                            line += gridMain.ListGridRows[i].Cells[j].Text;
                            if (j < gridMain.ListGridColumns.Count - 1)
                            {
                                line += "\t";
                            }
                        }
                        sw.WriteLine(line);
                    }
                }
            }
            catch {
                MessageBox.Show(Lan.g(this, "File in use by another program.  Close and try again."));
                return;
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show(Lan.g(this, "File created successfully"));
            }
        }
示例#18
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date first.");
                return;
            }
            if (PIn.Date(textDate.Text) > DateTime.Today && !PrefC.GetBool(PrefName.FutureTransDatesAllowed) &&
                !PrefC.GetBool(PrefName.AllowFutureInsPayments))
            {
                MsgBox.Show(this, "Payments cannot be for a date in the future.");
                return;                 //probably not necesasary since this is an old form, but just in case we use it again
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "At least one item must be selected, or use the delete button."));
                return;
            }
            if (IsNew)
            {
                //prevents backdating of initial check
                if (!Security.IsAuthorized(Permissions.InsPayCreate, PIn.Date(textDate.Text)))
                {
                    return;
                }
                //prevents attaching claimprocs with a date that is older than allowed by security.
            }
            else
            {
                //Editing an old entry will already be blocked if the date was too old, and user will not be able to click OK button.
                //This catches it if user changed the date to be older.
                if (!Security.IsAuthorized(Permissions.InsPayEdit, PIn.Date(textDate.Text)))
                {
                    return;
                }
            }
            if (comboClinic.SelectedIndex == 0)
            {
                ClaimPaymentCur.ClinicNum = 0;
            }
            else
            {
                ClaimPaymentCur.ClinicNum = _listClinics[comboClinic.SelectedIndex - 1].ClinicNum;
            }
            ClaimPaymentCur.CheckAmt    = PIn.Double(textAmount.Text);
            ClaimPaymentCur.CheckDate   = PIn.Date(textDate.Text);
            ClaimPaymentCur.CheckNum    = textCheckNum.Text;
            ClaimPaymentCur.BankBranch  = textBankBranch.Text;
            ClaimPaymentCur.CarrierName = textCarrierName.Text;
            ClaimPaymentCur.Note        = textNote.Text;
            try{
                ClaimPayments.Update(ClaimPaymentCur);                //error thrown if trying to change amount and already attached to a deposit.
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //this could be optimized to only save changes.
            //Would require a starting list to compare to.
            //But this isn't bad, since changes all saved at the very end
            List <int> selectedRows = new List <int>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                selectedRows.Add(gridMain.SelectedIndices[i]);
            }
            for (int i = 0; i < splits.Count; i++)
            {
                if (selectedRows.Contains(i))                //row is selected
                {
                    ClaimProcs.SetForClaimOld(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate, true);
                    //Audit trail isn't perfect, since it doesn't make an entry if you remove a claim from a payment.
                    //And it always makes more audit trail entries when you click OK, even if you didn't actually attach new claims.
                    //But since this will cover the vast majority if situations.
                    if (IsNew)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.InsPayCreate, splits[i].PatNum,
                                                  Patients.GetLim(splits[i].PatNum).GetNameLF() + ", "
                                                  + Lan.g(this, "Total Amt: ") + ClaimPaymentCur.CheckAmt.ToString("c") + ", "
                                                  + Lan.g(this, "Claim Split: ") + splits[i].InsPayAmt.ToString("c"));
                    }
                    else
                    {
                        SecurityLogs.MakeLogEntry(Permissions.InsPayEdit, splits[i].PatNum,
                                                  Patients.GetLim(splits[i].PatNum).GetNameLF() + ", "
                                                  + Lan.g(this, "Total Amt: ") + ClaimPaymentCur.CheckAmt.ToString("c") + ", "
                                                  + Lan.g(this, "Claim Split: ") + splits[i].InsPayAmt.ToString("c"));
                    }
                }
                else                 //row not selected
                                     //If user had not been attaching their inspayments to checks, then this will cause such payments to annoyingly have their
                                     //date changed to the current date.  This prompts them to call us.  Then, we tell them to attach to checks.
                {
                    ClaimProcs.SetForClaimOld(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate, false);
                }
            }
            DialogResult = DialogResult.OK;
        }
示例#19
0
        private void FillGrid()
        {
            Recalls.Synch(PatNum);
            Recalls.SynchScheduledApptFull(PatNum);
            RecallList = Recalls.GetList(PatNum);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRecallsPat", "Type"), 90);

            gridMain.Columns.Add(col);
            //col=new ODGridColumn(Lan.g("TableRecallsPat","Disabled"),60,HorizontalAlignment.Center);
            //gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "PreviousDate"), 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "Due Date"), 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "Sched Date"), 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "Interval"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "Status"), 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRecallsPat", "Note"), 100);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow  row;
            ODGridCell cell;

            IsPerio       = false;
            butPerio.Text = Lan.g(this, "Set Perio");
            string cellStr;

            for (int i = 0; i < RecallList.Count; i++)
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallList[i].RecallTypeNum)
                {
                    IsPerio       = true;
                    butPerio.Text = Lan.g(this, "Set Prophy");
                }
                row = new ODGridRow();
                row.Cells.Add(RecallTypes.GetDescription(RecallList[i].RecallTypeNum));
                //if(RecallList[i].IsDisabled){
                //	row.Cells.Add("X");
                //}
                //else{
                //	row.Cells.Add("");
                //}
                if (RecallList[i].DatePrevious.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(RecallList[i].DatePrevious.ToShortDateString());
                }
                if (RecallList[i].DateDue.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    cell = new ODGridCell(RecallList[i].DateDue.ToShortDateString());
                    if (RecallList[i].DateDue < DateTime.Today)
                    {
                        cell.Bold      = YN.Yes;
                        cell.ColorText = Color.Firebrick;
                    }
                    row.Cells.Add(cell);
                }
                if (RecallList[i].DateScheduled.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(RecallList[i].DateScheduled.ToShortDateString());
                }
                row.Cells.Add(RecallList[i].RecallInterval.ToString());
                row.Cells.Add(DefC.GetValue(DefCat.RecallUnschedStatus, RecallList[i].RecallStatus));
                cellStr = "";
                if (RecallList[i].IsDisabled)
                {
                    cellStr += Lan.g(this, "Disabled");
                }
                if (RecallList[i].DisableUntilDate.Year > 1880)
                {
                    if (cellStr != "")
                    {
                        cellStr += ", ";
                    }
                    cellStr += Lan.g(this, "Disabled until ") + RecallList[i].DisableUntilDate.ToShortDateString();
                }
                if (RecallList[i].DisableUntilBalance > 0)
                {
                    if (cellStr != "")
                    {
                        cellStr += ", ";
                    }
                    cellStr += Lan.g(this, "Disabled until balance ") + RecallList[i].DisableUntilBalance.ToString("c");
                }
                if (RecallList[i].Note != "")
                {
                    if (cellStr != "")
                    {
                        cellStr += ", ";
                    }
                    cellStr += RecallList[i].Note;
                }
                row.Cells.Add(cellStr);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
示例#20
0
        private void FormVaccinePatEdit_Load(object sender, EventArgs e)
        {
            Patient pat = Patients.GetLim(VaccinePatCur.PatNum);

            if (pat.Age != 0 && pat.Age < 3)
            {
                labelDocument.Text = "Document reason not given below.  Reason can include a contraindication due to a specific allergy, adverse effect, intollerance, or specific disease.";              //less leeway with reasons for kids.
            }
            comboVaccine.Items.Clear();
            for (int i = 0; i < VaccineDefs.Listt.Count; i++)
            {
                comboVaccine.Items.Add(VaccineDefs.Listt[i].CVXCode + " - " + VaccineDefs.Listt[i].VaccineName);
                if (VaccineDefs.Listt[i].VaccineDefNum == VaccinePatCur.VaccineDefNum)
                {
                    comboVaccine.SelectedIndex = i;
                }
            }
            if (!IsNew && VaccinePatCur.VaccineDefNum != 0)
            {
                VaccineDef       vaccineDef   = VaccineDefs.GetOne(VaccinePatCur.VaccineDefNum);      //Need vaccine to get manufacturer.
                DrugManufacturer manufacturer = DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
                textManufacturer.Text = manufacturer.ManufacturerCode + " - " + manufacturer.ManufacturerName;
            }
            if (VaccinePatCur.DateTimeStart.Year > 1880)
            {
                textDateTimeStart.Text = VaccinePatCur.DateTimeStart.ToString();
            }
            if (VaccinePatCur.DateTimeEnd.Year > 1880)
            {
                textDateTimeStop.Text = VaccinePatCur.DateTimeEnd.ToString();
            }
            if (VaccinePatCur.AdministeredAmt != 0)
            {
                textAmount.Text = VaccinePatCur.AdministeredAmt.ToString();
            }
            comboUnits.Items.Clear();
            comboUnits.Items.Add("none");
            comboUnits.SelectedIndex = 0;
            for (int i = 0; i < DrugUnits.Listt.Count; i++)
            {
                comboUnits.Items.Add(DrugUnits.Listt[i].UnitIdentifier);
                if (DrugUnits.Listt[i].DrugUnitNum == VaccinePatCur.DrugUnitNum)
                {
                    comboUnits.SelectedIndex = i + 1;
                }
            }
            textLotNum.Text = VaccinePatCur.LotNumber;
            if (VaccinePatCur.DateExpire.Year > 1880)
            {
                textDateExpiration.Text = VaccinePatCur.DateExpire.ToShortDateString();
            }
            listRefusalReason.Items.Clear();
            string[] arrayVaccineRefusalReasons = Enum.GetNames(typeof(VaccineRefusalReason));
            for (int i = 0; i < arrayVaccineRefusalReasons.Length; i++)
            {
                listRefusalReason.Items.Add(arrayVaccineRefusalReasons[i]);
                VaccineRefusalReason refusalReason = (VaccineRefusalReason)i;
                if (refusalReason == VaccinePatCur.RefusalReason)
                {
                    listRefusalReason.SelectedIndex = i;
                }
            }
            listCompletionStatus.Items.Clear();
            string[] arrayCompletionStatuses = Enum.GetNames(typeof(VaccineCompletionStatus));
            for (int i = 0; i < arrayCompletionStatuses.Length; i++)
            {
                listCompletionStatus.Items.Add(arrayCompletionStatuses[i]);
                VaccineCompletionStatus completionStatus = (VaccineCompletionStatus)i;
                if (completionStatus == VaccinePatCur.CompletionStatus)
                {
                    listCompletionStatus.SelectedIndex = i;
                }
            }
            textNote.Text = VaccinePatCur.Note;
            if (IsNew)
            {
                if (pat.ClinicNum == 0)
                {
                    VaccinePatCur.FilledCity = PrefC.GetString(PrefName.PracticeCity);
                    VaccinePatCur.FilledST   = PrefC.GetString(PrefName.PracticeST);
                }
                else
                {
                    Clinic clinic = Clinics.GetClinic(pat.ClinicNum);
                    VaccinePatCur.FilledCity = clinic.City;
                    VaccinePatCur.FilledST   = clinic.State;
                }
            }
            textFilledCity.Text = VaccinePatCur.FilledCity;
            textFilledSt.Text   = VaccinePatCur.FilledST;
            if (IsNew)
            {
                VaccinePatCur.UserNum = Security.CurUser.UserNum;
            }
            Userod user = Userods.GetUser(VaccinePatCur.UserNum);

            if (user != null)           //Will be null for vaccines entered in older versions, before the UserNum column was created.
            {
                textUser.Text = user.UserName;
            }
            _provNumSelectedOrdering = VaccinePatCur.ProvNumOrdering;
            comboProvNumOrdering.Items.Clear();
            for (int i = 0; i < ProviderC.ListShort.Count; i++)
            {
                comboProvNumOrdering.Items.Add(ProviderC.ListShort[i].GetLongDesc());                //Only visible provs added to combobox.
                if (ProviderC.ListShort[i].ProvNum == VaccinePatCur.ProvNumOrdering)
                {
                    comboProvNumOrdering.SelectedIndex = i;                  //Sets combo text too.
                }
            }
            if (comboProvNumOrdering.SelectedIndex == -1)                                    //The provider exists but is hidden
            {
                comboProvNumOrdering.Text = Providers.GetLongDesc(_provNumSelectedOrdering); //Appends "(hidden)" to the end of the long description.
            }
            _provNumSelectedAdministering = VaccinePatCur.ProvNumAdminister;
            comboProvNumAdministering.Items.Clear();
            for (int i = 0; i < ProviderC.ListShort.Count; i++)
            {
                comboProvNumAdministering.Items.Add(ProviderC.ListShort[i].GetLongDesc());                //Only visible provs added to combobox.
                if (ProviderC.ListShort[i].ProvNum == VaccinePatCur.ProvNumAdminister)
                {
                    comboProvNumAdministering.SelectedIndex = i;                  //Sets combo text too.
                }
            }
            if (comboProvNumAdministering.SelectedIndex == -1)                                         //The provider exists but is hidden
            {
                comboProvNumAdministering.Text = Providers.GetLongDesc(_provNumSelectedAdministering); //Appends "(hidden)" to the end of the long description.
            }
            comboAdministrationRoute.Items.Clear();
            string[] arrayVaccineAdministrationRoutes = Enum.GetNames(typeof(VaccineAdministrationRoute));
            for (int i = 0; i < arrayVaccineAdministrationRoutes.Length; i++)
            {
                comboAdministrationRoute.Items.Add(arrayVaccineAdministrationRoutes[i]);
                VaccineAdministrationRoute administrationRoute = (VaccineAdministrationRoute)i;
                if (administrationRoute == VaccinePatCur.AdministrationRoute)
                {
                    comboAdministrationRoute.SelectedIndex = i;
                }
            }
            comboAdministrationSite.Items.Clear();
            string[] arrayVaccineAdministrationSites = Enum.GetNames(typeof(VaccineAdministrationSite));
            for (int i = 0; i < arrayVaccineAdministrationSites.Length; i++)
            {
                comboAdministrationSite.Items.Add(arrayVaccineAdministrationSites[i]);
                VaccineAdministrationSite administrationSite = (VaccineAdministrationSite)i;
                if (administrationSite == VaccinePatCur.AdministrationSite)
                {
                    comboAdministrationSite.SelectedIndex = i;
                }
            }
            listAdministrationNote.Items.Clear();
            string[] arrayAdministrationNotes = Enum.GetNames(typeof(VaccineAdministrationNote));
            for (int i = 0; i < arrayAdministrationNotes.Length; i++)
            {
                listAdministrationNote.Items.Add(arrayAdministrationNotes[i]);
                VaccineAdministrationNote administrationNote = (VaccineAdministrationNote)i;
                if (administrationNote == VaccinePatCur.AdministrationNoteCode)
                {
                    listAdministrationNote.SelectedIndex = i;
                }
            }
            listAction.Items.Clear();
            string[] arrayVaccineActions = Enum.GetNames(typeof(VaccineAction));
            for (int i = 0; i < arrayVaccineActions.Length; i++)
            {
                listAction.Items.Add(arrayVaccineActions[i]);
                VaccineAction action = (VaccineAction)i;
                if (action == VaccinePatCur.ActionCode)
                {
                    listAction.SelectedIndex = i;
                }
            }
            _listVaccineObservations = VaccineObses.GetForVaccine(VaccinePatCur.VaccinePatNum);
            FillObservations();
        }
示例#21
0
        private void butRetrieve_Click(object sender, EventArgs e)
        {
            if (comboClearhouse.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a clearinghouse first.");
                return;
            }
            if (!MsgBox.Show(this, true, "Connect to clearinghouse to retrieve reports?"))
            {
                return;
            }
            Clearinghouse clearhouseHq      = _listHqClearinghouses[comboClearhouse.SelectedIndex];
            Clearinghouse clearinghouseClin = Clearinghouses.OverrideFields(clearhouseHq, Clinics.ClinicNum);

            if (!Directory.Exists(clearinghouseClin.ResponsePath))
            {
                MsgBox.Show(this, "Clearinghouse does not have a valid Report Path set.");
                return;
            }
            ODProgressExtended progressbar = new ODProgressExtended(ClearinghouseEvent.Name, new ClearinghouseEvent(), this
                                                                    , new ProgressBarHelper((Lans.g(this, "Clearinghouse Progress")), progressBarEventType: ProgBarEventType.Header), lanThis: this.Name);

            //For Tesia, user wouldn't normally manually retrieve.
            if (clearhouseHq.ISA08 == "113504607")
            {
                if ((PrefC.RandomKeys && !PrefC.GetBool(PrefName.EasyNoClinics)) ||            //See FormClaimsSend_Load
                    PrefC.GetLong(PrefName.ClearinghouseDefaultDent) != clearhouseHq.ClearinghouseNum)                      //default
                {
                    //But they might need to in these situations.
                    string errorMessage = Clearinghouses.RetrieveAndImport(clearinghouseClin, false, progressbar);
                    progressbar.UpdateProgressDetailed("", tagString: "reports", percentVal: "100%", barVal: 100);
                    if (errorMessage == "")
                    {
                        progressbar.UpdateProgress(Lan.g(this, "Retrieval and import successful"));
                    }
                    else
                    {
                        progressbar.UpdateProgress(errorMessage);
                    }
                    progressbar.UpdateProgress(Lan.g(this, "Done"));
                }
                else
                {
                    progressbar.UpdateProgress(Lan.g(this, "No need to retrieve. Available reports are automatically downloaded every three minutes."));
                }
                progressbar.OnProgressDone();
                return;
            }
            if (clearhouseHq.CommBridge == EclaimsCommBridge.None || clearhouseHq.CommBridge == EclaimsCommBridge.Renaissance ||
                clearhouseHq.CommBridge == EclaimsCommBridge.RECS)
            {
                progressbar.UpdateProgress(Lan.g(this, "No built-in functionality for retrieving reports from this clearinghouse."));
                progressbar.OnProgressDone();
                return;
            }
            labelRetrieving.Visible = true;
            string errorMesssage = Clearinghouses.RetrieveAndImport(clearinghouseClin, false, progressbar);

            progressbar.UpdateProgressDetailed("", tagString: "reports", percentVal: "100%", barVal: 100);
            if (clearhouseHq.CommBridge == EclaimsCommBridge.ClaimConnect && errorMesssage == "" && Directory.Exists(clearinghouseClin.ResponsePath))
            {
                //Since the dentalxchange website was successfully launched in this scenario, the user does not need any further notification.
            }
            else if (errorMesssage == "")
            {
                progressbar.UpdateProgress(Lan.g(this, "Retrieve and import successful."));
            }
            else
            {
                progressbar.UpdateProgress(Lans.g(progressbar.LanThis, "Error Log:") + "\r\n" + errorMesssage);
            }
            labelRetrieving.Visible = false;
            progressbar.OnProgressDone();
            if (progressbar.IsCanceled)             //close
            {
                progressbar.Close();
            }
        }
示例#22
0
        private void FillGrid()
        {
            long selectedProvNum = 0;

            if (gridMain.SelectedIndices.Length == 1)
            {
                selectedProvNum = PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["ProvNum"].ToString());
            }
            int scroll = gridMain.ScrollValue;

            Cache.Refresh(InvalidType.Providers);
            long schoolClass = 0;

            if (groupDentalSchools.Visible && comboClass.SelectedIndex > 0)
            {
                schoolClass = SchoolClasses.List[comboClass.SelectedIndex - 1].SchoolClassNum;
            }
            bool isAlph = false;

            if (groupDentalSchools.Visible && checkAlphabetical.Checked)
            {
                isAlph = true;
            }
            table = Providers.Refresh(schoolClass, isAlph);
            //fix orders
            bool doFix = false;

            if (groupDentalSchools.Visible)
            {
                if (checkAlphabetical.Checked)
                {
                    doFix = false;
                }
                else if (comboClass.SelectedIndex == 0)
                {
                    doFix = false;
                }
                else
                {
                    doFix = true;
                }
            }
            else
            {
                doFix = true;
            }
            if (doFix)
            {
                bool     neededFixing = false;
                Provider prov;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (table.Rows[i]["ItemOrder"].ToString() != i.ToString())
                    {
                        prov           = Providers.GetProv(PIn.Long(table.Rows[i]["ProvNum"].ToString()));
                        prov.ItemOrder = i;
                        Providers.Update(prov);
                    }
                }
                if (neededFixing)
                {
                    DataValid.SetInvalid(InvalidType.Providers);
                    table = Providers.Refresh(schoolClass, isAlph);
                }
            }
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableProviders", "Abbrev"), 90);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "Last Name"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "First Name"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "User Name"), 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableProviders", "Hidden"), 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            if (!PrefC.GetBool(PrefName.EasyHideDentalSchools))
            {
                col = new ODGridColumn(Lan.g("TableProviders", "Class"), 100);
                gridMain.Columns.Add(col);
            }
            col = new ODGridColumn(Lan.g("TableProviders", "Patients"), 50, HorizontalAlignment.Center);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["Abbr"].ToString());
                row.Cells.Add(table.Rows[i]["LName"].ToString());
                row.Cells.Add(table.Rows[i]["FName"].ToString());
                row.Cells.Add(table.Rows[i]["UserName"].ToString());
                if (table.Rows[i]["IsHidden"].ToString() == "1")
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                if (!PrefC.GetBool(PrefName.EasyHideDentalSchools))
                {
                    if (table.Rows[i]["GradYear"].ToString() != "")
                    {
                        row.Cells.Add(table.Rows[i]["GradYear"].ToString() + "-" + table.Rows[i]["Descript"].ToString());
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                }
                row.Cells.Add(table.Rows[i]["PatCount"].ToString());
                //row.Tag
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["ProvNum"].ToString() == selectedProvNum.ToString())
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
            //Done filling the grid.  Update the provider combo box in case its order changed.
            if (groupMovePats.Visible)
            {
                comboProv.Items.Clear();
                for (int i = 0; i < ProviderC.ListShort.Count; i++)
                {
                    comboProv.Items.Add(ProviderC.ListShort[i].GetLongDesc());
                }
            }
            gridMain.ScrollValue = scroll;
        }
示例#23
0
 private void FormWikiSetup_Load(object sender, EventArgs e)
 {
     textMaster.Text                  = WikiPages.MasterPage.PageContent;
     checkDetectLinks.Checked         = PrefC.GetBool(PrefName.WikiDetectLinks);
     checkCreatePageFromLinks.Checked = PrefC.GetBool(PrefName.WikiCreatePageFromLink);
 }
示例#24
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            int     payPlanVersion = PrefC.GetInt(PrefName.PayPlansVersion);
            string  bDate;
            string  eDate;
            decimal rcvStart          = 0;
            decimal rcvCharge         = 0;
            decimal rcvPayPlanCredit  = 0;
            decimal rcvProd           = 0;
            decimal rcvPayPlanCharges = 0;
            decimal rcvAdj            = 0;
            decimal rcvWriteoff       = 0;
            decimal rcvPayment        = 0;
            decimal rcvInsPayment     = 0;
            decimal runningRcv        = 0;
            decimal rcvDaily          = 0;

            decimal[] colTotals = new decimal[11];
            string    wMonth;
            string    wYear;
            string    wDay = "01";
            string    wDate;

            // Get the year / month and instert the 1st of the month for stop point for calculated running balance
            wYear  = date1.SelectionStart.Year.ToString();
            wMonth = date1.SelectionStart.Month.ToString();
            if (wMonth.Length < 2)
            {
                wMonth = "0" + wMonth;
            }
            wDate = wYear + "-" + wMonth + "-" + wDay;
            List <long> listProvNums = new List <long>();
            bool        hasAllProvs  = (listProv.SelectedIndices[0] == 0);

            if (!hasAllProvs)
            {
                for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                {
                    //Minus 1 due to the 'Practice' option.
                    listProvNums.Add(_listProvs[listProv.SelectedIndices[i] - 1].ProvNum);
                }
            }
            bool isPayPlan2;

            if (payPlanVersion == 2)
            {
                isPayPlan2 = true;
            }
            else
            {
                isPayPlan2 = false;
            }
            ReportComplex report             = new ReportComplex(true, isPayPlan2); //Landscape if using PayPlan Version 2
            DataTable     TableProduction    = new DataTable();                     //Production
            DataTable     TablePayPlanCredit = new DataTable();                     //PayPlanCredits
            DataTable     TableCharge        = new DataTable();                     //charges(Production-PayPlanCredits)
            DataTable     TablePayPlanCharge = new DataTable();                     //PayPlanCharges
            DataTable     TableCapWriteoff   = new DataTable();                     //capComplete writeoffs
            DataTable     TableInsWriteoff   = new DataTable();                     //ins writeoffs
            DataTable     TablePay           = new DataTable();                     //payments - Patient
            DataTable     TableIns           = new DataTable();                     //payments - Ins, added SPK
            DataTable     TableAdj           = new DataTable();                     //adjustments

            //
            // Main Loop:  This will loop twice 1st loop gets running balance to start of month selected
            //             2nd will break the numbers down by day and calculate the running balances
            //
            for (int j = 0; j <= 1; j++)
            {
                if (j == 0)
                {
                    bDate = "0001-01-01";
                    eDate = wDate;
                }
                else
                {
                    bDate = wDate;
                    eDate = POut.Date(date1.SelectionStart.AddDays(1)).Substring(1, 10);                   // Needed because all Queries are < end date to get correct Starting AR
                }
                TableProduction = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableProduction");
                if (isPayPlan2)
                {
                    TablePayPlanCredit = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TablePayPlanCredit");
                    TableCharge        = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableCharge");
                    TablePayPlanCharge = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TablePayPlanCharge");
                }
                TableCapWriteoff = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableCapWriteoff");
                TableInsWriteoff = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableInsWriteoff");
                TablePay         = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TablePay");
                TableIns         = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableIns");
                TableAdj         = RpReceivablesBreakdown.GetRecvBreakdownTable(date1.SelectionStart, listProvNums, radioWriteoffPay.Checked, isPayPlan2, wDate, eDate, bDate, "TableAdj");
                //Sum up all the transactions grouped by date.
                Dictionary <DateTime, decimal> dictPayPlanCharges = TablePayPlanCharge.Select().GroupBy(x => PIn.Date(x["ChargeDate"].ToString()))
                                                                    .ToDictionary(y => y.Key, y => y.ToList().Sum(z => PIn.Decimal(z["Amt"].ToString())));
                //1st Loop Calculate running Accounts Receivable upto the 1st of the Month Selected
                //2nd Loop Calculate the Daily Accounts Receivable upto the Date Selected
                //Finaly Generate Report showing the breakdown upto the date specified with totals for what is on the report
                if (j == 0)
                {
                    for (int k = 0; k < TableCharge.Rows.Count; k++)
                    {
                        rcvCharge += PIn.Decimal(TableCharge.Rows[k][1].ToString());                        //Production-PayPlanCredits
                    }
                    rcvPayPlanCharges += dictPayPlanCharges.Sum(x => x.Value);
                    for (int k = 0; k < TableCapWriteoff.Rows.Count; k++)
                    {
                        rcvWriteoff += PIn.Decimal(TableCapWriteoff.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TableInsWriteoff.Rows.Count; k++)
                    {
                        rcvWriteoff += PIn.Decimal(TableInsWriteoff.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TablePay.Rows.Count; k++)
                    {
                        rcvPayment += PIn.Decimal(TablePay.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TableIns.Rows.Count; k++)
                    {
                        rcvInsPayment += PIn.Decimal(TableIns.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TableAdj.Rows.Count; k++)
                    {
                        rcvAdj += PIn.Decimal(TableAdj.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TableProduction.Rows.Count; k++)
                    {
                        rcvProd += PIn.Decimal(TableProduction.Rows[k][1].ToString());
                    }
                    for (int k = 0; k < TablePayPlanCredit.Rows.Count; k++)
                    {
                        rcvPayPlanCredit += PIn.Decimal(TablePayPlanCredit.Rows[k][1].ToString());
                    }
                    TableProduction.Clear();
                    TablePayPlanCredit.Clear();
                    TableCharge.Clear();
                    TablePayPlanCharge.Clear();
                    TableCapWriteoff.Clear();
                    TableInsWriteoff.Clear();
                    TablePay.Clear();
                    TableIns.Clear();
                    TableAdj.Clear();
                    rcvStart = (rcvProd - rcvPayPlanCredit + rcvPayPlanCharges + rcvAdj - rcvWriteoff) - (rcvPayment + rcvInsPayment);
                }
                else
                {
                    rcvCharge         = 0;
                    rcvPayPlanCredit  = 0;
                    rcvAdj            = 0;
                    rcvInsPayment     = 0;
                    rcvPayment        = 0;
                    rcvProd           = 0;
                    rcvPayPlanCharges = 0;
                    rcvWriteoff       = 0;
                    rcvDaily          = 0;
                    runningRcv        = rcvStart;
                    DataTable TableQ = new DataTable();
                    TableQ.Columns.Add("Date");
                    TableQ.Columns.Add("Production");
                    TableQ.Columns.Add("PayPlanCredits");
                    TableQ.Columns.Add("Charges");
                    TableQ.Columns.Add("PayPlanCharges");
                    TableQ.Columns.Add("Adjustments");
                    TableQ.Columns.Add("Writeoffs");
                    TableQ.Columns.Add("Payment");
                    TableQ.Columns.Add("InsPayment");
                    TableQ.Columns.Add("Daily");
                    TableQ.Columns.Add("Running");
                    eDate = POut.Date(date1.SelectionStart).Substring(1, 10); // Reset EndDate to Selected Date
                    DateTime[] dates = new DateTime[(PIn.Date(eDate) - PIn.Date(bDate)).Days + 1];
                    for (int i = 0; i < dates.Length; i++)                    //usually 31 days in loop
                    {
                        dates[i] = PIn.Date(bDate).AddDays(i);
                        //create new row called 'row' based on structure of TableQ
                        DataRow row = TableQ.NewRow();
                        row[0] = dates[i].ToShortDateString();
                        for (int k = 0; k < TableProduction.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableProduction.Rows[k][0].ToString())))
                            {
                                rcvProd += PIn.Decimal(TableProduction.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TablePayPlanCredit.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TablePayPlanCredit.Rows[k][0].ToString())))
                            {
                                rcvPayPlanCredit += PIn.Decimal(TablePayPlanCredit.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TableCharge.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableCharge.Rows[k][0].ToString())))
                            {
                                rcvCharge += PIn.Decimal(TableCharge.Rows[k][1].ToString());
                            }
                        }
                        decimal rcvPayPlanChargesForDay = 0;
                        if (dictPayPlanCharges.TryGetValue(dates[i], out rcvPayPlanChargesForDay))
                        {
                            rcvPayPlanCharges += rcvPayPlanChargesForDay;
                        }
                        for (int k = 0; k < TableCapWriteoff.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableCapWriteoff.Rows[k][0].ToString())))
                            {
                                rcvWriteoff += PIn.Decimal(TableCapWriteoff.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TableAdj.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableAdj.Rows[k][0].ToString())))
                            {
                                rcvAdj += PIn.Decimal(TableAdj.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TableInsWriteoff.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableInsWriteoff.Rows[k][0].ToString())))
                            {
                                rcvWriteoff += PIn.Decimal(TableInsWriteoff.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TablePay.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TablePay.Rows[k][0].ToString())))
                            {
                                rcvPayment += PIn.Decimal(TablePay.Rows[k][1].ToString());
                            }
                        }
                        for (int k = 0; k < TableIns.Rows.Count; k++)
                        {
                            if (dates[i] == (PIn.Date(TableIns.Rows[k][0].ToString())))
                            {
                                rcvInsPayment += PIn.Decimal(TableIns.Rows[k][1].ToString());
                            }
                        }
                        //rcvPayPlanCharges and rcvPayPlanCredit will be 0 if not on version 2.
                        rcvDaily              = (rcvProd - rcvPayPlanCredit + rcvPayPlanCharges + rcvAdj - rcvWriteoff) - (rcvPayment + rcvInsPayment);
                        runningRcv           += (rcvProd - rcvPayPlanCredit + rcvPayPlanCharges + rcvAdj - rcvWriteoff) - (rcvPayment + rcvInsPayment);
                        row["Production"]     = rcvProd.ToString("n");
                        row["PayPlanCredits"] = rcvPayPlanCredit.ToString("n");
                        row["Charges"]        = rcvCharge.ToString("n");
                        row["PayPlanCharges"] = rcvPayPlanCharges.ToString("n");
                        row["Adjustments"]    = rcvAdj.ToString("n");
                        row["Writeoffs"]      = rcvWriteoff.ToString("n");
                        row["Payment"]        = rcvPayment.ToString("n");
                        row["InsPayment"]     = rcvInsPayment.ToString("n");
                        row["Daily"]          = rcvDaily.ToString("n");
                        row["Running"]        = runningRcv.ToString("n");
                        colTotals[1]         += rcvProd;
                        colTotals[2]         += rcvPayPlanCredit;
                        colTotals[3]         += rcvCharge;
                        colTotals[4]         += rcvPayPlanCharges;
                        colTotals[5]         += rcvAdj;
                        colTotals[6]         += rcvWriteoff;
                        colTotals[7]         += rcvPayment;
                        colTotals[8]         += rcvInsPayment;
                        colTotals[9]         += rcvDaily;
                        colTotals[10]         = runningRcv;
                        TableQ.Rows.Add(row);                          //adds row to table Q
                        rcvAdj            = 0;
                        rcvInsPayment     = 0;
                        rcvPayment        = 0;
                        rcvProd           = 0;
                        rcvPayPlanCharges = 0;
                        rcvWriteoff       = 0;
                        rcvCharge         = 0;
                        rcvPayPlanCredit  = 0;
                    }
                    //Drop the PayPlan columns if not version 2
                    if (!isPayPlan2)
                    {
                        TableQ.Columns.RemoveAt(2);                        //PayPlanCredits
                        TableQ.Columns.RemoveAt(2);                        //Production - PayPlanCredits
                        TableQ.Columns.RemoveAt(2);                        //PayPlanCharges
                    }
                    ////columnCount will get incremented on the second ColTotal call so we can use it in this way
                    //if(payPlanVersion==2) {
                    //	report.ColTotal[1]=PIn.Decimal(colTotals[1].ToString("n")); //prod
                    //	report.ColTotal[2]=PIn.Decimal(colTotals[2].ToString("n")); //payplancharges
                    //	report.ColTotal[3]=PIn.Decimal(colTotals[3].ToString("n")); //adjustment
                    //	report.ColTotal[4]=PIn.Decimal(colTotals[4].ToString("n")); //writeoffs
                    //	report.ColTotal[5]=PIn.Decimal(colTotals[5].ToString("n")); //payment
                    //	report.ColTotal[6]=PIn.Decimal(colTotals[6].ToString("n")); //inspayment
                    //	report.ColTotal[7]=PIn.Decimal(colTotals[7].ToString("n")); //daily
                    //	report.ColTotal[8]=PIn.Decimal(colTotals[8].ToString("n")); //running
                    //}
                    //else {
                    //	report.ColTotal[1]=PIn.Decimal(colTotals[1].ToString("n")); //prod
                    //	report.ColTotal[2]=PIn.Decimal(colTotals[3].ToString("n")); //adjustment
                    //	report.ColTotal[3]=PIn.Decimal(colTotals[4].ToString("n")); //writeoffs
                    //	report.ColTotal[4]=PIn.Decimal(colTotals[5].ToString("n")); //payment
                    //	report.ColTotal[5]=PIn.Decimal(colTotals[6].ToString("n")); //inspayment
                    //	report.ColTotal[6]=PIn.Decimal(colTotals[7].ToString("n")); //daily
                    //	report.ColTotal[7]=PIn.Decimal(colTotals[8].ToString("n")); //running
                    //}
                    Font font         = new Font("Tahoma", 9);
                    Font boldFont     = new Font("Tahoma", 9, FontStyle.Bold);
                    Font fontTitle    = new Font("Tahoma", 17, FontStyle.Bold);
                    Font fontSubTitle = new Font("Tahoma", 10, FontStyle.Bold);
                    report.ReportName = Lan.g(this, "Receivables Breakdown");
                    report.AddTitle("Title", Lan.g(this, "Receivables Breakdown"), fontTitle);
                    report.AddSubTitle("PracticeTitle", PrefC.GetString(PrefName.PracticeTitle), fontSubTitle);
                    report.AddSubTitle("Date SubTitle", date1.SelectionStart.ToString("d"), fontSubTitle);
                    string provNames = "";
                    for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                    {
                        if (hasAllProvs)
                        {
                            provNames = "All Providers";
                            break;
                        }
                        if (i > 0)
                        {
                            provNames += ", ";
                        }
                        provNames += _listProvs[listProv.SelectedIndices[i] - 1].Abbr;
                    }
                    report.AddSubTitle("Provider SubTitle", provNames);
                    int[]       summaryGroups1 = { 1 };
                    QueryObject query          = report.AddQuery(TableQ, Lan.g(this, "Date") + ": " + DateTimeOD.Today.ToString("d"));
                    query.AddColumn("Date", 72, FieldValueType.Date);
                    query.AddColumn("Production", 80, FieldValueType.Number);
                    query.GetColumnDetail("Production").ContentAlignment = ContentAlignment.MiddleRight;
                    if (isPayPlan2)
                    {
                        query.AddColumn("PayPlanCredits", 90, FieldValueType.Number);
                        query.GetColumnDetail("PayPlanCredits").ContentAlignment = ContentAlignment.MiddleRight;
                        query.AddColumn("Prod - PPCred", 85, FieldValueType.Number);
                        query.GetColumnDetail("Prod - PPCred").ContentAlignment = ContentAlignment.MiddleRight;
                        query.AddColumn("PayPlanCharges", 100, FieldValueType.Number);
                        query.GetColumnDetail("PayPlanCharges").ContentAlignment = ContentAlignment.MiddleRight;
                    }
                    query.AddColumn("Adjustment", 80, FieldValueType.Number);
                    query.GetColumnDetail("Adjustment").ContentAlignment = ContentAlignment.MiddleRight;
                    query.AddColumn("Writeoff", 80, FieldValueType.Number);
                    query.GetColumnDetail("Writeoff").ContentAlignment = ContentAlignment.MiddleRight;
                    query.AddColumn("Payment", 80, FieldValueType.Number);
                    query.GetColumnDetail("Payment").ContentAlignment = ContentAlignment.MiddleRight;
                    query.AddColumn("InsPayment", 80, FieldValueType.Number);
                    query.GetColumnDetail("InsPayment").ContentAlignment = ContentAlignment.MiddleRight;
                    query.AddColumn("Daily A/R", 100, FieldValueType.Number);
                    query.GetColumnDetail("Daily A/R").ContentAlignment = ContentAlignment.MiddleRight;
                    query.AddColumn("Ending A/R", 100);
                    query.GetColumnDetail("Ending A/R").ContentAlignment = ContentAlignment.MiddleRight;
                    query.GetColumnDetail("Ending A/R").Font             = boldFont;
                    if (isPayPlan2)
                    {
                        report.AddFooterText("Desc", "Receivables Calculation: (Production - PayPlanCredits + PayPlanCharges + Adjustments - Writeoffs) "
                                             + "- (Payments + Insurance Payments)", font, 0, ContentAlignment.MiddleCenter);
                    }
                    else
                    {
                        report.AddFooterText("Desc", "Receivables Calculation: (Production + Adjustments - Writeoffs) - (Payments + Insurance Payments)", font, 0, ContentAlignment.MiddleCenter);
                    }
                    //report.AddText("EndingAR","Final Ending A/R: "+runningRcv.ToString(),boldFont,0,ContentAlignment.MiddleLeft);
                    report.AddPageNum(font);
                    if (!report.SubmitQueries())
                    {
                        return;
                    }
                    FormReportComplex FormR = new FormReportComplex(report);
                    FormR.ShowDialog();
                    DialogResult = DialogResult.OK;
                } //END If
            }     // END For Loop
        }         //END OK button Clicked
示例#25
0
        private void ShowProgressForm(DateTime changedSince)
        {
            if (checkTroubleshooting.Checked)
            {
                IsTroubleshootMode = true;
            }
            else
            {
                IsTroubleshootMode = false;
            }
            DateTime timeSynchStarted = MiscData.GetNowDateTime();

            FormP        = new FormProgress();
            FormP.MaxVal = 100;          //to keep the form from closing until the real MaxVal is set.
            FormP.NumberMultiplication = 1;
            FormP.DisplayText          = "Preparing records for upload.";
            FormP.NumberFormat         = "F0";
            //start the thread that will perform the upload
            ThreadStart uploadDelegate = delegate { UploadWorker(changedSince, timeSynchStarted); };
            Thread      workerThread   = new Thread(uploadDelegate);

            workerThread.Start();
            //display the progress dialog to the user:
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.Cancel)
            {
                workerThread.Abort();
            }
            changed = true;
            textDateTimeLastRun.Text = PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).ToShortDateString() + " " + PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).ToShortTimeString();
        }
示例#26
0
文件: FormASAP.cs 项目: nampn/ODental
        private void FillGrid()
        {
            this.Cursor = Cursors.WaitCursor;

            /*string order="";
             * switch(comboOrder.SelectedIndex) {
             *      case 0:
             *              order="status";
             *              break;
             *      case 1:
             *              order="alph";
             *              break;
             *      case 2:
             *              order="date";
             *              break;
             * }*/
            long provNum = 0;

            if (comboProv.SelectedIndex != 0)
            {
                provNum = ProviderC.ListShort[comboProv.SelectedIndex - 1].ProvNum;
            }
            long siteNum = 0;

            if (!PrefC.GetBool(PrefName.EasyHidePublicHealth) && comboSite.SelectedIndex != 0)
            {
                siteNum = SiteC.List[comboSite.SelectedIndex - 1].SiteNum;
            }
            long clinicNum = 0;

            if (comboClinic.SelectedIndex > 0)
            {
                clinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
            }
            ListASAP = Appointments.RefreshASAP(provNum, siteNum, clinicNum);
            int scrollVal = grid.ScrollValue;

            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableASAP", "Patient"), 140);

            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableASAP", "Date"), 65);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableASAP", "Status"), 110);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableASAP", "Prov"), 50);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableASAP", "Procedures"), 150);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableASAP", "Notes"), 200);
            grid.Columns.Add(col);
            grid.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < ListASAP.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(patientNames[ListASAP[i].PatNum]);
                if (ListASAP[i].AptDateTime.Year < 1880)                //shouldn't be possible.
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(ListASAP[i].AptDateTime.ToShortDateString());
                }
                row.Cells.Add(DefC.GetName(DefCat.RecallUnschedStatus, ListASAP[i].UnschedStatus));
                row.Cells.Add(Providers.GetAbbr(ListASAP[i].ProvNum));
                row.Cells.Add(ListASAP[i].ProcDescript);
                row.Cells.Add(ListASAP[i].Note);
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollValue = scrollVal;
            Cursor           = Cursors.Default;
        }
示例#27
0
        ///<summary>a general function to reduce the amount of code for uploading</summary>
        private static void SynchGeneric(List <long> PKNumList, SynchEntity entity, double totalCount, ref double currentVal)
        {
            //Dennis: a try catch block here has been avoid on purpose.
            List <long> BlockPKNumList = null;
            int         localBatchSize = BatchSize;

            if (IsTroubleshootMode)
            {
                localBatchSize = 1;
            }
            string AtoZpath = ImageStore.GetPreferredAtoZpath();

            for (int start = 0; start < PKNumList.Count; start += localBatchSize)
            {
                if ((start + localBatchSize) > PKNumList.Count)
                {
                    localBatchSize = PKNumList.Count - start;
                }
                try{
                    BlockPKNumList = PKNumList.GetRange(start, localBatchSize);
                    switch (entity)
                    {
                    case SynchEntity.patient:
                        List <Patientm> changedPatientmList = Patientms.GetMultPats(BlockPKNumList);
                        mb.SynchPatients(PrefC.GetString(PrefName.RegistrationKey), changedPatientmList.ToArray());
                        break;

                    case SynchEntity.appointment:
                        List <Appointmentm> changedAppointmentmList = Appointmentms.GetMultApts(BlockPKNumList);
                        mb.SynchAppointments(PrefC.GetString(PrefName.RegistrationKey), changedAppointmentmList.ToArray());
                        break;

                    case SynchEntity.prescription:
                        List <RxPatm> changedRxList = RxPatms.GetMultRxPats(BlockPKNumList);
                        mb.SynchPrescriptions(PrefC.GetString(PrefName.RegistrationKey), changedRxList.ToArray());
                        break;

                    case SynchEntity.provider:
                        List <Providerm> changedProvList = Providerms.GetMultProviderms(BlockPKNumList);
                        mb.SynchProviders(PrefC.GetString(PrefName.RegistrationKey), changedProvList.ToArray());
                        break;

                    case SynchEntity.pharmacy:
                        List <Pharmacym> changedPharmacyList = Pharmacyms.GetMultPharmacyms(BlockPKNumList);
                        mb.SynchPharmacies(PrefC.GetString(PrefName.RegistrationKey), changedPharmacyList.ToArray());
                        break;

                    case SynchEntity.labpanel:
                        List <LabPanelm> ChangedLabPanelList = LabPanelms.GetMultLabPanelms(BlockPKNumList);
                        mb.SynchLabPanels(PrefC.GetString(PrefName.RegistrationKey), ChangedLabPanelList.ToArray());
                        break;

                    case SynchEntity.labresult:
                        List <LabResultm> ChangedLabResultList = LabResultms.GetMultLabResultms(BlockPKNumList);
                        mb.SynchLabResults(PrefC.GetString(PrefName.RegistrationKey), ChangedLabResultList.ToArray());
                        break;

                    case SynchEntity.medication:
                        List <Medicationm> ChangedMedicationList = Medicationms.GetMultMedicationms(BlockPKNumList);
                        mb.SynchMedications(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationList.ToArray());
                        break;

                    case SynchEntity.medicationpat:
                        List <MedicationPatm> ChangedMedicationPatList = MedicationPatms.GetMultMedicationPatms(BlockPKNumList);
                        mb.SynchMedicationPats(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationPatList.ToArray());
                        break;

                    case SynchEntity.allergy:
                        List <Allergym> ChangedAllergyList = Allergyms.GetMultAllergyms(BlockPKNumList);
                        mb.SynchAllergies(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyList.ToArray());
                        break;

                    case SynchEntity.allergydef:
                        List <AllergyDefm> ChangedAllergyDefList = AllergyDefms.GetMultAllergyDefms(BlockPKNumList);
                        mb.SynchAllergyDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyDefList.ToArray());
                        break;

                    case SynchEntity.disease:
                        List <Diseasem> ChangedDiseaseList = Diseasems.GetMultDiseasems(BlockPKNumList);
                        mb.SynchDiseases(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseList.ToArray());
                        break;

                    case SynchEntity.diseasedef:
                        List <DiseaseDefm> ChangedDiseaseDefList = DiseaseDefms.GetMultDiseaseDefms(BlockPKNumList);
                        mb.SynchDiseaseDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseDefList.ToArray());
                        break;

                    case SynchEntity.icd9:
                        List <ICD9m> ChangedICD9List = ICD9ms.GetMultICD9ms(BlockPKNumList);
                        mb.SynchICD9s(PrefC.GetString(PrefName.RegistrationKey), ChangedICD9List.ToArray());
                        break;

                    case SynchEntity.statement:
                        List <Statementm> ChangedStatementList = Statementms.GetMultStatementms(BlockPKNumList);
                        mb.SynchStatements(PrefC.GetString(PrefName.RegistrationKey), ChangedStatementList.ToArray());
                        break;

                    case SynchEntity.document:
                        List <Documentm> ChangedDocumentList = Documentms.GetMultDocumentms(BlockPKNumList, AtoZpath);
                        mb.SynchDocuments(PrefC.GetString(PrefName.RegistrationKey), ChangedDocumentList.ToArray());
                        break;

                    case SynchEntity.recall:
                        List <Recallm> ChangedRecallList = Recallms.GetMultRecallms(BlockPKNumList);
                        mb.SynchRecalls(PrefC.GetString(PrefName.RegistrationKey), ChangedRecallList.ToArray());
                        break;

                    case SynchEntity.deletedobject:
                        List <DeletedObject> ChangedDeleteObjectList = DeletedObjects.GetMultDeletedObjects(BlockPKNumList);
                        mb.DeleteObjects(PrefC.GetString(PrefName.RegistrationKey), ChangedDeleteObjectList.ToArray());
                        break;

                    case SynchEntity.patientdel:
                        mb.DeletePatientsRecords(PrefC.GetString(PrefName.RegistrationKey), BlockPKNumList.ToArray());
                        break;
                    }
                    //progressIndicator.CurrentVal+=LocalBatchSize;//not allowed
                    currentVal += localBatchSize;
                    if (Application.OpenForms["FormProgress"] != null)                   // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system.
                    {
                        FormP.Invoke(new PassProgressDelegate(PassProgressToDialog),
                                     new object[] { currentVal, "?currentVal of ?maxVal records uploaded", totalCount, "" });
                    }
                }
                catch (Exception e) {
                    if (IsTroubleshootMode)
                    {
                        string errorMessage = entity + " with Primary Key = " + BlockPKNumList.First() + " failed to synch. " + "\n" + e.Message;
                        throw new Exception(errorMessage);
                    }
                    else
                    {
                        throw e;
                    }
                }
            }            //for loop ends here
        }
示例#28
0
        ///<summary>Returns false if user does not wish to continue after seeing alert.</summary>
        public static bool DisplayAlerts(long patNum, long rxDefNum)
        {
            List <RxAlert> alertList = null;

            //if(rxDefNum==0){
            //	alertList=RxAlerts.RefreshByRxCui(rxCui);//for CPOE
            //}
            //else{
            alertList = RxAlerts.Refresh(rxDefNum);          //for Rx
            //}
            List <Disease>       diseases           = Diseases.Refresh(patNum);
            List <Allergy>       allergies          = Allergies.Refresh(patNum);
            List <MedicationPat> medicationPats     = MedicationPats.Refresh(patNum, false);    //Exclude discontinued, only active meds.
            List <string>        diseaseMatches     = new List <string>();
            List <string>        allergiesMatches   = new List <string>();
            List <string>        medicationsMatches = new List <string>();
            List <string>        customMessages     = new List <string>();
            bool showHighSigOnly = PrefC.GetBool(PrefName.EhrRxAlertHighSeverity);

            for (int i = 0; i < alertList.Count; i++)
            {
                for (int j = 0; j < diseases.Count; j++)
                {
                    //This does not look for matches with icd9s.
                    if (alertList[i].DiseaseDefNum == diseases[j].DiseaseDefNum && diseases[j].ProbStatus == 0)                //ProbStatus is active.
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            diseaseMatches.Add(DiseaseDefs.GetName(diseases[j].DiseaseDefNum));
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < allergies.Count; j++)
                {
                    if (alertList[i].AllergyDefNum == allergies[j].AllergyDefNum && allergies[j].StatusIsActive)
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            allergiesMatches.Add(AllergyDefs.GetOne(alertList[i].AllergyDefNum).Description);
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < medicationPats.Count; j++)
                {
                    bool       isMedInteraction = false;
                    Medication medForAlert      = Medications.GetMedication(alertList[i].MedicationNum);
                    if (medForAlert == null)
                    {
                        continue;                                                                                              //MedicationNum will be 0 for all other alerts that are not medication alerts.
                    }
                    if (medicationPats[j].MedicationNum != 0 && alertList[i].MedicationNum == medicationPats[j].MedicationNum) //Medication from medication list.
                    {
                        isMedInteraction = true;
                    }
                    else if (medicationPats[j].MedicationNum == 0 && medForAlert.RxCui != 0 && medicationPats[j].RxCui == medForAlert.RxCui)               //Medication from NewCrop. Unfortunately, neither of these RxCuis are required.
                    {
                        isMedInteraction = true;
                    }
                    if (!isMedInteraction)
                    {
                        continue;                        //No known interaction.
                    }
                    //Medication interaction.
                    if (showHighSigOnly && !alertList[i].IsHighSignificance) //if set to only show high significance alerts and this is not a high significance interaction, do not show alert
                    {
                        continue;                                            //Low significance alert.
                    }
                    if (alertList[i].NotificationMsg == "")
                    {
                        Medications.RefreshCache();
                        medicationsMatches.Add(Medications.GetMedication(alertList[i].MedicationNum).MedName);
                    }
                    else
                    {
                        customMessages.Add(alertList[i].NotificationMsg);
                    }
                }
            }
            //these matches do not include ones that have custom messages.
            if (diseaseMatches.Count > 0 ||
                allergiesMatches.Count > 0 ||
                medicationsMatches.Count > 0)
            {
                string alert = "";
                for (int i = 0; i < diseaseMatches.Count; i++)
                {
                    if (i == 0)
                    {
                        alert += Lan.g("RxAlertL", "This patient has the following medical problems: ");
                    }
                    alert += diseaseMatches[i];
                    if ((i + 1) == diseaseMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < allergiesMatches.Count; i++)
                {
                    if (i == 0 && diseaseMatches.Count > 0)
                    {
                        alert += "and the following allergies: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient has the following allergies: ");
                    }
                    alert += allergiesMatches[i];
                    if ((i + 1) == allergiesMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < medicationsMatches.Count; i++)
                {
                    if (i == 0 && (diseaseMatches.Count > 0 || allergiesMatches.Count > 0))
                    {
                        alert += "and is taking the following medications: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient is taking the following medications: ");
                    }
                    alert += medicationsMatches[i];
                    if ((i + 1) == medicationsMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                alert += "\r\n" + Lan.g("RxAlertL", "Continue anyway?");
                if (MessageBox.Show(alert, "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            for (int i = 0; i < customMessages.Count; i++)
            {
                if (MessageBox.Show(customMessages[i] + "\r\n" + Lan.g("RxAlertL", "Continue anyway?"), "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#29
0
 ///<summary>Returns false if validation failed.  This also makes sure the web service exists, the customer is paid, and the registration key is correct.</summary>
 private bool SavePrefs()
 {
     //validation
     if (textSynchMinutes.errorProvider1.GetError(textSynchMinutes) != "" ||
         textDateBefore.errorProvider1.GetError(textDateBefore) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return(false);
     }
     //yes, workstation is allowed to be blank.  That's one way for user to turn off auto synch.
     //if(textMobileSynchWorkStation.Text=="") {
     //	MsgBox.Show(this,"WorkStation cannot be empty");
     //	return false;
     //}
     // the text field is read because the keyed in values have not been saved yet
     //if(textMobileSyncServerURL.Text.Contains("192.168.0.196") || textMobileSyncServerURL.Text.Contains("localhost")) {
     if (textMobileSyncServerURL.Text.Contains("10.10.1.196") || textMobileSyncServerURL.Text.Contains("localhost"))
     {
         IgnoreCertificateErrors();                // done so that TestWebServiceExists() does not thow an error.
     }
     // if this is not done then an old non-functional url prevents any new url from being saved.
     Prefs.UpdateString(PrefName.MobileSyncServerURL, textMobileSyncServerURL.Text);
     if (!TestWebServiceExists())
     {
         MsgBox.Show(this, "Web service not found.");
         return(false);
     }
     if (mb.GetCustomerNum(PrefC.GetString(PrefName.RegistrationKey)) == 0)
     {
         MsgBox.Show(this, "Registration key is incorrect.");
         return(false);
     }
     if (!VerifyPaidCustomer())
     {
         return(false);
     }
     //Minimum 10 char.  Must contain uppercase, lowercase, numbers, and symbols. Valid symbols are: !@#$%^&+=
     //The set of symbols checked was far too small, not even including periods, commas, and parentheses.
     //So I rewrote it all.  New error messages say exactly what's wrong with it.
     if (textMobileUserName.Text != "")           //allowed to be blank
     {
         if (textMobileUserName.Text.Length < 10)
         {
             MsgBox.Show(this, "User Name must be at least 10 characters long.");
             return(false);
         }
         if (!Regex.IsMatch(textMobileUserName.Text, "[A-Z]+"))
         {
             MsgBox.Show(this, "User Name must contain an uppercase letter.");
             return(false);
         }
         if (!Regex.IsMatch(textMobileUserName.Text, "[a-z]+"))
         {
             MsgBox.Show(this, "User Name must contain an lowercase letter.");
             return(false);
         }
         if (!Regex.IsMatch(textMobileUserName.Text, "[0-9]+"))
         {
             MsgBox.Show(this, "User Name must contain a number.");
             return(false);
         }
         if (!Regex.IsMatch(textMobileUserName.Text, "[^0-9a-zA-Z]+"))                //absolutely anything except number, lower or upper.
         {
             MsgBox.Show(this, "User Name must contain punctuation or symbols.");
             return(false);
         }
     }
     if (textDateBefore.Text == "")          //default to one year if empty
     {
         textDateBefore.Text = DateTime.Today.AddYears(-1).ToShortDateString();
         //not going to bother informing user.  They can see it.
     }
     //save to db------------------------------------------------------------------------------------
     if (Prefs.UpdateString(PrefName.MobileSyncServerURL, textMobileSyncServerURL.Text)
         | Prefs.UpdateInt(PrefName.MobileSyncIntervalMinutes, PIn.Int(textSynchMinutes.Text))                        //blank entry allowed
         | Prefs.UpdateString(PrefName.MobileExcludeApptsBeforeDate, POut.Date(PIn.Date(textDateBefore.Text), false)) //blank
         | Prefs.UpdateString(PrefName.MobileSyncWorkstationName, textMobileSynchWorkStation.Text)
         | Prefs.UpdateString(PrefName.MobileUserName, textMobileUserName.Text)
         )
     {
         changed = true;
         Prefs.RefreshCache();
     }
     //Username and password-----------------------------------------------------------------------------
     mb.SetMobileWebUserPassword(PrefC.GetString(PrefName.RegistrationKey), textMobileUserName.Text.Trim(), textMobilePassword.Text.Trim());
     return(true);
 }
示例#30
0
        private void FormRecallSetup_Load(object sender, System.EventArgs e)
        {
            checkGroupFamilies.Checked = PrefC.GetBool(PrefName.RecallGroupByFamily);
            textPostcardsPerSheet.Text = PrefC.GetLong(PrefName.RecallPostcardsPerSheet).ToString();
            checkReturnAdd.Checked     = PrefC.GetBool(PrefName.RecallCardsShowReturnAdd);
            checkGroupFamilies.Checked = PrefC.GetBool(PrefName.RecallGroupByFamily);
            if (PrefC.GetLong(PrefName.RecallDaysPast) == -1)
            {
                textDaysPast.Text = "";
            }
            else
            {
                textDaysPast.Text = PrefC.GetLong(PrefName.RecallDaysPast).ToString();
            }
            if (PrefC.GetLong(PrefName.RecallDaysFuture) == -1)
            {
                textDaysFuture.Text = "";
            }
            else
            {
                textDaysFuture.Text = PrefC.GetLong(PrefName.RecallDaysFuture).ToString();
            }
            if (PrefC.GetBool(PrefName.RecallExcludeIfAnyFutureAppt))
            {
                radioExcludeFutureYes.Checked = true;
            }
            else
            {
                radioExcludeFutureNo.Checked = true;
            }
            textRight.Text = PrefC.GetDouble(PrefName.RecallAdjustRight).ToString();
            textDown.Text  = PrefC.GetDouble(PrefName.RecallAdjustDown).ToString();
            //comboStatusMailedRecall.Items.Clear();
            for (int i = 0; i < DefC.Short[(int)DefCat.RecallUnschedStatus].Length; i++)
            {
                comboStatusMailedRecall.Items.Add(DefC.Short[(int)DefCat.RecallUnschedStatus][i].ItemName);
                comboStatusEmailedRecall.Items.Add(DefC.Short[(int)DefCat.RecallUnschedStatus][i].ItemName);
                if (DefC.Short[(int)DefCat.RecallUnschedStatus][i].DefNum == PrefC.GetLong(PrefName.RecallStatusMailed))
                {
                    comboStatusMailedRecall.SelectedIndex = i;
                }
                if (DefC.Short[(int)DefCat.RecallUnschedStatus][i].DefNum == PrefC.GetLong(PrefName.RecallStatusEmailed))
                {
                    comboStatusEmailedRecall.SelectedIndex = i;
                }
            }
            for (int i = 0; i < DefC.Short[(int)DefCat.ApptConfirmed].Length; i++)
            {
                comboStatusEmailedConfirm.Items.Add(DefC.Short[(int)DefCat.ApptConfirmed][i].ItemName);
                if (DefC.Short[(int)DefCat.ApptConfirmed][i].DefNum == PrefC.GetLong(PrefName.ConfirmStatusEmailed))
                {
                    comboStatusEmailedConfirm.SelectedIndex = i;
                }
            }
            for (int i = 0; i < DefC.Short[(int)DefCat.ApptConfirmed].Length; i++)
            {
                comboStatusTextMessagedConfirm.Items.Add(DefC.Short[(int)DefCat.ApptConfirmed][i].ItemName);
                if (DefC.Short[(int)DefCat.ApptConfirmed][i].DefNum == PrefC.GetLong(PrefName.ConfirmStatusTextMessaged))
                {
                    comboStatusTextMessagedConfirm.SelectedIndex = i;
                }
            }
            List <long> recalltypes = new List <long>();

            string[] typearray = PrefC.GetString(PrefName.RecallTypesShowingInList).Split(',');
            if (typearray.Length > 0)
            {
                for (int i = 0; i < typearray.Length; i++)
                {
                    recalltypes.Add(PIn.Long(typearray[i]));
                }
            }
            for (int i = 0; i < RecallTypeC.Listt.Count; i++)
            {
                listTypes.Items.Add(RecallTypeC.Listt[i].Description);
                if (recalltypes.Contains(RecallTypeC.Listt[i].RecallTypeNum))
                {
                    listTypes.SetSelected(i, true);
                }
            }
            if (PrefC.GetLong(PrefName.RecallShowIfDaysFirstReminder) == -1)
            {
                textDaysFirstReminder.Text = "";
            }
            else
            {
                textDaysFirstReminder.Text = PrefC.GetLong(PrefName.RecallShowIfDaysFirstReminder).ToString();
            }
            if (PrefC.GetLong(PrefName.RecallShowIfDaysSecondReminder) == -1)
            {
                textDaysSecondReminder.Text = "";
            }
            else
            {
                textDaysSecondReminder.Text = PrefC.GetLong(PrefName.RecallShowIfDaysSecondReminder).ToString();
            }
            if (PrefC.GetLong(PrefName.RecallMaxNumberReminders) == -1)
            {
                textMaxReminders.Text = "";
            }
            else
            {
                textMaxReminders.Text = PrefC.GetLong(PrefName.RecallMaxNumberReminders).ToString();
            }
            if (PrefC.GetBool(PrefName.RecallUseEmailIfHasEmailAddress))
            {
                radioUseEmailTrue.Checked = true;
            }
            else
            {
                radioUseEmailFalse.Checked = true;
            }
            FillGrid();
        }