protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_DMSP_1546 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L6PA_GMSPfID_1538 getParam = new P_L6PA_GMSPfID_1538(); getParam.HEC_PatientID = Parameter.HEC_PatientID; var patient = cls_Get_MS_Patients_For_ID.Invoke(Connection, Transaction, getParam, securityTicket).Result; if (patient != null) { if (patient.Addresses != null) { foreach (var address in patient.Addresses) { P_L6PA_MSVAFP_1545 delAddressPar = new P_L6PA_MSVAFP_1545(); delAddressPar.CMN_AddressID = address.CMN_AddressID; cls_Delete_MS_AddressForPatient.Invoke(Connection, Transaction, delAddressPar, securityTicket); } } if (patient.Contacts != null) { foreach (var contact in patient.Contacts) { ORM_CMN_PER_CommunicationContact.Query cQuery = new ORM_CMN_PER_CommunicationContact.Query(); cQuery.CMN_PER_CommunicationContactID = contact.CMN_PER_CommunicationContactID; cQuery.IsDeleted = false; cQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_CommunicationContact.Query.SoftDelete(Connection, Transaction, cQuery); } } ORM_CMN_PER_PersonInfo.Query ORM_CMN_PER_PersonInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); ORM_CMN_PER_PersonInfoQuery.CMN_PER_PersonInfoID = patient.CMN_PER_PersonInfoID; ORM_CMN_PER_PersonInfoQuery.IsDeleted = false; ORM_CMN_PER_PersonInfoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo.Query.SoftDelete(Connection, Transaction, ORM_CMN_PER_PersonInfoQuery); ORM_CMN_BPT_BusinessParticipant.Query ORM_CMN_BPT_BusinessParticipantoQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); ORM_CMN_BPT_BusinessParticipantoQuery.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipantID; ORM_CMN_BPT_BusinessParticipantoQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipantoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant.Query.SoftDelete(Connection, Transaction, ORM_CMN_BPT_BusinessParticipantoQuery); ORM_HEC_Patient.Query ORM_HEC_PatientQuery = new ORM_HEC_Patient.Query(); ORM_HEC_PatientQuery.HEC_PatientID = patient.HEC_PatientID; ORM_HEC_PatientQuery.IsDeleted = false; ORM_HEC_PatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient.Query.SoftDelete(Connection, Transaction, ORM_HEC_PatientQuery); ORM_HEC_Patient_HealthInsurance.Query ORM_HEC_Patient_HealthInsuranceoQuery = new ORM_HEC_Patient_HealthInsurance.Query(); ORM_HEC_Patient_HealthInsuranceoQuery.HEC_Patient_HealthInsurancesID = patient.HEC_Patient_HealthInsurancesID; ORM_HEC_Patient_HealthInsuranceoQuery.IsDeleted = false; ORM_HEC_Patient_HealthInsuranceoQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient_HealthInsurance.Query.SoftDelete(Connection, Transaction, ORM_HEC_Patient_HealthInsuranceoQuery); ORM_HEC_STU_Study_ParticipatingPatient.Query ORM_HEC_STU_Study_ParticipatingPatientQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); ORM_HEC_STU_Study_ParticipatingPatientQuery.HEC_STU_Study_ParticipatingPatientID = patient.HEC_STU_Study_ParticipatingPatientID; ORM_HEC_STU_Study_ParticipatingPatientQuery.IsDeleted = false; ORM_HEC_STU_Study_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_STU_Study_ParticipatingPatient.Query.SoftDelete(Connection, Transaction, ORM_HEC_STU_Study_ParticipatingPatientQuery); ORM_USR_Account.Query ORM_USR_AccountQuery = new ORM_USR_Account.Query(); ORM_USR_AccountQuery.IsDeleted = false; ORM_USR_AccountQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_AccountQuery.BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipantID; ORM_USR_Account.Query.SoftDelete(Connection, Transaction, ORM_USR_AccountQuery); var accountRes = ORM_USR_Account.Query.Search(Connection, Transaction, ORM_USR_AccountQuery); if (accountRes.Count == 1) { ORM_USR_Device_AccountCode.Query ORM_USR_Device_AccountCodeQuery = new ORM_USR_Device_AccountCode.Query(); ORM_USR_Device_AccountCodeQuery.IsDeleted = false; ORM_USR_Device_AccountCodeQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Device_AccountCodeQuery.Account_RefID = accountRes[0].USR_AccountID; } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SBBVP_1223 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); 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.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); returnValue.Result = patient.HEC_PatientID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SMSP_1548 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); 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.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); ORM_USR_Account account; ORM_USR_Account.Query ORM_USR_AccountQuery = new ORM_USR_Account.Query(); ORM_USR_AccountQuery.IsDeleted = false; ORM_USR_AccountQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_AccountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var accountRes = ORM_USR_Account.Query.Search(Connection, Transaction, ORM_USR_AccountQuery); if (accountRes.Count == 1) { account = accountRes[0]; } else { account = new ORM_USR_Account(); account.Tenant_RefID = securityTicket.TenantID; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.AccountType = 3; account.Save(Connection, Transaction); } ORM_USR_Device_AccountCode.Query ORM_USR_Device_AccountCodeQuery = new ORM_USR_Device_AccountCode.Query(); ORM_USR_Device_AccountCodeQuery.IsDeleted = false; ORM_USR_Device_AccountCodeQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Device_AccountCodeQuery.Account_RefID = account.USR_AccountID; var accountCodeRes = ORM_USR_Device_AccountCode.Query.Search(Connection, Transaction, ORM_USR_Device_AccountCodeQuery); if (accountCodeRes.Count == 0) { P_L2DC_GUDCfT_1505 codeParam = new P_L2DC_GUDCfT_1505(); codeParam.codeLength = 8; var checkCodeValue = cls_GetUniqueDeviceCodeForTenant.Invoke(Connection, Transaction, codeParam, securityTicket).Result; ORM_USR_Device_AccountCode_StatusHistory AccountCode_StatusHistory = new ORM_USR_Device_AccountCode_StatusHistory(); AccountCode_StatusHistory.Tenant_RefID = securityTicket.TenantID; AccountCode_StatusHistory.IsAccountCode_Active = true; AccountCode_StatusHistory.Save(Connection, Transaction); ORM_USR_Device_AccountCode devoceAccpimtCpde = new ORM_USR_Device_AccountCode(); devoceAccpimtCpde.Account_RefID = account.USR_AccountID; devoceAccpimtCpde.Tenant_RefID = securityTicket.TenantID; devoceAccpimtCpde.AccountCode_Value = checkCodeValue.CodeValue; devoceAccpimtCpde.IsAccountCode_Expirable = false; devoceAccpimtCpde.AccountCode_CurrentStatus_RefID = AccountCode_StatusHistory.USR_Device_AccountCode_StatusHistoryID; devoceAccpimtCpde.Save(Connection, Transaction); AccountCode_StatusHistory.Device_AccountCode_RefID = devoceAccpimtCpde.USR_Device_AccountCodeID; AccountCode_StatusHistory.Save(Connection, Transaction); } returnValue.Result = patient.HEC_PatientID; return(returnValue); #endregion UserCode }
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 }
protected static FR_L5PA_SP__1607 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SP__1607 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PA_SP__1607(); returnValue.Result = new L5PA_SP__1607(); ORM_HEC_Patient item = new ORM_HEC_Patient(); bool isOK = true; #region Save if (Parameter.IsEdit == false) { P_L5PA_CIPEIP_1213 healthInsuranceParam = new P_L5PA_CIPEIP_1213(); healthInsuranceParam.PracticeID = Parameter.PracticeID; healthInsuranceParam.HealthInsuranceNumber = Parameter.HealthInsuranceNumber; var hInsurance = cls_CheckIfPatientExistsInPractice.Invoke(Connection, Transaction, healthInsuranceParam, securityTicket).Result; //var healtInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); //healtInsuranceQuery.HealthInsurance_Number = Parameter.HealthInsuranceNumber; //healtInsuranceQuery.Tenant_RefID = securityTicket.TenantID; //healtInsuranceQuery.IsDeleted = false; //var hInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healtInsuranceQuery).FirstOrDefault(); if (hInsurance.numberofID == 0) { Guid patientID = Parameter.PatientID; Guid CMN_BPT_BusinessParticipantID = Guid.NewGuid(); item.HEC_PatientID = patientID; item.CMN_BPT_BusinessParticipant_RefID = CMN_BPT_BusinessParticipantID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); #region save CMN_BPT_BusinessParticipant ORM_CMN_BPT_BusinessParticipant bussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); bussinessParticipant.CMN_BPT_BusinessParticipantID = CMN_BPT_BusinessParticipantID; bussinessParticipant.DisplayName = Parameter.Name + Parameter.LastName; bussinessParticipant.IsNaturalPerson = true; bussinessParticipant.IsCompany = false; Guid NaturalPerson_CMN_PER_PersonInfoID = Guid.NewGuid(); bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = NaturalPerson_CMN_PER_PersonInfoID; bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.Empty; bussinessParticipant.IsTenant = false; bussinessParticipant.IfTenant_Tenant_RefID = Guid.Empty; bussinessParticipant.Tenant_RefID = securityTicket.TenantID; bussinessParticipant.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = NaturalPerson_CMN_PER_PersonInfoID; personInfo.FirstName = Parameter.Name; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.Birthdate; personInfo.Gender = Parameter.Gender; personInfo.ProfileImage_Document_RefID = Guid.Empty; personInfo.Modification_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); ORM_HEC_Patient_MedicalPractice medicalPractice = new ORM_HEC_Patient_MedicalPractice(); medicalPractice.HEC_Patient_MedicalPracticeID = Guid.NewGuid(); medicalPractice.HEC_Patient_RefID = patientID; medicalPractice.HEC_MedicalPractices_RefID = Parameter.PracticeID; medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance healtInsurance = new ORM_HEC_Patient_HealthInsurance(); healtInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid(); healtInsurance.HealthInsurance_Number = Parameter.HealthInsuranceNumber; healtInsurance.Patient_RefID = patientID; healtInsurance.HealthInsurance_State_RefID = Guid.Empty; healtInsurance.InsuranceStateCode = Parameter.InsuranceStateCode; healtInsurance.Tenant_RefID = securityTicket.TenantID; //TODO healtInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HealthInsuranceCompanyID; healtInsurance.Save(Connection, Transaction); #endregion } else { isOK = false; } } #endregion #region Edit else { var result = item.Load(Connection, Transaction, Parameter.PatientID); if (result.Status != FR_Status.Success || item.HEC_PatientID == Guid.Empty) { //var error = new FR_Guid(); //error.ErrorMessage = "No Such ID"; //error.Status = FR_Status.Error_Internal; //return error; } //bussinessParticipant var query1 = new ORM_CMN_BPT_BusinessParticipant.Query(); query1.CMN_BPT_BusinessParticipantID = item.CMN_BPT_BusinessParticipant_RefID; var bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query1).First(); //personInfo var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query2).FirstOrDefault(); //medicalPractice var query3 = new ORM_HEC_Patient_MedicalPractice.Query(); query3.HEC_Patient_RefID = Parameter.PatientID; var medicalPractice = ORM_HEC_Patient_MedicalPractice.Query.Search(Connection, Transaction, query3).First(); //healthInsurance var query4 = new ORM_HEC_Patient_HealthInsurance.Query(); query4.Patient_RefID = Parameter.PatientID; var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, query4).First(); #region Delete Patient if (Parameter.IsDeleted == true) { item.IsDeleted = true; item.Save(Connection, Transaction); } #endregion else { //edit person info personInfo.FirstName = Parameter.Name; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.Birthdate; personInfo.Gender = Parameter.Gender; personInfo.Save(Connection, Transaction); //edit medical practise medicalPractice.HEC_MedicalPractices_RefID = Parameter.PracticeID; medicalPractice.Save(Connection, Transaction); // health insurance healthInsurance.HealthInsurance_State_RefID = Guid.Empty; healthInsurance.InsuranceStateCode = Parameter.InsuranceStateCode; healthInsurance.HealthInsurance_Number = Parameter.HealthInsuranceNumber; //TODO healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HealthInsuranceCompanyID; healthInsurance.Save(Connection, Transaction); item.Save(Connection, Transaction); } } #endregion returnValue.Result.isOK = isOK; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_DBBVP_1711 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L6PA_GBBVPfID_1714 getParam = new P_L6PA_GBBVPfID_1714(); getParam.HEC_PatientID = Parameter.HEC_PatientID; var patient = cls_Get_BBV_Patients_For_ID.Invoke(Connection, Transaction, getParam, securityTicket).Result; if (patient != null) { if (patient.Addresses != null) { foreach (var address in patient.Addresses) { P_L6PA_DBBVAFP_1703 delAddressPar = new P_L6PA_DBBVAFP_1703(); delAddressPar.CMN_AddressID = address.CMN_AddressID; cls_Delete_BBV_AddressForPatient.Invoke(Connection, Transaction, delAddressPar, securityTicket); } } if (patient.Contacts != null) { foreach (var contact in patient.Contacts) { ORM_CMN_PER_CommunicationContact.Query cQuery = new ORM_CMN_PER_CommunicationContact.Query(); cQuery.CMN_PER_CommunicationContactID = contact.CMN_PER_CommunicationContactID; cQuery.IsDeleted = false; cQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_CommunicationContact.Query.SoftDelete(Connection, Transaction, cQuery); } } ORM_CMN_PER_PersonInfo.Query ORM_CMN_PER_PersonInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); ORM_CMN_PER_PersonInfoQuery.CMN_PER_PersonInfoID = patient.CMN_PER_PersonInfoID; ORM_CMN_PER_PersonInfoQuery.IsDeleted = false; ORM_CMN_PER_PersonInfoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo.Query.SoftDelete(Connection, Transaction, ORM_CMN_PER_PersonInfoQuery); ORM_CMN_BPT_BusinessParticipant.Query ORM_CMN_BPT_BusinessParticipantoQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); ORM_CMN_BPT_BusinessParticipantoQuery.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipantID; ORM_CMN_BPT_BusinessParticipantoQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipantoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant.Query.SoftDelete(Connection, Transaction, ORM_CMN_BPT_BusinessParticipantoQuery); ORM_HEC_Patient.Query ORM_HEC_PatientQuery = new ORM_HEC_Patient.Query(); ORM_HEC_PatientQuery.HEC_PatientID = patient.HEC_PatientID; ORM_HEC_PatientQuery.IsDeleted = false; ORM_HEC_PatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient.Query.SoftDelete(Connection, Transaction, ORM_HEC_PatientQuery); ORM_HEC_Patient_HealthInsurance.Query ORM_HEC_Patient_HealthInsuranceoQuery = new ORM_HEC_Patient_HealthInsurance.Query(); ORM_HEC_Patient_HealthInsuranceoQuery.HEC_Patient_HealthInsurancesID = patient.HEC_Patient_HealthInsurancesID; ORM_HEC_Patient_HealthInsuranceoQuery.IsDeleted = false; ORM_HEC_Patient_HealthInsuranceoQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient_HealthInsurance.Query.SoftDelete(Connection, Transaction, ORM_HEC_Patient_HealthInsuranceoQuery); ORM_HEC_STU_Study_ParticipatingPatient.Query ORM_HEC_STU_Study_ParticipatingPatientQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); ORM_HEC_STU_Study_ParticipatingPatientQuery.HEC_STU_Study_ParticipatingPatientID = patient.HEC_STU_Study_ParticipatingPatientID; ORM_HEC_STU_Study_ParticipatingPatientQuery.IsDeleted = false; ORM_HEC_STU_Study_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_STU_Study_ParticipatingPatient.Query.SoftDelete(Connection, Transaction, ORM_HEC_STU_Study_ParticipatingPatientQuery); var transactionsQuery = new ORM_HEC_Patient_Prescription_Transaction.Query(); transactionsQuery.PrescriptionTransaction_Patient_RefID = patient.HEC_PatientID; transactionsQuery.IsDeleted = false; ORM_HEC_Patient_Prescription_Transaction.Query.SoftDelete(Connection, Transaction, transactionsQuery); } return(returnValue); #endregion UserCode }