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_SMSAFP_1547 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 getPatientParam = new P_L6PA_GMSPfID_1538(); getPatientParam.HEC_PatientID = Parameter.HEC_PatientID; L6PA_GMSPfID_1538 patient = cls_Get_MS_Patients_For_ID.Invoke(Connection, Transaction, getPatientParam, securityTicket).Result; if (patient == null) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } ORM_CMN_PER_PersonInfo_2_Address.Query query = new ORM_CMN_PER_PersonInfo_2_Address.Query(); query.CMN_PER_PersonInfo_RefID = patient.CMN_PER_PersonInfoID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; var queryRes = ORM_CMN_PER_PersonInfo_2_Address.Query.Search(Connection, Transaction, query); ORM_CMN_Address address = new ORM_CMN_Address(); if (Parameter.CMN_AddressID != Guid.Empty) { var result = address.Load(Connection, Transaction, Parameter.CMN_AddressID); if (result.Status != FR_Status.Success || address.CMN_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.City_Name; address.City_PostalCode = Parameter.City_PostalCode; address.Province_Name = Parameter.Province_Name; address.Tenant_RefID = securityTicket.TenantID; address.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo_2_Address assignment = queryRes.FirstOrDefault(a => a.CMN_Address_RefID == Parameter.CMN_AddressID); if (assignment == null) { assignment = new ORM_CMN_PER_PersonInfo_2_Address(); assignment.CMN_Address_RefID = address.CMN_AddressID; assignment.CMN_PER_PersonInfo_RefID = patient.CMN_PER_PersonInfoID; assignment.Tenant_RefID = securityTicket.TenantID; if (queryRes.Count == 0) { assignment.IsPrimary = true; } assignment.SequenceNumber = queryRes.Count + 1; } assignment.Save(Connection, Transaction); returnValue.Result = address.CMN_AddressID; return(returnValue); #endregion UserCode }