public void DeleteAllRecords(String RegistrationKey) { try { Logger.Information("In DeleteAllRecords"); customerNum = util.GetDentalOfficeID(RegistrationKey); if (customerNum == 0) { return; } //mobile web Patientms.DeleteAll(customerNum); Appointmentms.DeleteAll(customerNum); RxPatms.DeleteAll(customerNum); Providerms.DeleteAll(customerNum); Pharmacyms.DeleteAll(customerNum); Recallms.DeleteAll(customerNum); //pat portal LabPanelms.DeleteAll(customerNum); LabResultms.DeleteAll(customerNum); Medicationms.DeleteAll(customerNum); MedicationPatms.DeleteAll(customerNum); AllergyDefms.DeleteAll(customerNum); Allergyms.DeleteAll(customerNum); DiseaseDefms.DeleteAll(customerNum); Diseasems.DeleteAll(customerNum); ICD9ms.DeleteAll(customerNum); Statementms.DeleteAll(customerNum); Documentms.DeleteAll(customerNum); } catch (Exception ex) { Logger.LogError("IpAddress=" + HttpContext.Current.Request.UserHostAddress + " DentalOfficeID=" + customerNum, ex); throw new Exception("Exception in DeleteAllRecords"); } }
protected void Page_Load(object sender, EventArgs e) { try { CustomerNum = util.GetCustomerNum(Message); if (CustomerNum == 0) { return; } if (Request["PatNum"] != null) { Int64.TryParse(Request["PatNum"].ToString().Trim(), out PatNum); } Int64.TryParse(Session["CustomerNum"].ToString(), out CustomerNum); pat = Patientms.GetOne(CustomerNum, PatNum); pat.Age = Patientms.DateToAge(pat.Birthdate); PatName = util.GetPatientName(pat); String DialString1 = @" <a href=""tel:"; String DialString2 = @""" class=""style2"">dial</a>"; if (!String.IsNullOrEmpty(pat.HmPhone)) { DialLinkHmPhone = DialString1 + pat.HmPhone + DialString2; } if (!String.IsNullOrEmpty(pat.WkPhone)) { DialLinkWkPhone = DialString1 + pat.WkPhone + DialString2; } if (!String.IsNullOrEmpty(pat.WirelessPhone)) { DialLinkWirelessPhone = DialString1 + pat.WirelessPhone + DialString2; } if (!String.IsNullOrEmpty(pat.Email)) { EmailString = @"<a href=""mailto:" + pat.Email + @""" class=""style2"">" + pat.Email + "</a>"; } List <Appointmentm> appointmentmList = Appointmentms.GetAppointmentms(CustomerNum, PatNum); appointmentmList = appointmentmList.Where(a => a.AptStatus != ApptStatus.UnschedList && a.AptStatus != ApptStatus.Planned).ToList(); //exclude unscheduled and planned appointments. Repeater1.DataSource = appointmentmList; Repeater1.DataBind(); List <RxPatm> rxList = RxPatms.GetRxPatms(CustomerNum, PatNum); Repeater2.DataSource = rxList; Repeater2.DataBind(); List <Allergym> allergyList = Allergyms.GetAllergyms(CustomerNum, PatNum); Repeater3.DataSource = allergyList; Repeater3.DataBind(); } catch (Exception ex) { LabelError.Text = Util.ErrorMessage; Logger.LogError(ex); } }
public void SynchAppointments(String RegistrationKey, List <Appointmentm> appointmentList) { try { Logger.Information("In SynchAppointments"); customerNum = util.GetDentalOfficeID(RegistrationKey); if (customerNum == 0) { return; } Appointmentms.UpdateFromChangeList(appointmentList, customerNum); } catch (Exception ex) { Logger.LogError("IpAddress=" + HttpContext.Current.Request.UserHostAddress + " DentalOfficeID=" + customerNum, ex); throw new Exception("Exception in SynchAppointments"); } }
protected void Page_Load(object sender, EventArgs e) { try { CustomerNum = util.GetCustomerNum(Message); if (CustomerNum == 0) { return; } if (Request["AptNum"] != null) { Int64.TryParse(Request["AptNum"].ToString().Trim(), out AptNum); } apt = Appointmentms.GetOne(CustomerNum, AptNum); pat = Patientms.GetOne(CustomerNum, apt.PatNum); PatName = util.GetPatientName(pat); } catch (Exception ex) { LabelError.Text = Util.ErrorMessage; Logger.LogError(ex); } }
///<summary>a general function to reduce the amount of code for uploading</summary> private static void SynchGeneric(List <long> PKNumList, SynchEntity entity, double totalCount, ref double currentVal) { //Dennis: a try catch block here has been avoid on purpose. List <long> BlockPKNumList = null; int localBatchSize = BatchSize; if (IsTroubleshootMode) { localBatchSize = 1; } string AtoZpath = ImageStore.GetPreferredAtoZpath(); for (int start = 0; start < PKNumList.Count; start += localBatchSize) { if ((start + localBatchSize) > PKNumList.Count) { localBatchSize = PKNumList.Count - start; } try{ BlockPKNumList = PKNumList.GetRange(start, localBatchSize); switch (entity) { case SynchEntity.patient: List <Patientm> changedPatientmList = Patientms.GetMultPats(BlockPKNumList); mb.SynchPatients(PrefC.GetString(PrefName.RegistrationKey), changedPatientmList.ToArray()); break; case SynchEntity.appointment: List <Appointmentm> changedAppointmentmList = Appointmentms.GetMultApts(BlockPKNumList); mb.SynchAppointments(PrefC.GetString(PrefName.RegistrationKey), changedAppointmentmList.ToArray()); break; case SynchEntity.prescription: List <RxPatm> changedRxList = RxPatms.GetMultRxPats(BlockPKNumList); mb.SynchPrescriptions(PrefC.GetString(PrefName.RegistrationKey), changedRxList.ToArray()); break; case SynchEntity.provider: List <Providerm> changedProvList = Providerms.GetMultProviderms(BlockPKNumList); mb.SynchProviders(PrefC.GetString(PrefName.RegistrationKey), changedProvList.ToArray()); break; case SynchEntity.pharmacy: List <Pharmacym> changedPharmacyList = Pharmacyms.GetMultPharmacyms(BlockPKNumList); mb.SynchPharmacies(PrefC.GetString(PrefName.RegistrationKey), changedPharmacyList.ToArray()); break; case SynchEntity.labpanel: List <LabPanelm> ChangedLabPanelList = LabPanelms.GetMultLabPanelms(BlockPKNumList); mb.SynchLabPanels(PrefC.GetString(PrefName.RegistrationKey), ChangedLabPanelList.ToArray()); break; case SynchEntity.labresult: List <LabResultm> ChangedLabResultList = LabResultms.GetMultLabResultms(BlockPKNumList); mb.SynchLabResults(PrefC.GetString(PrefName.RegistrationKey), ChangedLabResultList.ToArray()); break; case SynchEntity.medication: List <Medicationm> ChangedMedicationList = Medicationms.GetMultMedicationms(BlockPKNumList); mb.SynchMedications(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationList.ToArray()); break; case SynchEntity.medicationpat: List <MedicationPatm> ChangedMedicationPatList = MedicationPatms.GetMultMedicationPatms(BlockPKNumList); mb.SynchMedicationPats(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationPatList.ToArray()); break; case SynchEntity.allergy: List <Allergym> ChangedAllergyList = Allergyms.GetMultAllergyms(BlockPKNumList); mb.SynchAllergies(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyList.ToArray()); break; case SynchEntity.allergydef: List <AllergyDefm> ChangedAllergyDefList = AllergyDefms.GetMultAllergyDefms(BlockPKNumList); mb.SynchAllergyDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyDefList.ToArray()); break; case SynchEntity.disease: List <Diseasem> ChangedDiseaseList = Diseasems.GetMultDiseasems(BlockPKNumList); mb.SynchDiseases(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseList.ToArray()); break; case SynchEntity.diseasedef: List <DiseaseDefm> ChangedDiseaseDefList = DiseaseDefms.GetMultDiseaseDefms(BlockPKNumList); mb.SynchDiseaseDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseDefList.ToArray()); break; case SynchEntity.icd9: List <ICD9m> ChangedICD9List = ICD9ms.GetMultICD9ms(BlockPKNumList); mb.SynchICD9s(PrefC.GetString(PrefName.RegistrationKey), ChangedICD9List.ToArray()); break; case SynchEntity.statement: List <Statementm> ChangedStatementList = Statementms.GetMultStatementms(BlockPKNumList); mb.SynchStatements(PrefC.GetString(PrefName.RegistrationKey), ChangedStatementList.ToArray()); break; case SynchEntity.document: List <Documentm> ChangedDocumentList = Documentms.GetMultDocumentms(BlockPKNumList, AtoZpath); mb.SynchDocuments(PrefC.GetString(PrefName.RegistrationKey), ChangedDocumentList.ToArray()); break; case SynchEntity.recall: List <Recallm> ChangedRecallList = Recallms.GetMultRecallms(BlockPKNumList); mb.SynchRecalls(PrefC.GetString(PrefName.RegistrationKey), ChangedRecallList.ToArray()); break; case SynchEntity.deletedobject: List <DeletedObject> ChangedDeleteObjectList = DeletedObjects.GetMultDeletedObjects(BlockPKNumList); mb.DeleteObjects(PrefC.GetString(PrefName.RegistrationKey), ChangedDeleteObjectList.ToArray()); break; case SynchEntity.patientdel: mb.DeletePatientsRecords(PrefC.GetString(PrefName.RegistrationKey), BlockPKNumList.ToArray()); break; } //progressIndicator.CurrentVal+=LocalBatchSize;//not allowed currentVal += localBatchSize; if (Application.OpenForms["FormProgress"] != null) // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system. { FormP.Invoke(new PassProgressDelegate(PassProgressToDialog), new object[] { currentVal, "?currentVal of ?maxVal records uploaded", totalCount, "" }); } } catch (Exception e) { if (IsTroubleshootMode) { string errorMessage = entity + " with Primary Key = " + BlockPKNumList.First() + " failed to synch. " + "\n" + e.Message; throw new Exception(errorMessage); } else { throw e; } } } //for loop ends here }
///<summary>This is the function that the worker thread uses to actually perform the upload. Can also call this method in the ordinary way if the data to be transferred is small. The timeSynchStarted must be passed in to ensure that no records are skipped due to small time differences.</summary> private static void UploadWorker(DateTime changedSince, DateTime timeSynchStarted) { int totalCount = 100; try { //Dennis: try catch may not work: Does not work in threads, not sure about this. Note that all methods inside this try catch block are without exception handling. This is done on purpose so that when an exception does occur it does not update PrefName.MobileSyncDateTimeLastRun //The handling of PrefName.MobileSynchNewTables79 should never be removed in future versions DateTime changedProv = changedSince; DateTime changedDeleted = changedSince; DateTime changedPat = changedSince; DateTime changedStatement = changedSince; DateTime changedDocument = changedSince; DateTime changedRecall = changedSince; if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables79Done, false)) { changedProv = DateTime.MinValue; changedDeleted = DateTime.MinValue; } if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables112Done, false)) { changedPat = DateTime.MinValue; changedStatement = DateTime.MinValue; changedDocument = DateTime.MinValue; } if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables121Done, false)) { changedRecall = DateTime.MinValue; UploadPreference(PrefName.PracticeTitle); //done again because the previous upload did not include the prefnum } bool synchDelPat = true; if (PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).Hour == timeSynchStarted.Hour) { synchDelPat = false; // synching delPatNumList is timeconsuming (15 seconds) for a dental office with around 5000 patients and it's mostly the same records that have to be deleted every time a synch happens. So it's done only once hourly. } //MobileWeb List <long> patNumList = Patientms.GetChangedSincePatNums(changedPat); List <long> aptNumList = Appointmentms.GetChangedSinceAptNums(changedSince, PrefC.GetDate(PrefName.MobileExcludeApptsBeforeDate)); List <long> rxNumList = RxPatms.GetChangedSinceRxNums(changedSince); List <long> provNumList = Providerms.GetChangedSinceProvNums(changedProv); List <long> pharNumList = Pharmacyms.GetChangedSincePharmacyNums(changedSince); List <long> allergyDefNumList = AllergyDefms.GetChangedSinceAllergyDefNums(changedSince); List <long> allergyNumList = Allergyms.GetChangedSinceAllergyNums(changedSince); //exclusively Patient Portal List <long> eligibleForUploadPatNumList = Patientms.GetPatNumsEligibleForSynch(); List <long> labPanelNumList = LabPanelms.GetChangedSinceLabPanelNums(changedSince, eligibleForUploadPatNumList); List <long> labResultNumList = LabResultms.GetChangedSinceLabResultNums(changedSince); List <long> medicationNumList = Medicationms.GetChangedSinceMedicationNums(changedSince); List <long> medicationPatNumList = MedicationPatms.GetChangedSinceMedicationPatNums(changedSince, eligibleForUploadPatNumList); List <long> diseaseDefNumList = DiseaseDefms.GetChangedSinceDiseaseDefNums(changedSince); List <long> diseaseNumList = Diseasems.GetChangedSinceDiseaseNums(changedSince, eligibleForUploadPatNumList); List <long> icd9NumList = ICD9ms.GetChangedSinceICD9Nums(changedSince); List <long> statementNumList = Statementms.GetChangedSinceStatementNums(changedStatement, eligibleForUploadPatNumList, statementLimitPerPatient); List <long> documentNumList = Documentms.GetChangedSinceDocumentNums(changedDocument, statementNumList); List <long> recallNumList = Recallms.GetChangedSinceRecallNums(changedRecall); List <long> delPatNumList = Patientms.GetPatNumsForDeletion(); //List<DeletedObject> dO=DeletedObjects.GetDeletedSince(changedDeleted);dennis: delete this line later List <long> deletedObjectNumList = DeletedObjects.GetChangedSinceDeletedObjectNums(changedDeleted); totalCount = patNumList.Count + aptNumList.Count + rxNumList.Count + provNumList.Count + pharNumList.Count + labPanelNumList.Count + labResultNumList.Count + medicationNumList.Count + medicationPatNumList.Count + allergyDefNumList.Count + allergyNumList.Count + diseaseDefNumList.Count + diseaseNumList.Count + icd9NumList.Count + statementNumList.Count + documentNumList.Count + recallNumList.Count + deletedObjectNumList.Count; if (synchDelPat) { totalCount += delPatNumList.Count; } double currentVal = 0; if (Application.OpenForms["FormProgress"] != null) // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system. { FormP.Invoke(new PassProgressDelegate(PassProgressToDialog), new object[] { currentVal, "?currentVal of ?maxVal records uploaded", totalCount, "" }); } IsSynching = true; SynchGeneric(patNumList, SynchEntity.patient, totalCount, ref currentVal); SynchGeneric(aptNumList, SynchEntity.appointment, totalCount, ref currentVal); SynchGeneric(rxNumList, SynchEntity.prescription, totalCount, ref currentVal); SynchGeneric(provNumList, SynchEntity.provider, totalCount, ref currentVal); SynchGeneric(pharNumList, SynchEntity.pharmacy, totalCount, ref currentVal); //pat portal SynchGeneric(labPanelNumList, SynchEntity.labpanel, totalCount, ref currentVal); SynchGeneric(labResultNumList, SynchEntity.labresult, totalCount, ref currentVal); SynchGeneric(medicationNumList, SynchEntity.medication, totalCount, ref currentVal); SynchGeneric(medicationPatNumList, SynchEntity.medicationpat, totalCount, ref currentVal); SynchGeneric(allergyDefNumList, SynchEntity.allergydef, totalCount, ref currentVal); SynchGeneric(allergyNumList, SynchEntity.allergy, totalCount, ref currentVal); SynchGeneric(diseaseDefNumList, SynchEntity.diseasedef, totalCount, ref currentVal); SynchGeneric(diseaseNumList, SynchEntity.disease, totalCount, ref currentVal); SynchGeneric(icd9NumList, SynchEntity.icd9, totalCount, ref currentVal); SynchGeneric(statementNumList, SynchEntity.statement, totalCount, ref currentVal); SynchGeneric(documentNumList, SynchEntity.document, totalCount, ref currentVal); SynchGeneric(recallNumList, SynchEntity.recall, totalCount, ref currentVal); if (synchDelPat) { SynchGeneric(delPatNumList, SynchEntity.patientdel, totalCount, ref currentVal); } //DeleteObjects(dO,totalCount,ref currentVal);// this has to be done at this end because objects may have been created and deleted between synchs. If this function is place above then the such a deleted object will not be deleted from the server. SynchGeneric(deletedObjectNumList, SynchEntity.deletedobject, totalCount, ref currentVal); // this has to be done at this end because objects may have been created and deleted between synchs. If this function is place above then the such a deleted object will not be deleted from the server. if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables79Done, true)) { Prefs.UpdateBool(PrefName.MobileSynchNewTables79Done, true); } if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables112Done, true)) { Prefs.UpdateBool(PrefName.MobileSynchNewTables112Done, true); } if (!PrefC.GetBoolSilent(PrefName.MobileSynchNewTables121Done, true)) { Prefs.UpdateBool(PrefName.MobileSynchNewTables121Done, true); } Prefs.UpdateDateT(PrefName.MobileSyncDateTimeLastRun, timeSynchStarted); IsSynching = false; } catch (Exception e) { IsSynching = false; // this will ensure that the synch can start again. If this variable remains true due to an exception then a synch will never take place automatically. if (Application.OpenForms["FormProgress"] != null) // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system. { FormP.Invoke(new PassProgressDelegate(PassProgressToDialog), new object[] { 0, "?currentVal of ?maxVal records uploaded", totalCount, e.Message }); } } }
protected void Page_Load(object sender, EventArgs e) { try { CustomerNum = util.GetCustomerNum(Message); if (CustomerNum == 0) { return; } #region process dates int Year = 0; int Month = 0; int Day = 0; DateTime AppointmentDate = DateTime.MinValue; if (Request["year"] != null && Request["month"] != null && Request["day"] != null) { Int32.TryParse(Request["year"].ToString().Trim(), out Year); Int32.TryParse(Request["month"].ToString().Trim(), out Month); Int32.TryParse(Request["day"].ToString().Trim(), out Day); AppointmentDate = new DateTime(Year, Month, Day); } else { //dennis set cookies here this would be read by javascript on the client browser. HttpCookie DemoDateCookieY = new HttpCookie("DemoDateCookieY"); HttpCookie DemoDateCookieM = new HttpCookie("DemoDateCookieM"); HttpCookie DemoDateCookieD = new HttpCookie("DemoDateCookieD"); if (CustomerNum == util.GetDemoDentalOfficeID()) { AppointmentDate = util.GetDemoTodayDate(); //for demo only. The date is set to a preset date in webconfig. DemoDateCookieY.Value = AppointmentDate.Year + ""; DemoDateCookieM.Value = AppointmentDate.Month + ""; DemoDateCookieD.Value = AppointmentDate.Day + ""; } else { DemoDateCookieY.Value = ""; // these are explicitely set to empty, because the javascript on the browser is picking values from previously set cookies DemoDateCookieM.Value = ""; DemoDateCookieD.Value = ""; AppointmentDate = DateTime.Today; } Response.Cookies.Add(DemoDateCookieY); // if expiry is not specified the cookie lasts till the end of session Response.Cookies.Add(DemoDateCookieM); Response.Cookies.Add(DemoDateCookieD); } DayLabel.Text = AppointmentDate.ToString("ddd") + ", " + AppointmentDate.ToString("MMM") + AppointmentDate.ToString("dd"); DateTime PreviousDate = AppointmentDate.AddDays(-1); PreviousDateDay = PreviousDate.Day; PreviousDateMonth = PreviousDate.Month; PreviousDateYear = PreviousDate.Year; DateTime NextDate = AppointmentDate.AddDays(1); NextDateDay = NextDate.Day; NextDateMonth = NextDate.Month; NextDateYear = NextDate.Year; #endregion #region process providers long ProvNum = 0; if (Request["ProvNum"] == null) { if (Session["ProvNum"] != null) { Int64.TryParse(Session["ProvNum"].ToString(), out ProvNum); } } else { Int64.TryParse(Request["ProvNum"].ToString().Trim(), out ProvNum); Session["ProvNum"] = ProvNum.ToString(); } #endregion List <Appointmentm> appointmentmList; if (ProvNum == 0) { appointmentmList = Appointmentms.GetAppointmentms(CustomerNum, AppointmentDate, AppointmentDate); } else { appointmentmList = Appointmentms.GetAppointmentms(CustomerNum, ProvNum, AppointmentDate, AppointmentDate); } appointmentmList = appointmentmList.Where(a => a.AptStatus != ApptStatus.UnschedList && a.AptStatus != ApptStatus.Planned).ToList(); //exclude unscheduled and planned appointments. Repeater1.DataSource = appointmentmList; Repeater1.DataBind(); } catch (Exception ex) { LabelError.Text = Util.ErrorMessage; Logger.LogError(ex); } }
public AppointmentModel(Patientm patm) { appointmentmList = Appointmentms.GetAppointmentms(patm.CustomerNum, patm.PatNum); }