public void SaveAccount(Account doctor, string connectionString, string sessionTicket, out TransactionalInformation transaction) { var request = HttpContext.Current.Request; var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(HttpContext.Current.Request); transaction = new TransactionalInformation(); var securityTicket = VerifySessionToken(sessionTicket); var data = cls_Get_Account_Information_with_PracticeID.Invoke(connectionString, securityTicket).Result; IEnumerable <IEnumerable <IElasticMapper> > elastic_backup = null; try { #region PARAMETER P_DO_SD_1026 parameter = new P_DO_SD_1026(); var passwordForSave = ""; if (!String.IsNullOrEmpty(doctor.inPassword)) { passwordForSave = Util.CalculateMD5Hash(doctor.inPassword); } parameter.Account_PasswordForEmail = doctor.inPassword; parameter.Account_Holder = doctor.account_holder; parameter.Account_Password = passwordForSave; parameter.Bank = doctor.bank_name; parameter.BIC = doctor.bic; parameter.Email = doctor.email; parameter.IBAN = doctor.iban; parameter.First_Name = doctor.first_name; parameter.Last_Name = doctor.last_name; parameter.LANR = doctor.lanr; parameter.Phone = doctor.phone; parameter.PracticeID = new Guid(doctor.practice_id); parameter.Salutation = doctor.salutation; parameter.Title = doctor.title; parameter.Login_Email = doctor.login_email; parameter.From_Practice_Bank = doctor.is_bank_inherited; parameter.DoctorID = new Guid(doctor.id); parameter.Account_Deactivated = false; #endregion Account previous_state = null; Thread detailsThread = new Thread(() => GetDoctorAccountPreviousDetails(out previous_state, Guid.Parse(doctor.id), connectionString, sessionTicket, request)); detailsThread.Start(); var doctor_id = Guid.Empty; Guid.TryParse(doctor.id, out doctor_id); #region UPDATE ELASTIC ON BASE CHANGE if (doctor_id != Guid.Empty) { var doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(connectionString, new P_DO_GDDfDID_0823() { DoctorID = doctor_id }, securityTicket).Result.FirstOrDefault(); if (doctor_details != null) { if (doctor_details.first_name != doctor.first_name || doctor_details.last_name != doctor.last_name || doctor_details.lanr != doctor.lanr || doctor.title != doctor_details.title) { elastic_backup = Elastic_Rollback.GetBackup(securityTicket.TenantID.ToString(), doctor.id, "doctor"); var values = new string[] { GenericUtils.GetDoctorName(doctor), doctor.lanr }; var elastic_data = Elastic_Rollback.GetUpdatedData(securityTicket.TenantID.ToString(), doctor.id, "doctor", values); Elastic_Rollback.InsertDataIntoElastic(elastic_data, securityTicket.TenantID.ToString()); } } } #endregion var id = cls_Save_Doctor.Invoke(connectionString, parameter, securityTicket).Result; Logger.LogDocAppInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, securityTicket, doctor, previous_state), data.PracticeName); } catch (Exception ex) { Logger.LogDocAppInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, securityTicket, ex), data.PracticeName); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; if (elastic_backup != null) { Elastic_Rollback.InsertDataIntoElastic(elastic_backup, securityTicket.TenantID.ToString()); } } }
public void CreatePractice(Practice practice, string connectionString, string sessionTicket, out TransactionalInformation transaction) { var request = HttpContext.Current.Request; var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(request); transaction = new TransactionalInformation(); var securityTicket = VerifySessionToken(sessionTicket); var userData = cls_Get_Account_Information_with_PracticeID.Invoke(connectionString, securityTicket).Result; IEnumerable <IEnumerable <IElasticMapper> > elastic_backup = null; try { #region PARAMETER P_DO_SP_1547 parameter = new P_DO_SP_1547(); if (!String.IsNullOrEmpty(practice.contact_person_name)) { string PersonFirstName = ""; string PersonLastName = ""; string personInfo = practice.contact_person_name; int i = personInfo.IndexOf(' '); if (i > 1) { PersonFirstName = personInfo.Substring(0, i); PersonLastName = personInfo.Substring(i + 1); } else { PersonFirstName = practice.contact_person_name; PersonLastName = " "; } parameter.Contact_PersonFirstName = PersonFirstName; parameter.Contact_PersonLastName = PersonLastName; } var passwordForSave = ""; if (!String.IsNullOrEmpty(practice.inPassword)) { passwordForSave = Util.CalculateMD5Hash(practice.inPassword); } parameter.PracticeID = new Guid(practice.id); parameter.Account_PasswordForEmail = practice.inPassword; parameter.Practice_Name = practice.name; parameter.BSNR = practice.bsnr; parameter.Street = practice.address; parameter.No = practice.No; parameter.Zip = practice.ZIP.ToString(); parameter.City = practice.town; parameter.Main_Email = practice.email == null ? "" : practice.email; parameter.Main_Phone = practice.phone; parameter.Fax = practice.fax == null ? "" : practice.fax; parameter.Email = practice.contact_email == null ? "" : practice.contact_email; parameter.Phone = practice.phone == null ? "" : practice.phone; parameter.Account_Holder = practice.account_holder == null ? "" : practice.account_holder; parameter.BIC = practice.bic == null ? "" : practice.bic; parameter.IBAN = practice.iban == null ? "" : practice.iban; parameter.Bank = practice.bank == null ? "" : practice.bank; parameter.Login_Email = practice.login_email; parameter.Account_Password = passwordForSave; parameter.Surgery_Practice = practice.IsSurgeryPractice; parameter.Orders_Drugs = practice.IsOrderDrugs; parameter.Default_Shipping_Date_Offset = practice.default_shipping_date_offset.ToString(); parameter.Only_Label_Required = practice.IsOnlyLabelRequired; parameter.Waive_Service_Fee = practice.isWaiveServiceFee; parameter.ShouldDownloadReportUponSubmission = practice.ShouldDownloadReportUponSubmission; parameter.PressEnterToSearch = practice.PressEnterToSearch; parameter.PracticeHasOctDevice = practice.PracticeHasOctDevice; parameter.DefaultPharmacy = String.IsNullOrEmpty(practice.DefaultPharmacy) ? Guid.Empty.ToString() : practice.DefaultPharmacy; parameter.IsQuickOrderActive = practice.IsQuickOrderActive; parameter.DeliveryDateFrom = practice.DeliveryDateFrom; parameter.DeliveryDateTo = practice.DeliveryDateTo; parameter.UseGracePeriod = practice.UseGracePeriod; #endregion Practice previous_state = null; Thread detailsThread = new Thread(() => GetPracticeAccountPreviousDetails(out previous_state, Guid.Parse(practice.id), connectionString, sessionTicket, request)); #region UPDATE ELASTIC ON BASE CHANGE Guid practice_id = Guid.Empty; Guid.TryParse(practice.id, out practice_id); if (practice_id != Guid.Empty) { var practice_details = cls_Get_Practice_Details_for_PracticeID.Invoke(connectionString, new P_DO_GPDfPID_1432() { PracticeID = practice_id }, securityTicket).Result.FirstOrDefault(); if (practice_details != null) { if (practice_details.practice_BSNR != practice.bsnr || practice_details.practice_name != practice.name) { elastic_backup = Elastic_Rollback.GetBackup(securityTicket.TenantID.ToString(), practice.id, "practice"); var values = new string[] { practice.name, practice.bsnr }; var elastic_data = Elastic_Rollback.GetUpdatedData(securityTicket.TenantID.ToString(), practice.id.ToString(), "practice", values); Elastic_Rollback.InsertDataIntoElastic(elastic_data, securityTicket.TenantID.ToString()); } } } #endregion var data = cls_Save_Practice.Invoke(connectionString, parameter, securityTicket).Result; Logger.LogDocAppInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, securityTicket, practice, previous_state), userData.PracticeName); } catch (Exception ex) { Logger.LogDocAppInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, securityTicket, ex), userData.PracticeName); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; if (elastic_backup != null) { Elastic_Rollback.InsertDataIntoElastic(elastic_backup, securityTicket.TenantID.ToString()); } } }
/// <summary> /// Save new medication or edit existing one /// </summary> /// <param name="medication"></param> /// <param name="connectionString"></param> /// <param name="sessionTicket"></param> /// <param name="transaction"></param> public void SaveMedication(MedicationModel medication, string connectionString, string sessionTicket, out TransactionalInformation transaction) { var request = HttpContext.Current.Request; var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(request); transaction = new TransactionalInformation(); var userSecurityTicket = VerifySessionToken(sessionTicket); IEnumerable <IEnumerable <IElasticMapper> > elastic_backup = null; try { #region PARAMETER P_MC_SM_1132 medication_parameter = new P_MC_SM_1132(); medication_parameter.MedicationID = medication.MedicationID; medication_parameter.Medication = medication.Medication; medication_parameter.ProprietaryDrug = medication.ProprietaryDrug; medication_parameter.PZNScheme = medication.PZNScheme; medication_parameter.Dosage = medication.Dosage; medication_parameter.Unit = medication.Unit; #endregion MedicationModel previous_state = null; if (medication.MedicationID != Guid.Empty) { var detailsThread = new Thread(() => GetMedicationPreviousDetails(out previous_state, medication.MedicationID, connectionString, sessionTicket, request)); detailsThread.Start(); var medication_details = cls_Get_Medication_for_MedicationID.Invoke(connectionString, new P_MC_GMfMID_1433() { MedicationID = medication.MedicationID }, userSecurityTicket).Result; if (medication_details != null && medication_details.Medication != medication.Medication) { elastic_backup = Elastic_Rollback.GetBackup(userSecurityTicket.TenantID.ToString(), medication.HecDrugID.ToString(), "drug"); var values = new string[] { medication.Medication }; var elastic_data = Elastic_Rollback.GetUpdatedData(userSecurityTicket.TenantID.ToString(), medication.HecDrugID.ToString(), "drug", values); Elastic_Rollback.InsertDataIntoElastic(elastic_data, userSecurityTicket.TenantID.ToString()); } } cls_Save_Medication.Invoke(connectionString, medication_parameter, userSecurityTicket); Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, medication, previous_state)); } catch (Exception ex) { Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex)); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; if (elastic_backup != null) { Elastic_Rollback.InsertDataIntoElastic(elastic_backup, userSecurityTicket.TenantID.ToString()); } } }