protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CA_SCS_1333 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here var adress = new ORM_CMN_UniversalContactDetail(); var company2Adress = new ORM_CMN_COM_CompanyInfo_Address(); if (Parameter.CMN_AddressID != Guid.Empty) { var result = adress.Load(Connection, Transaction, Parameter.CMN_AddressID); if (result.Status != FR_Status.Success || adress.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } company2Adress.Address_UCD_RefID = Parameter.CMN_AddressID; } if (Parameter.CMN_COM_CompanyInfo_AddressID != Guid.Empty) { var result = company2Adress.Load(Connection, Transaction, Parameter.CMN_COM_CompanyInfo_AddressID); if (result.Status != FR_Status.Success || company2Adress.CMN_COM_CompanyInfo_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (Parameter.IsDeleted == true) { adress.IsDeleted = true; company2Adress.IsDeleted = true; company2Adress.Save(Connection, Transaction); return(new FR_Guid(adress.Save(Connection, Transaction), adress.CMN_UniversalContactDetailID)); } //Creation specific parameters (Tenant, Account ... ) if (Parameter.CMN_AddressID == Guid.Empty) { company2Adress.Address_UCD_RefID = adress.CMN_UniversalContactDetailID; company2Adress.Tenant_RefID = securityTicket.TenantID; adress.Tenant_RefID = securityTicket.TenantID; } adress.Street_Name = Parameter.Street_Name; adress.Street_Number = Parameter.Street_Number; adress.Town = Parameter.City_Name; adress.ZIP = Parameter.City_PostalCode; adress.Country_Name = Parameter.Country_Name; adress.Region_Code = Parameter.Country_ISOCode; company2Adress.IsDefault = Parameter.IsDefault; company2Adress.Address_Description = Parameter.AddressName; company2Adress.CompanyInfo_RefID = Parameter.CompanyInfo_RefID; company2Adress.IsBilling = Parameter.IsAddress_Billing; company2Adress.IsShipping = Parameter.IsAddress_Shipping; company2Adress.Save(Connection, Transaction); return(new FR_Guid(adress.Save(Connection, Transaction), adress.CMN_UniversalContactDetailID)); #endregion UserCode }
public static void Save_practices_to_DB(Practice_Model_from_xlsx Parameter, string connectionString, SessionSecurityTicket securityTicket) { DbConnection Connection = null; DbTransaction Transaction = null; bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } try { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); var returnValue = new FR_Guid(); Guid companyInfoID = Guid.NewGuid(); Guid BusinessParticipantID = Guid.NewGuid(); Guid PracticeAddressID = Guid.NewGuid(); Guid practice_id = Guid.NewGuid(); if (!String.IsNullOrEmpty(Parameter.LoginEmail)) //uncomment this if you've created account // if(false) { string[] stringUser = Parameter.LoginEmail.Split('@'); string usernameStr = stringUser[0]; try { var practiceAccountInfo = ORM_USR_Account.Query.Search(Connection, Transaction, new ORM_USR_Account.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, AccountSignInEmailAddress = Parameter.LoginEmail, }).Single(); var accountGroupQuery = new ORM_USR_Account_FunctionLevelRights_Group.Query(); accountGroupQuery.Tenant_RefID = securityTicket.TenantID; accountGroupQuery.IsDeleted = false; accountGroupQuery.GlobalPropertyMatchingID = "mm.docconect.doc.app.group"; var accountGroup = ORM_USR_Account_FunctionLevelRights_Group.Query.Search(Connection, Transaction, accountGroupQuery).SingleOrDefault(); if (accountGroup == null) { accountGroup = new ORM_USR_Account_FunctionLevelRights_Group(); accountGroup.Tenant_RefID = securityTicket.TenantID; accountGroup.Label = "mm.docconect.doc.app.group"; accountGroup.GlobalPropertyMatchingID = "mm.docconect.doc.app.group"; accountGroup.Creation_Timestamp = DateTime.Now; accountGroup.USR_Account_FunctionLevelRights_GroupID = Guid.NewGuid(); accountGroup.Save(Connection, Transaction); } var functionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); functionLevelRightQ.Tenant_RefID = securityTicket.TenantID; functionLevelRightQ.IsDeleted = false; functionLevelRightQ.GlobalPropertyMatchingID = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; var existingunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, functionLevelRightQ).SingleOrDefault(); Guid tempFunctionLevelRightID = Guid.Empty; if (existingunctionLevelRight == null) { ORM_USR_Account_FunctionLevelRight functionLevelRight = new ORM_USR_Account_FunctionLevelRight(); functionLevelRight.USR_Account_FunctionLevelRightID = Guid.NewGuid(); functionLevelRight.FunctionLevelRights_Group_RefID = accountGroup.USR_Account_FunctionLevelRights_GroupID; functionLevelRight.Tenant_RefID = securityTicket.TenantID; functionLevelRight.Creation_Timestamp = DateTime.Now; functionLevelRight.RightName = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; functionLevelRight.GlobalPropertyMatchingID = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; functionLevelRight.Save(Connection, Transaction); tempFunctionLevelRightID = functionLevelRight.USR_Account_FunctionLevelRightID; } else { tempFunctionLevelRightID = existingunctionLevelRight.USR_Account_FunctionLevelRightID; } var accountToFunctionLevelRight = new ORM_USR_Account_2_FunctionLevelRight(); accountToFunctionLevelRight.Tenant_RefID = securityTicket.TenantID; accountToFunctionLevelRight.Creation_Timestamp = DateTime.Now; accountToFunctionLevelRight.AssignmentID = Guid.NewGuid(); accountToFunctionLevelRight.Account_RefID = practiceAccountInfo.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = tempFunctionLevelRightID; // USR_Account_FunctionLevelRightID accountToFunctionLevelRight.Save(Connection, Transaction); var businessParticipantQ = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQ.IsDeleted = false; businessParticipantQ.Tenant_RefID = securityTicket.TenantID; businessParticipantQ.CMN_BPT_BusinessParticipantID = practiceAccountInfo.BusinessParticipant_RefID; BusinessParticipantID = practiceAccountInfo.BusinessParticipant_RefID; var practiceinfoinBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQ).Single(); practiceinfoinBusinessParticipant.DisplayName = Parameter.PracticeName; practiceinfoinBusinessParticipant.IsCompany = true; practiceinfoinBusinessParticipant.Modification_Timestamp = DateTime.Now; practiceinfoinBusinessParticipant.Save(Connection, Transaction); companyInfoID = practiceinfoinBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; var companyInfo = new ORM_CMN_COM_CompanyInfo.Query(); companyInfo.IsDeleted = false; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.CMN_COM_CompanyInfoID = companyInfoID; var companyInfoPractice = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfo).Single(); companyInfoPractice.CompanyInfo_EstablishmentNumber = Parameter.BSNR; companyInfoPractice.Save(Connection, Transaction); var companyInfoAddressPractice = new ORM_CMN_COM_CompanyInfo_Address(); companyInfoAddressPractice.CompanyInfo_RefID = companyInfoID; companyInfoAddressPractice.IsDefault = true; companyInfoAddressPractice.IsShipping = true; companyInfoAddressPractice.IsBilling = true; companyInfoAddressPractice.Tenant_RefID = securityTicket.TenantID; companyInfoAddressPractice.Address_UCD_RefID = Guid.NewGuid(); companyInfoAddressPractice.Address_Description = "Standard address for billing, shipping"; companyInfoAddressPractice.Save(Connection, Transaction); PracticeAddressID = companyInfoAddressPractice.Address_UCD_RefID; var universlContactPractice = new ORM_CMN_UniversalContactDetail(); universlContactPractice.IsDeleted = false; universlContactPractice.Tenant_RefID = securityTicket.TenantID; universlContactPractice.CMN_UniversalContactDetailID = PracticeAddressID; universlContactPractice.CompanyName_Line1 = Parameter.PracticeName; universlContactPractice.IsCompany = true; universlContactPractice.Street_Name = Parameter.Street; universlContactPractice.Street_Number = Parameter.No; universlContactPractice.ZIP = Parameter.Zip; universlContactPractice.Town = Parameter.City; universlContactPractice.Contact_Email = Parameter.MainEmail; universlContactPractice.Contact_Telephone = Parameter.MainPhone; universlContactPractice.Contact_Fax = Parameter.Fax; universlContactPractice.Creation_Timestamp = DateTime.Now; universlContactPractice.Modification_Timestamp = DateTime.Now; universlContactPractice.Save(Connection, Transaction); } catch (Exception ex) { throw new Exception("Exception occured durng data retrieval in method cls_Save_Practice", ex); //Log the error (uncomment dex variable name and add a line here to write a log. } } // else{ var companyInfoAddress2 = new ORM_CMN_COM_CompanyInfo_Address(); companyInfoAddress2.IsDeleted = false; companyInfoAddress2.Tenant_RefID = securityTicket.TenantID; companyInfoAddress2.CompanyInfo_RefID = companyInfoID; companyInfoAddress2.IsDefault = true; companyInfoAddress2.IsContact = true; companyInfoAddress2.Address_UCD_RefID = Guid.NewGuid(); companyInfoAddress2.Address_Description = "Standard contact person data"; companyInfoAddress2.Creation_Timestamp = DateTime.Now; companyInfoAddress2.Save(Connection, Transaction); string personInfo = Parameter.ContactPerson; string PersonFirstName = ""; string PersonLastName = ""; int i = personInfo.IndexOf(' '); if (i > 1) { PersonFirstName = personInfo.Substring(0, i); PersonLastName = personInfo.Substring(i + 1); } else { PersonFirstName = Parameter.ContactPerson; PersonLastName = " "; } var universlContactPractice2 = new ORM_CMN_UniversalContactDetail(); universlContactPractice2.CMN_UniversalContactDetailID = companyInfoAddress2.Address_UCD_RefID; universlContactPractice2.IsDeleted = false; universlContactPractice2.Tenant_RefID = securityTicket.TenantID; universlContactPractice2.IsCompany = false; universlContactPractice2.First_Name = PersonFirstName; universlContactPractice2.Last_Name = PersonLastName; universlContactPractice2.Contact_Email = Parameter.Email; universlContactPractice2.Contact_Telephone = Parameter.Phone; universlContactPractice2.Creation_Timestamp = DateTime.Now; universlContactPractice2.Modification_Timestamp = DateTime.Now; universlContactPractice2.Save(Connection, Transaction); var business2bankAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); business2bankAccount.IsDeleted = false; business2bankAccount.Tenant_RefID = securityTicket.TenantID; business2bankAccount.CMN_BPT_BusinessParticipant_RefID = BusinessParticipantID; business2bankAccount.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); var bankAccountPractice = new ORM_ACC_BNK_BankAccount(); bankAccountPractice.IsDeleted = false; bankAccountPractice.Tenant_RefID = securityTicket.TenantID; bankAccountPractice.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountPractice.OwnerText = Parameter.AccountHolder; bankAccountPractice.IBAN = Parameter.IBAN; bankAccountPractice.Bank_RefID = Guid.NewGuid(); bankAccountPractice.Creation_Timestamp = DateTime.Now; bankAccountPractice.Save(Connection, Transaction); var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountPractice.Bank_RefID; bank.BICCode = Parameter.Bic; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); var customer = new ORM_CMN_BPT_CTM_Customer(); customer.IsDeleted = false; customer.Tenant_RefID = securityTicket.TenantID; customer.Ext_BusinessParticipant_RefID = BusinessParticipantID; customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Creation_Timestamp = DateTime.Now; customer.Save(Connection, Transaction); var organizationalUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit(); organizationalUnit.IsDeleted = false; organizationalUnit.Tenant_RefID = securityTicket.TenantID; organizationalUnit.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; organizationalUnit.IsMedicalPractice = true; organizationalUnit.IfMedicalPractise_HEC_MedicalPractice_RefID = Guid.NewGuid(); organizationalUnit.Creation_Timestamp = DateTime.Now; organizationalUnit.Modification_Timestamp = DateTime.Now; organizationalUnit.Save(Connection, Transaction); var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.IsDeleted = false; medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.HEC_MedicalPractiseID = organizationalUnit.IfMedicalPractise_HEC_MedicalPractice_RefID; medicalPractice.Creation_Timestamp = DateTime.Now; medicalPractice.Modification_Timestamp = DateTime.Now; medicalPractice.Save(Connection, Transaction); practice_id = medicalPractice.HEC_MedicalPractiseID; var medicalPRactice2Universal = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal.IsDeleted = false; medicalPRactice2Universal.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal.Value_Boolean = Parameter.IsSurgeryPractice; medicalPRactice2Universal.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal.Save(Connection, Transaction); var practiceUniversal = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal.IsDeleted = false; practiceUniversal.Tenant_RefID = securityTicket.TenantID; practiceUniversal.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal.PropertyName = "Surgery Practice"; practiceUniversal.IsValue_Boolean = true; practiceUniversal.Creation_Timestamp = DateTime.Now; practiceUniversal.Modification_Timestamp = DateTime.Now; practiceUniversal.Save(Connection, Transaction); var medicalPRactice2Universal2 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal2.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal2.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal2.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal2.Value_Boolean = Parameter.IsOrderDrugs; medicalPRactice2Universal2.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal2.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal2.Save(Connection, Transaction); var practiceUniversal2 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal2.IsDeleted = false; practiceUniversal2.Tenant_RefID = securityTicket.TenantID; practiceUniversal2.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal2.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal2.PropertyName = "Order Drugs"; practiceUniversal2.IsValue_Boolean = true; practiceUniversal2.Creation_Timestamp = DateTime.Now; practiceUniversal2.Modification_Timestamp = DateTime.Now; practiceUniversal2.Save(Connection, Transaction); // default shipping date offset var medicalPRactice2Universal3 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal3.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal3.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal3.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal3.Value_Number = double.Parse(Parameter.DefaultShippingDateOffset); medicalPRactice2Universal3.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal3.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal3.Save(Connection, Transaction); var practiceUniversal3 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal3.IsDeleted = false; practiceUniversal3.Tenant_RefID = securityTicket.TenantID; practiceUniversal3.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal3.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal3.PropertyName = "Default Shipping Date Offset"; practiceUniversal3.IsValue_Number = true; practiceUniversal3.Creation_Timestamp = DateTime.Now; practiceUniversal3.Modification_Timestamp = DateTime.Now; practiceUniversal3.Save(Connection, Transaction); var medicalPRactice2Universal4 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal4.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal4.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal4.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal4.Value_Boolean = Parameter.IsOnlyLabelRequired; medicalPRactice2Universal4.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal4.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal4.Save(Connection, Transaction); var practiceUniversal4 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal4.IsDeleted = false; practiceUniversal4.Tenant_RefID = securityTicket.TenantID; practiceUniversal4.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal4.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal4.PropertyName = "Only Label Required"; practiceUniversal4.IsValue_Boolean = true; practiceUniversal4.Creation_Timestamp = DateTime.Now; practiceUniversal4.Modification_Timestamp = DateTime.Now; practiceUniversal4.Save(Connection, Transaction); var medicalPRactice2Universal5 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal5.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal5.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal5.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal5.Value_Boolean = Parameter.isWaiveServiceFee; medicalPRactice2Universal5.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal5.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal5.Save(Connection, Transaction); var practiceUniversal5 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal5.IsDeleted = false; practiceUniversal5.Tenant_RefID = securityTicket.TenantID; practiceUniversal5.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal5.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal5.PropertyName = "Waive Service Fee"; practiceUniversal5.IsValue_Boolean = true; practiceUniversal5.Creation_Timestamp = DateTime.Now; practiceUniversal5.Modification_Timestamp = DateTime.Now; practiceUniversal5.Save(Connection, Transaction); // } Practice_Doctors_Model DPModel = new Practice_Doctors_Model(); DPModel.account_status = "aktiv"; DPModel.id = practice_id.ToString(); DPModel.name = Parameter.PracticeName; DPModel.name_untouched = Parameter.PracticeName; DPModel.salutation = ""; DPModel.type = "Practice"; DPModel.autocomplete_name = Parameter.PracticeName; DPModel.address = Parameter.Street + " " + Parameter.No; DPModel.zip = Parameter.Zip; DPModel.city = Parameter.City; DPModel.bank_untouched = Parameter.Bank != null ? Parameter.Bank : ""; DPModel.bank = Parameter.Bank != null ? Parameter.Bank : ""; if (Parameter.Email != null) { DPModel.email = Parameter.MainEmail; } DPModel.phone = Parameter.MainPhone; if (Parameter.IBAN != null) { DPModel.iban = Parameter.IBAN; } if (Parameter.Bic != null) { DPModel.bic = Parameter.Bic; } DPModel.bsnr_lanr = Parameter.BSNR; DPModel.aditional_info = ""; DPModel.contract = 0; DPModel.tenantid = securityTicket.TenantID.ToString(); DPModel.role = Parameter.IsSurgeryPractice ? "op" : "ac"; List <Practice_Doctors_Model> DPModelL = new List <Practice_Doctors_Model>(); DPModelL.Add(DPModel); Add_Practice_Doctors_to_Elastic.Import_Practice_Data_to_ElasticDB(DPModelL, securityTicket.TenantID.ToString()); //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw ex; } }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OP_SP_1602 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var languages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; P_L3MP_SPBI_1602 basePracticeParam = new P_L3MP_SPBI_1602(); basePracticeParam.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; basePracticeParam.Contact_EmergencyPhoneNumber = Parameter.PhoneNumber; basePracticeParam.Contact_Website_URL = Parameter.HomepageURL; basePracticeParam.PracticeEmail = Parameter.ContactEmail; basePracticeParam.PracticeName = Parameter.DisplyName; basePracticeParam.Region_Name = Parameter.AddressRegion; basePracticeParam.Street_Name = Parameter.AddressStreetName; basePracticeParam.Street_Number = Parameter.AddressStreetNumber; basePracticeParam.Town = Parameter.AddressCity; basePracticeParam.ZIP = Parameter.AddressZipCode; var practiceID = cls_Save_Practice_BaseInfo.Invoke(Connection, Transaction, basePracticeParam, securityTicket).Result; var practicesQuery = new ORM_HEC_MedicalPractis.Query(); practicesQuery.HEC_MedicalPractiseID = practiceID; var practices = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practicesQuery).First(); var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = practices.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).First(); ORM_CMN_BPT_BusinessParticipant bpContctPerson; if (practices.ContactPerson_RefID != Guid.Empty) { var bpContctPersonQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bpContctPersonQuery.CMN_BPT_BusinessParticipantID = practices.ContactPerson_RefID; bpContctPerson = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bpContctPersonQuery).First(); } else { bpContctPerson = new ORM_CMN_BPT_BusinessParticipant(); bpContctPerson.Tenant_RefID = securityTicket.TenantID; bpContctPerson.IsNaturalPerson = true; } bpContctPerson.DisplayName = Parameter.ContactPerson_Name; bpContctPerson.Save(Connection, Transaction); practices.ContactPerson_RefID = bpContctPerson.CMN_BPT_BusinessParticipantID; ORM_CMN_CAL_WeeklyOfficeHours_Template officeHours; ORM_CMN_CAL_WeeklyOfficeHours_Template consultingHours; if (practices.WeeklyOfficeHours_Template_RefID != Guid.Empty && practices.WeeklySurgeryHours_Template_RefID != Guid.Empty) { var officeHoursQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Template.Query(); officeHoursQuery.CMN_CAL_WeeklyOfficeHours_TemplateID = practices.WeeklyOfficeHours_Template_RefID; officeHours = ORM_CMN_CAL_WeeklyOfficeHours_Template.Query.Search(Connection, Transaction, officeHoursQuery).First(); officeHoursQuery.CMN_CAL_WeeklyOfficeHours_TemplateID = practices.WeeklySurgeryHours_Template_RefID; consultingHours = ORM_CMN_CAL_WeeklyOfficeHours_Template.Query.Search(Connection, Transaction, officeHoursQuery).First(); } else { officeHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); officeHours.CMN_CAL_WeeklyOfficeHours_TemplateID = Guid.NewGuid(); consultingHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); consultingHours.CMN_CAL_WeeklyOfficeHours_TemplateID = Guid.NewGuid(); practices.WeeklyOfficeHours_Template_RefID = officeHours.CMN_CAL_WeeklyOfficeHours_TemplateID; practices.WeeklySurgeryHours_Template_RefID = consultingHours.CMN_CAL_WeeklyOfficeHours_TemplateID; } consultingHours.Tenant_RefID = securityTicket.TenantID; officeHours.Tenant_RefID = securityTicket.TenantID; consultingHours.FormattedOfficeHours = Parameter.Consultation_FormattedOfficeHours; officeHours.FormattedOfficeHours = Parameter.Working_FormattedOfficeHours; consultingHours.Save(Connection, Transaction); officeHours.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo_Type companyType; var companyTypeQuery = new ORM_CMN_COM_CompanyInfo_Type.Query(); companyTypeQuery.IsDeleted = false; companyTypeQuery.CMN_COM_CompanyInfo_TypeID = Parameter.PracticeType_RefID; companyType = ORM_CMN_COM_CompanyInfo_Type.Query.Search(Connection, Transaction, companyTypeQuery).FirstOrDefault(); if (companyType == null) { companyType = new ORM_CMN_COM_CompanyInfo_Type(); companyType.CMN_COM_CompanyInfo_TypeID = Parameter.PracticeType_RefID; companyType.CompanyType_Name = new Dict(); companyType.CompanyType_Name.DictionaryID = Guid.NewGuid(); if (languages != null) { foreach (var item in languages) { companyType.CompanyType_Name.AddEntry(item.CMN_LanguageID, STLD_PracticeType.typesItems.First(t => t.Value == Parameter.PracticeType_RefID).Text); } } } companyInfo.CompanyType_RefID = Parameter.PracticeType_RefID; ORM_HEC_PublicHealthcare_PhysitianAssociation pHealthcare; var pHealthcareQuery = new ORM_HEC_PublicHealthcare_PhysitianAssociation.Query(); pHealthcareQuery.HEC_PublicHealthcare_PhysitianAssociationID = Parameter.HealthAssociation_RefID; pHealthcare = ORM_HEC_PublicHealthcare_PhysitianAssociation.Query.Search(Connection, Transaction, pHealthcareQuery).FirstOrDefault(); if (pHealthcare == null) { pHealthcare = new ORM_HEC_PublicHealthcare_PhysitianAssociation(); pHealthcare.HEC_PublicHealthcare_PhysitianAssociationID = Parameter.HealthAssociation_RefID; pHealthcare.HealthAssociation_Name = STLD_MedicalAssociation.associationItems.First(t => t.Value == Parameter.HealthAssociation_RefID).Text; pHealthcare.Save(Connection, Transaction); } practices.AssociatedWith_PhysitianAssociation_RefID = Parameter.HealthAssociation_RefID; ORM_CMN_BPT_CTM_Customer customer; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count == 0) { customer = new ORM_CMN_BPT_CTM_Customer(); customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } else { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); } var affinityStatusQuery = new ORM_CMN_BPT_CTM_AffinityStatus.Query(); affinityStatusQuery.CMN_BPT_CTM_AffinityStatusID = Parameter.AffinityStatus_RefID; var affinityStatus = ORM_CMN_BPT_CTM_AffinityStatus.Query.Search(Connection, Transaction, affinityStatusQuery).FirstOrDefault(); if (affinityStatus == null) { affinityStatus = new ORM_CMN_BPT_CTM_AffinityStatus(); affinityStatus.CMN_BPT_CTM_AffinityStatusID = Parameter.AffinityStatus_RefID; affinityStatus.AffinityStatus_Name = new Dict(); affinityStatus.AffinityStatus_Name.DictionaryID = Guid.NewGuid(); if (languages != null) { foreach (var item in languages) { affinityStatus.AffinityStatus_Name.AddEntry(item.CMN_LanguageID, STLD_AffinityStatus.affinityItems.First(t => t.Value == Parameter.AffinityStatus_RefID).Text); } } affinityStatus.Save(Connection, Transaction); } customer.CustomerAffinityStatus_RefID = Parameter.AffinityStatus_RefID; customer.Tenant_RefID = securityTicket.TenantID; customer.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo_Address compAddress; ORM_CMN_UniversalContactDetail address; var compAddressQuery = new ORM_CMN_COM_CompanyInfo_Address.Query(); compAddressQuery.Tenant_RefID = securityTicket.TenantID; compAddressQuery.CompanyInfo_RefID = practices.Ext_CompanyInfo_RefID; var compAddressRes = ORM_CMN_COM_CompanyInfo_Address.Query.Search(Connection, Transaction, compAddressQuery); if (compAddressRes.Count > 0) { compAddress = compAddressRes.First(); var addressQuery = new ORM_CMN_UniversalContactDetail.Query(); addressQuery.CMN_UniversalContactDetailID = compAddress.Address_UCD_RefID; address = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, addressQuery).First(); } else { compAddress = new ORM_CMN_COM_CompanyInfo_Address(); compAddress.CMN_COM_CompanyInfo_AddressID = Guid.NewGuid(); compAddress.IsShipping = true; compAddress.CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; address = new ORM_CMN_UniversalContactDetail(); address.CMN_UniversalContactDetailID = Guid.NewGuid(); compAddress.Address_UCD_RefID = address.CMN_UniversalContactDetailID; } address.Town = Parameter.ShippingAddressCity; address.Street_Number = Parameter.ShippingAddressStreetNumber; address.Street_Name = Parameter.ShippingAddressStreetName; address.ZIP = Parameter.ShippingAddressZipCode; address.Region_Name = Parameter.ShippingAddressRegion; address.Tenant_RefID = securityTicket.TenantID; address.Save(Connection, Transaction); compAddress.Tenant_RefID = securityTicket.TenantID; compAddress.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant contactPBP; if (practices.ContactPerson_RefID != Guid.Empty) { var contactPBPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); contactPBPQuery.CMN_BPT_BusinessParticipantID = practices.ContactPerson_RefID; contactPBP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, contactPBPQuery).First(); } else { contactPBP = new ORM_CMN_BPT_BusinessParticipant(); contactPBP.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); contactPBP.IsCompany = true; practices.ContactPerson_RefID = contactPBP.CMN_BPT_BusinessParticipantID; } contactPBP.DisplayName = Parameter.ContactPerson_Name; contactPBP.Tenant_RefID = securityTicket.TenantID; contactPBP.Save(Connection, Transaction); companyInfo.Save(Connection, Transaction); practices.Save(Connection, Transaction); returnValue.Result = practices.HEC_MedicalPractiseID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MP_DPBID_1026 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L3MP_GPfID_1222 param = new P_L3MP_GPfID_1222(); param.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; var practice = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, param, securityTicket).Result; if (practice != null) { ORM_CMN_UniversalContactDetail contactDetails = new ORM_CMN_UniversalContactDetail(); if (practice.BaseInfo.CMN_UniversalContactDetailID != Guid.Empty) { var result = contactDetails.Load(Connection, Transaction, practice.BaseInfo.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } contactDetails.IsDeleted = true; contactDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo info = new ORM_CMN_COM_CompanyInfo(); if (practice.BaseInfo.CMN_COM_CompanyInfoID != Guid.Empty) { var result = info.Load(Connection, Transaction, practice.BaseInfo.CMN_COM_CompanyInfoID); if (result.Status != FR_Status.Success || info.CMN_COM_CompanyInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } info.IsDeleted = true; info.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (practice.BaseInfo.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, practice.BaseInfo.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } bParticipant.IsDeleted = true; bParticipant.Save(Connection, Transaction); } ORM_HEC_MedicalPractis practis = new ORM_HEC_MedicalPractis(); if (practice.BaseInfo.HEC_MedicalPractiseID != Guid.Empty) { var result = practis.Load(Connection, Transaction, practice.BaseInfo.HEC_MedicalPractiseID); if (result.Status != FR_Status.Success || practis.HEC_MedicalPractiseID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } practis.IsDeleted = true; practis.Save(Connection, Transaction); } if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklyOfficeHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.BaseInfo.WeeklySurgeryHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklySurgeryHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.ShippingAddress != null) { ORM_CMN_UniversalContactDetail shippingDetails = new ORM_CMN_UniversalContactDetail(); if (practice.ShippingAddress.CMN_UniversalContactDetailID != Guid.Empty) { var result = shippingDetails.Load(Connection, Transaction, practice.ShippingAddress.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingDetails.IsDeleted = true; shippingDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo_Address shippingAddress = new ORM_CMN_COM_CompanyInfo_Address(); if (practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID != Guid.Empty) { var result = shippingAddress.Load(Connection, Transaction, practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID); if (result.Status != FR_Status.Success || shippingAddress.CMN_COM_CompanyInfo_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingAddress.IsDeleted = true; shippingAddress.Save(Connection, Transaction); } } var associatedBussinessParticipantsQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associatedBussinessParticipantsQuery.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; associatedBussinessParticipantsQuery.IsDeleted = false; var associatedBussinessParticipants = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associatedBussinessParticipantsQuery); if (associatedBussinessParticipants.Count != 0) { foreach (var assBussiness in associatedBussinessParticipants) { assBussiness.IsDeleted = true; assBussiness.Save(Connection, Transaction); //brisanje doktora ako je imao jednu praksu //var d2pAssignmentQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); //d2pAssignmentQuery.IsDeleted = false; //d2pAssignmentQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; //var d2pAssignmentRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, d2pAssignmentQuery).ToArray(); //if (d2pAssignmentRes.Length == 0) //{ // var docQuery = new ORM_HEC_Doctor.Query(); // docQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; // var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, docQuery).First(); // P_L3MD_DDbID_1031 delDoc = new P_L3MD_DDbID_1031(); // delDoc.DoctorID = doctor.HEC_DoctorID; // var delRes = cls_Delete_Doctor_byID.Invoke(Connection, Transaction, delDoc, securityTicket).Result; //} } } if (practice.OtherOphthal_PracticeData != null) { ORM_HEC_PublicHealthcare_PhysitianAssociation association = new ORM_HEC_PublicHealthcare_PhysitianAssociation(); if (practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID != Guid.Empty) { var result = association.Load(Connection, Transaction, practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (result.Status != FR_Status.Success || association.HEC_PublicHealthcare_PhysitianAssociationID == Guid.Empty) { var item = STLD_MedicalAssociation.associationItems.FirstOrDefault(a => a.Value == practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (item != null) { association.IsDeleted = true; association.HealthAssociation_Name = item.Text; association.Save(Connection, Transaction); } } } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = practice.BaseInfo.CMN_BPT_BusinessParticipantID; var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault(); if (customer != null) { customer.IsDeleted = true; customer.Save(Connection, Transaction); } var companyTypeQuery = new ORM_CMN_COM_CompanyInfo_Type.Query(); companyTypeQuery.IsDeleted = false; companyTypeQuery.CMN_COM_CompanyInfo_TypeID = practice.OtherOphthal_PracticeData.CMN_COM_CompanyInfo_TypeID; var companyType = ORM_CMN_COM_CompanyInfo_Type.Query.Search(Connection, Transaction, companyTypeQuery).First(); var pHealthcareQuery = new ORM_HEC_PublicHealthcare_PhysitianAssociation.Query(); pHealthcareQuery.HEC_PublicHealthcare_PhysitianAssociationID = practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID; var pHealthcare = ORM_HEC_PublicHealthcare_PhysitianAssociation.Query.Search(Connection, Transaction, pHealthcareQuery).First(); pHealthcare.IsDeleted = true; pHealthcare.Save(Connection, Transaction); if (customer != null) { var affinityStatusQuery = new ORM_CMN_BPT_CTM_AffinityStatus.Query(); affinityStatusQuery.CMN_BPT_CTM_AffinityStatusID = customer.CustomerAffinityStatus_RefID; var affinityStatus = ORM_CMN_BPT_CTM_AffinityStatus.Query.Search(Connection, Transaction, affinityStatusQuery).First(); if (affinityStatus != null) { affinityStatus.IsDeleted = true; affinityStatus.Save(Connection, Transaction); } } } } return(returnValue); #endregion UserCode }