///<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); } }
public static void FillPtInfo(OpenDental.ContrChart sender, Patient PatCur) { //first, get all the objects we need. Because they are by ref, the original gets altered. ODGrid gridPtInfo = (ODGrid)sender.Controls.Find("gridPtInfo", true)[0]; TabControl tabControlImages = (TabControl)sender.Controls.Find("tabControlImages", true)[0]; ODtextBox textTreatmentNotes = (ODtextBox)sender.Controls.Find("textTreatmentNotes", true)[0]; //bool TreatmentNoteChanged=sender.TreatmentNoteChanged;//might have to do a by ref here? //Then get some data that we need Family fam = null; PatientNote PatientNoteCur = null; List <PatPlan> PatPlanList = null; List <InsSub> SubList = null; List <InsPlan> PlanList = null; if (PatCur != null) { fam = Patients.GetFamily(PatCur.PatNum); PatientNoteCur = PatientNotes.Refresh(PatCur.PatNum, PatCur.Guarantor); PatPlanList = PatPlans.Refresh(PatCur.PatNum); SubList = InsSubs.RefreshForFam(fam); PlanList = InsPlans.RefreshForSubList(SubList); } //Then, continue with the slightly altered original method. gridPtInfo.Height = tabControlImages.Top - gridPtInfo.Top; textTreatmentNotes.Text = ""; if (PatCur != null) { textTreatmentNotes.Text = PatientNoteCur.Treatment; textTreatmentNotes.Enabled = true; textTreatmentNotes.Select(textTreatmentNotes.Text.Length + 2, 1); textTreatmentNotes.ScrollToCaret(); sender.TreatmentNoteChanged = false; } gridPtInfo.BeginUpdate(); gridPtInfo.Columns.Clear(); ODGridColumn col = new ODGridColumn("", 100); //Lan.g("TableChartPtInfo",""),); gridPtInfo.Columns.Add(col); col = new ODGridColumn("", 300); gridPtInfo.Columns.Add(col); gridPtInfo.Rows.Clear(); if (PatCur == null) { gridPtInfo.EndUpdate(); return; } ODGridRow row; //Age row = new ODGridRow(); row.Cells.Add("Age"); row.Cells.Add(PatientLogic.DateToAgeString(PatCur.Birthdate)); row.Tag = null; gridPtInfo.Rows.Add(row); //Credit type row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "ABC0")); row.Cells.Add(PatCur.CreditType); row.Tag = null; gridPtInfo.Rows.Add(row); //Billing type row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Billing Type")); row.Cells.Add(Defs.GetName(DefCat.BillingTypes, PatCur.BillingType)); row.Tag = null; gridPtInfo.Rows.Add(row); //Referrals List <RefAttach> RefAttachList = RefAttaches.Refresh(PatCur.PatNum); for (int i = 0; i < RefAttachList.Count; i++) { row = new ODGridRow(); row.ColorBackG = Color.Aquamarine; if (RefAttachList[i].RefType == ReferralType.RefFrom) { row.Cells.Add("Referred From"); } else { row.Cells.Add("Referred To"); } row.Cells.Add(Referrals.GetNameLF(RefAttachList[i].ReferralNum)); row.Tag = null; gridPtInfo.Rows.Add(row); } //Date First Visit row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Date First Visit")); if (PatCur.DateFirstVisit.Year < 1880) { row.Cells.Add("??"); } else if (PatCur.DateFirstVisit == DateTime.Today) { row.Cells.Add(Lan.g("TableChartPtInfo", "NEW PAT")); } else { row.Cells.Add(PatCur.DateFirstVisit.ToShortDateString()); } row.Tag = null; gridPtInfo.Rows.Add(row); //Prov - Pri & Sec row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Prov. (Pri, Sec)")); if (PatCur.SecProv != 0) { row.Cells.Add(Providers.GetAbbr(PatCur.PriProv) + ", " + Providers.GetAbbr(PatCur.SecProv)); } else { row.Cells.Add(Providers.GetAbbr(PatCur.PriProv) + ", " + "None"); } row.Tag = null; gridPtInfo.Rows.Add(row); //PriIns row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Pri Ins")); string name; if (PatPlanList.Count > 0) { name = InsPlans.GetCarrierName(InsSubs.GetOne(PatPlanList[0].InsSubNum).PlanNum, PlanList); if (PatPlanList[0].IsPending) { name += Lan.g("TableChartPtInfo", " (pending)"); } row.Cells.Add(name); } else { row.Cells.Add(""); } row.Tag = null; gridPtInfo.Rows.Add(row); //SecIns row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Sec Ins")); if (PatPlanList.Count > 1) { name = InsPlans.GetCarrierName(InsSubs.GetOne(PatPlanList[1].InsSubNum).PlanNum, PlanList); if (PatPlanList[1].IsPending) { name += Lan.g("TableChartPtInfo", " (pending)"); } row.Cells.Add(name); } else { row.Cells.Add(""); } row.Tag = null; gridPtInfo.Rows.Add(row); //Registration keys------------------------------------------------------------------------------------------- if (PrefC.GetBool(PrefName.DistributorKey)) { RegistrationKey[] keys = RegistrationKeys.GetForPatient(PatCur.PatNum); for (int i = 0; i < keys.Length; i++) { row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Registration Key")); string str = keys[i].RegKey.Substring(0, 4) + "-" + keys[i].RegKey.Substring(4, 4) + "-" + keys[i].RegKey.Substring(8, 4) + "-" + keys[i].RegKey.Substring(12, 4); if (keys[i].IsForeign) { str += "\r\nForeign"; } else { str += "\r\nUSA"; } str += "\r\nStarted: " + keys[i].DateStarted.ToShortDateString(); if (keys[i].DateDisabled.Year > 1880) { str += "\r\nDisabled: " + keys[i].DateDisabled.ToShortDateString(); } if (keys[i].DateEnded.Year > 1880) { str += "\r\nEnded: " + keys[i].DateEnded.ToShortDateString(); } if (keys[i].Note != "") { str += keys[i].Note; } row.Cells.Add(str); row.Tag = keys[i].Copy(); gridPtInfo.Rows.Add(row); } } ODGridCell cell; //medical fields----------------------------------------------------------------- bool showMed = true; if (Programs.IsEnabled(ProgramName.eClinicalWorks) && ProgramProperties.GetPropVal(ProgramName.eClinicalWorks, "IsStandalone") == "0") { showMed = false; } if (showMed) { //Get the Chart Module Medical color from the MiscColors category. Color colorChartModuleMedical = Defs.GetDefsForCategory(DefCat.MiscColors)[3].ItemColor; //premed flag. if (PatCur.Premed) { row = new ODGridRow(); row.Cells.Add(""); cell = new ODGridCell(); cell.Text = Lan.g("TableChartPtInfo", "Premedicate"); cell.ColorText = Color.Red; cell.Bold = YN.Yes; row.Cells.Add(cell); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); } //diseases List <Disease> DiseaseList = Diseases.Refresh(PatCur.PatNum); row = new ODGridRow(); cell = new ODGridCell(Lan.g("TableChartPtInfo", "Diseases")); cell.Bold = YN.Yes; row.Cells.Add(cell); if (DiseaseList.Count > 0) { row.Cells.Add(""); } else { row.Cells.Add(Lan.g("TableChartPtInfo", "none")); } row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); for (int i = 0; i < DiseaseList.Count; i++) { row = new ODGridRow(); cell = new ODGridCell(DiseaseDefs.GetName(DiseaseList[i].DiseaseDefNum)); cell.ColorText = Color.Red; cell.Bold = YN.Yes; row.Cells.Add(cell); row.Cells.Add(DiseaseList[i].PatNote); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); } //MedUrgNote row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Med Urgent")); cell = new ODGridCell(); cell.Text = PatCur.MedUrgNote; cell.ColorText = Color.Red; cell.Bold = YN.Yes; row.Cells.Add(cell); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); //Medical row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Medical Summary")); row.Cells.Add(PatientNoteCur.Medical); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); //Service row = new ODGridRow(); row.Cells.Add(Lan.g("TableChartPtInfo", "Service Notes")); row.Cells.Add(PatientNoteCur.Service); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); //medications Medications.RefreshCache(); List <MedicationPat> medList = MedicationPats.Refresh(PatCur.PatNum, false); row = new ODGridRow(); cell = new ODGridCell(Lan.g("TableChartPtInfo", "Medications")); cell.Bold = YN.Yes; row.Cells.Add(cell); if (medList.Count > 0) { row.Cells.Add(""); } else { row.Cells.Add(Lan.g("TableChartPtInfo", "none")); } row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); string text; Medication med; for (int i = 0; i < medList.Count; i++) { row = new ODGridRow(); med = Medications.GetMedication(medList[i].MedicationNum); text = med.MedName; if (med.MedicationNum != med.GenericNum) { text += "(" + Medications.GetMedication(med.GenericNum).MedName + ")"; } row.Cells.Add(text); text = medList[i].PatNote + "(" + Medications.GetGeneric(medList[i].MedicationNum).Notes + ")"; row.Cells.Add(text); row.ColorBackG = colorChartModuleMedical; row.Tag = "med"; gridPtInfo.Rows.Add(row); } } //if !eCW.enabled gridPtInfo.EndUpdate(); }