///<summary></summary> public FormInsPlanSelect(long patNum) { InitializeComponent(); PatNum = patNum; //usage: eg. from coverage. Since can be totally new subscriber, get all plans for them. FamCur = Patients.GetFamily(PatNum); PatCur = FamCur.GetPatient(PatNum); SubList = InsSubs.RefreshForFam(FamCur); PlanList = InsPlans.RefreshForSubList(SubList); _listPatCurPatPlans = PatPlans.Refresh(PatNum); if (_listPatCurPatPlans.Count == 1) { try { PatRelat = _listPatCurPatPlans[0].Relationship; SelectedSub = SubList.FirstOrDefault(x => x.InsSubNum == _listPatCurPatPlans[0].InsSubNum); SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList); if (SelectedSub == null || SelectedPlan == null) { throw new ApplicationException(); } } catch { PatRelat = 0; SelectedSub = null; SelectedPlan = null; } } //tbPlans.CellDoubleClicked += new OpenDental.ContrTable.CellEventHandler(tbPlans_CellDoubleClicked); Lan.F(this); }
public string RTS(Relat r) { string res = " "; switch (r) { case Relat.More: res = ">"; break; case Relat.Lesser: res = "<"; break; case Relat.Equal: res = "="; break; case Relat.None: res = " "; break; default: res = " "; break; } return(res); }
private void gridMain_CellDoubleClick(object sender, OpenDental.UI.ODGridClickEventArgs e) { if (listRelat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a relationship first.")); return; } PatRelat = (Relat)listRelat.SelectedIndex; SelectedSub = (InsSub)gridMain.ListGridRows[e.Row].Tag; SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList); DialogResult = DialogResult.OK; }
private void gridMain_CellDoubleClick(object sender, OpenDental.UI.ODGridClickEventArgs e) { if (ViewRelat && listRelat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a relationship first.")); return; } if (ViewRelat) { PatRelat = (Relat)listRelat.SelectedIndex; } SelectedPlan = PlanList[e.Row]; DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select a plan first.")); return; } if (ViewRelat && listRelat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a relationship first.")); return; } if (ViewRelat) { PatRelat = (Relat)listRelat.SelectedIndex; } SelectedPlan = PlanList[gridMain.GetSelectedIndex()]; DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select a plan first.")); return; } if (ViewRelat && listRelat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a relationship first.")); return; } if (ViewRelat) { PatRelat = (Relat)listRelat.SelectedIndex; } SelectedSub = (InsSub)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag; SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select a plan first.")); return; } if (listRelat.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select a relationship first.")); return; } //if(comboClaimForm.SelectedIndex==-1) { // MessageBox.Show(Lan.g(this,"Please select a claimform first.")); // return; //} PatRelat = (Relat)listRelat.SelectedIndex; SelectedSub = (InsSub)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag; SelectedPlan = InsPlans.GetPlan(SelectedSub.PlanNum, PlanList); //ClaimFormNum=ClaimForms.ListShort[comboClaimForm.SelectedIndex].ClaimFormNum; DialogResult = DialogResult.OK; }
///<summary>Used in C03 and E06</summary> public static string GetRelationshipCode(Relat relat){ switch (relat){ case Relat.Self: return "1"; case Relat.Spouse: return "2"; case Relat.Child: return "3"; case Relat.LifePartner: case Relat.SignifOther: return "4";//commonlaw spouse default://other (ex elderly care) return "5"; } }
///<summary>01 Spouse, 18 Self, 19 Child, 20 Employee, 21 Unknown, 39 Organ Donor, 40 Cadaver Donor, 53 Life Partner, G8 Other Relationship.</summary> private static string GetRelat(Relat relat) { switch(relat) { case (Relat.Self): return "18"; case (Relat.Child): return "19"; case (Relat.Dependent): return "G8";//Other relationship case (Relat.Employee): return "20"; case (Relat.HandicapDep): return "G8";//Other relationship case (Relat.InjuredPlaintiff): return "G8";//Other relationship case (Relat.LifePartner): return "53"; case (Relat.SignifOther): return "G8";//Other relationship case (Relat.Spouse): return "01"; } return ""; }
///<summary>The result is the etransNum of the response message. Or it might throw an exception if invalid data. This class is also responsible for saving the returned message to the etrans table, and for printing out the required form.</summary> public static long SendElegibility(long patNum,InsPlan plan,DateTime date,Relat relat,string patID,bool doPrint,InsSub insSub) { //string electID,long patNum,string groupNumber,string divisionNo, //string subscriberID,string patID,Relat patRelat,long subscNum,string dentaideCardSequence) //Note: This might be the only class of this kind that returns a string. It's a special situation. //We are simply not going to bother with language translation here. Carrier carrier=Carriers.GetCarrier(plan.CarrierNum); if(carrier==null) { throw new ApplicationException("Invalid carrier."); } if((carrier.CanadianSupportedTypes&CanSupTransTypes.EligibilityTransaction_08)!=CanSupTransTypes.EligibilityTransaction_08) { throw new ApplicationException("The carrier does not support eligibility transactions."); } if(carrier.CanadianNetworkNum==0) { throw new ApplicationException("Carrier network not set."); } CanadianNetwork network=CanadianNetworks.GetNetwork(carrier.CanadianNetworkNum); Patient patient=Patients.GetPat(patNum); Patient subscriber=Patients.GetPat(insSub.Subscriber); Provider provDefaultTreat=Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)); Clearinghouse clearhouse=Canadian.GetClearinghouse(); if(clearhouse==null){ throw new ApplicationException("Canadian clearinghouse not found."); } string saveFolder=clearhouse.ExportPath; if(!Directory.Exists(saveFolder)) { throw new ApplicationException(saveFolder+" not found."); } //validate---------------------------------------------------------------------------------------------------- string error=""; //if(carrier.CanadianNetworkNum==0){ // if(error!="") error+=", "; // error+="Carrier does not have network specified"; //} if(!Regex.IsMatch(carrier.ElectID,@"^[0-9]{6}$")){//not necessary, but nice if(error!="") error+=", "; error+="CarrierId 6 digits"; } if(!provDefaultTreat.IsCDAnet) { error+="Prov not setup as CDA provider"; } if(provDefaultTreat.NationalProvID.Length!=9) { if(error!="") error+=", "; error+="Prov CDA num 9 digits"; } if(provDefaultTreat.CanadianOfficeNum.Length!=4) { if(error!="") error+=", "; error+="Prov office num 4 char"; } //if(plan.GroupNum.Length==0 || groupNumber.Length>12 || groupNumber.Contains(" ")){ // if(error!="") error+=", "; // error+="Plan Number"; //} //if(subscriberID==""){//already validated. And it's allowed to be blank sometimes // if(error!="") error+=", "; // error+="SubscriberID"; //} if(patNum != insSub.Subscriber && relat==Relat.Self) {//if patient is not subscriber, and relat is self if(error!="") error+=", "; error+="Relationship cannot be self"; } if(patient.Gender==PatientGender.Unknown){ if(error!="") error+=", "; error+="Patient gender"; } if(patient.Birthdate.Year<1880 || patient.Birthdate>DateTime.Today) { if(error!="") error+=", "; error+="Patient birthdate"; } if(patient.LName=="") { if(error!="") error+=", "; error+="Patient lastname"; } if(patient.FName=="") { if(error!="") error+=", "; error+="Patient firstname"; } if(patient.CanadianEligibilityCode==0) { if(error!="") error+=", "; error+="Patient eligibility exception code"; } if(subscriber.Birthdate.Year<1880 || subscriber.Birthdate>DateTime.Today) { if(error!="") error+=", "; error+="Subscriber birthdate"; } if(subscriber.LName=="") { if(error!="") error+=", "; error+="Subscriber lastname"; } if(subscriber.FName=="") { if(error!="") error+=", "; error+="Subscriber firstname"; } if(error!="") { throw new ApplicationException(error); } Etrans etrans=Etranss.CreateCanadianOutput(patNum,carrier.CarrierNum,0, clearhouse.ClearinghouseNum,EtransType.Eligibility_CA,plan.PlanNum,insSub.InsSubNum); StringBuilder strb=new StringBuilder(); //create message---------------------------------------------------------------------------------------------- //A01 transaction prefix 12 AN strb.Append(Canadian.TidyAN(network.CanadianTransactionPrefix,12)); //A02 office sequence number 6 N strb.Append(Canadian.TidyN(etrans.OfficeSequenceNumber,6)); //A03 format version number 2 N strb.Append(carrier.CDAnetVersion);//eg. "04", validated in UI //A04 transaction code 2 N if(carrier.CDAnetVersion=="02"){ strb.Append("00");//eligibility } else{ strb.Append("08");//eligibility } //A05 carrier id number 6 N strb.Append(carrier.ElectID);//already validated as 6 digit number. //A06 software system id 3 AN strb.Append(Canadian.SoftwareSystemId()); if(carrier.CDAnetVersion=="04") { //A10 encryption method 1 N strb.Append(carrier.CanadianEncryptionMethod);//validated in UI } //A07 message length 5 N int len; bool C19PlanRecordPresent=false; if(carrier.CDAnetVersion=="02"){ len=178; strb.Append(Canadian.TidyN(len,4)); } else{ len=214; if(plan.CanadianPlanFlag=="A"){// || plan.CanadianPlanFlag=="N"){ C19PlanRecordPresent=true; } if(C19PlanRecordPresent){ len+=30; } strb.Append(Canadian.TidyN(len,5)); //A09 carrier transaction counter 5 N, only version 04 strb.Append(Canadian.TidyN(etrans.CarrierTransCounter,5)); } //B01 CDA provider number 9 AN strb.Append(Canadian.TidyAN(provDefaultTreat.NationalProvID,9));//already validated //B02 provider office number 4 AN strb.Append(Canadian.TidyAN(provDefaultTreat.CanadianOfficeNum,4));//already validated if(carrier.CDAnetVersion=="04"){ //B03 billing provider number 9 AN Provider provBilling=Providers.GetProv(Providers.GetBillingProvNum(provDefaultTreat.ProvNum,patient.ClinicNum)); strb.Append(Canadian.TidyAN(provBilling.NationalProvID,9));//already validated } if(carrier.CDAnetVersion=="02") { //C01 primary policy/plan number 8 AN (group number) //No special validation for version 02 strb.Append(Canadian.TidyAN(plan.GroupNum,8)); } else { //C01 primary policy/plan number 12 AN (group number) //only validated to ensure that it's not blank and is less than 12. Also that no spaces. strb.Append(Canadian.TidyAN(plan.GroupNum,12)); } //C11 primary division/section number 10 AN strb.Append(Canadian.TidyAN(plan.DivisionNo,10)); if(carrier.CDAnetVersion=="02") { //C02 subscriber id number 11 AN strb.Append(Canadian.TidyAN(insSub.SubscriberID.Replace("-",""),11));//no extra validation for version 02 } else{ //C02 subscriber id number 12 AN strb.Append(Canadian.TidyAN(insSub.SubscriberID.Replace("-",""),12));//validated } if(carrier.CDAnetVersion=="04") { //C17 primary dependant code 2 N. Optional strb.Append(Canadian.TidyN(patID,2)); } //C03 relationship code 1 N //User interface does not only show Canadian options, but all options are handled. strb.Append(Canadian.GetRelationshipCode(relat)); //C04 patient's sex 1 A //validated to not include "unknown" if(patient.Gender==PatientGender.Male) { strb.Append("M"); } else { strb.Append("F"); } //C05 patient birthday 8 N strb.Append(patient.Birthdate.ToString("yyyyMMdd"));//validated //C06 patient last name 25 AE strb.Append(Canadian.TidyAE(patient.LName,25,true));//validated //C07 patient first name 15 AE strb.Append(Canadian.TidyAE(patient.FName,15,true));//validated //C08 patient middle initial 1 AE strb.Append(Canadian.TidyAE(patient.MiddleI,1)); //C09 eligibility exception code 1 N strb.Append(Canadian.GetEligibilityCode(patient.CanadianEligibilityCode,carrier.CDAnetVersion=="02"));//validated if(carrier.CDAnetVersion=="04") { //C12 plan flag 1 A strb.Append(Canadian.GetPlanFlag(plan.CanadianPlanFlag)); //C18 plan record count 1 N if(C19PlanRecordPresent) { strb.Append("1"); } else { strb.Append("0"); } //C16 Eligibility date. 8 N. strb.Append(date.ToString("yyyyMMdd")); } //D01 subscriber birthday 8 N strb.Append(subscriber.Birthdate.ToString("yyyyMMdd"));//validated //D02 subscriber last name 25 AE strb.Append(Canadian.TidyAE(subscriber.LName,25,true));//validated //D03 subscriber first name 15 AE strb.Append(Canadian.TidyAE(subscriber.FName,15,true));//validated //D04 subscriber middle initial 1 AE strb.Append(Canadian.TidyAE(subscriber.MiddleI,1)); if(carrier.CDAnetVersion=="04") { //D10 language of insured 1 A if(subscriber.Language=="fr") { strb.Append("F"); } else { strb.Append("E"); } //D11 card sequence/version number 2 N //Not validated against type of carrier. Might need to check if Dentaide. strb.Append(Canadian.TidyN(plan.DentaideCardSequence,2)); //C19 plan record 30 AN if(C19PlanRecordPresent) { //todo: what text goes here? Not documented strb.Append(Canadian.TidyAN("",30)); } } string result=""; bool resultIsError=false; try { result=Canadian.PassToIca(strb.ToString(),clearhouse); } catch(ApplicationException ex) { result=ex.Message; resultIsError=true; //Etranss.Delete(etrans.EtransNum);//we don't want to do this, because we want the incremented etrans.OfficeSequenceNumber to be saved //Attach an ack indicating failure. } //Attach an ack to the etrans Etrans etransAck=new Etrans(); etransAck.PatNum=etrans.PatNum; etransAck.PlanNum=etrans.PlanNum; etransAck.InsSubNum=etrans.InsSubNum; etransAck.CarrierNum=etrans.CarrierNum; etransAck.DateTimeTrans=DateTime.Now; CCDFieldInputter fieldInputter=null; if(resultIsError){ etransAck.Etype=EtransType.AckError; etrans.Note="failed"; } else{ fieldInputter=new CCDFieldInputter(result); CCDField fieldG05=fieldInputter.GetFieldById("G05"); if(fieldG05!=null) { etransAck.AckCode=fieldG05.valuestr; } etransAck.Etype=fieldInputter.GetEtransType(); } Etranss.Insert(etransAck); Etranss.SetMessage(etransAck.EtransNum,result); etrans.AckEtransNum=etransAck.EtransNum; Etranss.Update(etrans); Etranss.SetMessage(etrans.EtransNum,strb.ToString()); if(resultIsError){ throw new ApplicationException(result); } if(doPrint) { new FormCCDPrint(etrans,result,true);//Print the form. } //Now we will process the 'result' here to extract the important data. Basically Yes or No on the eligibility. //We might not do this for any other trans type besides eligibility. string strResponse="";//"Eligibility check on "+DateTime.Today.ToShortDateString()+"\r\n"; //CCDField field=fieldInputter.GetFieldById("G05");//response status string valuestr=fieldInputter.GetValue("G05");//response status switch(valuestr){ case "E": strResponse+="Patient is eligible."; break; case "R": strResponse+="Patient not eligible, or error in data."; break; case "M": strResponse+="Manual claimform should be submitted for employer certified plan."; break; } etrans=Etranss.GetEtrans(etrans.EtransNum); etrans.Note=strResponse; Etranss.Update(etrans); return etransAck.EtransNum; /* CCDField[] fields=fieldInputter.GetFieldsById("G08");//Error Codes for(int i=0;i<fields.Length;i++){ retVal+="\r\n"; retVal+=fields[i].valuestr;//todo: need to turn this into a readable string. } fields=fieldInputter.GetFieldsById("G32");//Display messages for(int i=0;i<fields.Length;i++) { retVal+="\r\n"; retVal+=fields[i].valuestr; } return retVal;*/ }
private Claim CreateClaim(string claimType, List <PatPlan> patPlanList, List <InsPlan> planList, List <ClaimProc> claimProcList, Procedure proc, List <InsSub> subList) { long claimFormNum = 0; InsPlan planCur = new InsPlan(); InsSub subCur = new InsSub(); Relat relatOther = Relat.Self; long clinicNum = proc.ClinicNum; PlaceOfService placeService = proc.PlaceService; switch (claimType) { case "P": subCur = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList)), subList); planCur = InsPlans.GetPlan(subCur.PlanNum, planList); break; case "S": subCur = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList)), subList); planCur = InsPlans.GetPlan(subCur.PlanNum, planList); break; case "Med": //It's already been verified that a med plan exists subCur = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, planList, subList)), subList); planCur = InsPlans.GetPlan(subCur.PlanNum, planList); break; } ClaimProc claimProcCur = Procedures.GetClaimProcEstimate(proc.ProcNum, claimProcList, planCur, subCur.InsSubNum); if (claimProcCur == null) { claimProcCur = new ClaimProc(); ClaimProcs.CreateEst(claimProcCur, proc, planCur, subCur); } Claim claimCur = new Claim(); claimCur.PatNum = proc.PatNum; claimCur.DateService = proc.ProcDate; claimCur.ClinicNum = proc.ClinicNum; claimCur.PlaceService = proc.PlaceService; claimCur.ClaimStatus = "W"; claimCur.DateSent = DateTimeOD.Today; claimCur.PlanNum = planCur.PlanNum; claimCur.InsSubNum = subCur.InsSubNum; InsSub sub; switch (claimType) { case "P": claimCur.PatRelat = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList)); claimCur.ClaimType = "P"; claimCur.InsSubNum2 = PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList)); sub = InsSubs.GetSub(claimCur.InsSubNum2, subList); if (sub.PlanNum > 0 && InsPlans.RefreshOne(sub.PlanNum).IsMedical) { claimCur.PlanNum2 = 0; //no sec ins claimCur.PatRelat2 = Relat.Self; } else { claimCur.PlanNum2 = sub.PlanNum; //might be 0 if no sec ins claimCur.PatRelat2 = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList)); } break; case "S": claimCur.PatRelat = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, planList, subList)); claimCur.ClaimType = "S"; claimCur.InsSubNum2 = PatPlans.GetInsSubNum(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList)); sub = InsSubs.GetSub(claimCur.InsSubNum2, subList); claimCur.PlanNum2 = sub.PlanNum; claimCur.PatRelat2 = PatPlans.GetRelat(patPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, patPlanList, planList, subList)); break; case "Med": claimCur.PatRelat = PatPlans.GetFromList(patPlanList, subCur.InsSubNum).Relationship; claimCur.ClaimType = "Other"; if (PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical)) { claimCur.MedType = EnumClaimMedType.Institutional; } else { claimCur.MedType = EnumClaimMedType.Medical; } break; case "Other": claimCur.PatRelat = relatOther; claimCur.ClaimType = "Other"; //plannum2 is not automatically filled in. claimCur.ClaimForm = claimFormNum; if (planCur.IsMedical) { if (PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical)) { claimCur.MedType = EnumClaimMedType.Institutional; } else { claimCur.MedType = EnumClaimMedType.Medical; } } break; } if (planCur.PlanType == "c") //if capitation { claimCur.ClaimType = "Cap"; } claimCur.ProvTreat = proc.ProvNum; if (Providers.GetIsSec(proc.ProvNum)) { claimCur.ProvTreat = Patients.GetPat(proc.PatNum).PriProv; //OK if zero, because auto select first in list when open claim } claimCur.IsProsthesis = "N"; claimCur.ProvBill = Providers.GetBillingProvNum(claimCur.ProvTreat, claimCur.ClinicNum); //OK if zero, because it will get fixed in claim claimCur.EmployRelated = YN.No; claimCur.ClaimForm = planCur.ClaimFormNum; Claims.Insert(claimCur); //attach procedure claimProcCur.ClaimNum = claimCur.ClaimNum; if (planCur.PlanType == "c") //if capitation { claimProcCur.Status = ClaimProcStatus.CapClaim; } else { claimProcCur.Status = ClaimProcStatus.NotReceived; } if (planCur.UseAltCode && (ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1 != "")) { claimProcCur.CodeSent = ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1; } else if (planCur.IsMedical && proc.MedicalCode != "") { claimProcCur.CodeSent = proc.MedicalCode; } else { claimProcCur.CodeSent = ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode; if (claimProcCur.CodeSent.Length > 5 && claimProcCur.CodeSent.Substring(0, 1) == "D") { claimProcCur.CodeSent = claimProcCur.CodeSent.Substring(0, 5); } if (CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA { if (claimProcCur.CodeSent.Length > 5) //In Canadian e-claims, codes can contain letters or numbers and cannot be longer than 5 characters. { claimProcCur.CodeSent = claimProcCur.CodeSent.Substring(0, 5); } } } claimProcCur.LineNumber = (byte)1; ClaimProcs.Update(claimProcCur); return(claimCur); }
private void butOK_Click(object sender, System.EventArgs e) { if(gridMain.GetSelectedIndex()==-1){ MessageBox.Show(Lan.g(this,"Please select a plan first.")); return; } if(ViewRelat && listRelat.SelectedIndex==-1){ MessageBox.Show(Lan.g(this,"Please select a relationship first.")); return; } if(ViewRelat){ PatRelat=(Relat)listRelat.SelectedIndex; } SelectedSub=SubList[gridMain.GetSelectedIndex()]; SelectedPlan=InsPlans.GetPlan(SubList[gridMain.GetSelectedIndex()].PlanNum,PlanList); DialogResult=DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if(gridMain.GetSelectedIndex()==-1){ MessageBox.Show(Lan.g(this,"Please select a plan first.")); return; } if(listRelat.SelectedIndex==-1){ MessageBox.Show(Lan.g(this,"Please select a relationship first.")); return; } //if(comboClaimForm.SelectedIndex==-1) { // MessageBox.Show(Lan.g(this,"Please select a claimform first.")); // return; //} PatRelat=(Relat)listRelat.SelectedIndex; SelectedSub=SubList[gridMain.GetSelectedIndex()]; SelectedPlan=InsPlans.GetPlan(SubList[gridMain.GetSelectedIndex()].PlanNum,PlanList); //ClaimFormNum=ClaimForms.ListShort[comboClaimForm.SelectedIndex].ClaimFormNum; DialogResult=DialogResult.OK; }
/// <summary>claimType="P" or "S".</summary> public static Claim CreateClaim(string claimType, List <PatPlan> PatPlanList, List <InsPlan> InsPlanList, List <ClaimProc> ClaimProcList, List <Procedure> procsForPat, Patient pat, List <Procedure> procsForClaim, List <Benefit> benefitList, List <InsSub> SubList) { //Claim ClaimCur=CreateClaim("P",PatPlanList,InsPlanList,ClaimProcList,procsForPat); long claimFormNum = 0; EtransType eFormat = 0; InsPlan PlanCur1 = new InsPlan(); InsSub SubCur1 = new InsSub(); InsPlan PlanCur2 = new InsPlan(); InsSub SubCur2 = new InsSub(); Relat relatOther = Relat.Self; switch (claimType) { case "P": SubCur1 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList); PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList); SubCur2 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList); //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null break; case "S": SubCur1 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList); PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList); SubCur2 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList); //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null break; } //DataTable table=DataSetMain.Tables["account"]; Procedure proc; //proc=Procedures.GetProcFromList(procsForPat,PIn.Long(table.Rows[gridAccount.SelectedIndices[0]]["ProcNum"].ToString())); //long clinicNum=proc.ClinicNum; ClaimProc[] claimProcs = new ClaimProc[procsForClaim.Count]; //1:1 with procs long procNum; for (int i = 0; i < procsForClaim.Count; i++) //loop through selected procs //and try to find an estimate that can be used { procNum = procsForClaim[i].ProcNum; claimProcs[i] = Procedures.GetClaimProcEstimate(procNum, ClaimProcList, PlanCur1, SubCur1.InsSubNum); } for (int i = 0; i < claimProcs.Length; i++) //loop through each claimProc //and create any missing estimates. This handles claims to 3rd and 4th ins co's. { if (claimProcs[i] == null) { claimProcs[i] = new ClaimProc(); proc = procsForClaim[i]; ClaimProcs.CreateEst(claimProcs[i], proc, PlanCur1, SubCur1); } } Claim claim = new Claim(); Claims.Insert(claim); //to retreive a key for new Claim.ClaimNum claim.PatNum = pat.PatNum; claim.DateService = claimProcs[claimProcs.Length - 1].ProcDate; claim.ClinicNum = procsForClaim[0].ClinicNum; claim.DateSent = DateTime.Today; claim.ClaimStatus = "S"; //datereceived switch (claimType) { case "P": claim.PlanNum = SubCur1.PlanNum; claim.InsSubNum = PatPlans.GetInsSubNum(PatPlanList, 1); claim.PatRelat = PatPlans.GetRelat(PatPlanList, 1); claim.ClaimType = "P"; claim.PlanNum2 = SubCur2.PlanNum; //might be 0 if no sec ins claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2); claim.PatRelat2 = PatPlans.GetRelat(PatPlanList, 2); break; case "S": claim.PlanNum = SubCur1.PlanNum; claim.InsSubNum = PatPlans.GetInsSubNum(PatPlanList, 2); claim.PatRelat = PatPlans.GetRelat(PatPlanList, 2); claim.ClaimType = "S"; claim.PlanNum2 = SubCur2.PlanNum; claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 1); claim.PatRelat2 = PatPlans.GetRelat(PatPlanList, 1); break; } claim.ProvTreat = procsForClaim[0].ProvNum; claim.IsProsthesis = "I"; claim.ProvBill = Providers.GetBillingProvNum(claim.ProvTreat, claim.ClinicNum); claim.EmployRelated = YN.No; //attach procedures Procedure ProcCur; for (int i = 0; i < claimProcs.Length; i++) { ProcCur = procsForClaim[i]; claimProcs[i].ClaimNum = claim.ClaimNum; claimProcs[i].Status = ClaimProcStatus.NotReceived; //status for claims unsent or sent. //writeoff handled in ClaimL.CalculateAndUpdate() claimProcs[i].CodeSent = ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode; if (claimProcs[i].CodeSent.Length > 5 && claimProcs[i].CodeSent.Substring(0, 1) == "D") { claimProcs[i].CodeSent = claimProcs[i].CodeSent.Substring(0, 5); } claimProcs[i].LineNumber = (byte)(i + 1); ClaimProcs.Update(claimProcs[i]); } ClaimProcList = ClaimProcs.Refresh(pat.PatNum); ClaimL.CalculateAndUpdate(procsForPat, InsPlanList, claim, PatPlanList, benefitList, pat.Age, SubList); return(claim); }
public string SaveCharacter(string sUserUpdating, int iUserID) { MethodBase lmth = MethodBase.GetCurrentMethod(); string lsRoutineName = lmth.DeclaringType + "." + lmth.Name; string Timing; Timing = "Save character start: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"); SortedList sParams = new SortedList(); sParams.Add("@UserID", iUserID); sParams.Add("@CharacterID", CharacterID); sParams.Add("@CurrentUserID", CurrentUserID); sParams.Add("@CharacterStatus", CharacterStatusID); sParams.Add("@CharacterFirstName", FirstName); sParams.Add("@CharacterMiddleName", MiddleName); sParams.Add("@CharacterLastName", LastName); sParams.Add("@CharacterAKA", AKA); sParams.Add("@CharacterTitle", Title); sParams.Add("@CharacterRace", Race.CampaignRaceID); sParams.Add("@CharacterType", CharacterType); sParams.Add("@PlotLeadPerson", PlotLeadPerson); sParams.Add("@RulebookCharacter", RulebookCharacter); sParams.Add("@CharacterHistory", CharacterHistory); sParams.Add("@DateHistorySubmitted", DateHistorySubmitted); sParams.Add("@DateHistoryApproved", DateHistoryApproved); sParams.Add("@DateOfBirth", DateOfBirth); sParams.Add("@WhereFrom", WhereFrom); sParams.Add("@CurrentHome", CurrentHome); sParams.Add("@CardPrintName", CardPrintName); sParams.Add("@HousingListName", HousingListName); sParams.Add("@StartDate", StartDate); sParams.Add("@CharacterEmail", CharacterEmail); sParams.Add("@TotalCP", TotalCP); sParams.Add("@CharacterPhoto", CharacterPhoto); sParams.Add("@Costuming", Costuming); sParams.Add("@Weapons", Weapons); sParams.Add("@Accessories", Accessories); sParams.Add("@Items", Items); sParams.Add("@Treasure", Treasure); sParams.Add("@Makeup", Makeup); sParams.Add("@PlayerComments", PlayerComments); sParams.Add("@PrimaryTeamID", TeamID); sParams.Add("@VisibleToPCs", VisibleToPCs); sParams.Add("@Comments", StaffComments); DataTable dtCharInfo = cUtilities.LoadDataTable("uspInsUpdCHCharacters", sParams, "LARPortal", sUserUpdating, lsRoutineName + ".uspInsUpdCHCharacters"); Timing += ", character record update done: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"); sParams = new SortedList(); sParams.Add("@UserID", iUserID); sParams.Add("@CharacterID", CharacterID); if (AllowCharacterRebuild) { sParams.Add("@CharacterRebuildDate", AllowCharacterRebuildToDate); } else { sParams.Add("@ClearDate", 1); } DataTable dtSkillSets = cUtilities.LoadDataTable("uspSetCharacterRebuildToDate", sParams, "LARPortal", sUserUpdating, lsRoutineName + ".uspSetCharacterRebuildToDate"); foreach (cPicture Picture in Pictures) { Picture.CharacterID = CharacterID; if (Picture.RecordStatus == RecordStatuses.Delete) { Picture.Delete(sUserUpdating); } else { Picture.Save(sUserUpdating); } } if (ProfilePicture != null) { if (ProfilePicture.RecordStatus == RecordStatuses.Delete) { ProfilePicture.Delete(sUserUpdating); } else { ProfilePicture.Save(sUserUpdating); } } foreach (cCharacterSkill Skill in CharacterSkills) { if (Skill.RecordStatus == RecordStatuses.Delete) { Skill.Delete(sUserUpdating, iUserID); } else { Skill.Save(sUserUpdating, iUserID); } } Timing += ", skills update done: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"); foreach (cDescriptor Desc in Descriptors) { Desc.CharacterSkillSetID = SkillSetID; // CharacterSkillSetID[0]; if (Desc.RecordStatus == RecordStatuses.Delete) { Desc.Delete(sUserUpdating, iUserID); } else { Desc.Save(sUserUpdating, iUserID); } } foreach (cCharacterPlace Place in Places) { Place.CharacterID = CharacterID; Place.Save(iUserID); } foreach (cCharacterDeath Death in Deaths) { Death.Save(iUserID); } foreach (cActor Actor in Actors) { Actor.Save(iUserID); } foreach (cRelationship Relat in Relationships) { Relat.Save(sUserUpdating, iUserID); } foreach (cCharacterSkillCost cSkillCost in SkillCost) { cSkillCost.Save(sUserUpdating, iUserID); } Timing += ", character save done: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"); return(Timing); }
private void gridMain_CellDoubleClick(object sender,OpenDental.UI.ODGridClickEventArgs e) { if(ViewRelat && listRelat.SelectedIndex==-1) { MessageBox.Show(Lan.g(this,"Please select a relationship first.")); return; } if(ViewRelat) { PatRelat=(Relat)listRelat.SelectedIndex; } SelectedSub=SubList[e.Row]; SelectedPlan=InsPlans.GetPlan(SubList[e.Row].PlanNum,PlanList); DialogResult=DialogResult.OK; }
public Table(List <Oper> opers, List <Element> ter, List <Element> brack, Element br) { operations = opers; terms = ter; brackets = brack; brake = br; var merge = terms.Append(brake).Concat(brackets).Concat(opers); elements = merge.ToList(); int size = elements.Count; relations = new Relat[size][]; for (int i = 0; i < size; i++) { relations[i] = new Relat[size]; var firEl = elements[i]; for (int j = 0; j < size; j++) { var secEl = elements[j]; if (isOperation(firEl)) { var firOp = (Oper)firEl; if (isOperation(secEl)) { var secOp = (Oper)secEl; if (secOp.Unar) { relations[i][j] = Relat.Lesser; } else if (firOp.Prior > secOp.Prior) { relations[i][j] = Relat.More; } else if (firOp.Prior < secOp.Prior) { relations[i][j] = Relat.Lesser; } else if (firOp.LAssoc) { relations[i][j] = Relat.More; } else if (!firOp.LAssoc) { relations[i][j] = Relat.Lesser; } else { relations[i][j] = Relat.None; } } else if (isTerm(secEl) || isLeftBracket(secEl)) { relations[i][j] = Relat.Lesser; } else if (isRightBracket(secEl) || secEl == brake) { relations[i][j] = Relat.More; } else { relations[i][j] = Relat.None; } } else if (isTerm(firEl)) { if (isOperation(secEl) || isRightBracket(secEl) || secEl == brake) { relations[i][j] = Relat.More; } else { relations[i][j] = Relat.None; } } else if (firEl.Name == "(") { if (isOperation(secEl) || secEl.Name == "(" || isTerm(secEl) || secEl.Name == "[") { relations[i][j] = Relat.Lesser; } else if (secEl.Name == ")") { relations[i][j] = Relat.Equal; } else { relations[i][j] = Relat.None; } } else if (firEl.Name == "[") { if (isOperation(secEl) || secEl.Name == "(" || isTerm(secEl) || secEl.Name == "[") { relations[i][j] = Relat.Lesser; } else if (secEl.Name == "]") { relations[i][j] = Relat.Equal; } else { relations[i][j] = Relat.None; } } else if (isRightBracket(firEl)) { if (isOperation(secEl) || secEl.Name == ")" || secEl == brake || secEl.Name == "]") { relations[i][j] = Relat.More; } else { relations[i][j] = Relat.None; } } else if (firEl == brake) { if (isOperation(secEl) || isLeftBracket(secEl) || isTerm(secEl)) { relations[i][j] = Relat.Lesser; } else { relations[i][j] = Relat.None; } } else { relations[i][j] = Relat.None; } } } }
///<summary>Convert a patient relationship enum value into a human-readable, CDA required string.</summary> private string GetPatientRelationshipString(Relat relat){ switch(Canadian.GetRelationshipCode(relat)){ case "1": return isFrench?"Soi-même":"Self"; case "2": return isFrench?"Époux(se)":"Spouse"; case "3": return isFrench?"Enfant":"Child"; case "4": return isFrench?"Conjoint(e)":"Common Law Spouse"; case "5": return isFrench?"Autre":"Other"; default: break; } return ""; }
///<summary>The result is a string which can be dropped into the insplan.BenefitNotes. Or it might throw an exception if invalid data. This class is also responsible for saving the returned message to the etrans table and printing out the required form.</summary> public static string SendElegibility(string electID, int patNum, string groupNumber, string divisionNo, string subscriberID, string patID, Relat patRelat, int subscNum, string dentaideCardSequence) { //Note: This might be the only class of this kind that returns a string. It's a special situation. //We are simply not going to bother with language translation here. //determine carrier. Carrier carrier = Carriers.GetCanadian(electID); //this also happens to validate missing or short value if (carrier == null) { throw new ApplicationException("Invalid carrier EDI code."); } Clearinghouse clearhouse = Canadian.GetClearinghouse(); if (clearhouse == null) { throw new ApplicationException("Canadian clearinghouse not found."); } string saveFolder = clearhouse.ExportPath; if (!Directory.Exists(saveFolder)) { throw new ApplicationException(saveFolder + " not found."); } //Initialize objects----------------------------------------------------------------------------------------------- Patient patient = Patients.GetPat(patNum); Patient subscriber = Patients.GetPat(subscNum); Provider treatProv = Providers.GetProv(Patients.GetProvNum(patient)); Provider billProv = Providers.GetProv(Providers.GetBillingProvNum(treatProv.ProvNum)); //I had to use a dialog box to get the eligibility code. //validate any missing info---------------------------------------------------------------------------------- string error = ""; if (carrier.CanadianNetworkNum == 0) { if (error != "") { error += ", "; } error += "Carrier does not have network specified"; } if (!Regex.IsMatch(carrier.ElectID, @"^[0-9]{6}$")) //not necessary, but nice { if (error != "") { error += ", "; } error += "CarrierId 6 digits"; } if (treatProv.NationalProvID.Length != 9) { if (error != "") { error += ", "; } error += "TreatingProv CDA num 9 digits"; } if (treatProv.CanadianOfficeNum.Length != 4) { if (error != "") { error += ", "; } error += "TreatingProv office num 4 char"; } if (billProv.NationalProvID.Length != 9) { if (error != "") { error += ", "; } error += "BillingProv CDA num 9 digits"; } if (groupNumber.Length == 0 || groupNumber.Length > 12 || groupNumber.Contains(" ")) { if (error != "") { error += ", "; } error += "Plan Number"; } if (subscriberID == "") { if (error != "") { error += ", "; } error += "SubscriberID"; } if (patNum != subscNum && patRelat == Relat.Self) //if patient is not subscriber, and relat is self { if (error != "") { error += ", "; } error += "Relationship cannot be self"; } if (patient.Gender == PatientGender.Unknown) { if (error != "") { error += ", "; } error += "Patient gender"; } if (patient.Birthdate.Year < 1880 || patient.Birthdate > DateTime.Today) { if (error != "") { error += ", "; } error += "Patient birthdate"; } if (patient.LName == "") { if (error != "") { error += ", "; } error += "Patient lastname"; } if (patient.FName == "") { if (error != "") { error += ", "; } error += "Patient firstname"; } if (subscriber.Birthdate.Year < 1880 || subscriber.Birthdate > DateTime.Today) { if (error != "") { error += ", "; } error += "Subscriber birthdate"; } if (subscriber.LName == "") { if (error != "") { error += ", "; } error += "Subscriber lastname"; } if (subscriber.FName == "") { if (error != "") { error += ", "; } error += "Subscriber firstname"; } if (error != "") { throw new ApplicationException(error); } FormCanadianEligibility FormElig = new FormCanadianEligibility(); FormElig.ShowDialog(); if (FormElig.DialogResult != DialogResult.OK) { throw new ApplicationException("Eligibility Code or Date missing."); } //eligiblity code guaranteed to not be 0 at this point. Also date will be between 1980 and 10 years from now. Etrans etrans = Etranss.CreateCanadianOutput(patNum, carrier.CarrierNum, carrier.CanadianNetworkNum, clearhouse.ClearinghouseNum, EtransType.Eligibility_CA); string txt = ""; //create message---------------------------------------------------------------------------------------------- //A01 transaction prefix 12 AN //todo txt += "123456789012"; //To be later provided by the individual network. //A02 office sequence number 6 N txt += Canadian.TidyN(etrans.OfficeSequenceNumber, 6); //A03 format version number 2 N txt += "04"; //A04 transaction code 2 N txt += "08"; //eligibility //A05 carrier id number 6 N txt += carrier.ElectID; //already validated as 6 digit number. //A06 software system id 3 AN The third character is for version of OD. //todo txt += "OD1"; //To be later supplied by CDAnet staff to uniquely identify OD. //A10 encryption method 1 N //todo txt += "1"; //A07 message length 5 N int len = 214; //todo does not account for C19. Possibly 30 more. //if(C19 is used, Plan Record){ //len+=30; //} txt += Canadian.TidyN(len, 5); //A09 carrier transaction counter 5 N txt += Canadian.TidyN(etrans.CarrierTransCounter, 5); //B01 CDA provider number 9 AN txt += Canadian.TidyAN(treatProv.NationalProvID, 9); //already validated //B02 (treating) provider office number 4 AN txt += Canadian.TidyAN(treatProv.CanadianOfficeNum, 4); //already validated //B03 billing provider number 9 AN //todo, need to account for possible 5 digit prov id assigned by carrier txt += Canadian.TidyAN(billProv.NationalProvID, 9); //already validated //C01 primary policy/plan number 12 AN (group number) //only validated to ensure that it's not blank and is less than 12. Also that no spaces. txt += Canadian.TidyAN(groupNumber, 12); //C11 primary division/section number 10 AN txt += Canadian.TidyAN(divisionNo, 10); //C02 subscriber id number 12 AN txt += Canadian.TidyAN(subscriberID.Replace("-", ""), 12); //validated //C17 primary dependant code 2 N. Optional txt += Canadian.TidyN(patID, 2); //C03 relationship code 1 N //User interface does not only show Canadian options, but all options are handled. txt += Canadian.GetRelationshipCode(patRelat); //C04 patient's sex 1 A //validated to not include "unknown" if (patient.Gender == PatientGender.Male) { txt += "M"; } else { txt += "F"; } //C05 patient birthday 8 N txt += patient.Birthdate.ToString("yyyyMMdd"); //validated //C06 patient last name 25 AE txt += Canadian.TidyAE(patient.LName, 25, true); //validated //C07 patient first name 15 AE txt += Canadian.TidyAE(patient.FName, 15, true); //validated //C08 patient middle initial 1 AE txt += Canadian.TidyAE(patient.MiddleI, 1); //C09 eligibility exception code 1 N txt += Canadian.TidyN(FormElig.EligibilityCode, 1); //validated //C12 plan flag 1 A //todo //might not be carrier.IsPMP. Might have to do with plan, not carrier. See F17. txt += " "; //C18 plan record count 1 N //todo txt += "0"; //C16 Eligibility date. 8 N. txt += FormElig.AsOfDate.ToString("yyyyMMdd"); //validated //D01 subscriber birthday 8 N txt += subscriber.Birthdate.ToString("yyyyMMdd"); //validated //D02 subscriber last name 25 AE txt += Canadian.TidyAE(subscriber.LName, 25, true); //validated //D03 subscriber first name 15 AE txt += Canadian.TidyAE(subscriber.FName, 15, true); //validated //D04 subscriber middle initial 1 AE txt += Canadian.TidyAE(subscriber.MiddleI, 1); //D10 language of insured 1 A if (subscriber.Language == "fr") { txt += "F"; } else { txt += "E"; } //D11 card sequence/version number 2 N //todo: Not validated against type of carrier yet. Need to check if Dentaide. txt += Canadian.TidyN(dentaideCardSequence, 2); //todo If C18=1, then the following field would appear //C19 plan record 30 AN string result = ""; try { result = Canadian.PassToCCD(txt, carrier.CanadianNetworkNum, clearhouse); } catch (ApplicationException ex) { Etranss.Delete(etrans.EtransNum); throw new ApplicationException(ex.Message); } Etranss.SetMessage(etrans.EtransNum, txt); etrans.MessageText = txt; FormCCDPrint FormP = new FormCCDPrint(etrans); //Print the form. FormP.ShowDialog(); //Now we will process the 'result' here to extract the important data. Basically Yes or No on the eligibility. //We might not do this for any other trans type besides eligibility. string retVal = "Eligibility check on " + DateTime.Today.ToShortDateString() + "\r\n"; CCDFieldInputter fieldInputter = new CCDFieldInputter(result); CCDField field = fieldInputter.GetFieldById("G05");//response status //CCDFieldInputter could really use a GetValue(string fieldId) method so I don't have to use a field object. switch (field.valuestr) { case "E": retVal += "Patient is eligible."; break; case "R": retVal += "Patient not eligible, or error in data."; break; case "M": retVal += "Manual claimform should be submitted for employer certified plan."; break; } CCDField[] fields = fieldInputter.GetFieldsById("G08"); //Error Codes for (int i = 0; i < fields.Length; i++) { retVal += "\r\n"; retVal += fields[i].valuestr; //todo: need to turn this into a readable string. } fields = fieldInputter.GetFieldsById("G32"); //Display messages for (int i = 0; i < fields.Length; i++) { retVal += "\r\n"; retVal += fields[i].valuestr; } return(retVal); }