protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_SEBA_1001 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); bool isEdit = false; ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount(); if (Parameter.ACC_BNK_BankAccountID != Guid.Empty) { var result = bankAccount.Load(Connection, Transaction, Parameter.ACC_BNK_BankAccountID); if (result.Status != FR_Status.Success || bankAccount.ACC_BNK_BankAccountID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } isEdit = true; } ORM_ACC_BNK_Bank.Query bankQuery = new ORM_ACC_BNK_Bank.Query(); bankQuery.Tenant_RefID = securityTicket.TenantID; bankQuery.IsDeleted = false; ORM_ACC_BNK_Bank bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).FirstOrDefault(); bankAccount.Bank_RefID = bank == null ? new Guid() : bank.ACC_BNK_BankID; bankAccount.IBAN = Parameter.IBAN; bankAccount.OwnerText = Parameter.OwnerText; bankAccount.IsValid = true; bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.Save(Connection, Transaction); returnValue = new FR_Guid(bankAccount.ACC_BNK_BankAccountID); if (!isEdit) { ORM_CMN_BPT_BusinessParticipant_2_BankAccount bankAcc2BP = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); bankAcc2BP.ACC_BNK_BankAccount_RefID = bankAccount.ACC_BNK_BankAccountID; bankAcc2BP.CMN_BPT_BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipant_RefID; bankAcc2BP.Tenant_RefID = securityTicket.TenantID; bankAcc2BP.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var practice = new ORM_HEC_MedicalPractis() { HEC_MedicalPractiseID = Guid.NewGuid(), Tenant_RefID = securityTicket.TenantID, Ext_CompanyInfo_RefID = Guid.NewGuid() }; practice.Save(Connection, Transaction); var companyInfo = new ORM_CMN_COM_CompanyInfo() { CMN_COM_CompanyInfoID = practice.Ext_CompanyInfo_RefID, Tenant_RefID = securityTicket.TenantID, CompanyInfo_EstablishmentNumber = Parameter.Practice_BSNR }; companyInfo.Save(Connection, Transaction); var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, IsTenant = true }).Single(); bParticipant.IsCompany = true; bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; bParticipant.Save(Connection, Transaction); if (Parameter.Doctor != null) { var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_2_Account.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, USR_Account_RefID = Parameter.Doctor.AccountID }).Single(); var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID }).First(); personInfo.FirstName = Parameter.Doctor.FirstName; personInfo.LastName = Parameter.Doctor.LastName; personInfo.Title = Parameter.Doctor.Title; personInfo.Save(Connection, Transaction); var bussinessParticipantTable = new ORM_CMN_BPT_BusinessParticipant(); bussinessParticipantTable.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bussinessParticipantTable.IsNaturalPerson = true; bussinessParticipantTable.Tenant_RefID = securityTicket.TenantID; bussinessParticipantTable.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; bussinessParticipantTable.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; doctor.Account_RefID = Parameter.Doctor.AccountID; doctor.DoctorIDNumber = Parameter.Doctor.LANR; doctor.Save(Connection, Transaction); var associatedbusinessparticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedbusinessparticipants.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.Tenant_RefID = securityTicket.TenantID; associatedbusinessparticipants.Save(Connection, Transaction); if (Parameter.Doctor.BankData != null) { ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); bussiness_2_BankaAccount.AssignmentID = Guid.NewGuid(); bussiness_2_BankaAccount.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); bussiness_2_BankaAccount.Tenant_RefID = securityTicket.TenantID; bussiness_2_BankaAccount.Save(Connection, Transaction); ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount(); bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID; bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.OwnerText = Parameter.Doctor.BankData.AccountHolder; bankAccount.AccountNumber = Parameter.Doctor.BankData.AccountNumber; bankAccount.IBAN = Parameter.Doctor.BankData.IBAN; bankAccount.Bank_RefID = Guid.NewGuid(); bankAccount.Save(Connection, Transaction); ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank(); bank.ACC_BNK_BankID = bankAccount.Bank_RefID; bank.Tenant_RefID = securityTicket.TenantID; bank.BankName = Parameter.Doctor.BankData.BankName; bank.BICCode = Parameter.Doctor.BankData.BIC; bank.BankNumber = Parameter.Doctor.BankData.BankNumber; bank.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
public static void Save_Doctors_to_DB(Doctor_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"); Guid BusinessParticipantID = Guid.NewGuid(); Guid personInfoID = Guid.NewGuid(); Guid PracticeCustomerID = Guid.NewGuid(); Guid PracticeBusinessParticipantID = Guid.NewGuid(); Guid PracticeCompanyInfoID = Guid.NewGuid(); String PracticeName = ""; Guid BankAccountID = Guid.Empty; Guid doctor_id = Parameter.DoctorID; var isOpPractice = false; 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 doctorAccountInfo = 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 PracticeAccount2UniversalProperty = ORM_HEC_MedicalPractice_2_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_2_UniversalProperty.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_MedicalPractice_RefID = Parameter.PracticeID }).ToList(); List <ORM_HEC_MedicalPractice_UniversalProperty> PracticeUniversalPropertyList = new List <ORM_HEC_MedicalPractice_UniversalProperty>(); foreach (var item in PracticeAccount2UniversalProperty) { var PracticeUniversalProperty = ORM_HEC_MedicalPractice_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_UniversalProperty.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_MedicalPractice_UniversalPropertyID = item.HEC_MedicalPractice_UniversalProperty_RefID }).Single(); PracticeUniversalPropertyList.Add(PracticeUniversalProperty); } ; P_DO_GPAIDfPID_1522 practiceAccountIDParameter = new P_DO_GPAIDfPID_1522(); practiceAccountIDParameter.PracticeID = Parameter.PracticeID; var practiceAccountToFunctionLevelRightQ = new ORM_USR_Account_2_FunctionLevelRight.Query(); practiceAccountToFunctionLevelRightQ.Account_RefID = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, practiceAccountIDParameter, securityTicket).Result.accountID; practiceAccountToFunctionLevelRightQ.Tenant_RefID = securityTicket.TenantID; practiceAccountToFunctionLevelRightQ.IsDeleted = false; var practiceAccountToFunctionLevelRight = ORM_USR_Account_2_FunctionLevelRight.Query.Search(Connection, Transaction, practiceAccountToFunctionLevelRightQ).SingleOrDefault(); if (practiceAccountToFunctionLevelRight != null) { var practiceAccountFunctionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); practiceAccountFunctionLevelRightQ.Tenant_RefID = securityTicket.TenantID; practiceAccountFunctionLevelRightQ.IsDeleted = false; practiceAccountFunctionLevelRightQ.USR_Account_FunctionLevelRightID = practiceAccountToFunctionLevelRight.FunctionLevelRight_RefID; var practiceAccountFunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, practiceAccountFunctionLevelRightQ).SingleOrDefault(); if (practiceAccountFunctionLevelRight != null) { isOpPractice = practiceAccountFunctionLevelRight.GlobalPropertyMatchingID.Equals("mm.docconect.doc.app.op.practice"); } } var functionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); functionLevelRightQ.Tenant_RefID = securityTicket.TenantID; functionLevelRightQ.IsDeleted = false; functionLevelRightQ.GlobalPropertyMatchingID = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; var existingFunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, functionLevelRightQ).SingleOrDefault(); var tempFunctionLevelRightID = Guid.Empty; if (existingFunctionLevelRight == 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 = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; functionLevelRight.GlobalPropertyMatchingID = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; functionLevelRight.Save(Connection, Transaction); tempFunctionLevelRightID = functionLevelRight.USR_Account_FunctionLevelRightID; } else { tempFunctionLevelRightID = existingFunctionLevelRight.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 = doctorAccountInfo.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = tempFunctionLevelRightID; accountToFunctionLevelRight.Save(Connection, Transaction); var businessParticipantQ = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQ.IsDeleted = false; businessParticipantQ.Tenant_RefID = securityTicket.TenantID; businessParticipantQ.CMN_BPT_BusinessParticipantID = doctorAccountInfo.BusinessParticipant_RefID; BusinessParticipantID = doctorAccountInfo.BusinessParticipant_RefID; var DoctorBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQ).Single(); DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); DoctorBusinessParticipant.DisplayName = Parameter.FirstName + " " + Parameter.LastNAme; DoctorBusinessParticipant.IsNaturalPerson = true; DoctorBusinessParticipant.Modification_Timestamp = DateTime.Now; DoctorBusinessParticipant.Save(Connection, Transaction); personInfoID = DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var companyInfoPractice = new ORM_CMN_PER_PersonInfo(); companyInfoPractice.IsDeleted = false; companyInfoPractice.Tenant_RefID = securityTicket.TenantID; companyInfoPractice.CMN_PER_PersonInfoID = personInfoID; companyInfoPractice.FirstName = Parameter.FirstName; companyInfoPractice.LastName = Parameter.LastNAme; companyInfoPractice.Salutation_General = Parameter.Salutation; companyInfoPractice.Title = Parameter.Title; companyInfoPractice.Save(Connection, Transaction); var communicationContact = new ORM_CMN_PER_CommunicationContact(); communicationContact.IsDeleted = false; communicationContact.Contact_Type = Guid.NewGuid(); communicationContact.Tenant_RefID = securityTicket.TenantID; communicationContact.Modification_Timestamp = DateTime.Now; communicationContact.PersonInfo_RefID = personInfoID; communicationContact.Content = Parameter.Email; communicationContact.Save(Connection, Transaction); Guid CommunicationContactTypeID = communicationContact.Contact_Type; var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType.IsDeleted = false; communicationContactType.Tenant_RefID = securityTicket.TenantID; communicationContactType.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID; communicationContactType.Type = "Email"; communicationContactType.Save(Connection, Transaction); var communicationContact2 = new ORM_CMN_PER_CommunicationContact(); communicationContact2.IsDeleted = false; communicationContact2.Contact_Type = Guid.NewGuid(); communicationContact2.Tenant_RefID = securityTicket.TenantID; communicationContact2.Modification_Timestamp = DateTime.Now; communicationContact2.PersonInfo_RefID = personInfoID; communicationContact2.Content = Parameter.Phone; communicationContact2.Save(Connection, Transaction); Guid CommunicationContactTypeID2 = communicationContact2.Contact_Type; var communicationContactType2 = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType2.IsDeleted = false; communicationContactType2.Tenant_RefID = securityTicket.TenantID; communicationContactType2.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID2; communicationContactType2.Type = "Phone"; communicationContactType2.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.HEC_DoctorID = Guid.NewGuid(); doctor.IsDeleted = false; doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = BusinessParticipantID; doctor.DoctorIDNumber = Parameter.LANR.ToString(); doctor.Account_RefID = Parameter.account_id; doctor.Save(Connection, Transaction); doctor_id = doctor.HEC_DoctorID; var ogranizationUnitPractice = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, IfMedicalPractise_HEC_MedicalPractice_RefID = Parameter.PracticeID }).Single(); var organizationalunit_Staff = new ORM_CMN_BPT_CTM_OrganizationalUnit_Staff(); organizationalunit_Staff.IsDeleted = false; organizationalunit_Staff.Tenant_RefID = securityTicket.TenantID; organizationalunit_Staff.BusinessParticipant_RefID = BusinessParticipantID; organizationalunit_Staff.OrganizationalUnit_RefID = ogranizationUnitPractice.CMN_BPT_CTM_OrganizationalUnitID; organizationalunit_Staff.Save(Connection, Transaction); var CustomerPRactice = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_CTM_CustomerID = ogranizationUnitPractice.Customer_RefID }).Single(); var PracticeBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipantID = CustomerPRactice.Ext_BusinessParticipant_RefID }).Single(); PracticeName = PracticeBusinessParticipant.DisplayName; PracticeBusinessParticipantID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID; PracticeCompanyInfoID = PracticeBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; if (Parameter.IsUsePracticeBank) { var PracticeBusinessParticipant2bankaccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipant_RefID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID, }).Single(); 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 = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); BankAccountID = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; //end of save bank data if inherited from practice } else { if (!String.IsNullOrEmpty(Parameter.IBAN) || !String.IsNullOrEmpty(Parameter.Bank)) { 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 bankAccountDoctor = new ORM_ACC_BNK_BankAccount(); bankAccountDoctor.IsDeleted = false; bankAccountDoctor.Tenant_RefID = securityTicket.TenantID; bankAccountDoctor.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountDoctor.OwnerText = Parameter.AccountHolder; bankAccountDoctor.IBAN = Parameter.IBAN; bankAccountDoctor.Bank_RefID = Guid.NewGuid(); bankAccountDoctor.Creation_Timestamp = DateTime.Now; bankAccountDoctor.Save(Connection, Transaction); if (!String.IsNullOrEmpty(Parameter.Bank)) { var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountDoctor.Bank_RefID; bank.BICCode = Parameter.Bic; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); } BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; // end save bank data } } } catch { throw new Exception(); } } else { var DoctorBusinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); DoctorBusinessParticipant.IsDeleted = false; DoctorBusinessParticipant.Tenant_RefID = securityTicket.TenantID; DoctorBusinessParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); DoctorBusinessParticipant.DisplayName = Parameter.FirstName + " " + Parameter.LastNAme; DoctorBusinessParticipant.IsNaturalPerson = true; DoctorBusinessParticipant.Modification_Timestamp = DateTime.Now; DoctorBusinessParticipant.Save(Connection, Transaction); personInfoID = DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; BusinessParticipantID = DoctorBusinessParticipant.CMN_BPT_BusinessParticipantID; var companyInfoPractice = new ORM_CMN_PER_PersonInfo(); companyInfoPractice.IsDeleted = false; companyInfoPractice.Tenant_RefID = securityTicket.TenantID; companyInfoPractice.CMN_PER_PersonInfoID = personInfoID; companyInfoPractice.FirstName = Parameter.FirstName; companyInfoPractice.LastName = Parameter.LastNAme; companyInfoPractice.Salutation_General = Parameter.Salutation; companyInfoPractice.Title = Parameter.Title; companyInfoPractice.Save(Connection, Transaction); var communicationContact = new ORM_CMN_PER_CommunicationContact(); communicationContact.IsDeleted = false; communicationContact.Contact_Type = Guid.NewGuid(); communicationContact.Tenant_RefID = securityTicket.TenantID; communicationContact.Modification_Timestamp = DateTime.Now; communicationContact.PersonInfo_RefID = personInfoID; communicationContact.Content = Parameter.Email; communicationContact.Save(Connection, Transaction); Guid CommunicationContactTypeID = communicationContact.Contact_Type; var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType.IsDeleted = false; communicationContactType.Tenant_RefID = securityTicket.TenantID; communicationContactType.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID; communicationContactType.Type = "Email"; communicationContactType.Save(Connection, Transaction); var communicationContact2 = new ORM_CMN_PER_CommunicationContact(); communicationContact2.IsDeleted = false; communicationContact2.Contact_Type = Guid.NewGuid(); communicationContact2.Tenant_RefID = securityTicket.TenantID; communicationContact2.Modification_Timestamp = DateTime.Now; communicationContact2.PersonInfo_RefID = personInfoID; communicationContact2.Content = Parameter.Phone; communicationContact2.Save(Connection, Transaction); Guid CommunicationContactTypeID2 = communicationContact2.Contact_Type; var communicationContactType2 = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType2.IsDeleted = false; communicationContactType2.Tenant_RefID = securityTicket.TenantID; communicationContactType2.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID2; communicationContactType2.Type = "Phone"; communicationContactType2.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.HEC_DoctorID = Guid.NewGuid(); doctor.IsDeleted = false; doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = BusinessParticipantID; doctor.DoctorIDNumber = Parameter.LANR.ToString(); doctor.Account_RefID = Parameter.account_id; doctor.Save(Connection, Transaction); doctor_id = doctor.HEC_DoctorID; var ogranizationUnitPractice = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, IfMedicalPractise_HEC_MedicalPractice_RefID = Parameter.PracticeID }).Single(); var organizationalunit_Staff = new ORM_CMN_BPT_CTM_OrganizationalUnit_Staff(); organizationalunit_Staff.IsDeleted = false; organizationalunit_Staff.Tenant_RefID = securityTicket.TenantID; organizationalunit_Staff.BusinessParticipant_RefID = BusinessParticipantID; organizationalunit_Staff.OrganizationalUnit_RefID = ogranizationUnitPractice.CMN_BPT_CTM_OrganizationalUnitID; organizationalunit_Staff.Save(Connection, Transaction); var CustomerPRactice = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_CTM_CustomerID = ogranizationUnitPractice.Customer_RefID }).Single(); var PracticeBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipantID = CustomerPRactice.Ext_BusinessParticipant_RefID }).Single(); PracticeName = PracticeBusinessParticipant.DisplayName; PracticeBusinessParticipantID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID; PracticeCompanyInfoID = PracticeBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; if (Parameter.IsUsePracticeBank == true) { var PracticeBusinessParticipant2bankaccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipant_RefID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID, }).Single(); 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 = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); BankAccountID = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; //end of save bank data if inherited from practice } else { if (!String.IsNullOrEmpty(Parameter.IBAN) || !String.IsNullOrEmpty(Parameter.Bank)) { 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 bankAccountDoctor = new ORM_ACC_BNK_BankAccount(); bankAccountDoctor.IsDeleted = false; bankAccountDoctor.Tenant_RefID = securityTicket.TenantID; bankAccountDoctor.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountDoctor.OwnerText = Parameter.AccountHolder; bankAccountDoctor.IBAN = Parameter.IBAN; bankAccountDoctor.Bank_RefID = Guid.NewGuid(); bankAccountDoctor.Creation_Timestamp = DateTime.Now; bankAccountDoctor.Save(Connection, Transaction); if (!String.IsNullOrEmpty(Parameter.Bank)) { var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountDoctor.Bank_RefID; bank.BICCode = Parameter.Bic; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); } BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; // end save bank data } } } var PracticeCompanyInfoAddress = ORM_CMN_COM_CompanyInfo_Address.Query.Search(Connection, Transaction, new ORM_CMN_COM_CompanyInfo_Address.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CompanyInfo_RefID = PracticeCompanyInfoID, Address_Description = "Standard address for billing, shipping", }).SingleOrDefault(); Practice_Doctors_Model DPModel = new Practice_Doctors_Model(); if (PracticeCompanyInfoAddress != null) { var PracticeUCD = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_UniversalContactDetailID = PracticeCompanyInfoAddress.Address_UCD_RefID, }).SingleOrDefault(); DPModel.address = PracticeUCD.Street_Name + " " + PracticeUCD.Street_Number; DPModel.zip = PracticeUCD.ZIP; DPModel.city = PracticeUCD.Town; } DPModel.account_status = "aktiv"; DPModel.id = doctor_id.ToString(); var title = string.IsNullOrEmpty(Parameter.Title) ? "" : Parameter.Title.Trim(); DPModel.name = title + " " + Parameter.FirstName + " " + Parameter.LastNAme; DPModel.name_untouched = Parameter.FirstName + " " + Parameter.LastNAme; DPModel.bsnr_lanr = Parameter.LANR.ToString(); DPModel.autocomplete_name = title + " " + Parameter.FirstName + " " + Parameter.LastNAme; DPModel.salutation = title; DPModel.type = "Doctor"; DPModel.bank = string.IsNullOrEmpty(Parameter.Bank) ? "" : Parameter.Bank; DPModel.bank_untouched = string.IsNullOrEmpty(Parameter.Bank) ? "" : Parameter.Bank; DPModel.phone = Parameter.Phone; DPModel.email = string.IsNullOrEmpty(Parameter.Email) ? "" : Parameter.Email; DPModel.iban = string.IsNullOrEmpty(Parameter.IBAN) ? "" : Parameter.IBAN; DPModel.bic = string.IsNullOrEmpty(Parameter.Bic) ? "" : Parameter.Bic; DPModel.bank_id = BankAccountID.ToString(); DPModel.bank_info_inherited = Parameter.IsUsePracticeBank; DPModel.aditional_info = ""; DPModel.contract = 0; DPModel.tenantid = securityTicket.TenantID.ToString(); DPModel.practice_name_for_doctor = PracticeName; DPModel.practice_for_doctor_id = Parameter.PracticeID.ToString(); DPModel.role = isOpPractice ? "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()); #region Assignment to Contract var contractIvi = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, ContractName = "IVI-Vertrag" }).SingleOrDefault(); if (contractIvi != null) { Guid AssignmentID = Guid.NewGuid(); var insuranceTobrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, new ORM_HEC_CRT_InsuranceToBrokerContract.Query() { Ext_CMN_CTR_Contract_RefID = contractIvi.CMN_CTR_ContractID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false, }).SingleOrDefault(); if (insuranceTobrokerContract != null) { AssignmentID = insuranceTobrokerContract.HEC_CRT_InsuranceToBrokerContractID; } else { var insuranceTobrokerContractNew = new ORM_HEC_CRT_InsuranceToBrokerContract(); insuranceTobrokerContractNew.HEC_CRT_InsuranceToBrokerContractID = Guid.NewGuid(); insuranceTobrokerContractNew.Creation_Timestamp = DateTime.Now; insuranceTobrokerContractNew.IsDeleted = false; insuranceTobrokerContractNew.Tenant_RefID = securityTicket.TenantID; insuranceTobrokerContractNew.Ext_CMN_CTR_Contract_RefID = contractIvi.CMN_CTR_ContractID; insuranceTobrokerContractNew.Save(Connection, Transaction); AssignmentID = insuranceTobrokerContractNew.HEC_CRT_InsuranceToBrokerContractID; } var insuranceTobrokerContract2doctor = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingDoctor(); insuranceTobrokerContract2doctor.Creation_Timestamp = DateTime.Now; insuranceTobrokerContract2doctor.HEC_CRT_InsuranceToBrokerContract_ParticipatingDoctorID = Guid.NewGuid(); insuranceTobrokerContract2doctor.InsuranceToBrokerContract_RefID = AssignmentID; insuranceTobrokerContract2doctor.Tenant_RefID = securityTicket.TenantID; insuranceTobrokerContract2doctor.IsDeleted = false; insuranceTobrokerContract2doctor.Doctor_RefID = doctor_id; insuranceTobrokerContract2doctor.ValidFrom = new DateTime(2013, 6, 15); insuranceTobrokerContract2doctor.ValidThrough = DateTime.MinValue; insuranceTobrokerContract2doctor.Save(Connection, Transaction); P_DO_CDCD_1505 ParameterDoctorID = new P_DO_CDCD_1505(); ParameterDoctorID.DoctorID = doctor_id; var data = cls_Get_Doctor_Contract_Numbers.Invoke(Connection, Transaction, ParameterDoctorID, securityTicket).Result; int DoctorContracts = data.Count(); Doctor_Contracts ParameterDoctor = new Doctor_Contracts(); ParameterDoctor.DocID = doctor_id; Practice_Doctors_Model DoctorFound = Get_Doctors_for_PracticeID.Set_Contract_Number_for_DoctorID(ParameterDoctor, securityTicket); if (DoctorFound != null) { List <Practice_Doctors_Model> DoctorFoundL = new List <Practice_Doctors_Model>(); DoctorFound.contract = DoctorContracts; DoctorFoundL.Add(DoctorFound); Add_Practice_Doctors_to_Elastic.Import_Practice_Data_to_ElasticDB(DoctorFoundL, securityTicket.TenantID.ToString()); } P_DO_GPIDfDID_1353 ParametarDocID = new P_DO_GPIDfDID_1353(); ParametarDocID.DoctorID = doctor_id; DO_GPIDfDID_1353[] data2 = cls_Get_PracticeID_for_DoctorID.Invoke(Connection, Transaction, ParametarDocID, securityTicket).Result; P_DO_GCfPID_1507 ParametarPractice = new P_DO_GCfPID_1507(); ParametarPractice.PracticeID = data2.First().HEC_MedicalPractiseID; DO_GCfPID_1507[] Contracts = cls_Get_all_Doctors_Contract_Assignment_for_PracticeID.Invoke(Connection, Transaction, ParametarPractice, securityTicket).Result; int NumberOfContractsForPractice = Contracts.Count(); Practice_Doctors_Model practice = new Practice_Doctors_Model(); practice.id = ParametarPractice.PracticeID.ToString(); Practice_Doctors_Model PracticeFound = Get_Doctors_for_PracticeID.Get_Practice_for_PracticeID(practice, securityTicket); List <Practice_Doctors_Model> practiceL = new List <Practice_Doctors_Model>(); PracticeFound.contract = NumberOfContractsForPractice; practiceL.Add(PracticeFound); Add_Practice_Doctors_to_Elastic.Import_Practice_Data_to_ElasticDB(practiceL, securityTicket.TenantID.ToString()); } #endregion 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, PL5DO_SD_1349 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); if (Parameter.isDeleted == true) { P_L3MD_DDbID_1031 param1 = new P_L3MD_DDbID_1031(); param1.DoctorID = Parameter.DoctorID; var deleteQuery = new ORM_HEC_Patient_Treatment.Query(); deleteQuery.IsTreatmentPerformed = true; deleteQuery.IfTreatmentPerformed_ByDoctor_RefID = Parameter.DoctorID; var treatmentsList = ORM_HEC_Patient_Treatment.Query.Search(Connection, Transaction, deleteQuery).ToList(); foreach (var treatment in treatmentsList) { treatment.IsTreatmentPerformed = false; treatment.Save(Connection, Transaction); } cls_Delete_Doctor_byID.Invoke(Connection, Transaction, param1, securityTicket); } else { P_L3MD_SDBI_1349 param = new P_L3MD_SDBI_1349(); param.Account_RefID = Parameter.Account_RefID; param.DoctorID = Parameter.DoctorID; param.Title = Parameter.Title; param.FirstName = Parameter.FirstName; param.LastName = Parameter.LastName; param.ifLucentis_LoginEmail = Parameter.LoginEmail; param.isLucentisSave = true; param.ifLucentis_LANR = Parameter.ifLucentis_LANR; List <P_L3MD_SDBI_1349_Practice> practiceNewList = new List <P_L3MD_SDBI_1349_Practice>(); foreach (var practice in Parameter.Practices) { P_L3MD_SDBI_1349_Practice practiceNew = new P_L3MD_SDBI_1349_Practice(); practiceNew.AssociatedParticipant_FunctionName = practice.AssociatedParticipant_FunctionName; practiceNew.isDeleted = practice.isDeleted; practiceNew.PracticeID = practice.PracticeID; practiceNewList.Add(practiceNew); } param.Practices = practiceNewList.ToArray(); List <P_L3MD_SDBI_1349_Contacts> contactsNewList = new List <P_L3MD_SDBI_1349_Contacts>(); foreach (var contact in Parameter.Contacts) { P_L3MD_SDBI_1349_Contacts contactNew = new P_L3MD_SDBI_1349_Contacts(); contactNew.CMN_PER_CommunicationContact_TypeID = contact.CMN_PER_CommunicationContact_TypeID; contactNew.Content = contact.Content; contactsNewList.Add(contactNew); } param.Contacts = contactsNewList.ToArray(); Guid Hec_Doctor_ID = cls_Save_Doctor_BaseInfo.Invoke(Connection, Transaction, param, securityTicket).Result; if (Parameter.DoctorID != Guid.Empty) { #region Edit var doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.IsDeleted = false; doctorQuery.HEC_DoctorID = Hec_Doctor_ID; var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).FirstOrDefault(); if (doctor != null) { var bussiness_2_BankaAccountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query(); bussiness_2_BankaAccountQuery.IsDeleted = false; bussiness_2_BankaAccountQuery.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; var bussiness_2_BankaAccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, bussiness_2_BankaAccountQuery).FirstOrDefault(); if (bussiness_2_BankaAccount != null) { var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query(); bankAccountQuery.IsDeleted = false; bankAccountQuery.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID; var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).FirstOrDefault(); bankAccount.OwnerText = Parameter.AccountHolder; bankAccount.AccountNumber = Parameter.AccountNumber; bankAccount.IBAN = Parameter.IBAN; bankAccount.Save(Connection, Transaction); var bankQuery = new ORM_ACC_BNK_Bank.Query(); bankQuery.IsDeleted = false; bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID; var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).FirstOrDefault(); bank.BankName = Parameter.BankName; bank.BICCode = Parameter.BIC; bank.BankNumber = Parameter.BankNumber; bank.Save(Connection, Transaction); } else { ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount1 = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); bussiness_2_BankaAccount1.AssignmentID = Guid.NewGuid(); bussiness_2_BankaAccount1.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; bussiness_2_BankaAccount1.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); bussiness_2_BankaAccount1.Creation_Timestamp = DateTime.Now; bussiness_2_BankaAccount1.Tenant_RefID = securityTicket.TenantID; bussiness_2_BankaAccount1.IsDeleted = false; bussiness_2_BankaAccount1.Save(Connection, Transaction); ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount(); bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount1.ACC_BNK_BankAccount_RefID; bankAccount.Creation_Timestamp = DateTime.Now; bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.OwnerText = Parameter.AccountHolder; bankAccount.AccountNumber = Parameter.AccountNumber; bankAccount.IBAN = Parameter.IBAN; bankAccount.Bank_RefID = Guid.NewGuid(); bankAccount.IsDeleted = false; bankAccount.Save(Connection, Transaction); ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank(); bank.ACC_BNK_BankID = bankAccount.Bank_RefID; bank.Tenant_RefID = securityTicket.TenantID; bank.IsDeleted = false; bank.Creation_Timestamp = DateTime.Now; bank.BankName = Parameter.BankName; bank.BICCode = Parameter.BIC; bank.BankNumber = Parameter.BankNumber; bank.Save(Connection, Transaction); } } #endregion } else { #region Save var doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.IsDeleted = false; doctorQuery.HEC_DoctorID = Hec_Doctor_ID; var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).FirstOrDefault(); if (doctor != null) { ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); bussiness_2_BankaAccount.AssignmentID = Guid.NewGuid(); bussiness_2_BankaAccount.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); bussiness_2_BankaAccount.Creation_Timestamp = DateTime.Now; bussiness_2_BankaAccount.Tenant_RefID = securityTicket.TenantID; bussiness_2_BankaAccount.IsDeleted = false; bussiness_2_BankaAccount.Save(Connection, Transaction); ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount(); bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID; bankAccount.Creation_Timestamp = DateTime.Now; bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.OwnerText = Parameter.AccountHolder; bankAccount.AccountNumber = Parameter.AccountNumber; bankAccount.IBAN = Parameter.IBAN; bankAccount.Bank_RefID = Guid.NewGuid(); bankAccount.IsDeleted = false; bankAccount.Save(Connection, Transaction); ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank(); bank.ACC_BNK_BankID = bankAccount.Bank_RefID; bank.Tenant_RefID = securityTicket.TenantID; bank.IsDeleted = false; bank.Creation_Timestamp = DateTime.Now; bank.BankName = Parameter.BankName; bank.BICCode = Parameter.BIC; bank.BankNumber = Parameter.BankNumber; bank.Save(Connection, Transaction); } #endregion } returnValue.Result = Hec_Doctor_ID; } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_DO_SD_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); Guid BusinessParticipantID = Guid.NewGuid(); Guid personInfoID = Guid.NewGuid(); Guid PracticeCustomerID = Guid.NewGuid(); Guid PracticeBusinessParticipantID = Guid.NewGuid(); Guid PracticeCompanyInfoID = Guid.NewGuid(); String PracticeName = ""; Guid BankAccountID = Guid.Empty; Guid doctor_id = Parameter.DoctorID; var isOpPractice = false; //if (!String.IsNullOrEmpty(Parameter.Login_Email)) //uncomment this if you've created account if (false) { string[] stringUser = Parameter.Login_Email.Split('@'); string usernameStr = stringUser[0]; try { var doctorAccountInfo = ORM_USR_Account.Query.Search(Connection, Transaction, new ORM_USR_Account.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, AccountSignInEmailAddress = Parameter.Login_Email, }).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 PracticeAccount2UniversalProperty = ORM_HEC_MedicalPractice_2_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_2_UniversalProperty.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_MedicalPractice_RefID = Parameter.PracticeID }).ToList(); List <ORM_HEC_MedicalPractice_UniversalProperty> PracticeUniversalPropertyList = new List <ORM_HEC_MedicalPractice_UniversalProperty>(); foreach (var item in PracticeAccount2UniversalProperty) { var PracticeUniversalProperty = ORM_HEC_MedicalPractice_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_UniversalProperty.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_MedicalPractice_UniversalPropertyID = item.HEC_MedicalPractice_UniversalProperty_RefID }).Single(); PracticeUniversalPropertyList.Add(PracticeUniversalProperty); } ; P_DO_GPAIDfPID_1522 practiceAccountIDParameter = new P_DO_GPAIDfPID_1522(); practiceAccountIDParameter.PracticeID = Parameter.PracticeID; var practiceAccountToFunctionLevelRightQ = new ORM_USR_Account_2_FunctionLevelRight.Query(); practiceAccountToFunctionLevelRightQ.Account_RefID = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, practiceAccountIDParameter, securityTicket).Result.accountID; practiceAccountToFunctionLevelRightQ.Tenant_RefID = securityTicket.TenantID; practiceAccountToFunctionLevelRightQ.IsDeleted = false; var practiceAccountToFunctionLevelRight = ORM_USR_Account_2_FunctionLevelRight.Query.Search(Connection, Transaction, practiceAccountToFunctionLevelRightQ).SingleOrDefault(); if (practiceAccountToFunctionLevelRight != null) { var practiceAccountFunctionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); practiceAccountFunctionLevelRightQ.Tenant_RefID = securityTicket.TenantID; practiceAccountFunctionLevelRightQ.IsDeleted = false; practiceAccountFunctionLevelRightQ.USR_Account_FunctionLevelRightID = practiceAccountToFunctionLevelRight.FunctionLevelRight_RefID; var practiceAccountFunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, practiceAccountFunctionLevelRightQ).SingleOrDefault(); if (practiceAccountFunctionLevelRight != null) { isOpPractice = practiceAccountFunctionLevelRight.GlobalPropertyMatchingID.Equals("mm.docconect.doc.app.op.practice"); } } var functionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); functionLevelRightQ.Tenant_RefID = securityTicket.TenantID; functionLevelRightQ.IsDeleted = false; functionLevelRightQ.GlobalPropertyMatchingID = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; var existingFunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, functionLevelRightQ).SingleOrDefault(); var tempFunctionLevelRightID = Guid.Empty; if (existingFunctionLevelRight == 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 = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; functionLevelRight.GlobalPropertyMatchingID = isOpPractice ? "mm.docconect.doc.app.op.doctor" : "mm.docconect.doc.app.ac.doctor"; functionLevelRight.Save(Connection, Transaction); tempFunctionLevelRightID = functionLevelRight.USR_Account_FunctionLevelRightID; } else { tempFunctionLevelRightID = existingFunctionLevelRight.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 = doctorAccountInfo.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = tempFunctionLevelRightID; accountToFunctionLevelRight.Save(Connection, Transaction); var businessParticipantQ = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQ.IsDeleted = false; businessParticipantQ.Tenant_RefID = securityTicket.TenantID; businessParticipantQ.CMN_BPT_BusinessParticipantID = doctorAccountInfo.BusinessParticipant_RefID; BusinessParticipantID = doctorAccountInfo.BusinessParticipant_RefID; var DoctorBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQ).Single(); DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); DoctorBusinessParticipant.DisplayName = Parameter.First_Name + " " + Parameter.Last_Name; DoctorBusinessParticipant.IsNaturalPerson = true; DoctorBusinessParticipant.Modification_Timestamp = DateTime.Now; DoctorBusinessParticipant.Save(Connection, Transaction); personInfoID = DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var companyInfoPractice = new ORM_CMN_PER_PersonInfo(); companyInfoPractice.IsDeleted = false; companyInfoPractice.Tenant_RefID = securityTicket.TenantID; companyInfoPractice.CMN_PER_PersonInfoID = personInfoID; companyInfoPractice.FirstName = Parameter.First_Name; companyInfoPractice.LastName = Parameter.Last_Name; companyInfoPractice.Salutation_General = Parameter.Salutation; companyInfoPractice.Title = Parameter.Title; companyInfoPractice.Save(Connection, Transaction); var communicationContact = new ORM_CMN_PER_CommunicationContact(); communicationContact.IsDeleted = false; communicationContact.Contact_Type = Guid.NewGuid(); communicationContact.Tenant_RefID = securityTicket.TenantID; communicationContact.Modification_Timestamp = DateTime.Now; communicationContact.PersonInfo_RefID = personInfoID; communicationContact.Content = Parameter.Email; communicationContact.Save(Connection, Transaction); Guid CommunicationContactTypeID = communicationContact.Contact_Type; var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType.IsDeleted = false; communicationContactType.Tenant_RefID = securityTicket.TenantID; communicationContactType.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID; communicationContactType.Type = "Email"; communicationContactType.Save(Connection, Transaction); var communicationContact2 = new ORM_CMN_PER_CommunicationContact(); communicationContact2.IsDeleted = false; communicationContact2.Contact_Type = Guid.NewGuid(); communicationContact2.Tenant_RefID = securityTicket.TenantID; communicationContact2.Modification_Timestamp = DateTime.Now; communicationContact2.PersonInfo_RefID = personInfoID; communicationContact2.Content = Parameter.Phone; communicationContact2.Save(Connection, Transaction); Guid CommunicationContactTypeID2 = communicationContact2.Contact_Type; var communicationContactType2 = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType2.IsDeleted = false; communicationContactType2.Tenant_RefID = securityTicket.TenantID; communicationContactType2.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID2; communicationContactType2.Type = "Phone"; communicationContactType2.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.HEC_DoctorID = Guid.NewGuid(); doctor.IsDeleted = false; doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = BusinessParticipantID; doctor.DoctorIDNumber = Parameter.LANR.ToString(); doctor.Save(Connection, Transaction); doctor_id = doctor.HEC_DoctorID; var ogranizationUnitPractice = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, IfMedicalPractise_HEC_MedicalPractice_RefID = Parameter.PracticeID }).Single(); var organizationalunit_Staff = new ORM_CMN_BPT_CTM_OrganizationalUnit_Staff(); organizationalunit_Staff.IsDeleted = false; organizationalunit_Staff.Tenant_RefID = securityTicket.TenantID; organizationalunit_Staff.BusinessParticipant_RefID = BusinessParticipantID; organizationalunit_Staff.OrganizationalUnit_RefID = ogranizationUnitPractice.CMN_BPT_CTM_OrganizationalUnitID; organizationalunit_Staff.Save(Connection, Transaction); var CustomerPRactice = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_CTM_CustomerID = ogranizationUnitPractice.Customer_RefID }).Single(); var PracticeBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipantID = CustomerPRactice.Ext_BusinessParticipant_RefID }).Single(); PracticeName = PracticeBusinessParticipant.DisplayName; PracticeBusinessParticipantID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID; PracticeCompanyInfoID = PracticeBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; if (Parameter.From_Practice_Bank) { var PracticeBusinessParticipant2bankaccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipant_RefID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID, }).Single(); 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 = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); BankAccountID = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; //end of save bank data if inherited from practice } else { if (!String.IsNullOrEmpty(Parameter.IBAN) || !String.IsNullOrEmpty(Parameter.Bank)) { 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 bankAccountDoctor = new ORM_ACC_BNK_BankAccount(); bankAccountDoctor.IsDeleted = false; bankAccountDoctor.Tenant_RefID = securityTicket.TenantID; bankAccountDoctor.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountDoctor.OwnerText = Parameter.Account_Holder; bankAccountDoctor.IBAN = Parameter.IBAN; bankAccountDoctor.Bank_RefID = Guid.NewGuid(); bankAccountDoctor.Creation_Timestamp = DateTime.Now; bankAccountDoctor.Save(Connection, Transaction); if (!String.IsNullOrEmpty(Parameter.Bank)) { var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountDoctor.Bank_RefID; bank.BICCode = Parameter.BIC; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); } BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; // end save bank data } } } catch { throw new Exception(); } } else { var DoctorBusinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); DoctorBusinessParticipant.IsDeleted = false; DoctorBusinessParticipant.Tenant_RefID = securityTicket.TenantID; DoctorBusinessParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); DoctorBusinessParticipant.DisplayName = Parameter.First_Name + " " + Parameter.Last_Name; DoctorBusinessParticipant.IsNaturalPerson = true; DoctorBusinessParticipant.Modification_Timestamp = DateTime.Now; DoctorBusinessParticipant.Save(Connection, Transaction); personInfoID = DoctorBusinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; BusinessParticipantID = DoctorBusinessParticipant.CMN_BPT_BusinessParticipantID; var companyInfoPractice = new ORM_CMN_PER_PersonInfo(); companyInfoPractice.IsDeleted = false; companyInfoPractice.Tenant_RefID = securityTicket.TenantID; companyInfoPractice.CMN_PER_PersonInfoID = personInfoID; companyInfoPractice.FirstName = Parameter.First_Name; companyInfoPractice.LastName = Parameter.Last_Name; companyInfoPractice.Salutation_General = Parameter.Salutation; companyInfoPractice.Title = Parameter.Title; companyInfoPractice.Save(Connection, Transaction); var communicationContact = new ORM_CMN_PER_CommunicationContact(); communicationContact.IsDeleted = false; communicationContact.Contact_Type = Guid.NewGuid(); communicationContact.Tenant_RefID = securityTicket.TenantID; communicationContact.Modification_Timestamp = DateTime.Now; communicationContact.PersonInfo_RefID = personInfoID; communicationContact.Content = Parameter.Email; communicationContact.Save(Connection, Transaction); Guid CommunicationContactTypeID = communicationContact.Contact_Type; var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType.IsDeleted = false; communicationContactType.Tenant_RefID = securityTicket.TenantID; communicationContactType.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID; communicationContactType.Type = "Email"; communicationContactType.Save(Connection, Transaction); var communicationContact2 = new ORM_CMN_PER_CommunicationContact(); communicationContact2.IsDeleted = false; communicationContact2.Contact_Type = Guid.NewGuid(); communicationContact2.Tenant_RefID = securityTicket.TenantID; communicationContact2.Modification_Timestamp = DateTime.Now; communicationContact2.PersonInfo_RefID = personInfoID; communicationContact2.Content = Parameter.Phone; communicationContact2.Save(Connection, Transaction); Guid CommunicationContactTypeID2 = communicationContact2.Contact_Type; var communicationContactType2 = new ORM_CMN_PER_CommunicationContact_Type(); communicationContactType2.IsDeleted = false; communicationContactType2.Tenant_RefID = securityTicket.TenantID; communicationContactType2.CMN_PER_CommunicationContact_TypeID = CommunicationContactTypeID2; communicationContactType2.Type = "Phone"; communicationContactType2.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.HEC_DoctorID = Guid.NewGuid(); doctor.IsDeleted = false; doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = BusinessParticipantID; doctor.DoctorIDNumber = Parameter.LANR.ToString(); doctor.Save(Connection, Transaction); doctor_id = doctor.HEC_DoctorID; var ogranizationUnitPractice = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, IfMedicalPractise_HEC_MedicalPractice_RefID = Parameter.PracticeID }).Single(); var organizationalunit_Staff = new ORM_CMN_BPT_CTM_OrganizationalUnit_Staff(); organizationalunit_Staff.IsDeleted = false; organizationalunit_Staff.Tenant_RefID = securityTicket.TenantID; organizationalunit_Staff.BusinessParticipant_RefID = BusinessParticipantID; organizationalunit_Staff.OrganizationalUnit_RefID = ogranizationUnitPractice.CMN_BPT_CTM_OrganizationalUnitID; organizationalunit_Staff.Save(Connection, Transaction); var CustomerPRactice = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_CTM_CustomerID = ogranizationUnitPractice.Customer_RefID }).Single(); var PracticeBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipantID = CustomerPRactice.Ext_BusinessParticipant_RefID }).Single(); PracticeName = PracticeBusinessParticipant.DisplayName; PracticeBusinessParticipantID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID; PracticeCompanyInfoID = PracticeBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; if (Parameter.From_Practice_Bank == true) { var PracticeBusinessParticipant2bankaccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipant_RefID = PracticeBusinessParticipant.CMN_BPT_BusinessParticipantID, }).Single(); 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 = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); BankAccountID = PracticeBusinessParticipant2bankaccount.ACC_BNK_BankAccount_RefID; //end of save bank data if inherited from practice } else { if (!String.IsNullOrEmpty(Parameter.IBAN) || !String.IsNullOrEmpty(Parameter.Bank)) { 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 bankAccountDoctor = new ORM_ACC_BNK_BankAccount(); bankAccountDoctor.IsDeleted = false; bankAccountDoctor.Tenant_RefID = securityTicket.TenantID; bankAccountDoctor.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountDoctor.OwnerText = Parameter.Account_Holder; bankAccountDoctor.IBAN = Parameter.IBAN; bankAccountDoctor.Bank_RefID = Guid.NewGuid(); bankAccountDoctor.Creation_Timestamp = DateTime.Now; bankAccountDoctor.Save(Connection, Transaction); if (!String.IsNullOrEmpty(Parameter.Bank)) { var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountDoctor.Bank_RefID; bank.BICCode = Parameter.BIC; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); } BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; // end save bank data } } } var PracticeCompanyInfoAddress = ORM_CMN_COM_CompanyInfo_Address.Query.Search(Connection, Transaction, new ORM_CMN_COM_CompanyInfo_Address.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CompanyInfo_RefID = PracticeCompanyInfoID, Address_Description = "Standard address for billing, shipping", }).SingleOrDefault(); Practice_Doctors_Model DPModel = new Practice_Doctors_Model(); if (PracticeCompanyInfoAddress != null) { var PracticeUCD = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_UniversalContactDetailID = PracticeCompanyInfoAddress.Address_UCD_RefID, }).SingleOrDefault(); DPModel.address = PracticeUCD.Street_Name + " " + PracticeUCD.Street_Number; DPModel.zip = PracticeUCD.ZIP; DPModel.city = PracticeUCD.Town; } DPModel.account_status = "aktiv"; DPModel.id = doctor_id.ToString(); var title = string.IsNullOrEmpty(Parameter.Title) ? "" : Parameter.Title.Trim(); DPModel.name = title + " " + Parameter.Last_Name + " " + Parameter.First_Name; DPModel.name_untouched = Parameter.Last_Name + " " + Parameter.First_Name; DPModel.bsnr_lanr = Parameter.LANR.ToString(); DPModel.salutation = title; DPModel.type = "Doctor"; DPModel.bank = string.IsNullOrEmpty(Parameter.Bank) ? "" : Parameter.Bank; DPModel.bank_untouched = string.IsNullOrEmpty(Parameter.Bank) ? "" : Parameter.Bank; DPModel.phone = Parameter.Phone; DPModel.email = string.IsNullOrEmpty(Parameter.Email) ? "" : Parameter.Email; DPModel.iban = string.IsNullOrEmpty(Parameter.IBAN) ? "" : Parameter.IBAN; DPModel.bic = string.IsNullOrEmpty(Parameter.BIC) ? "" : Parameter.BIC; DPModel.bank_id = BankAccountID.ToString(); DPModel.bank_info_inherited = Parameter.From_Practice_Bank; DPModel.aditional_info = ""; DPModel.contract = 0; DPModel.tenantid = securityTicket.TenantID.ToString(); DPModel.practice_name_for_doctor = PracticeName; DPModel.practice_for_doctor_id = Parameter.PracticeID.ToString(); DPModel.role = isOpPractice ? "op" : "ac"; List <Practice_Doctors_Model> DPModelL = new List <Practice_Doctors_Model>(); DPModelL.Add(DPModel); Add_New_Practice.Import_Practice_Data_to_ElasticDB(DPModelL, securityTicket.TenantID.ToString()); return(returnValue); #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_L5PA_SPHIaBD_1143 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Save if (!Parameter.IsDeleted) { //ORM_HEC_Patient var patientQuery = new ORM_HEC_Patient.Query(); patientQuery.IsDeleted = false; patientQuery.Tenant_RefID = securityTicket.TenantID; patientQuery.HEC_PatientID = Parameter.PatientID; var patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single(); var businessParticipantBank_2_accountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query(); businessParticipantBank_2_accountQuery.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipantBank_2_accountQuery.IsDeleted = false; businessParticipantBank_2_accountQuery.Tenant_RefID = securityTicket.TenantID; var businessParticipantBank_2_account = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, businessParticipantBank_2_accountQuery).SingleOrDefault(); if (businessParticipantBank_2_account == null) { //ORM_CMN_BPT_BusinessParticipant_2_BankAccount businessParticipantBank_2_account = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); businessParticipantBank_2_account.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); businessParticipantBank_2_account.AssignmentID = Guid.NewGuid(); businessParticipantBank_2_account.Tenant_RefID = securityTicket.TenantID; businessParticipantBank_2_account.Creation_Timestamp = DateTime.Now; businessParticipantBank_2_account.Save(Connection, Transaction); //ORM_ACC_BNK_BankAccount var bankAccount = new ORM_ACC_BNK_BankAccount(); bankAccount.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID; bankAccount.OwnerText = Parameter.OwnerText; bankAccount.AccountNumber = Parameter.AccountNumber; bankAccount.IBAN = Parameter.IBAN; bankAccount.Bank_RefID = Guid.NewGuid(); bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.Creation_Timestamp = DateTime.Now; bankAccount.Save(Connection, Transaction); //ORM_ACC_BNK_Bank var bank = new ORM_ACC_BNK_Bank(); bank.ACC_BNK_BankID = bankAccount.Bank_RefID; bank.BankName = Parameter.BankName; bank.BICCode = Parameter.BICCode; bank.Tenant_RefID = securityTicket.TenantID; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); //ORM_HEC_Patient_HealthInsurance var healthInsurance = new ORM_HEC_Patient_HealthInsurance(); healthInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid(); healthInsurance.Patient_RefID = Parameter.PatientID; healthInsurance.HealthInsurance_Number = Parameter.HealthInsurance_Number; healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HEC_HealthInsurance_CompanyID; healthInsurance.HealthInsurance_State_RefID = Parameter.HEC_Patient_HealthInsurance_StateID; healthInsurance.InsuranceValidFrom = Parameter.InsuranceValidFrom; healthInsurance.InsuranceValidThrough = Parameter.InsuranceValidThrough; healthInsurance.IsNotSelfInsured = Parameter.IsNotSelfInsured; if (healthInsurance.IsNotSelfInsured) { healthInsurance.IsNotSelfInsured_InsuredPersonBirthday = Parameter.IsNotSelfInsured_InsuredPersonBirthday; healthInsurance.IsNotSelfInsured_InsuredPersonName = Parameter.IsNotSelfInsured_InsuredPersonName; } healthInsurance.Creation_Timestamp = DateTime.Now; healthInsurance.Tenant_RefID = securityTicket.TenantID; healthInsurance.Save(Connection, Transaction); } else { var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query(); bankAccountQuery.IsDeleted = false; bankAccountQuery.Tenant_RefID = securityTicket.TenantID; bankAccountQuery.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID; var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).Single(); bankAccount.OwnerText = Parameter.OwnerText; bankAccount.AccountNumber = Parameter.AccountNumber; bankAccount.IBAN = Parameter.IBAN; bankAccount.Save(Connection, Transaction); var bankQuery = new ORM_ACC_BNK_Bank.Query(); bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID; bankQuery.IsDeleted = false; bankQuery.Tenant_RefID = securityTicket.TenantID; var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).Single(); bank.BankName = Parameter.BankName; bank.BICCode = Parameter.BICCode; bank.Save(Connection, Transaction); var healthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); healthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; healthInsuranceQuery.IsDeleted = false; healthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healthInsuranceQuery).Single(); healthInsurance.HealthInsurance_Number = Parameter.HealthInsurance_Number; healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HEC_HealthInsurance_CompanyID; healthInsurance.HealthInsurance_State_RefID = Parameter.HEC_Patient_HealthInsurance_StateID; healthInsurance.InsuranceValidFrom = Parameter.InsuranceValidFrom; healthInsurance.InsuranceValidThrough = Parameter.InsuranceValidThrough; healthInsurance.IsNotSelfInsured = Parameter.IsNotSelfInsured; healthInsurance.IsNotSelfInsured_InsuredPersonBirthday = Parameter.IsNotSelfInsured_InsuredPersonBirthday; healthInsurance.IsNotSelfInsured_InsuredPersonName = Parameter.IsNotSelfInsured_InsuredPersonName; healthInsurance.Save(Connection, Transaction); } } #endregion else { #region delete var patientQuery = new ORM_HEC_Patient.Query(); patientQuery.IsDeleted = false; patientQuery.Tenant_RefID = securityTicket.TenantID; patientQuery.HEC_PatientID = Parameter.PatientID; var patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single(); patient.IsDeleted = true; patient.Save(Connection, Transaction); var businessParticipantBank_2_accountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query(); businessParticipantBank_2_accountQuery.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipantBank_2_accountQuery.IsDeleted = false; businessParticipantBank_2_accountQuery.Tenant_RefID = securityTicket.TenantID; var businessParticipantBank_2_account = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, businessParticipantBank_2_accountQuery).Single(); businessParticipantBank_2_account.IsDeleted = true; businessParticipantBank_2_account.Save(Connection, Transaction); var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query(); bankAccountQuery.IsDeleted = false; bankAccountQuery.Tenant_RefID = securityTicket.TenantID; bankAccountQuery.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID; var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).Single(); bankAccount.IsDeleted = true; bankAccount.Save(Connection, Transaction); var bankQuery = new ORM_ACC_BNK_Bank.Query(); bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID; bankQuery.IsDeleted = false; bankQuery.Tenant_RefID = securityTicket.TenantID; var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).Single(); bank.IsDeleted = true; bank.Save(Connection, Transaction); var healthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); healthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; healthInsuranceQuery.IsDeleted = false; healthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healthInsuranceQuery).Single(); healthInsurance.IsDeleted = true; healthInsurance.Save(Connection, Transaction); #endregion } return(returnValue); #endregion UserCode }