Exemplo n.º 1
0
 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");
     }
 }
        public string GetProviderColor(Appointmentm ap)
        {
            string HexColor = "#FFFFFF";

            try {
                Providerm pv;
                if (ap.AptStatus == ApptStatus.Complete)
                {
                    return("#808080");                    //gray
                }
                if (ap.IsHygiene)
                {
                    if (ap.ProvHyg == 0)                    //no hygenist
                    {
                        return(HexColor);
                    }
                    pv = Providerms.GetOne(CustomerNum, ap.ProvHyg);
                }
                else
                {
                    pv = Providerms.GetOne(CustomerNum, ap.ProvNum);
                }
                if (pv != null)
                {
                    HexColor = ColorTranslator.ToHtml(pv.ProvColor);
                }
                return(HexColor);
            }
            catch (Exception ex) {
                Logger.LogError("CustomerNum=" + CustomerNum + " ap.ProvNum=" + ap.ProvNum, ex);
                return(HexColor);
            }
        }
Exemplo n.º 3
0
 public void SynchProviders(String RegistrationKey, List <Providerm> providerList)
 {
     try {
         Logger.Information("In SynchProviders");
         customerNum = util.GetDentalOfficeID(RegistrationKey);
         if (customerNum == 0)
         {
             return;
         }
         Providerms.UpdateFromChangeList(providerList, customerNum);
     }
     catch (Exception ex) {
         Logger.LogError("IpAddress=" + HttpContext.Current.Request.UserHostAddress + " DentalOfficeID=" + customerNum, ex);
         throw new Exception("Exception in SynchProviders");
     }
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         CustomerNum = util.GetCustomerNum(Message);
         if (CustomerNum == 0)
         {
             return;
         }
         List <Providerm> providermList = Providerms.GetProviderms(CustomerNum);
         //the elements inthe drop down are padded left and right so that they are centered.
         for (int i = 0; i < providermList.Count; i++)
         {
             string abbr      = providermList[i].Abbr;
             int    PadLength = 14 - abbr.Length / 2;
             providermList[i].Abbr = abbr.PadLeft(PadLength, ' ').PadRight(PadLength, ' ').Replace(" ", "&nbsp;");
         }
         Repeater1.DataSource = providermList;
         Repeater1.DataBind();
     }
     catch (Exception ex) {
         LabelError.Text = Util.ErrorMessage;
         Logger.LogError(ex);
     }
 }
Exemplo n.º 5
0
        ///<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
        }
Exemplo n.º 6
0
        ///<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 });
                }
            }
        }