Exemplo n.º 1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textCarrierName.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Carrier Name cannot be blank."));
         return;
     }
     if (textVersion.Visible && textVersion.Text != "" && textVersion.Text != "2" && textVersion.Text != "3" &&
         textVersion.Text != "4")
     {
         MsgBox.Show(this, "Version Number must be 2, 3, or 4.");
         return;
     }
     CarrierCur.CarrierName = textCarrierName.Text;
     CarrierCur.Phone       = textPhone.Text;
     CarrierCur.Address     = textAddress.Text;
     CarrierCur.Address2    = textAddress2.Text;
     CarrierCur.City        = textCity.Text;
     CarrierCur.State       = textState.Text;
     CarrierCur.Zip         = textZip.Text;
     CarrierCur.ElectID     = textElectID.Text;
     CarrierCur.NoSendElect = checkNoSendElect.Checked;
     if (checkIsCDAnet.Checked)
     {
         CarrierCur.IsCDA = true;
         //CarrierCur.IsPMP=checkPMP.Checked;
         if (comboNetwork.SelectedIndex == 0)
         {
             CarrierCur.CanadianNetworkNum = 0;
         }
         else
         {
             CarrierCur.CanadianNetworkNum = CanadianNetworks.Listt[comboNetwork.SelectedIndex - 1].CanadianNetworkNum;
         }
         CarrierCur.CDAnetVersion = textVersion.Text;
     }
     else
     {
         CarrierCur.IsCDA = false;
         //CarrierCur.IsPMP=false;
     }
     if (IsNew)
     {
         try{
             Carriers.Insert(CarrierCur);
         }
         catch (ApplicationException ex) {
             MessageBox.Show(ex.Message);
             return;
         }
     }
     else
     {
         try{
             Carriers.Update(CarrierCur);
         }
         catch (ApplicationException ex) {
             MessageBox.Show(ex.Message);
             return;
         }
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 2
0
        private void butSend_Click(object sender, EventArgs ea)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Exactly one Rx must be selected.");
                return;
            }
            Pharmacy      pharmacy = Pharmacies.GetOne(listRx[gridMain.SelectedIndices[0]].PharmacyNum);
            StringBuilder strb     = new StringBuilder();
            //These characters will be replaced in a production by unprintable characters, but hardcoded for debugging.
            char   f = ':';        //separates fields within a composite element
            char   e = '+';        //(separates composite elements) SureScripts may require an unprintable character here.
            char   d = '.';        //decimal notation
            char   r = '/';        //release indicator
            char   p = '*';        //repetition separator
            string s = "'\r\n";    //segment separator

                        #if DEBUG
            if (true)
            {
                //Set false if you want to use unprintable characters to simulate running in release mode.
            }
            else
            {
                //f=''; we don't know the values for these characters yet.
                //e='';
                //d='';
                //r='';
                //p='';
                //s='';
            }
                        #else
            //f=''; we don't know the values for these characters yet.
            //e='';
            //d='';
            //r='';
            //p='';
            //s='';
                        #endif
            RxPat          rx          = listRx[gridMain.SelectedIndices[0]];
            Patient        pat         = Patients.GetPat(rx.PatNum);
            Provider       prov        = Providers.GetProv(rx.ProvNum);
            PatPlan        patPlan     = PatPlans.GetPatPlan(pat.PatNum, 1);
            Family         fam         = Patients.GetFamily(pat.PatNum);
            List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
            InsSub         sub         = InsSubs.GetOne(patPlan.InsSubNum);
            InsPlan        plan        = InsPlans.GetPlan(sub.PlanNum, planList);
            Carrier        car         = Carriers.GetCarrier(plan.CarrierNum);
            DateTime       msgTimeSent = DateTime.Now;
            //Hardcoded values should never change. Ex:Message type, version, release should always be SCRIPT:010:006
            //Hardcoded values allowed to change until released version.
            //UNA:+./*'------------------------------------------------------------------------------------------------
            strb.Append("UNA" + f + e + d + r + p + s);
            //UIB+UNOA:0++1234567+++77777777:C:PASSWORDQ+7701630:P+19971001:081522'------------------------------------
            strb.Append("UIB" + e);                                                                                                //000
            strb.Append("UNOA" + f + "0" + e);                                                                                     //010 Syntax identifier and version
            strb.Append(e);                                                                                                        //020 not used
            strb.Append(Sout(POut.Long(rx.RxNum)) + e);                                                                            //030 Transaction reference (Clinic system trace number.) Sender creates a Unique Trace number for each message sent.
            strb.Append(e);                                                                                                        //040 not used
            strb.Append(e);                                                                                                        //050 not used
            strb.Append("56873771" + f + "C" + f + "PASSWORDQ" + e);                                                               //060 Sender identification (This is the Clinic ID of the sender; C means it is a Clinic.)
            strb.Append(Sout(pharmacy.PharmID) + f + "P" + e);                                                                     //070 Recipient ID (NCPDP Provider ID Number of pharmacy; P means it is a pharmacy.)
            strb.Append(Sout(msgTimeSent.ToString("yyyyMMdd")) + f + Sout(msgTimeSent.ToString("HHmmss")) + s);                    //080 Date of initiation CCYYMMDD:HHMMSS,S
            //UIH+SCRIPT:010:006:NEWRX+110072+++19971001:081522'-------------------------------------------------------
            strb.Append("UIH" + e);                                                                                                //000
            strb.Append("SCRIPT" + f + "010" + f + "006" + f + "NEWRX" + e);                                                       //010 Message type:version:release:function.
            //Clinic's reference number for message. Usually this is the folio number for the patient. However, this is the ID by which the clinic will be able to refer to this prescription.
            strb.Append(Sout(rx.RxNum.ToString()) + e);                                                                            //020 Message reference number (Must match number in UIT segment below, must be unique. Recommend using rx num)
            strb.Append(e);                                                                                                        //030 conditional Dialogue Reference
            strb.Append(e);                                                                                                        //040 not used
            strb.Append(Sout(msgTimeSent.ToString("yyyyMMdd")) + f + Sout(msgTimeSent.ToString("HHmmss")) + s);                    //050 Date of initiation
            //PVD+P1+7701630:D3+++++MAIN STREET PHARMACY++6152205656:TE'-----------------------------------------------
            strb.Append("PVD" + e);                                                                                                //000
            strb.Append("P1" + e);                                                                                                 //010 Provider coded (see external code list pg.109)
            strb.Append(Sout(pharmacy.PharmID) + f + "D3" + e);                                                                    //020 Reference number and qualifier (Pharmacy ID)
            strb.Append(e);                                                                                                        //030 not used
            strb.Append(e);                                                                                                        //040 conditional Provider specialty
            strb.Append(e);                                                                                                        //050 conditional The name of the prescriber or pharmacist or supervisor
            strb.Append(e);                                                                                                        //060 not used
            strb.Append(e);                                                                                                        //070 conditional The clinic or pharmacy name
            strb.Append(Sout(pharmacy.Address) + f + Sout(pharmacy.City) + f + Sout(pharmacy.State) + f + Sout(pharmacy.Zip) + e); //080 Address
            strb.Append(Regex.Replace(Sout(pharmacy.Phone), @"[-()]", string.Empty) + f + "TE" + s);                               //090 Communication number and qualifier
            //PVD+PC+6666666:0B+++JONES:MARK++++6152219800:TE'---------------------------------------------------------
            strb.Append("PVD" + e);                                                                                                //000
            strb.Append("PC" + e);                                                                                                 //010 Provider coded
            strb.Append(Sout(prov.StateRxID) + f + "0B" + e);                                                                      //020 Reference number and qualifier (0B: Provider State License Number)
            strb.Append(e);                                                                                                        //030 not used
            strb.Append(e);                                                                                                        //040 conditional Provider specialty
            strb.Append(Sout(prov.LName) + f + Sout(prov.FName) + e);                                                              //050 The name of the prescriber or pharmacist or supervisor
            strb.Append(e);                                                                                                        //060 not used
            strb.Append(e);                                                                                                        //070 conditional The clinic or pharmacy name
            strb.Append(e);                                                                                                        //080 conditional Address
            strb.Append(Regex.Replace(Sout(PrefC.GetString(PrefName.PracticePhone)), @"[-()]", string.Empty) + f + "TE" + s);      //090 Communication number and qualifier
            //PTT++19541225+SMITH:MARY+F+333445555:SY'-----------------------------------------------------------------
            strb.Append("PTT" + e);                                                                                                //000
            strb.Append(e);                                                                                                        //010 conditional Individual relationship
            strb.Append(Sout(pat.Birthdate.ToString("yyyyMMdd")) + e);                                                             //020 Birth date of patient YYYYMMDD
            strb.Append(Sout(pat.LName) + f + Sout(pat.FName) + e);                                                                //030 Name
            strb.Append(Sout(pat.Gender.ToString().Substring(0, 1)) + e);                                                          //040 Gender (M,F,U)
            strb.Append(Sout(pat.SSN.Replace("-", "")) + f + "SY" + s);                                                            //050 Patient ID and/or SSN and qualifier
            //COO+123456:BO+INSURANCE COMPANY NAME++123456789++AA112'--------------------------------------------------
            strb.Append("COO" + e);                                                                                                //000
            strb.Append(Sout(plan.RxBIN) + f + "BO" + e);                                                                          //010 Payer ID Information and qualifier (Primary Payer's identification number? BO is for BIN Location Number.)
            strb.Append(Sout(car.CarrierName) + e);                                                                                //020 Payer name
            strb.Append(e);                                                                                                        //030 conditional Service type, coded
            strb.Append(Sout(sub.SubscriberID) + e);                                                                               //040 Cardholder ID
            strb.Append(e);                                                                                                        //050 conditional Cardholder name
            strb.Append(Sout(plan.GroupNum) + s);                                                                                  //060 Group ID
            //DRU------------------------------------------------------------------------------------------------------
            //DRU+P:CALAN SR 240MG::::240:::::::AA:C42998:AB:C28253+::60:38:AC:C48542+:1 TID -TAKE ONE TABLET TWO TIMES A DAY UNTIL GONE+85:19971001:102*ZDS:30:804+0+R:1'
            strb.Append("DRU" + e);          //000
            //P means prescribed. Drug prescribed is Calan Sr 240mg.
            //240 is the strength (free text); AA is the Source for NCI Pharmaceutical Dosage Form. C42998 is the code for “Tablet dosing form”.
            //AB is the Source for NCI Units of Presentation. C28253 is the code for “Milligram”. So this means the prescription is for 240mg tablets.
            //There's AA, AB and AC - AC is Potency Unit
            //The definitions for C42998 and C28253 and be found @ http://nciterms.nci.nih.gov/ncitbrowser/pages/vocabulary.jsf?dictionary=NCI_Thesaurus
            strb.Append("P" + f + Sout(rx.Drug) + f + f + f + f + f + f + Sout(rx.RxCui.ToString()) + f + "SBD" + e); //f+f+f+f+"AA"+f+"C42998"+f+"AB"+f+"C28253"+e);//010 Item Description Identification
            //This means dispense 60 tablets. 38 is the code value for Original Qty. AC is the Source for NCI Potency Units. C48542 is the code for “Tablet dosing unit”.
            strb.Append("" + f + f + Sout(rx.Disp) + f + f + "AA" + f + Sout(rx.DosageCode) + e);                     //020 Quantity
            strb.Append(f + Sout(rx.Sig) + e);                                                                        //030 Directions
            //85 qualifier for Date Issued (Written date) 102 is qualifier for CCYYMMDD format.
            //ZDS is the qualifier for Days Supply. 30 is the number of days supply. 804 is the qualifier for Quantity of Days.
            strb.Append("85" + f + Sout(rx.RxDate.ToString("yyyyMMdd")) + f + "102" + e); //+p+"ZDS"+f+"30"+f+"804"+e);//040 Date Note: It is strongly recommended that Days Supply (value “ZDS”) be supported.
            strb.Append("0" + e);                                                         //050 Product/Service substitution, coded
            strb.Append("R" + f + Sout(rx.Refills) + s);                                  //060 Refill and quantity
            //UIT+110072+6'---------------------------------------------------------------------------------------------
            strb.Append("UIT" + e);                                                       //000
            strb.Append(Sout(rx.RxNum.ToString()) + e);                                   //010 Message reference number
            strb.Append("5" + s);                                                         //020 Mandatory field. This is the count of the number of segments in the message including the UIH and UIT
            //UIZ++1'---------------------------------------------------------------------------------------------------
            strb.Append("UIZ" + e);                                                       //000
            strb.Append(e);                                                               //010 not used
            strb.Append("1" + s);                                                         //020 Number of messages per interchange. The count of UIH-UIT occurrences
            //Uncomment if you want to see the message text:
            //MsgBoxCopyPaste msgbox=new MsgBoxCopyPaste(strb.ToString());
            //msgbox.ShowDialog();
            Cursor = Cursors.WaitCursor;
            try {
                                #if EHRTEST
                EHR.EhrEmail.Send("10.6 SCRIPT for NEWRX", "SCRIPT.txt", strb.ToString());
                                #else
                //can't send email unless in debug/ehrtest mode.
                                #endif
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            Cursor = Cursors.Default;
            MessageBox.Show("Sent");
            rx.SendStatus = RxSendStatus.SentElect;          //Removes the Rx from the grid.
            RxPats.Update(rx);
            FillGrid();
        }
Exemplo n.º 3
0
        private void FillPlanData()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            //col=new ODGridColumn(Lan.g("TableInsPlans","#"),20);
            //gridMain.Columns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Subscriber"), 140);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Ins Carrier"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Date Effect."), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Date Term."), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Used By"), 90);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;
            //PatPlan[] patPlanArray;
            InsPlan plan;

            for (int i = 0; i < SubList.Count; i++)
            {
                if (!checkShowPlansNotInUse.Checked &&                //Only show insurance plans for PatCur.
                    !_listPatCurPatPlans.Exists(x => x.InsSubNum == SubList[i].InsSubNum))
                {
                    continue;
                }
                row     = new GridRow();
                row.Tag = SubList[i];
                //row.Cells.Add((gridMain.Rows.Count+1).ToString());
                row.Cells.Add(FamCur.GetNameInFamLF(SubList[i].Subscriber));
                plan = InsPlans.GetPlan(SubList[i].PlanNum, PlanList);
                row.Cells.Add(Carriers.GetName(plan.CarrierNum));
                if (SubList[i].DateEffective.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(SubList[i].DateEffective.ToString("d"));
                }
                if (SubList[i].DateTerm.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(SubList[i].DateTerm.ToString("d"));
                }
                int countPatPlans = PatPlans.GetCountBySubNum(SubList[i].InsSubNum);
                row.Cells.Add(countPatPlans.ToString());
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            listRelat.Items.Clear();
            for (int i = 0; i < Enum.GetNames(typeof(Relat)).Length; i++)
            {
                listRelat.Items.Add(Lan.g("enumRelat", Enum.GetNames(typeof(Relat))[i]));
            }
        }
Exemplo n.º 4
0
        ///<summary>Only gets run once.</summary>
        private void FillGrid()
        {
            Cursor = Cursors.WaitCursor;
            //ListAll: Set externally before loading.
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Employer", 100);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Carrier", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Phone", 82);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Address", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("City", 80);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("ST", 25);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Zip", 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Group#", 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Group Name", 90);
            gridMain.Columns.Add(col);
            //col=new ODGridColumn("noE",35);
            //gridMain.Columns.Add(col);
            //col=new ODGridColumn("ElectID",45);
            //gridMain.Columns.Add(col);
            col = new ODGridColumn("Plans", 40);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Plan Note", 180);
            gridMain.Columns.Add(col);
            //TrojanID and PlanNote not shown
            gridMain.Rows.Clear();
            ODGridRow row;
            Carrier   carrier;

            for (int i = 0; i < ListAll.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Employers.GetName(ListAll[i].EmployerNum));
                carrier = Carriers.GetCarrier(ListAll[i].CarrierNum);
                row.Cells.Add(carrier.CarrierName);
                row.Cells.Add(carrier.Phone);
                row.Cells.Add(carrier.Address);
                row.Cells.Add(carrier.City);
                row.Cells.Add(carrier.State);
                row.Cells.Add(carrier.Zip);
                row.Cells.Add(ListAll[i].GroupNum);
                row.Cells.Add(ListAll[i].GroupName);
                //if(carrier.NoSendElect)
                //	row.Cells.Add("X");
                //else
                //	row.Cells.Add("");
                //row.Cells.Add(carrier.ElectID);
                row.Cells.Add(ListAll[i].NumberPlans.ToString());
                row.Cells.Add(ListAll[i].PlanNote);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(0, true);
            Cursor = Cursors.Default;
        }
Exemplo n.º 5
0
        private void FillGrid()
        {
            Carriers.Refresh();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            if (checkCDAnet.Checked)
            {
                gridMain.Size = new Size(745, gridMain.Height);
                col           = new ODGridColumn(Lan.g("TableCarriers", "Carrier Name"), 160);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "ElectID"), 60);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "PMP"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Network"), 50);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Version"), 50);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "02"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "03"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "04"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "05"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "06"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "07"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "08"), 50, HorizontalAlignment.Center);
                gridMain.Columns.Add(col);
            }
            else
            {
                gridMain.Size = new Size(839, gridMain.Height);
                col           = new ODGridColumn(Lan.g("TableCarriers", "Carrier Name"), 160);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Phone"), 90);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Address"), 130);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Address2"), 120);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "City"), 110);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "ST"), 60);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "Zip"), 90);
                gridMain.Columns.Add(col);
                col = new ODGridColumn(Lan.g("TableCarriers", "ElectID"), 60);
                gridMain.Columns.Add(col);
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            if (checkCDAnet.Checked)
            {
                table = Carriers.Refresh(true);
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    row = new ODGridRow();
                    //row.Tag//CarrierNum
                    row.Cells.Add(table.Rows[i]["CarrierName"].ToString());
                    row.Cells.Add(table.Rows[i]["ElectID"].ToString());
                    row.Cells.Add(table.Rows[i]["PMP"].ToString());
                    row.Cells.Add(table.Rows[i]["Network"].ToString());
                    row.Cells.Add(table.Rows[i]["Version"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans02"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans03"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans04"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans05"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans06"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans07"].ToString());
                    row.Cells.Add(table.Rows[i]["Trans08"].ToString());
                    gridMain.Rows.Add(row);
                }
            }
            else
            {
                for (int i = 0; i < Carriers.List.Length; i++)
                {
                    row = new ODGridRow();
                    row.Cells.Add(Carriers.List[i].CarrierName);
                    row.Cells.Add(Carriers.List[i].Phone);
                    row.Cells.Add(Carriers.List[i].Address);
                    row.Cells.Add(Carriers.List[i].Address2);
                    row.Cells.Add(Carriers.List[i].City);
                    row.Cells.Add(Carriers.List[i].State);
                    row.Cells.Add(Carriers.List[i].Zip);
                    row.Cells.Add(Carriers.List[i].ElectID);
                    gridMain.Rows.Add(row);
                }
            }

            gridMain.EndUpdate();
            //if(tbCarriers.SelectedIndices.Length>0){
            //	tbCarriers.ScrollToLine(tbCarriers.SelectedIndices[0]);
            //}
        }
Exemplo n.º 6
0
        ///<summary></summary>
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textMain.Text == "")
            {
                MsgBox.Show(this, "Please paste the text generated by the other program into the large box first.");
                return;
            }
            pat               = new Patient();
            pat.PriProv       = PrefC.GetLong(PrefName.PracticeDefaultProv);
            pat.BillingType   = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            guar              = new Patient();
            guar.PriProv      = PrefC.GetLong(PrefName.PracticeDefaultProv);
            guar.BillingType  = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            subsc             = new Patient();
            subsc.PriProv     = PrefC.GetLong(PrefName.PracticeDefaultProv);
            subsc.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            sub               = new InsSub();
            sub.ReleaseInfo   = true;
            sub.AssignBen     = true;
            plan              = new InsPlan();
            carrier           = new Carrier();
            insRelat          = "self"; //this is the default if not included
            guarRelat         = "self";
            InsEmp            = "";
            GuarEmp           = "";
            NoteMedicalComp   = "";
            insPresent        = false;
            annualMax         = -1;
            deductible        = -1;
            XmlTextReader reader = new XmlTextReader(new StringReader(textMain.Text));

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

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

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

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

            //Patient-------------------------------------------------------------------------------------
            //DataTable table;
            long    patNum      = Patients.GetPatNumByNameAndBirthday(pat.LName, pat.FName, pat.Birthdate);
            Patient existingPat = null;

            existingPatOld = null;      //we will need this to do an update.
            if (patNum != 0)            //a patient already exists, so only add missing fields
            {
                existingPat    = Patients.GetPat(patNum);
                existingPatOld = existingPat.Copy();
                if (existingPat.MiddleI == "")              //only alter existing if blank
                {
                    existingPat.MiddleI = pat.MiddleI;
                }
                if (pat.Gender != PatientGender.Unknown)
                {
                    existingPat.Gender = pat.Gender;
                }
                if (existingPat.Preferred == "")
                {
                    existingPat.Preferred = pat.Preferred;
                }
                if (existingPat.Address == "")
                {
                    existingPat.Address = pat.Address;
                }
                if (existingPat.Address2 == "")
                {
                    existingPat.Address2 = pat.Address2;
                }
                if (existingPat.City == "")
                {
                    existingPat.City = pat.City;
                }
                if (existingPat.State == "")
                {
                    existingPat.State = pat.State;
                }
                if (existingPat.Zip == "")
                {
                    existingPat.Zip = pat.Zip;
                }
                if (existingPat.HmPhone == "")
                {
                    existingPat.HmPhone = pat.HmPhone;
                }
                if (existingPat.Email == "")
                {
                    existingPat.Email = pat.Email;
                }
                if (existingPat.WkPhone == "")
                {
                    existingPat.WkPhone = pat.WkPhone;
                }
                if (existingPat.Position == PatientPosition.Single)
                {
                    existingPat.Position = pat.Position;
                }
                if (existingPat.SSN == "")
                {
                    existingPat.SSN = pat.SSN;
                }
                existingPat.AddrNote += pat.AddrNote;              //concat
                Patients.Update(existingPat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(existingPat.PatNum, existingPat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, existingPat.Guarantor);
                //guarantor will not be altered in any way
            }            //if patient already exists
            else         //patient is new, so insert
            {
                Patients.Insert(pat, false);
                SecurityLogs.MakeLogEntry(Permissions.PatientCreate, pat.PatNum, "Created from Import Patient XML tool.");
                existingPatOld = pat.Copy();
                pat.Guarantor  = pat.PatNum;             //this can be changed later.
                Patients.Update(pat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(pat.PatNum, pat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, pat.Guarantor);
            }
            //guar-----------------------------------------------------------------------------------------------------
            if (existingPat == null)          //only add or alter guarantor for new patients
            {
                if (guarRelat == "self")
                {
                    //pat is already set with guar as self
                    //ignore all guar fields except EmployerName
                    existingPatOld  = pat.Copy();
                    pat.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                    Patients.Update(pat, existingPatOld);
                }
                else
                {
                    //if guarRelat is not self, and name and birthdate not supplied, a warning was issued, and relat was changed to self.
                    //add guarantor or attach to an existing guarantor
                    long guarNum = Patients.GetPatNumByNameAndBirthday(guar.LName, guar.FName, guar.Birthdate);
                    if (guarNum != 0)                    //a guar already exists, so simply attach. Make no other changes
                    {
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = guarNum;
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                    else                     //we need to completely create guar, then attach
                    {
                        Patients.Insert(guar, false);
                        SecurityLogs.MakeLogEntry(Permissions.PatientCreate, guar.PatNum, "Created from Import Patient XML tool.");
                        //set guar for guar
                        existingPatOld   = guar.Copy();
                        guar.Guarantor   = guar.PatNum;
                        guar.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                        Patients.Update(guar, existingPatOld);
                        //set guar for pat
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = guar.PatNum;
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                }
            }
            //subsc--------------------------------------------------------------------------------------------------
            if (!insPresent)
            {
                //this takes care of missing carrier name or subscriber info.
                MsgBox.Show(this, "Done");
                DialogResult = DialogResult.OK;
            }
            if (insRelat == "self")
            {
                sub.Subscriber = pat.PatNum;
            }
            else             //we need to find or add the subscriber
            {
                patNum = Patients.GetPatNumByNameAndBirthday(subsc.LName, subsc.FName, subsc.Birthdate);
                if (patNum != 0)                //a subsc already exists, so simply attach. Make no other changes
                {
                    sub.Subscriber = patNum;
                }
                else                 //need to create and attach a subscriber
                {
                    Patients.Insert(subsc, false);
                    SecurityLogs.MakeLogEntry(Permissions.PatientCreate, subsc.PatNum, "Created from Import Patient XML tool.");
                    //set guar to same guar as patient
                    existingPatOld  = subsc.Copy();
                    subsc.Guarantor = pat.Guarantor;
                    Patients.Update(subsc, existingPatOld);
                    sub.Subscriber = subsc.PatNum;
                }
            }
            //carrier-------------------------------------------------------------------------------------------------
            //Carriers.Cur=carrier;
            carrier = Carriers.GetIdentical(carrier);          //this automatically finds or creates a carrier
            //plan------------------------------------------------------------------------------------------------------
            plan.EmployerNum = Employers.GetEmployerNum(InsEmp);
            plan.CarrierNum  = carrier.CarrierNum;
            InsPlans.Insert(plan);
            //Attach plan to subscriber
            sub.PlanNum = plan.PlanNum;
            InsSubs.Insert(sub);
            //Then attach plan
            List <PatPlan> PatPlanList = PatPlans.Refresh(pat.PatNum);
            PatPlan        patplan     = new PatPlan();

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

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

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

            case "guardian":
                patplan.Relationship = Relat.Dependent;
                break;
            }
            PatPlans.Insert(patplan);
            //benefits
            if (annualMax != -1 && CovCats.GetCount(true) > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Limitations;
                ben.CovCatNum   = CovCats.GetFirst(true).CovCatNum;
                ben.MonetaryAmt = annualMax;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            if (deductible != -1 && CovCats.GetCount(true) > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Deductible;
                ben.CovCatNum   = CovCats.GetFirst(true).CovCatNum;
                ben.MonetaryAmt = deductible;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            MsgBox.Show(this, "Done");
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 7
0
        private void Import834_Unsafe()
        {
            if (!MsgBox.Show(this, true, "Importing insurance plans is a database intensive operation and can take 10 minutes or more to run.  "
                             + "It is best to import insurance plans after hours or during another time period when database usage is otherwise low.\r\n"
                             + "Click OK to import insurance plans now, or click Cancel."))
            {
                return;
            }
            checkIsPatientCreate.Enabled = false;
            gridInsPlans.Enabled         = false;
            butOK.Enabled     = false;
            butCancel.Enabled = false;
            Cursor            = Cursors.WaitCursor;
            Prefs.UpdateBool(PrefName.Ins834IsPatientCreate, checkIsPatientCreate.Checked);
            int           rowIndex             = 1;
            int           createdPatsCount     = 0;
            int           updatedPatsCount     = 0;
            int           skippedPatsCount     = 0;
            int           createdCarrierCount  = 0;
            int           createdPlanCount     = 0;
            int           droppedPlanCount     = 0;
            int           updatedPlanCount     = 0;
            StringBuilder sbErrorMessages      = new StringBuilder();
            List <int>    listImportedSegments = new List <int> ();      //Used to reconstruct the 834 with imported patients removed.

            for (int i = 0; i < _x834.ListTransactions.Count; i++)
            {
                Hx834_Tran tran = _x834.ListTransactions[i];
                for (int j = 0; j < tran.ListMembers.Count; j++)
                {
                    Hx834_Member member = tran.ListMembers[j];
                    ShowStatus("Progress " + (rowIndex).ToString().PadLeft(6) + "/" + gridInsPlans.Rows.Count.ToString().PadLeft(6)
                               + "  Importing plans for patient " + member.Pat.GetNameLF());
                    //The patient's status is not affected by the maintenance code.  After reviewing all of the possible maintenance codes in
                    //member.MemberLevelDetail.MaintenanceTypeCode, we believe that all statuses suggest either insert or update, except for "Cancel".
                    //Nathan and Derek feel that archiving the patinet in response to a Cancel request is a bit drastic.
                    //Thus we ignore the patient maintenance code and always assume insert/update.
                    //Even if the status was "Cancel", then updating the patient does not hurt.
                    bool isMemberImported = false;
                    bool isMultiMatch     = false;
                    if (member.Pat.PatNum == 0)
                    {
                        //The patient may need to be created below.  However, the patient may have already been inserted in a pervious iteration of this loop
                        //in following scenario: Two different 834s include updates for the same patient and both documents are being imported at the same time.
                        //If the patient was already inserted, then they would show up in _listPatients and also in the database.  Attempt to locate the patient
                        //in _listPatients again before inserting.
                        List <Patient> listPatientMatches = Patients.GetPatientsByNameAndBirthday(member.Pat, _listPatients);
                        if (listPatientMatches.Count == 1)
                        {
                            member.Pat.PatNum = listPatientMatches[0].PatNum;
                        }
                        else if (listPatientMatches.Count > 1)
                        {
                            isMultiMatch = true;
                        }
                    }
                    if (isMultiMatch)
                    {
                        skippedPatsCount++;
                    }
                    else if (member.Pat.PatNum == 0 && checkIsPatientCreate.Checked)
                    {
                        //The code here mimcs the behavior of FormPatientSelect.butAddPt_Click().
                        Patients.Insert(member.Pat, false);
                        Patient memberPatOld = member.Pat.Copy();
                        member.Pat.PatStatus   = PatientStatus.Patient;
                        member.Pat.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
                        if (!PrefC.GetBool(PrefName.PriProvDefaultToSelectProv))
                        {
                            //Set the patients primary provider to the practice default provider.
                            member.Pat.PriProv = Providers.GetDefaultProvider().ProvNum;
                        }
                        member.Pat.ClinicNum = Clinics.ClinicNum;
                        member.Pat.Guarantor = member.Pat.PatNum;
                        Patients.Update(member.Pat, memberPatOld);
                        int patIdx    = _listPatients.BinarySearch(member.Pat); //Preserve sort order by locating the index in which to insert the newly added patient.
                        int insertIdx = ~patIdx;                                //According to MSDN, the index returned by BinarySearch() is a "bitwise compliment", since not currently in list.
                        _listPatients.Insert(insertIdx, member.Pat);
                        SecurityLogs.MakeLogEntry(Permissions.PatientCreate, member.Pat.PatNum, "Created from Import Ins Plans 834.", LogSources.InsPlanImport834);
                        isMemberImported = true;
                        createdPatsCount++;
                    }
                    else if (member.Pat.PatNum == 0 && !checkIsPatientCreate.Checked)
                    {
                        skippedPatsCount++;
                    }
                    else                                                                                  //member.Pat.PatNum!=0
                    {
                        Patient patDb = _listPatients.FirstOrDefault(x => x.PatNum == member.Pat.PatNum); //Locate by PatNum, in case user selected manually.
                        member.MergePatientIntoDbPatient(patDb);                                          //Also updates the patient to the database and makes log entry.
                        _listPatients.Remove(patDb);                                                      //Remove patient from list so we can add it back in the correct location (in case name or bday changed).
                        int patIdx = _listPatients.BinarySearch(patDb);                                   //Preserve sort order by locating the index in which to insert the newly added patient.
                        //patIdx could be positive if the user manually selected a patient when there were multiple matches found.
                        //If patIdx is negative, then according to MSDN, the index returned by BinarySearch() is a "bitwise compliment".
                        //If there were mult instances of patDb BinarySearch() would return 0, which should not be complimented (OutOfRangeException)
                        int insertIdx = (patIdx >= 0)?patIdx:~patIdx;
                        _listPatients.Insert(insertIdx, patDb);
                        isMemberImported = true;
                        updatedPatsCount++;
                    }
                    if (isMemberImported)
                    {
                        //Import insurance changes for patient.
                        for (int k = 0; k < member.ListHealthCoverage.Count; k++)
                        {
                            Hx834_HealthCoverage healthCoverage = member.ListHealthCoverage[k];
                            if (k > 0)
                            {
                                rowIndex++;
                            }
                            List <Carrier> listCarriers = Carriers.GetByNameAndTin(tran.Payer.Name, tran.Payer.IdentificationCode);
                            if (listCarriers.Count == 0)
                            {
                                Carrier carrier = new Carrier();
                                carrier.CarrierName = tran.Payer.Name;
                                carrier.TIN         = tran.Payer.IdentificationCode;
                                Carriers.Insert(carrier);
                                DataValid.SetInvalid(InvalidType.Carriers);
                                listCarriers.Add(carrier);
                                SecurityLogs.MakeLogEntry(Permissions.CarrierCreate, 0, "Carrier '" + carrier.CarrierName
                                                          + "' created from Import Ins Plans 834.", LogSources.InsPlanImport834);
                                createdCarrierCount++;
                            }
                            //Update insurance plans.  Match based on carrier and SubscriberId.
                            bool isDropping = false;
                            if (healthCoverage.HealthCoverage.MaintenanceTypeCode == "002")
                            {
                                isDropping = true;
                            }
                            //The insPlanNew will only be inserted if necessary.  Created temporarily in order to determine if insert is needed.
                            InsPlan insPlanNew = InsertOrUpdateInsPlan(null, member, listCarriers[0], false);
                            //Since the insurance plans in the 834 do not include very much information, it is likely that many patients will share the same exact plan.
                            //We look for an existing plan being used by any other patinents which match the fields we typically import.
                            List <InsPlan> listInsPlans = InsPlans.GetAllByCarrierNum(listCarriers[0].CarrierNum);
                            InsPlan        insPlanMatch = null;
                            for (int p = 0; p < listInsPlans.Count; p++)
                            {
                                //Set the PlanNums equal so that AreEqualValue() will ignore this field.  We must ignore PlanNum, since we do not know the PlanNum.
                                insPlanNew.PlanNum = listInsPlans[p].PlanNum;
                                if (InsPlans.AreEqualValue(listInsPlans[p], insPlanNew))
                                {
                                    insPlanMatch = listInsPlans[p];
                                    break;
                                }
                            }
                            Family         fam          = Patients.GetFamily(member.Pat.PatNum);
                            List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(fam);
                            List <PatPlan> listPatPlans = PatPlans.Refresh(member.Pat.PatNum);
                            InsSub         insSubMatch  = null;
                            PatPlan        patPlanMatch = null;
                            for (int p = 0; p < listInsSubs.Count; p++)
                            {
                                InsSub insSub = listInsSubs[p];
                                //According to section 1.4.3 of the standard, the preferred method of matching a dependent to a subscriber is to use the subscriberId.
                                if (insSub.SubscriberID.Trim() != member.SubscriberId.Trim())
                                {
                                    continue;
                                }
                                insSubMatch  = insSub;
                                patPlanMatch = PatPlans.GetFromList(listPatPlans, insSub.InsSubNum);
                                break;
                            }
                            if (patPlanMatch == null && isDropping)                           //No plan match and dropping plan.
                            //Nothing to do.  The plan either never existed or is already dropped.
                            {
                            }
                            else if (patPlanMatch == null && !isDropping)                           //No plan match and not dropping plan.  Create the plan.
                            {
                                insPlanMatch = InsertOrUpdateInsPlan(insPlanMatch, member, listCarriers[0]);
                                insSubMatch  = InsertOrUpdateInsSub(insSubMatch, insPlanMatch, member, healthCoverage, listCarriers[0]);
                                patPlanMatch = InsertOrUpdatePatPlan(patPlanMatch, insSubMatch, insPlanMatch, member, listCarriers[0], listPatPlans);
                                createdPlanCount++;
                            }
                            else if (patPlanMatch != null && isDropping)                           //Plan matched and dropping plan.  Drop the plan.
                            //This code mimics the behavior of FormInsPlan.butDrop_Click(), except here we do not care if there are claims for this plan today.
                            //We need this feature to be as streamlined as possible so that it might become an automated process later.
                            //Testing for claims on today's date does not seem that useful anyway, or at least not as useful as checking for any claims
                            //associated to the plan, instead of just today's date.
                            {
                                PatPlans.Delete(patPlanMatch.PatPlanNum);                                //Estimates recomputed within Delete()
                                SecurityLogs.MakeLogEntry(Permissions.InsPlanDropPat, patPlanMatch.PatNum,
                                                          "Insurance plan dropped from patient for carrier '" + listCarriers[0].CarrierName + "' and groupnum "
                                                          + "'" + insPlanMatch.GroupNum + "' and subscriber ID '" + insSubMatch.SubscriberID + "' "
                                                          + "from Import Ins Plans 834.", insPlanMatch.PlanNum, LogSources.InsPlanImport834, insPlanMatch.SecDateTEdit);
                                droppedPlanCount++;
                            }
                            else if (patPlanMatch != null && !isDropping)                            //Plan matched and not dropping plan.  Update the plan.
                            {
                                insPlanMatch = InsertOrUpdateInsPlan(insPlanMatch, member, listCarriers[0]);
                                insSubMatch  = InsertOrUpdateInsSub(insSubMatch, insPlanMatch, member, healthCoverage, listCarriers[0]);
                                patPlanMatch = InsertOrUpdatePatPlan(patPlanMatch, insSubMatch, insPlanMatch, member, listCarriers[0], listPatPlans);
                                updatedPlanCount++;
                            }
                        }                        //end loop k
                        //Remove the member from the X834.
                        int endSegIndex = 0;
                        if (j < tran.ListMembers.Count - 1)
                        {
                            endSegIndex = tran.ListMembers[j + 1].MemberLevelDetail.SegmentIndex - 1;
                        }
                        else
                        {
                            X12Segment segSe = _x834.GetNextSegmentById(member.MemberLevelDetail.SegmentIndex + 1, "SE");                       //SE segment is required.
                            endSegIndex = segSe.SegmentIndex - 1;
                        }
                        for (int s = member.MemberLevelDetail.SegmentIndex; s <= endSegIndex; s++)
                        {
                            listImportedSegments.Add(s);
                        }
                    }
                    rowIndex++;
                }                                                       //end loop j
            }                                                           //end loop i
            if (listImportedSegments.Count > 0 && skippedPatsCount > 0) //Some patients imported, while others did not.
            {
                if (MoveFileToArchiveFolder())
                {
                    //Save the unprocessed members back to the import directory, so the user can try to import them again.
                    File.WriteAllText(_x834.FilePath, _x834.ReconstructRaw(listImportedSegments));
                }
            }
            else if (listImportedSegments.Count > 0)             //All patinets imported.
            {
                MoveFileToArchiveFolder();
            }
            else if (skippedPatsCount > 0)             //No patients imported.  All patients were skipped.
            //Leave the raw file unaltered and where it is, so it can be processed again.
            {
            }
            Cursor = Cursors.Default;
            string msg = Lan.g(this, "Done.");

            if (createdPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients created:") + " " + createdPatsCount;
            }
            if (updatedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients updated:") + " " + updatedPatsCount;
            }
            if (skippedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients skipped:") + " " + skippedPatsCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdCarrierCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of carriers created:") + " " + createdCarrierCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans created:") + " " + createdPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (droppedPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans dropped:") + " " + droppedPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (updatedPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans updated:") + " " + updatedPlanCount;
                msg += sbErrorMessages.ToString();
            }
            MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(msg);

            msgBox.ShowDialog();
        }
        ///<summary>Gets all claims for the patient selected.  Fills gridClaims and tags each row with its corrisponding claim object.</summary>
        private void FillGridClaims()
        {
            int  sortByColIdx = gridClaims.SortedByColumnIdx;           //Keep previous sorting
            bool isSortAsc    = gridClaims.SortedIsAscending;

            if (sortByColIdx == -1)
            {
                sortByColIdx = 0;
                isSortAsc    = false;
            }
            gridClaims.BeginUpdate();
            gridClaims.Rows.Clear();
            gridClaims.Columns.Clear();
            gridClaims.Columns.Add(new UI.ODGridColumn("Date Service", 100, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.DateParse
            });
            gridClaims.Columns.Add(new UI.ODGridColumn("Carrier", 240, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.StringCompare
            });
            gridClaims.Columns.Add(new UI.ODGridColumn("Status", 120, HorizontalAlignment.Center)
            {
                SortingStrategy = UI.GridSortingStrategy.StringCompare
            });
            if (!PrefC.GetBool(PrefName.EasyNoClinics))             //Using clinics
            {
                gridClaims.Columns.Add(new UI.ODGridColumn("Clinic", 190, HorizontalAlignment.Left)
                {
                    SortingStrategy = UI.GridSortingStrategy.StringCompare
                });
            }
            gridClaims.Columns.Add(new UI.ODGridColumn("ClaimFee", 70, HorizontalAlignment.Right)
            {
                SortingStrategy = UI.GridSortingStrategy.AmountParse
            });
            List <Claim> listClaims = Claims.Refresh(_patNum);

            for (int i = 0; i < listClaims.Count; i++)
            {
                UI.ODGridRow row = new UI.ODGridRow();
                row.Tag = listClaims[i];
                row.Cells.Add(listClaims[i].DateService.ToShortDateString());                           //DOS
                row.Cells.Add(Carriers.GetName(InsPlans.RefreshOne(listClaims[i].PlanNum).CarrierNum)); //Carrier
                row.Cells.Add(Claims.GetClaimStatusString(listClaims[i].ClaimStatus));                  //Status
                if (!PrefC.GetBool(PrefName.EasyNoClinics))                                             //Using clinics
                {
                    Clinic clinic = Clinics.GetClinic(listClaims[i].ClinicNum);
                    if (clinic == null)
                    {
                        row.Cells.Add("");                        //Clinic
                    }
                    else
                    {
                        row.Cells.Add(clinic.Description);                        //Clinic
                    }
                }
                row.Cells.Add(listClaims[i].ClaimFee.ToString("f"));                //Claimfee
                gridClaims.Rows.Add(row);
            }
            gridClaims.EndUpdate();
            gridClaims.SortForced(sortByColIdx, isSortAsc);
        }
Exemplo n.º 9
0
        /*
         * private void FillClaimForms(){
         *      for(int i=0;i<ClaimForms.ListShort.Length;i++) {
         *              comboClaimForm.Items.Add(ClaimForms.ListShort[i].Description);
         *              if(ClaimForms.ListShort[i].ClaimFormNum==PrefC.GetLong(PrefName.DefaultClaimForm)) {
         *                      comboClaimForm.SelectedIndex=i;
         *              }
         *      }
         * }*/

        private void FillPlanData()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableInsPlans", "Plan"), 50);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Subscriber"), 140);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Ins Carrier"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Date Effect."), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInsPlans", "Date Term."), 90);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow        row;
            List <GridRow> listRows = new List <GridRow>();         //create a list of gridrows so that we can order them by Ordinal after creating them.

            for (int i = 0; i < SubList.Count; i++)
            {
                row = new GridRow();
                if (!checkShowPlansNotInUse.Checked &&                //Only show insurance plans for PatCur.
                    !_listPatCurPatPlans.Exists(x => x.InsSubNum == SubList[i].InsSubNum))
                {
                    continue;
                }
                else if (checkShowPlansNotInUse.Checked && !_listPatCurPatPlans.Exists(x => x.InsSubNum == SubList[i].InsSubNum))
                {
                    row.Cells.Add("Not Used");
                }
                else
                {
                    PatPlan patPlan = _listPatCurPatPlans.FirstOrDefault(x => x.InsSubNum == SubList[i].InsSubNum);
                    if (patPlan == null)
                    {
                        continue;
                    }
                    if (patPlan.Ordinal == 1)
                    {
                        row.Cells.Add("Pri");
                    }
                    else if (patPlan.Ordinal == 2)
                    {
                        row.Cells.Add("Sec");
                    }
                    else
                    {
                        row.Cells.Add("Other");
                    }
                }
                InsPlan plan = InsPlans.GetPlan(SubList[i].PlanNum, PlanList);
                row.Tag = SubList[i];
                row.Cells.Add(FamCur.GetNameInFamLF(SubList[i].Subscriber));
                row.Cells.Add(Carriers.GetName(plan.CarrierNum));
                if (SubList[i].DateEffective.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(SubList[i].DateEffective.ToString("d"));
                }
                if (SubList[i].DateTerm.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(SubList[i].DateTerm.ToString("d"));
                }
                listRows.Add(row);
            }
            listRows = listRows.OrderBy(x => x.Cells[0].Text != "Pri")
                       .ThenBy(x => x.Cells[0].Text != "Sec")
                       .ThenBy(x => x.Cells[0].Text != "Other")
                       .ThenBy(x => x.Cells[0].Text != "Not Used").ToList();
            for (int i = 0; i < listRows.Count; i++)
            {
                gridMain.ListGridRows.Add(listRows[i]);
            }
            gridMain.EndUpdate();
            listRelat.Items.Clear();
            for (int i = 0; i < Enum.GetNames(typeof(Relat)).Length; i++)
            {
                listRelat.Items.Add(Lan.g("enumRelat", Enum.GetNames(typeof(Relat))[i]));
            }
        }
Exemplo n.º 10
0
        ///<summary>raised for each page to be printed.  One page per appointment.</summary>
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            if (ApptNum != 0)           //just for one appointment
            {
                date = Appointments.DateSelected;
            }
            Graphics   g = ev.Graphics;
            float      y = 50;
            float      x = 0;
            string     str;
            float      sizeW;       //used when measuring text for placement
            Font       fontTitle   = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
            Font       fontHeading = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold);
            Font       font        = new Font(FontFamily.GenericSansSerif, 8);
            SolidBrush brush       = new SolidBrush(Color.Black);

            //Title----------------------------------------------------------------------------------------------------------
            str   = Lan.g(this, "Routing Slip");
            sizeW = g.MeasureString(str, fontTitle).Width;
            x     = 425 - sizeW / 2;
            g.DrawString(str, fontTitle, brush, x, y);
            y += 35;
            x  = 75;
            //Today's appointment, including procedures-----------------------------------------------------------------------
            Family  fam = Patients.GetFamily(Appts[pagesPrinted].PatNum);
            Patient pat = fam.GetPatient(Appts[pagesPrinted].PatNum);

            str = pat.GetNameFL();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Appts[pagesPrinted].AptDateTime.ToShortTimeString() + "  " + Appts[pagesPrinted].AptDateTime.ToShortDateString();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = (Appts[pagesPrinted].Pattern.Length * 5).ToString() + " " + Lan.g(this, "minutes");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Providers.GetAbbr(Appts[pagesPrinted].ProvNum);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            if (Appts[pagesPrinted].ProvHyg != 0)
            {
                str = Providers.GetAbbr(Appts[pagesPrinted].ProvHyg);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Procedures:");
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Procedure[] procsAll = Procedures.Refresh(pat.PatNum);
            Procedure[] procsApt = Procedures.GetProcsOneApt(Appts[pagesPrinted].AptNum, procsAll);
            for (int i = 0; i < procsApt.Length; i++)
            {
                str = "   " + Procedures.GetDescription(procsApt[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Note:") + " " + Appts[pagesPrinted].Note;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Patient/Family Info---------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Patient Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "PatNum:") + " " + pat.PatNum.ToString();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Age:") + " ";
            if (pat.Age > 0)
            {
                str += pat.Age.ToString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Date of First Visit:") + " ";
            if (pat.DateFirstVisit.Year < 1880)
            {
                str += "?";
            }
            else if (pat.DateFirstVisit == Appts[pagesPrinted].AptDateTime.Date)
            {
                str += Lan.g(this, "New Patient");
            }
            else
            {
                str += pat.DateFirstVisit.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Billing Type:") + " " + DefB.GetName(DefCat.BillingTypes, pat.BillingType);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Recall[] recallList = Recalls.GetList(new int[] { pat.PatNum });
            str = Lan.g(this, "Recall Due Date:") + " ";
            if (recallList.Length > 0)
            {
                str += recallList[0].DateDue.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Medical notes:") + " " + pat.MedUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Other Family Members
            str = Lan.g(this, "Other Family Members");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < fam.List.Length; i++)
            {
                if (fam.List[i].PatNum == pat.PatNum)
                {
                    continue;
                }
                str = fam.List[i].GetNameFL();
                if (fam.List[i].Age > 0)
                {
                    str += ",   " + fam.List[i].Age.ToString();
                }
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Insurance Info--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Insurance");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            PatPlan[]   patPlanList   = PatPlans.Refresh(pat.PatNum);
            InsPlan[]   plans         = InsPlans.Refresh(fam);
            ClaimProc[] claimProcList = ClaimProcs.Refresh(pat.PatNum);
            Benefit[]   benefits      = Benefits.Refresh(patPlanList);
            InsPlan     plan;
            Carrier     carrier;
            string      subscriber;
            double      max;
            double      deduct;

            if (patPlanList.Length == 0)
            {
                str = Lan.g(this, "none");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            for (int i = 0; i < patPlanList.Length; i++)
            {
                plan    = InsPlans.GetPlan(patPlanList[i].PlanNum, plans);
                carrier = Carriers.GetCarrier(plan.CarrierNum);
                str     = carrier.CarrierName;
                g.DrawString(str, fontHeading, brush, x, y);
                y         += 18;
                subscriber = fam.GetNameInFamFL(plan.Subscriber);
                if (subscriber == "")               //subscriber from another family
                {
                    subscriber = Patients.GetLim(plan.Subscriber).GetNameLF();
                }
                str = Lan.g(this, "Subscriber:") + " " + subscriber;
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = Lan.g(this, "Annual Max:") + " ";
                max = Benefits.GetAnnualMax(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (max != -1)
                {
                    str += max.ToString("n0") + " ";
                }
                str   += "   ";
                str   += Lan.g(this, "Deductible:") + " ";
                deduct = Benefits.GetDeductible(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (deduct != -1)
                {
                    str += deduct.ToString("n0");
                }
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = "";
                for (int j = 0; j < benefits.Length; j++)
                {
                    if (benefits[j].PlanNum != plan.PlanNum)
                    {
                        continue;
                    }
                    if (benefits[j].BenefitType != InsBenefitType.Percentage)
                    {
                        continue;
                    }
                    if (str != "")
                    {
                        str += ",  ";
                    }
                    str += CovCats.GetDesc(benefits[j].CovCatNum) + " " + benefits[j].Percent.ToString() + "%";
                }
                if (str != "")
                {
                    g.DrawString(str, font, brush, x, y);
                    y += 15;
                }
                str = Lan.g(this, "Ins Used:") + " "
                      + InsPlans.GetInsUsed(claimProcList, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits).ToString("n");
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = Lan.g(this, "Ins Pending:") + " "
                      + InsPlans.GetPending(claimProcList, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits).ToString("n");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Account Info---------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Account Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "Guarantor:") + " " + fam.List[0].GetNameFL();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Balance:") + (fam.List[0].BalTotal - fam.List[0].InsEst).ToString("c");
            if (fam.List[0].InsEst > .01)
            {
                str += "  (" + fam.List[0].BalTotal.ToString("c") + " - "
                       + fam.List[0].InsEst.ToString("c") + " " + Lan.g(this, "InsEst") + ")";
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Aging:")
                  + "  0-30:" + fam.List[0].Bal_0_30.ToString("c")
                  + "  31-60:" + fam.List[0].Bal_31_60.ToString("c")
                  + "  61-90:" + fam.List[0].Bal_61_90.ToString("c")
                  + "  90+:" + fam.List[0].BalOver90.ToString("c");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Fam Urgent Fin Note:")
                  + fam.List[0].FamFinUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 15;
            y += 10;
            //Treatment Plan--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Treatment Plan");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < procsAll.Length; i++)
            {
                if (procsAll[i].ProcStatus != ProcStat.TP)
                {
                    continue;
                }
                str = Procedures.GetDescription(procsAll[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            pagesPrinted++;
            if (pagesPrinted == Appts.Length)
            {
                ev.HasMorePages = false;
                pagesPrinted    = 0;
            }
            else
            {
                ev.HasMorePages = true;
            }
        }
Exemplo n.º 11
0
        private void FillGrid()
        {
            gridRemainTimeUnits.BeginUpdate();
            gridRemainTimeUnits.ListGridRows.Clear();
            List <PatPlan> listPatPlans    = PatPlans.Refresh(_patCur.PatNum);
            List <InsSub>  listInsSubs     = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <Benefit> listPatBenefits = Benefits.Refresh(listPatPlans, listInsSubs);

            if (listPatBenefits.IsNullOrEmpty())
            {
                gridRemainTimeUnits.EndUpdate();
                return;
            }
            List <InsPlan> listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Carrier> listCarriers = Carriers.GetCarriers(listInsPlans.Select(x => x.CarrierNum).ToList());
            //Get the LIM information for all potential subscribers.
            List <Patient> listSubscribers = Patients.GetLimForPats(listInsSubs.Select(x => x.Subscriber).ToList());
            GridRow        gridRow;
            //Get the last year of completed procedures because there is no current TimePeriod for benefits that will care about older procedures.
            //A subset of these procedures will be used for each specific benefit in order to correctly represent the time units remaining.
            List <Procedure> listCompletedProcs = Procedures.GetCompletedForDateRange(
                DateTime.Today.AddYears(-1),
                DateTimeOD.Today,
                listPatNums: new List <long> {
                _patCur.PatNum
            });
            //Get all of the claimprocs associated to the completed procedures in order to link procedures to insurance plans.
            List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listCompletedProcs.Select(x => x.ProcNum).ToList());

            foreach (Benefit benefit in listPatBenefits)
            {
                if (benefit.CovCatNum == 0 ||           //no category
                    benefit.BenefitType != InsBenefitType.Limitations ||                     //benefit type is not limitations
                    (benefit.TimePeriod != BenefitTimePeriod.CalendarYear &&                     //neither calendar year, serviceyear, or 12 months
                     benefit.TimePeriod != BenefitTimePeriod.ServiceYear &&
                     benefit.TimePeriod != BenefitTimePeriod.NumberInLast12Months) ||
                    benefit.Quantity < 0 ||                    //quantity is negative (negatives are allowed in FormBenefitEdit)
                    benefit.QuantityQualifier != BenefitQuantity.NumberOfServices ||                    //qualifier us not the number of services
                    (benefit.CoverageLevel != BenefitCoverageLevel.Family &&                     //neither individual nor family coverage level
                     benefit.CoverageLevel != BenefitCoverageLevel.Individual))
                {
                    continue;
                }
                List <Procedure> listProcs;
                //for calendar year, get completed procs from January.01.CurYear ~ Curdate
                if (benefit.TimePeriod == BenefitTimePeriod.CalendarYear)
                {
                    //01/01/CurYear. is there a better way?
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, 1, 1));
                }
                else if (benefit.TimePeriod == BenefitTimePeriod.NumberInLast12Months)
                {
                    //today - 12 months - 1 day. Procedures exactly 1 year ago are not counted in the range
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= DateTimeOD.Today.AddYears(-1).AddDays(1));
                }
                else                                                                  //if not calendar year, then it must be service year
                {
                    int monthRenew = InsPlans.RefreshOne(benefit.PlanNum).MonthRenew; //monthrenew only stores the month as an int.
                    if (DateTimeOD.Today.Month >= monthRenew)                         //if the the current date is past the renewal month, use the current year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, monthRenew, 1));
                    }
                    else                       //otherwise use the previous year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1));
                    }
                }
                Dictionary <long, List <ClaimProc> > dictClaimProcsPerSub;
                if (benefit.PatPlanNum != 0)
                {
                    //The list of benefits that we are looping through was filled via listPatPlans so this will never fail.
                    //If this line fails then it means that there was a valid PlanNum AND a valid PatPlanNum set on the benefit which is invalid ATM.
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.InsSubNum == listPatPlans.First(y => y.PatPlanNum == benefit.PatPlanNum).InsSubNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                else                  //benefit.PatPlanNum was not set so benefit.PlanNum must be set.
                {
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.PlanNum == benefit.PlanNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                foreach (long insSubNum in dictClaimProcsPerSub.Keys)
                {
                    //The insSubNum should have a corresponding entry within listInsSubs.
                    InsSub insSub = listInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNum);
                    if (insSub == null)
                    {
                        continue;                        //If not found then there are claimprocs associated to an inssub that is associated to a dropped or missing plan.
                    }
                    InsPlan insPlan    = listInsPlans.FirstOrDefault(x => x.PlanNum == insSub.PlanNum);
                    Carrier carrier    = listCarriers.FirstOrDefault(x => x.CarrierNum == insPlan.CarrierNum);
                    Patient subscriber = listSubscribers.FirstOrDefault(x => x.PatNum == insSub.Subscriber);
                    CovCat  category   = CovCats.GetCovCat(benefit.CovCatNum);
                    //Filter out any procedures that are not associated to the insurance plan of the current benefit.
                    List <Procedure> listFilterProcs = listProcs.FindAll(x => x.ProcNum.In(dictClaimProcsPerSub[insSubNum].Select(y => y.ProcNum)));
                    //Calculate the amount used for one benefit.
                    double amtUsed   = CovCats.GetAmtUsedForCat(listFilterProcs, category);
                    double amtRemain = benefit.Quantity - amtUsed;
                    gridRow = new GridRow((carrier == null) ? "Unknown" : carrier.CarrierName,
                                          (subscriber == null) ? "Unknown" : subscriber.GetNameFL(),
                                          category.Description.ToString(),
                                          benefit.Quantity.ToString(),
                                          amtUsed.ToString("F"),
                                          (amtRemain > 0) ? amtRemain.ToString("F") : "0");
                    gridRemainTimeUnits.ListGridRows.Add(gridRow);
                }
            }
            gridRemainTimeUnits.EndUpdate();
        }
Exemplo n.º 12
0
        private bool VerifyCarrierCombineData(long pickedCarrierNum, List <long> pickedCarrierNums)
        {
            List <Carrier> listCarriers = Carriers.GetCarriers(pickedCarrierNums);
            List <string>  listWarnings = new List <string>();
            Carrier        carCur       = listCarriers.FirstOrDefault(x => x.CarrierNum == pickedCarrierNum);

            if (carCur == null)           //In case it wasn't included in the list of picked carrier nums.
            {
                carCur = Carriers.GetCarrier(pickedCarrierNum);
            }
            if (carCur == null)           //In case it is a completely invalid carrier
            {
                return(false);            //should never happen.
            }
            //==================== NAME ====================
            if (listCarriers.Any(x => x.CarrierName != carCur.CarrierName && !string.IsNullOrWhiteSpace(x.CarrierName)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Name"));
            }
            //==================== ADDRESS INFO ====================
            if (listCarriers.Any(x => x.Address != carCur.Address && !string.IsNullOrWhiteSpace(x.Address)) ||
                listCarriers.Any(x => x.Address2 != carCur.Address2 && !string.IsNullOrWhiteSpace(x.Address2)) ||
                listCarriers.Any(x => x.City != carCur.City && !string.IsNullOrWhiteSpace(x.City)) ||
                listCarriers.Any(x => x.State != carCur.State && !string.IsNullOrWhiteSpace(x.State)) ||
                listCarriers.Any(x => x.Zip != carCur.Zip && !string.IsNullOrWhiteSpace(x.Zip)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Address"));
            }
            //==================== PHONE ====================
            if (listCarriers.Any(x => x.Phone != carCur.Phone && !string.IsNullOrWhiteSpace(x.Phone)))
            {
                listWarnings.Add(Lan.g(this, "Carrier Phone"));
            }
            //==================== ElectID ====================
            if (listCarriers.Any(x => x.ElectID != carCur.ElectID && !string.IsNullOrWhiteSpace(x.ElectID)))
            {
                listWarnings.Add(Lan.g(this, "Carrier ElectID"));
            }
            //==================== TIN ====================
            if (listCarriers.Any(x => x.TIN != carCur.TIN && !string.IsNullOrWhiteSpace(x.TIN)))
            {
                listWarnings.Add(Lan.g(this, "Carrier TIN"));
            }
            //==================== CDAnetVersion ====================
            if (listCarriers.Any(x => x.CDAnetVersion != carCur.CDAnetVersion && !string.IsNullOrWhiteSpace(x.CDAnetVersion)))
            {
                listWarnings.Add(Lan.g(this, "Carrier CDAnet Version"));
            }
            //==================== IsCDA ====================
            if (listCarriers.Any(x => x.IsCDA != carCur.IsCDA))
            {
                listWarnings.Add(Lan.g(this, "Carrier Is CDA"));
            }
            //==================== CanadianNetworkNum ====================
            if (listCarriers.Any(x => x.CanadianNetworkNum != carCur.CanadianNetworkNum))
            {
                listWarnings.Add(Lan.g(this, "Canadian Network"));
            }
            //==================== NoSendElect ====================
            if (listCarriers.Any(x => x.NoSendElect != carCur.NoSendElect))
            {
                listWarnings.Add(Lan.g(this, "Send Elect"));
            }
            //==================== IsHidden ====================
            if (listCarriers.Any(x => x.IsHidden != carCur.IsHidden))
            {
                listWarnings.Add(Lan.g(this, "Is Hidden"));
            }
            //==================== CanadianEncryptionMethod ====================
            if (listCarriers.Any(x => x.CanadianEncryptionMethod != carCur.CanadianEncryptionMethod))
            {
                listWarnings.Add(Lan.g(this, "Canadian Encryption Method"));
            }
            //==================== CanadianSupportedTypes ====================
            if (listCarriers.Any(x => x.CanadianSupportedTypes != carCur.CanadianSupportedTypes))
            {
                listWarnings.Add(Lan.g(this, "Canadian Supported Types"));
            }
            //==================== Additional fields ====================
            //If anyone asks for them, these fields can also be checked.
            // public long							SecUserNumEntry;
            // public DateTime					SecDateEntry;
            // public DateTime					SecDateTEdit;
            //====================USER PROMPT====================
            if (listWarnings.Count > 0)
            {
                string warningMessage = Lan.g(this, "WARNING!") + " " + Lan.g(this, "Mismatched data has been detected between selected carriers") + ":\r\n\r\n"
                                        + string.Join("\r\n", listWarnings) + "\r\n\r\n"
                                        + Lan.g(this, "Would you like to continue combining carriers anyway?");
                if (MessageBox.Show(warningMessage, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 13
0
        private void butCombine_Click(object sender, System.EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.InsCarrierCombine))
            {
                return;
            }
            if (gridMain.SelectedIndices.Length < 2)
            {
                MessageBox.Show(Lan.g(this, "Please select multiple items first while holding down the control key."));
                return;
            }
            if (MessageBox.Show(Lan.g(this, "Combine all these carriers into a single carrier? This will affect all patients using these carriers.  The next window will let you select which carrier to keep when combining."), ""
                                , MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            List <long> pickedCarrierNums = new List <long>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                pickedCarrierNums.Add(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["CarrierNum"].ToString()));
            }
            FormCarrierCombine FormCB = new FormCarrierCombine();

            FormCB.CarrierNums = pickedCarrierNums;
            FormCB.ShowDialog();
            if (FormCB.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (!VerifyCarrierCombineData(FormCB.PickedCarrierNum, pickedCarrierNums))
            {
                return;
            }
            //int[] combCarrierNums=new int[tbCarriers.SelectedIndices.Length];
            //for(int i=0;i<tbCarriers.SelectedIndices.Length;i++){
            //	carrierNums[i]=Carriers.List[tbCarriers.SelectedIndices[i]].CarrierNum;
            //}
            try{
                //Prepare audit trail entry data, then combine, then make audit trail entries if successful
                List <string>          carrierNames = new List <string>();
                List <List <InsPlan> > listInsPlans = new List <List <InsPlan> >();
                string carrierTo = Carriers.GetName(FormCB.PickedCarrierNum);
                for (int i = 0; i < pickedCarrierNums.Count; i++)
                {
                    carrierNames.Add(Carriers.GetName(pickedCarrierNums[i]));
                    listInsPlans.Add(InsPlans.GetAllByCarrierNum(pickedCarrierNums[i]));
                }
                Carriers.Combine(pickedCarrierNums, FormCB.PickedCarrierNum);
                //Carriers were combined successfully. Loop through all the associated insplans and make a securitylog entry that their carrier changed.
                for (int i = 0; i < listInsPlans.Count; i++)
                {
                    for (int j = 0; j < listInsPlans[i].Count; j++)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.InsCarrierCombine, 0, Lan.g(this, "Carrier with name ") + " " + carrierNames[i] + " "
                                                  + Lan.g(this, "was combined with") + " " + carrierTo, listInsPlans[i][j].PlanNum, listInsPlans[i][j].SecDateTEdit);
                        if (carrierNames[i].Trim().ToLower() != carrierTo.Trim().ToLower())
                        {
                            SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName, 0, Lan.g(this, "Carrier with name ") + " " + carrierNames[i] + " "
                                                      + Lan.g(this, "was merged with") + " " + carrierTo, listInsPlans[i][j].PlanNum, listInsPlans[i][j].SecDateTEdit);
                        }
                    }
                }
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            DataValid.SetInvalid(InvalidType.Carriers);
            FillGrid();
        }
Exemplo n.º 14
0
        private void FillGrid()
        {
            List <string> selectedCarrierNums = new List <string>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                selectedCarrierNums.Add(table.Rows[gridMain.SelectedIndices[i]]["CarrierNum"].ToString());
            }
            //Carriers.Refresh();
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            /*if(checkCDAnet.Checked){
             *      //gridMain.Size=new Size(745,gridMain.Height);
             *      col=new ODGridColumn(Lan.g("TableCarriers","Carrier Name"),160);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","EDI Code"),60);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","PMP"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","Network"),50);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","Version"),50);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","02"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","03"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","04"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","05"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","06"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","07"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","08"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             *      col=new ODGridColumn(Lan.g("TableCarriers","Hidden"),50,HorizontalAlignment.Center);
             *      gridMain.Columns.Add(col);
             * }
             * else{*/
            //gridMain.Size=new Size(839,gridMain.Height);
            col = new GridColumn(Lan.g("TableCarriers", "Carrier Name"), 160);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "Phone"), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "Address"), 130);
            gridMain.ListGridColumns.Add(col);
            //col=new ODGridColumn(Lan.g("TableCarriers","Address2"),120);
            //gridMain.Columns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "City"), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "ST"), 50);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "Zip"), 70);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "ElectID"), 50);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "Hidden"), 50, HorizontalAlignment.Center);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableCarriers", "Plans"), 50);
            gridMain.ListGridColumns.Add(col);
            if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
            {
                col = new GridColumn(Lan.g("TableCarriers", "CDAnet"), 50);
                gridMain.ListGridColumns.Add(col);
            }
            //}
            gridMain.ListGridRows.Clear();
            GridRow row;

            table = Carriers.GetBigList(checkCDAnet.Checked, checkShowHidden.Checked, textCarrier.Text, textPhone.Text);
            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new GridRow();

                /*if(checkCDAnet.Checked){
                 *      row.Cells.Add(table.Rows[i]["CarrierName"].ToString());
                 *      row.Cells.Add(table.Rows[i]["ElectID"].ToString());
                 *      row.Cells.Add(table.Rows[i]["pMP"].ToString());
                 *      row.Cells.Add(table.Rows[i]["network"].ToString());
                 *      row.Cells.Add(table.Rows[i]["version"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans02"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans03"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans04"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans05"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans06"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans07"].ToString());
                 *      row.Cells.Add(table.Rows[i]["trans08"].ToString());
                 *      row.Cells.Add(table.Rows[i]["isHidden"].ToString());
                 * }
                 * else{*/
                row.Cells.Add(table.Rows[i]["CarrierName"].ToString());
                row.Cells.Add(table.Rows[i]["Phone"].ToString());
                if (Programs.GetCur(ProgramName.DentalTekSmartOfficePhone).Enabled)
                {
                    row.Cells[row.Cells.Count - 1].ColorText = Color.Blue;
                    row.Cells[row.Cells.Count - 1].Underline = YN.Yes;
                }
                row.Cells.Add(table.Rows[i]["Address"].ToString());
                //row.Cells.Add(table.Rows[i]["Address2"].ToString());
                row.Cells.Add(table.Rows[i]["City"].ToString());
                row.Cells.Add(table.Rows[i]["State"].ToString());
                row.Cells.Add(table.Rows[i]["Zip"].ToString());
                row.Cells.Add(table.Rows[i]["ElectID"].ToString());
                row.Cells.Add(table.Rows[i]["isHidden"].ToString());
                row.Cells.Add(table.Rows[i]["insPlanCount"].ToString());
                if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))                 //Canadian. en-CA or fr-CA
                {
                    row.Cells.Add(table.Rows[i]["isCDA"].ToString());
                }
                //}
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (selectedCarrierNums.Contains(table.Rows[i]["CarrierNum"].ToString()))
                {
                    gridMain.SetSelected(i, true);
                }
            }
            //if(tbCarriers.SelectedIndices.Length>0){
            //	tbCarriers.ScrollToLine(tbCarriers.SelectedIndices[0]);
            //}
        }
Exemplo n.º 15
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length < 2)
            {
                MessageBox.Show(Lan.g(this, "Please select at least two items first."));
                return;
            }
            InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length];
            for (int i = 0; i < listSelected.Length; i++)
            {
                listSelected[i] = InsPlans.GetPlan(PIn.PInt(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null);
            }
            FormInsPlansMerge FormI = new FormInsPlansMerge();

            FormI.ListAll = listSelected;
            FormI.ShowDialog();
            if (FormI.DialogResult != DialogResult.OK)
            {
                return;
            }
            //Do the merge.
            InsPlan        planToMergeTo = FormI.PlanToMergeTo.Copy();
            List <Benefit> benList       = Benefits.RefreshForAll(planToMergeTo);

            Cursor = Cursors.WaitCursor;
            List <int> planNums;

            for (int i = 0; i < listSelected.Length; i++)      //loop through each selected plan group
            //skip the planToMergeTo, because it's already correct
            {
                if (planToMergeTo.PlanNum == listSelected[i].PlanNum)
                {
                    continue;
                }
                planNums = new List <int>(InsPlans.GetPlanNumsOfSamePlans(Employers.GetName(listSelected[i].EmployerNum),
                                                                          listSelected[i].GroupName, listSelected[i].GroupNum, listSelected[i].DivisionNo,
                                                                          Carriers.GetName(listSelected[i].CarrierNum),
                                                                          listSelected[i].IsMedical, listSelected[i].PlanNum, false));//remember that planNum=0
                //First plan info
                InsPlans.UpdateForLike(listSelected[i], planToMergeTo);
                //for(int j=0;j<planNums.Count;j++) {
                //InsPlans.ComputeEstimatesForPlan(planNums[j]);
                //Eliminated in 5.0 for speed.
                //}
                //then benefits
                Benefits.UpdateListForIdentical(new List <Benefit>(), benList, planNums);             //there will always be changes
                //Then PlanNote.  This is much simpler than the usual synch, because user has seen all versions of note.
                InsPlans.UpdateNoteForPlans(planNums, planToMergeTo.PlanNote);
            }
            FillGrid();
            //highlight the merged plan
            for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < listSelected.Length; j++)
                {
                    if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString())
                    {
                        gridMain.SetSelected(i, true);
                    }
                }
            }
            Cursor = Cursors.Default;
        }
Exemplo n.º 16
0
        ///<summary></summary>
        private void FillGrid()
        {
            Cursor = Cursors.WaitCursor;
            int indexSelected = 0;

            if (gridMain.SelectedIndices.Length > 0)
            {
                indexSelected = gridMain.GetSelectedIndex();
            }
            //ListAll: Set externally before loading.
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Employer", 100);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Carrier", 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Phone", 82);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Address", 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("City", 80);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("ST", 25);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Zip", 50);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Group#", 70);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Group Name", 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Subs", 40);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Plan Note", 180);
            gridMain.ListGridColumns.Add(col);
            //TrojanID and PlanNote not shown
            gridMain.ListGridRows.Clear();
            GridRow row;
            Carrier carrier;

            for (int i = 0; i < ListAll.Length; i++)
            {
                row = new GridRow();
                row.Cells.Add(Employers.GetName(ListAll[i].EmployerNum));
                carrier = Carriers.GetCarrier(ListAll[i].CarrierNum);
                row.Cells.Add(carrier.CarrierName);
                row.Cells.Add(carrier.Phone);
                row.Cells.Add(carrier.Address);
                row.Cells.Add(carrier.City);
                row.Cells.Add(carrier.State);
                row.Cells.Add(carrier.Zip);
                row.Cells.Add(ListAll[i].GroupNum);
                row.Cells.Add(ListAll[i].GroupName);
                row.Cells.Add(ListAll[i].NumberSubscribers.ToString());
                row.Cells.Add(ListAll[i].PlanNote);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(indexSelected, true);
            Cursor = Cursors.Default;
        }