コード例 #1
0
        public static string RunThree()
        {
            long     carrierNum = CarrierTC.GetCarrierNumById("111555");
            Carrier  carrier    = Carriers.GetCarrier(carrierNum);
            Provider prov       = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
            Etrans   etransAck;

            return(Run(3, carrier, null, prov, out etransAck, new DateTime(1999, 6, 1)));
        }
コード例 #2
0
        public static string RunThree()
        {
            long          carrierNum = CarrierTC.GetCarrierNumById("111555");
            Carrier       carrier    = Carriers.GetCarrier(carrierNum);
            Provider      prov       = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
            List <Etrans> etransAcks;

            return(Run(1, carrier, prov, prov, new DateTime(1999, 6, 16), out etransAcks));
        }
コード例 #3
0
ファイル: CarrierTC.cs プロジェクト: kjb7749/testImport
        ///<summary>encryptionMethod should be 1 or 2.</summary>
        public static void SetEncryptionMethod(long planNum, byte encryptionMethod)
        {
            InsPlan plan    = InsPlans.RefreshOne(planNum);
            Carrier carrier = Carriers.GetCarrier(plan.CarrierNum);

            if (carrier.CanadianEncryptionMethod != encryptionMethod)
            {
                carrier.CanadianEncryptionMethod = encryptionMethod;
                Carriers.Update(carrier);
                Carriers.RefreshCache();
            }
        }
コード例 #4
0
ファイル: CarrierTC.cs プロジェクト: kjb7749/testImport
        ///<summary>version should be "02" or "04". Returns old version.</summary>
        public static string SetCDAnetVersion(long planNum, string version)
        {
            InsPlan plan       = InsPlans.RefreshOne(planNum);
            Carrier carrier    = Carriers.GetCarrier(plan.CarrierNum);
            string  oldVersion = carrier.CDAnetVersion;

            if (carrier.CDAnetVersion != version)
            {
                carrier.CDAnetVersion = version;
                Carriers.Update(carrier);
                Carriers.RefreshCache();
            }
            return(oldVersion);
        }
コード例 #5
0
ファイル: Reversal.cs プロジェクト: kjb7749/testImport
        public static string Run(int scriptNum, string responseExpected, Claim claim)
        {
            string        retVal          = "";
            InsPlan       insPlan         = InsPlans.GetPlan(claim.PlanNum, null);
            InsSub        insSub          = InsSubs.GetOne(claim.InsSubNum);
            Carrier       carrier         = Carriers.GetCarrier(insPlan.CarrierNum);
            Clearinghouse clearinghouseHq =
                Clearinghouses.GetClearinghouse(Clearinghouses.AutomateClearinghouseHqSelection(carrier.ElectID, claim.MedType));
            Clearinghouse    clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);
            long             etransNum         = CanadianOutput.SendClaimReversal(clearinghouseClin, claim, insPlan, insSub);
            Etrans           etrans            = Etranss.GetEtrans(etransNum);
            string           message           = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData          = new CCDFieldInputter(message);
            string           responseStatus    = formData.GetValue("G05");

            if (responseStatus != responseExpected)
            {
                return("G05 should be " + responseExpected + "\r\n");
            }
            retVal += "Reversal #" + scriptNum.ToString() + " successful.\r\n";
            return(retVal);
        }
コード例 #6
0
        ///<summary>Sends data for Patient.Cur to an export file and then launches an exe to notify PT.  If patient exists, this simply opens the patient.  If patient does not exist, then this triggers creation of the patient in PT Dental.  If isUpdate is true, then the export file and exe will have different names. In PT, update is a separate programlink with a separate button.</summary>
        public static void SendData(Program ProgramCur, Patient pat, bool isUpdate)
        {
            //ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);
            //ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "InfoFile path");
            //string infoFile=PPCur.PropertyValue;
            if (!Directory.Exists(dir))
            {
                MessageBox.Show(dir + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (pat == null)
            {
                MessageBox.Show("No patient is selected.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportAddExe))
            {
                MessageBox.Show(dir + "\\" + exportAddExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportUpdateExe))
            {
                MessageBox.Show(dir + "\\" + exportUpdateExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            string filename = dir + "\\" + exportAddCsv;

            if (isUpdate)
            {
                filename = dir + "\\" + exportUpdateCsv;
            }
            using (StreamWriter sw = new StreamWriter(filename, false)){               //overwrites if it already exists.
                sw.WriteLine("PAT_PK,PAT_LOGFK,PAT_LANFK,PAT_TITLE,PAT_FNAME,PAT_MI,PAT_LNAME,PAT_CALLED,PAT_ADDR1,PAT_ADDR2,PAT_CITY,PAT_ST,PAT_ZIP,PAT_HPHN,PAT_WPHN,PAT_EXT,PAT_FAX,PAT_PAGER,PAT_CELL,PAT_EMAIL,PAT_SEX,PAT_EDOCS,PAT_STATUS,PAT_TYPE,PAT_BIRTH,PAT_SSN,PAT_NOCALL,PAT_NOCORR,PAT_DISRES,PAT_LSTUPD,PAT_INSNM,PAT_INSGPL,PAT_INSAD1,PAT_INSAD2,PAT_INSCIT,PAT_INSST,PAT_INSZIP,PAT_INSPHN,PAT_INSEXT,PAT_INSCON,PAT_INSGNO,PAT_EMPNM,PAT_EMPAD1,PAT_EMPAD2,PAT_EMPCIT,PAT_EMPST,PAT_EMPZIP,PAT_EMPPHN,PAT_REFLNM,PAT_REFFNM,PAT_REFMI,PAT_REFPHN,PAT_REFEML,PAT_REFSPE,PAT_NOTES,PAT_FPSCAN,PAT_PREMED,PAT_MEDS,PAT_FTSTUD,PAT_PTSTUD,PAT_COLLEG,PAT_CHRTNO,PAT_OTHID,PAT_RESPRT,PAT_POLHLD,PAT_CUSCD,PAT_PMPID");
                sw.Write(",");                                                         //PAT_PK  Primary key. Long alphanumeric. We do not use.
                sw.Write(",");                                                         //PAT_LOGFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_LANFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_TITLE We do not have this field yet
                sw.Write(Tidy(pat.FName) + ",");                                       //PAT_FNAME
                sw.Write(Tidy(pat.MiddleI) + ",");                                     //PAT_MI
                sw.Write(Tidy(pat.LName) + ",");                                       //PAT_LNAME
                sw.Write(Tidy(pat.Preferred) + ",");                                   //PAT_CALLED Nickname
                sw.Write(Tidy(pat.Address) + ",");                                     //PAT_ADDR1
                sw.Write(Tidy(pat.Address2) + ",");                                    //PAT_ADDR2
                sw.Write(Tidy(pat.City) + ",");                                        //PAT_CITY
                sw.Write(Tidy(pat.State) + ",");                                       //PAT_ST
                sw.Write(Tidy(pat.Zip) + ",");                                         //PAT_ZIP
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.HmPhone) + ",");       //PAT_HPHN No punct
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WkPhone) + ",");       //PAT_WPHN
                sw.Write(",");                                                         //PAT_EXT
                sw.Write(",");                                                         //PAT_FAX
                sw.Write(",");                                                         //PAT_PAGER
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WirelessPhone) + ","); //PAT_CELL
                sw.Write(Tidy(pat.Email) + ",");                                       //PAT_EMAIL
                if (pat.Gender == PatientGender.Female)
                {
                    sw.Write("Female");
                }
                else if (pat.Gender == PatientGender.Male)
                {
                    sw.Write("Male");
                }
                sw.Write(",");                            //PAT_SEX might be blank if unknown
                sw.Write(",");                            //PAT_EDOCS Internal PT logical, it can be ignored.
                sw.Write(pat.PatStatus.ToString() + ","); //PAT_STATUS Any text allowed
                sw.Write(pat.Position.ToString() + ",");  //PAT_TYPE Any text allowed
                if (pat.Birthdate.Year > 1880)
                {
                    sw.Write(pat.Birthdate.ToString("MM/dd/yyyy"));                    //PAT_BIRTH MM/dd/yyyy
                }
                sw.Write(",");
                sw.Write(Tidy(pat.SSN) + ",");              //PAT_SSN No punct
                if (pat.PreferContactMethod == ContactMethod.DoNotCall ||
                    pat.PreferConfirmMethod == ContactMethod.DoNotCall ||
                    pat.PreferRecallMethod == ContactMethod.DoNotCall)
                {
                    sw.Write("1");
                }
                sw.Write(",");                //PAT_NOCALL T if no call
                sw.Write(",");                //PAT_NOCORR No correspondence HIPAA
                sw.Write(",");                //PAT_DISRES Internal PT logical, it can be ignored.
                sw.Write(",");                //PAT_LSTUPD Internal PT logical, it can be ignored.
                List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum);
                Family         fam         = Patients.GetFamily(pat.PatNum);
                List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
                List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
                PatPlan        patplan     = null;
                InsSub         sub         = null;
                InsPlan        plan        = null;
                Carrier        carrier     = null;
                Employer       emp         = null;
                if (patPlanList.Count > 0)
                {
                    patplan = patPlanList[0];
                    sub     = InsSubs.GetSub(patplan.InsSubNum, subList);
                    plan    = InsPlans.GetPlan(sub.PlanNum, planList);
                    carrier = Carriers.GetCarrier(plan.CarrierNum);
                    if (plan.EmployerNum != 0)
                    {
                        emp = Employers.GetEmployer(plan.EmployerNum);
                    }
                }
                if (plan == null)
                {
                    sw.Write(",");                    //PAT_INSNM
                    sw.Write(",");                    //PAT_INSGPL Ins group plan name
                    sw.Write(",");                    //PAT_INSAD1
                    sw.Write(",");                    //PAT_INSAD2
                    sw.Write(",");                    //PAT_INSCIT
                    sw.Write(",");                    //PAT_INSST
                    sw.Write(",");                    //PAT_INSZIP
                    sw.Write(",");                    //PAT_INSPHN
                }
                else
                {
                    sw.Write(Tidy(carrier.CarrierName) + ",");                         //PAT_INSNM
                    sw.Write(Tidy(plan.GroupName) + ",");                              //PAT_INSGPL Ins group plan name
                    sw.Write(Tidy(carrier.Address) + ",");                             //PAT_INSAD1
                    sw.Write(Tidy(carrier.Address2) + ",");                            //PAT_INSAD2
                    sw.Write(Tidy(carrier.City) + ",");                                //PAT_INSCIT
                    sw.Write(Tidy(carrier.State) + ",");                               //PAT_INSST
                    sw.Write(Tidy(carrier.Zip) + ",");                                 //PAT_INSZIP
                    sw.Write(TelephoneNumbers.FormatNumbersOnly(carrier.Phone) + ","); //PAT_INSPHN
                }
                sw.Write(",");                                                         //PAT_INSEXT
                sw.Write(",");                                                         //PAT_INSCON Ins contact person
                if (plan == null)
                {
                    sw.Write(",");
                }
                else
                {
                    sw.Write(Tidy(plan.GroupNum) + ",");                  //PAT_INSGNO Ins group number
                }
                if (emp == null)
                {
                    sw.Write(",");                    //PAT_EMPNM
                }
                else
                {
                    sw.Write(Tidy(emp.EmpName) + ","); //PAT_EMPNM
                }
                sw.Write(",");                         //PAT_EMPAD1
                sw.Write(",");                         //PAT_EMPAD2
                sw.Write(",");                         //PAT_EMPCIT
                sw.Write(",");                         //PAT_EMPST
                sw.Write(",");                         //PAT_EMPZIP
                sw.Write(",");                         //PAT_EMPPHN

                /*we don't support employer info yet.
                 * sw.Write(Tidy(emp.Address)+",");//PAT_EMPAD1
                 * sw.Write(Tidy(emp.Address2)+",");//PAT_EMPAD2
                 * sw.Write(Tidy(emp.City)+",");//PAT_EMPCIT
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPST
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPZIP
                 * sw.Write(TelephoneNumbers.FormatNumbersOnly(emp.Phone)+",");//PAT_EMPPHN*/
                Referral referral = Referrals.GetReferralForPat(pat.PatNum);              //could be null
                if (referral == null)
                {
                    sw.Write(",");                    //PAT_REFLNM
                    sw.Write(",");                    //PAT_REFFNM
                    sw.Write(",");                    //PAT_REFMI
                    sw.Write(",");                    //PAT_REFPHN
                    sw.Write(",");                    //PAT_REFEML Referral source email
                    sw.Write(",");                    //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                else
                {
                    sw.Write(Tidy(referral.LName) + ",");                //PAT_REFLNM
                    sw.Write(Tidy(referral.FName) + ",");                //PAT_REFFNM
                    sw.Write(Tidy(referral.MName) + ",");                //PAT_REFMI
                    sw.Write(referral.Telephone + ",");                  //PAT_REFPHN
                    sw.Write(Tidy(referral.EMail) + ",");                //PAT_REFEML Referral source email
                    if (referral.PatNum == 0 && !referral.NotPerson)     //not a patient, and is a person
                    {
                        sw.Write(Defs.GetName(DefCat.ProviderSpecialties, referral.Specialty));
                    }
                    sw.Write(",");            //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                sw.Write(",");                //PAT_NOTES No limits.  We won't use this right now for exports.
                //sw.Write(",");//PAT_NOTE1-PAT_NOTE10 skipped
                sw.Write(",");                //PAT_FPSCAN Internal PT logical, it can be ignored.
                if (pat.Premed)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                        //PAT_PREMED F or T
                sw.Write(Tidy(pat.MedUrgNote) + ","); //PAT_MEDS The meds that they must premedicate with.
                if (pat.StudentStatus == "F")         //fulltime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                //PAT_FTSTUD T/F
                if (pat.StudentStatus == "P") //parttime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                         //PAT_PTSTUD
                sw.Write(Tidy(pat.SchoolName) + ",");  //PAT_COLLEG Name of college
                sw.Write(Tidy(pat.ChartNumber) + ","); //PAT_CHRTNO
                sw.Write(pat.PatNum.ToString() + ","); //PAT_OTHID The primary key in Open Dental ************IMPORTANT***************
                if (pat.PatNum == pat.Guarantor)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                                    //PAT_RESPRT Responsible party checkbox T/F
                if (plan != null && pat.PatNum == sub.Subscriber) //if current patient is the subscriber on their primary plan
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");               //PAT_POLHLD Policy holder checkbox T/F
                sw.Write(",");               //PAT_CUSCD Web sync folder, used internally this can be ignored.
                sw.Write("");                //PAT_PMPID Practice Management Program ID. Can be ignored
                sw.WriteLine();
            }
            try{
                if (isUpdate)
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportUpdateExe);                //already validated to exist
                }
                else
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportAddExe);                //already validated to exist
                }
                //MessageBox.Show("done");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #7
0
ファイル: Dutch.cs プロジェクト: royedwards/DRDNet
        ///<summary>Called once for each claim to be created.  For claims with a lot of procedures, this may actually create multiple claims.
        ///Normally returns empty string unless something went wrong.</summary>
        public static bool CreateClaim(Clearinghouse clearinghouseClin, ClaimSendQueueItem queueItem, int batchNum)
        {
            StringBuilder strb = new StringBuilder();
            string        t    = "\t";

            strb.Append("110\t111\t112\t118\t203/403\tF108/204/404\t205/405\t206\t207\t208\t209\t210\t211\t212\t215\t217\t219\t406\t408\t409\t410\t411\t413\t414\t415\t416\t418\t419\t420\t421\t422\t423\t424\t425\t426\t428\t429\t430\t432\t433\r\n");
            Claim            claim              = Claims.GetClaim(queueItem.ClaimNum);
            Provider         provBill           = Providers.GetProv(claim.ProvBill);
            Patient          pat                = Patients.GetPat(claim.PatNum);
            InsPlan          insplan            = InsPlans.GetPlan(claim.PlanNum, new List <InsPlan>());
            InsSub           insSub             = InsSubs.GetSub(claim.InsSubNum, new List <InsSub>());
            Carrier          carrier            = Carriers.GetCarrier(insplan.CarrierNum);
            List <ClaimProc> claimProcList      = ClaimProcs.Refresh(pat.PatNum);
            List <ClaimProc> claimProcsForClaim = ClaimProcs.GetForSendClaim(claimProcList, claim.ClaimNum);
            List <Procedure> procList           = Procedures.Refresh(claim.PatNum);
            Procedure        proc;
            ProcedureCode    procCode;

            //ProcedureCode procCode;
            for (int i = 0; i < claimProcsForClaim.Count; i++)
            {
                //claimProcsForClaim already excludes any claimprocs with ProcNum=0, so no payments etc.
                proc = Procedures.GetProcFromList(procList, claimProcsForClaim[i].ProcNum);
                //procCode=Pro
                strb.Append(provBill.SSN + t);        //110
                strb.Append(provBill.MedicaidID + t); //111
                strb.Append(t);                       //112
                strb.Append(t);                       //118
                strb.Append(pat.SSN + t);             //203/403
                strb.Append(carrier.CarrierName + t); //carrier name?
                strb.Append(insSub.SubscriberID + t);
                strb.Append(pat.PatNum.ToString() + t);
                strb.Append(pat.Birthdate.ToString("dd-MM-yyyy") + t);
                if (pat.Gender == PatientGender.Female)
                {
                    strb.Append("2" + t);                  //"V"+t);
                }
                else
                {
                    strb.Append("1" + t);                  //M"+t);
                }
                strb.Append("1" + t);
                strb.Append(DutchLName(pat.LName) + t);                //last name without prefix
                strb.Append(DutchLNamePrefix(pat.LName) + t);          //prefix
                strb.Append("2" + t);
                strb.Append(DutchInitials(pat) + t);                   //215. initials
                strb.Append(pat.Zip + t);
                strb.Append(DutchAddressNumber(pat.Address) + t);      //219 house number.  Already validated.
                strb.Append(t);
                strb.Append(proc.ProcDate.ToString("dd-MM-yyyy") + t); //procDate
                procCode = ProcedureCodes.GetProcCode(proc.CodeNum);
                string strProcCode = procCode.ProcCode;
                if (strProcCode.EndsWith("00"))                 //ending with 00 indicates it's a lab code.
                {
                    strb.Append("02" + t);
                }
                else
                {
                    strb.Append("01" + t);                  //409. Procedure code (01) or lab costs (02)
                }
                strb.Append(t);
                strb.Append(t);
                strb.Append(strProcCode + t);
                strb.Append(GetUL(proc, procCode) + t);                             //414. U/L.
                strb.Append(Tooth.ToInternat(proc.ToothNum) + t);
                strb.Append(Tooth.SurfTidyForClaims(proc.Surf, proc.ToothNum) + t); //needs validation
                strb.Append(t);
                if (claim.AccidentRelated == "")                                    //not accident
                {
                    strb.Append("N" + t);
                }
                else
                {
                    strb.Append("J" + t);
                }
                strb.Append(pat.SSN + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append("1" + t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append(proc.ProcFee.ToString("F") + t);
                strb.Append(t);
                strb.Append(t);
                strb.Append("\r\n");
            }
            string saveFolder = clearinghouseClin.ExportPath;

            if (!Directory.Exists(saveFolder))
            {
                MessageBox.Show(saveFolder + " " + Lans.g("Dutch", "not found."));
                return(false);
            }
            string saveFile = ODFileUtils.CombinePaths(saveFolder, "claims" + claim.ClaimNum.ToString() + ".txt");

            File.WriteAllText(saveFile, strb.ToString());
            //MessageBox.Show(strb.ToString());
            return(true);
        }
コード例 #8
0
        ///<summary>Called from Eclaims and includes multiple claims.</summary>
        public static string SendBatch(Clearinghouse clearinghouseClin, List <ClaimSendQueueItem> queueItems, int batchNum)
        {
            //STEP 1 - Build XML output.
            List <DP_RACINDP>    listDps       = new List <DP_RACINDP>();
            List <ProcedureCode> listProcCodes = ProcedureCodes.GetAllCodes();
            List <Etrans>        listEtrans    = new List <Etrans>();

            foreach (ClaimSendQueueItem queueItem in queueItems)
            {
                Etrans etrans = Etranss.SetClaimSentOrPrinted(queueItem.ClaimNum, queueItem.PatNum, clearinghouseClin.HqClearinghouseNum, EtransType.Claim_Ramq, batchNum, Security.CurUser.UserNum);
                listEtrans.Add(etrans);
                //Now we need to update our cache of claims to reflect the change that took place in the database above in Etranss.SetClaimSentOrPrinted()
                queueItem.ClaimStatus = "S";
                Claim      claim          = Claims.GetClaim(queueItem.ClaimNum);
                Provider   provClaimTreat = Providers.GetProv(claim.ProvTreat);
                DP_RACINDP dp             = new DP_RACINDP();
                #region Header
                dp.CHN           = DP_RACINDPCHN.Item06;
                dp.CHNSpecified  = true;
                dp.ENRG          = DP_RACINDPENRG.Item1;
                dp.ENRGSpecified = true;
                //We hijack the TaxID number for the TRNSM field.  The TRNSM is a office identifying number.  Test range for developers is 18000 to 18999.
                dp.TRNSM = clearinghouseClin.SenderTIN;
                dp.DISP  = provClaimTreat.NationalProvID;
                //dp.CPTE_ADMN=;//Administrative account number.  Not currently used.
                JulianCalendar calendar = new JulianCalendar();
                dp.ATTES = (DateTime.Now.Year % 10).ToString()                               //One digit for year
                           + calendar.GetDayOfYear(DateTime.Now).ToString().PadLeft(3, '0')  //3 digits for Julian day of year.
                           + (etrans.CarrierTransCounter % 1000).ToString().PadLeft(3, '0'); //3 digits for sequence number.
                dp.NCE        = (etrans.CarrierTransCounter % 10000).ToString().PadLeft(4, '0');
                dp.DISP_REFNT = claim.CanadianReferralProviderNum.Trim();
                //dp.DIAGN=;//Diagnostic code.  Not currently used.
                dp.ETAB = provClaimTreat.CanadianOfficeNum;              //Usually empty.
                //dp.ADMIS=;//Date of patient admission.  Not currently used.  This would be the same as the date of service for dental claims anyway.
                //dp.SORTI=;//Date patient discharged.  Not currently used.  This would be the same as the date of service for dental claims anyway.
                dp.TOT_DEM = claim.ClaimFee.ToString().Replace(".", "").PadLeft(6, '0');
                dp.COMPL   = TidyStr(claim.ClaimNote, 200);
                //dp.CS=;//Not sure what this is.  Not currently used.
                //dp.AUTOR=claim.PreAuthString;//Authorization number when invoicing acrylic prostheses. Required if DAT_AUTOR is present. Not currently used.
                //dp.DAT_AUTOR=claim.CanadianDateInitialLower;//Date of authorization when invoicing acrylic prostheses. Format YYMMDD. Not currently used.
                dp.SERV = claim.DateService.ToString("yyMMdd");
                #endregion Header
                #region Insurance
                //Most fields in the insuranace section are optional.
                InsSub insSub = InsSubs.GetOne(claim.InsSubNum);
                dp.PERS_ASSU     = new DP_RACINDPPERS_ASSU();
                dp.PERS_ASSU.NAM = insSub.SubscriberID;
                Patient pat = Patients.GetPat(claim.PatNum);
                dp.PERS_ASSU.PRE = TidyStr(pat.FName, 20);
                dp.PERS_ASSU.NOM = TidyStr(pat.LName, 30);
                if (pat.Birthdate.Year > 1880)
                {
                    dp.PERS_ASSU.NAISS = pat.Birthdate.ToString("yyyyMMdd");
                }
                if (pat.Gender == PatientGender.Male)
                {
                    dp.PERS_ASSU.SEXE = DP_RACINDPPERS_ASSUSEXE.M;
                }
                else if (pat.Gender == PatientGender.Female)
                {
                    dp.PERS_ASSU.SEXE = DP_RACINDPPERS_ASSUSEXE.F;
                }
                else
                {
                    //There is no value for UNKNOWN.  This field is optional if the subscriber ID is present anyway.
                }
                List <PatPlan> listPatPlans = PatPlans.Refresh(claim.PatNum);
                PatPlan        patPlan      = PatPlans.GetByInsSubNum(listPatPlans, insSub.InsSubNum);
                dp.PERS_ASSU.CAM = patPlan.PatID;
                if (insSub.DateTerm.Year > 1880)
                {
                    dp.PERS_ASSU.EXPIR_CAM = insSub.DateTerm.ToString("yyMM");
                }
                InsPlan insPlan  = InsPlans.RefreshOne(claim.PlanNum);
                InsPlan insPlan2 = InsPlans.RefreshOne(claim.PlanNum2);
                Carrier carrier  = null;
                if (claim.ClaimType == "S")
                {
                    carrier = Carriers.GetCarrier(insPlan2.CarrierNum);
                }
                else
                {
                    carrier = Carriers.GetCarrier(insPlan.CarrierNum);
                }
                if (carrier.Address.Trim() != "")
                {
                    dp.PERS_ASSU.ADR_1 = carrier.Address;
                    dp.PERS_ASSU.ADR_2 = carrier.Address2;
                    dp.PERS_ASSU.CP    = carrier.Zip;
                }
                #endregion Insurance
                #region Procedures
                List <ClaimProc>      listClaimProcsForPat   = ClaimProcs.Refresh(claim.PatNum);
                List <ClaimProc>      listClaimProcsForClaim = ClaimProcs.GetForSendClaim(listClaimProcsForPat, claim.ClaimNum);        //Excludes labs.
                List <Procedure>      listProcsForPat        = Procedures.Refresh(claim.PatNum);
                List <DP_RACINDPACTE> listProcs = new List <DP_RACINDPACTE>();
                foreach (ClaimProc claimProc in listClaimProcsForClaim)
                {
                    Procedure proc = Procedures.GetProcFromList(listProcsForPat, claimProc.ProcNum);
                    if (proc.ProcFee == 0)
                    {
                        continue;
                    }
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum, listProcCodes);
                    if (procCode.NoBillIns)
                    {
                        continue;
                    }
                    DP_RACINDPACTE acteProc = new DP_RACINDPACTE();
                    acteProc.ACTE = procCode.ProcCode;
                    if (procCode.ProcCode.Length > 5)
                    {
                        acteProc.ACTE = procCode.ProcCode.Substring(0, 5);
                    }
                    acteProc.ROLE = "1";                  //1 for principal role and 2 for assistant role.
                    //acte.MODIF=;//Optional.  Not sure what to put here, so leaving blank for now.
                    acteProc.UNIT = proc.UnitQty.ToString().PadLeft(3, '0');
                    acteProc.MNT  = proc.ProcFee.ToString("F").Replace(".", "").PadLeft(6, '0');
                    acteProc.DENT = proc.ToothNum.ToString().PadLeft(2, '0');
                    acteProc.SURF = proc.Surf.ToString().PadLeft(2, '0');
                    listProcs.Add(acteProc);
                    List <Procedure> listLabProcs = Procedures.GetCanadianLabFees(proc.ProcNum, listProcsForPat);
                    foreach (Procedure labProc in listLabProcs)
                    {
                        if (labProc.ProcFee == 0)
                        {
                            continue;
                        }
                        ProcedureCode  labProcCode = ProcedureCodes.GetProcCode(labProc.CodeNum, listProcCodes);
                        DP_RACINDPACTE acteLab     = new DP_RACINDPACTE();
                        acteLab.ACTE = labProcCode.ProcCode;
                        if (labProcCode.ProcCode.Length > 5)
                        {
                            acteLab.ACTE = labProcCode.ProcCode.Substring(0, 5);
                        }
                        acteLab.ROLE = "1";                      //1 for principal role and 2 for assistant role.
                        acteLab.MNT  = labProc.ProcFee.ToString("F").Replace(".", "").PadLeft(6, '0');
                        listProcs.Add(acteLab);
                    }
                }
                dp.ACTE = listProcs.ToArray();
                #endregion Procedures
                listDps.Add(dp);
            }
            DP_RACIN batch = new DP_RACIN();
            batch.DP = listDps.ToArray();
            StringWriter  sw         = new StringWriter();
            XmlSerializer serializer = new XmlSerializer(typeof(DP_RACIN));
            serializer.Serialize(sw, batch);
            string xml = sw.ToString();
            //Save a copy of the batch xml to each etrans entry (one per claim).
            EtransMessageText etransMsgText = new EtransMessageText();
            etransMsgText.MessageText = xml;
            EtransMessageTexts.Insert(etransMsgText);
            foreach (Etrans etrans in listEtrans)
            {
                etrans.EtransMessageTextNum = etransMsgText.EtransMessageTextNum;
                Etranss.Update(etrans);
            }
            //Step 2 - ZIP XML and save to report path.  The zip file name and file name within the zip file do not matter.
            string  zipFilePath = CodeBase.ODFileUtils.CreateRandomFile(clearinghouseClin.ExportPath, ".zip", "claims");
            ZipFile zip         = null;
            try {
                zip = new ZipFile();
                zip.UseZip64WhenSaving = Zip64Option.Always;
                zip.AddEntry("claims" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xml", xml);
                zip.Save(zipFilePath);
                zip.Dispose();
            }
            catch (Exception ex) {
                ex.ToString();
                if (zip != null)
                {
                    zip.Dispose();
                }
                if (File.Exists(zipFilePath))
                {
                    try {
                        File.Delete(zipFilePath);
                    }
                    catch (Exception ex2) {
                        ex2.ToString();
                    }
                }
            }
            return(xml);
        }
コード例 #9
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> listProcs, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)
        {
            //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
            //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
            MessageHL7 msgHl7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def     hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment    apt          = Appointments.GetOneApt(aptNum);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int repeatCount = 1;
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1)
                {
                    repeatCount = listProcs.Count;
                }
                else if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    repeatCount = listPatPlans.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                //or the patient does not have any current insplans for IN1 segments
                for (int j = 0; j < repeatCount; j++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList, IN1 is optional and can repeat as well, repeat for the number of patplans in patplanList
                {
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1 && listProcs.Count > j)
                    {
                        prov = Providers.GetProv(listProcs[j].ProvNum);
                    }
                    Procedure proc = null;
                    if (listProcs.Count > j)                   //procList could be an empty list
                    {
                        proc = listProcs[j];
                    }
                    PatPlan patPlanCur = null;
                    InsPlan insPlanCur = null;
                    InsSub  insSubCur  = null;
                    Carrier carrierCur = null;
                    Patient subscriber = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                    {
                        patPlanCur = listPatPlans[j];
                        insSubCur  = InsSubs.GetOne(patPlanCur.InsSubNum);
                        insPlanCur = InsPlans.RefreshOne(insSubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insPlanCur.CarrierNum);
                        subscriber = Patients.GetPat(insSubCur.Subscriber);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patPlanCur, insSubCur, insPlanCur, carrierCur, listPatPlans.Count, subscriber);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateField(hl7Def, fieldName, MessageTypeHL7.DFT, pat, prov, proc, guar, apt, j + 1, eventType,
                                                                            pdfDescription, pdfDataString, MessageStructureHL7.DFT_P03, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }
コード例 #10
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound ADT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateADT(Patient pat, Patient guar, EventTypeHL7 eventType)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound ADT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.ADT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //ADT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7     messageHL7   = new MessageHL7(MessageTypeHL7.ADT);
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int countRepeat = 1;
                //IN1 segment can repeat, get the number of current insurance plans attached to the patient
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    countRepeat = listPatPlans.Count;
                }
                //countRepeat is usually 1, but for repeatable/optional fields, it may be 0 or greater than 1
                //for example, countRepeat can be zero if the patient does not have any current insplans, in which case no IN1 segments will be included
                for (int j = 0; j < countRepeat; j++)           //IN1 is optional and can repeat so add as many as listPatplans
                {
                    PatPlan patplanCur = null;
                    InsPlan insplanCur = null;
                    InsSub  inssubCur  = null;
                    Carrier carrierCur = null;
                    Patient patSub     = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)                   //index repeat is guaranteed to be less than listPatplans.Count
                    {
                        patplanCur = listPatPlans[j];
                        inssubCur  = InsSubs.GetOne(patplanCur.InsSubNum);
                        insplanCur = InsPlans.RefreshOne(inssubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insplanCur.CarrierNum);
                        if (pat.PatNum == inssubCur.Subscriber)
                        {
                            patSub = pat.Copy();
                        }
                        else
                        {
                            patSub = Patients.GetPat(inssubCur.Subscriber);
                        }
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patplanCur, inssubCur, insplanCur, carrierCur, listPatPlans.Count, patSub);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateFieldADT(hl7Def, fieldName, pat, prov, guar, j + 1, eventType, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }