public static void RemofeFirstNameAndLastNameForTest(DbConnection Connection, DbTransaction Transaction, SessionSecurityTicket securityTicket) { var accountQuery = new ORM_USR_Account.Query(); accountQuery.IsDeleted = false; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.USR_AccountID = new Guid("5348559C-6256-4BBC-B7BF-DD80B63F9F03"); var account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).Single(); var businesParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businesParticipantQuery.CMN_BPT_BusinessParticipantID = account.BusinessParticipant_RefID; businesParticipantQuery.Tenant_RefID = securityTicket.TenantID; businesParticipantQuery.IsDeleted = false; var businesParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businesParticipantQuery).Single(); businesParticipant.DisplayName = string.Empty; businesParticipant.Save(Connection, Transaction); var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.CMN_PER_PersonInfoID = businesParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfoQuery.IsDead = false; personInfoQuery.Tenant_RefID = securityTicket.TenantID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).Single(); personInfo.FirstName = string.Empty; personInfo.LastName = string.Empty; personInfo.Save(Connection, Transaction); Console.WriteLine("Changed first name and last name. "); }
public static void AddACUserRoleToAccount(DbConnection Connection, DbTransaction Transaction, SessionSecurityTicket securityTicket) { //check if mm group exists var accountGroupQuery = new ORM_USR_Account_FunctionLevelRights_Group.Query(); accountGroupQuery.Tenant_RefID = securityTicket.TenantID; accountGroupQuery.IsDeleted = false; accountGroupQuery.GlobalPropertyMatchingID = Properties.Settings.Default.DocAppGroup; 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 = Properties.Settings.Default.DocAppGroup; accountGroup.GlobalPropertyMatchingID = Properties.Settings.Default.DocAppGroup; accountGroup.Creation_Timestamp = DateTime.Now; accountGroup.USR_Account_FunctionLevelRights_GroupID = Guid.NewGuid(); accountGroup.Save(Connection, Transaction); } var accountQuery = new ORM_USR_Account.Query(); accountQuery.IsDeleted = false; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.USR_AccountID = new Guid("D2310A2B-4587-4512-BA3A-48099B31B7C5"); var account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).Single(); 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 = account.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = Guid.NewGuid();// USR_Account_FunctionLevelRightID accountToFunctionLevelRight.Save(Connection, Transaction); ORM_USR_Account_FunctionLevelRight functionLevelRight = new ORM_USR_Account_FunctionLevelRight(); functionLevelRight.USR_Account_FunctionLevelRightID = accountToFunctionLevelRight.FunctionLevelRight_RefID; functionLevelRight.FunctionLevelRights_Group_RefID = accountGroup.USR_Account_FunctionLevelRights_GroupID; functionLevelRight.Tenant_RefID = securityTicket.TenantID; functionLevelRight.Creation_Timestamp = DateTime.Now; functionLevelRight.RightName = Properties.Settings.Default.ACDocAccountDocApp; functionLevelRight.GlobalPropertyMatchingID = Properties.Settings.Default.ACDocAccountDocApp; functionLevelRight.Save(Connection, Transaction); Console.WriteLine("Added ac doctor account role."); }
public static void AddRegularUserRoleToAccount(DbConnection Connection, DbTransaction Transaction, SessionSecurityTicket securityTicket) { //check if mm group exists var accountGroupQuery = new ORM_USR_Account_FunctionLevelRights_Group.Query(); accountGroupQuery.Tenant_RefID = securityTicket.TenantID; accountGroupQuery.IsDeleted = false; accountGroupQuery.GlobalPropertyMatchingID = Properties.Settings.Default.MMAppGroup; 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 = Properties.Settings.Default.MMAppGroup; accountGroup.GlobalPropertyMatchingID = Properties.Settings.Default.MMAppGroup; accountGroup.Creation_Timestamp = DateTime.Now; accountGroup.USR_Account_FunctionLevelRights_GroupID = Guid.NewGuid(); accountGroup.Save(Connection, Transaction); } var accountQuery = new ORM_USR_Account.Query(); accountQuery.IsDeleted = false; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.USR_AccountID = new Guid("5348559C-6256-4BBC-B7BF-DD80B63F9F03"); var account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).Single(); 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 = account.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = Guid.NewGuid();// USR_Account_FunctionLevelRightID accountToFunctionLevelRight.Save(Connection, Transaction); ORM_USR_Account_FunctionLevelRight functionLevelRight = new ORM_USR_Account_FunctionLevelRight(); functionLevelRight.USR_Account_FunctionLevelRightID = accountToFunctionLevelRight.FunctionLevelRight_RefID; functionLevelRight.FunctionLevelRights_Group_RefID = accountGroup.USR_Account_FunctionLevelRights_GroupID; functionLevelRight.Tenant_RefID = securityTicket.TenantID; functionLevelRight.Creation_Timestamp = DateTime.Now; functionLevelRight.RightName = Properties.Settings.Default.RegularAccountMMApp; functionLevelRight.GlobalPropertyMatchingID = Properties.Settings.Default.RegularAccountMMApp; functionLevelRight.Save(Connection, Transaction); Console.WriteLine("Added regular account role."); }
protected static FR_L5CA_GAGfSC_1456_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5CA_GAGfSC_1456 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5CA_GAGfSC_1456_Array(); ORM_CMN_PRO_SubscribedCatalog.Query query = new ORM_CMN_PRO_SubscribedCatalog.Query(); query.CMN_PRO_SubscribedCatalogID = Parameter.SubscribedCatalogID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; ORM_CMN_PRO_SubscribedCatalog subscribedCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, query).SingleOrDefault(); if (subscribedCatalog != null && subscribedCatalog.CMN_PRO_SubscribedCatalogID == Parameter.SubscribedCatalogID) { string matching = subscribedCatalog.IsCatalogPublic ? EnumUtils.GetEnumDescription(EProductGroup.ABDA) : EnumUtils.GetEnumDescription(EProductGroup.HauseList); ORM_USR_Account.Query query2 = new ORM_USR_Account.Query(); query2.USR_AccountID = securityTicket.AccountID; query2.Tenant_RefID = securityTicket.TenantID; query2.IsDeleted = false; ORM_USR_Account account = ORM_USR_Account.Query.Search(Connection, Transaction, query2).SingleOrDefault(); if (account != null && account.USR_AccountID == query2.USR_AccountID) { ORM_CMN_PRO_ProductGroup.Query query3 = new ORM_CMN_PRO_ProductGroup.Query(); query3.GlobalPropertyMatchingID = matching; //+ account.BusinessParticipant_RefID; query3.Tenant_RefID = securityTicket.TenantID; query3.IsDeleted = false; var productGroups = ORM_CMN_PRO_ProductGroup.Query.Search(Connection, Transaction, query3); returnValue.Result = productGroups.Select(x => new L5CA_GAGfSC_1456 { CMN_PRO_ProductGroupID = x.CMN_PRO_ProductGroupID, Parent_RefID = x.Parent_RefID, ProductGroup_Name = x.ProductGroup_Name, ProductGroup_Description = x.ProductGroup_Description } ).ToArray(); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CTPA_1225 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here var diagnose_details = cls_Get_Diagnose_Details_for_DiagnoseID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1608() { DiagnoseID = Parameter.diagnose_id }, securityTicket).Result; ORM_HEC_ACT_PlannedAction treatment_planned_action = null; if (Parameter.treatment_planned_action_id != Guid.Empty) { treatment_planned_action = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_ACT_PlannedActionID = Parameter.treatment_planned_action_id }).SingleOrDefault(); } if (treatment_planned_action == null) { treatment_planned_action = new ORM_HEC_ACT_PlannedAction(); treatment_planned_action.Creation_Timestamp = DateTime.Now; treatment_planned_action.HEC_ACT_PlannedActionID = Guid.NewGuid(); treatment_planned_action.IsPlannedFollowup = true; treatment_planned_action.IfPlannedFollowup_PreviousAction_RefID = Parameter.initial_performed_action_id; treatment_planned_action.IsPerformed = false; treatment_planned_action.MedicalPractice_RefID = Parameter.practice_id; treatment_planned_action.Modification_Timestamp = DateTime.Now; treatment_planned_action.Patient_RefID = Parameter.patient_id; treatment_planned_action.PlannedFor_Date = Parameter.treatment_date; treatment_planned_action.Tenant_RefID = securityTicket.TenantID; } if (Parameter.treatment_doctor_id != Guid.Empty) { var doctor_account_id = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDAIDfDID_1549() { DoctorID = Parameter.treatment_doctor_id }, securityTicket).Result.accountID; var doctor_accountQ = new ORM_USR_Account.Query(); doctor_accountQ.USR_AccountID = doctor_account_id; doctor_accountQ.Tenant_RefID = securityTicket.TenantID; doctor_accountQ.IsDeleted = false; var doctor_account = ORM_USR_Account.Query.Search(Connection, Transaction, doctor_accountQ).SingleOrDefault(); if (doctor_account != null) { treatment_planned_action.ToBePerformedBy_BusinessParticipant_RefID = doctor_account.BusinessParticipant_RefID; } } treatment_planned_action.Save(Connection, Transaction); returnValue.Result = treatment_planned_action.HEC_ACT_PlannedActionID; var treatment_planned_action_potential_procedure = ORM_HEC_ACT_PlannedAction_PotentialProcedure.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction_PotentialProcedure.Query() { PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID, PotentialProcedure_RefID = Parameter.intraocular_procedure_id, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (treatment_planned_action_potential_procedure == null) { treatment_planned_action_potential_procedure = new ORM_HEC_ACT_PlannedAction_PotentialProcedure(); treatment_planned_action_potential_procedure.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_potential_procedure.PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID; treatment_planned_action_potential_procedure.PotentialProcedure_RefID = Parameter.intraocular_procedure_id; } treatment_planned_action_potential_procedure.Modification_Timestamp = DateTime.Now; treatment_planned_action_potential_procedure.Save(Connection, Transaction); var treatment_planned_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); treatment_planned_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.treatment"; treatment_planned_action_typeQ.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_typeQ.IsDeleted = false; var treatment_planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, treatment_planned_action_typeQ).SingleOrDefault(); var treatment_planned_action_type_id = Guid.Empty; if (treatment_planned_action_type == null) { treatment_planned_action_type = new ORM_HEC_ACT_ActionType(); Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "behandlung" : "treatment"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } treatment_planned_action_type.ActionType_Name = action_type_name_dict; treatment_planned_action_type.Creation_Timestamp = DateTime.Now; treatment_planned_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.treatment"; treatment_planned_action_type.Modification_Timestamp = DateTime.Now; treatment_planned_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); treatment_planned_action_type.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_type.Save(Connection, Transaction); treatment_planned_action_type_id = treatment_planned_action_type.HEC_ACT_ActionTypeID; } else { treatment_planned_action_type_id = treatment_planned_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PlannedAction_2_ActionType treatment_planned_action_2_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); treatment_planned_action_2_type.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_2_type.Creation_Timestamp = DateTime.Now; treatment_planned_action_2_type.IsDeleted = false; treatment_planned_action_2_type.HEC_ACT_ActionType_RefID = treatment_planned_action_type_id; treatment_planned_action_2_type.HEC_ACT_PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID; treatment_planned_action_2_type.Modification_Timestamp = DateTime.Now; treatment_planned_action_2_type.HEC_ACT_PlannedAction_2_ActionTypeID = Guid.NewGuid(); treatment_planned_action_2_type.Save(Connection, Transaction); var treatment_planned_action_required_product = ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query() { BoundTo_HealthcareProcurementOrderPosition_RefID = Parameter.procurement_order_id, PlannedAction_PotentialProcedure_RefID = treatment_planned_action_potential_procedure.HEC_ACT_PlannedAction_PotentialProcedureID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (treatment_planned_action_required_product == null) { treatment_planned_action_required_product = new ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct(); treatment_planned_action_required_product.BoundTo_HealthcareProcurementOrderPosition_RefID = Parameter.procurement_order_id; treatment_planned_action_required_product.PlannedAction_PotentialProcedure_RefID = treatment_planned_action_potential_procedure.HEC_ACT_PlannedAction_PotentialProcedureID; treatment_planned_action_required_product.Tenant_RefID = securityTicket.TenantID; } treatment_planned_action_required_product.Modification_Timestamp = DateTime.Now; treatment_planned_action_required_product.HealthcareProduct_RefID = Parameter.drug_id; treatment_planned_action_required_product.Save(Connection, Transaction); #region DIAGNOSE if (Parameter.diagnose_id != Guid.Empty) { var patient_diagnosis = new ORM_HEC_Patient_Diagnosis(); patient_diagnosis.Creation_Timestamp = DateTime.Now; patient_diagnosis.HEC_Patient_DiagnosisID = Guid.NewGuid(); patient_diagnosis.Modification_Timestamp = DateTime.Now; patient_diagnosis.Patient_RefID = Parameter.patient_id; patient_diagnosis.R_IsConfirmed = Parameter.is_confirmed; patient_diagnosis.R_PotentialDiagnosis_RefID = Parameter.diagnose_id; patient_diagnosis.Tenant_RefID = securityTicket.TenantID; patient_diagnosis.Save(Connection, Transaction); ORM_HEC_DIA_Diagnosis_Localization diagnosis_localization = new ORM_HEC_DIA_Diagnosis_Localization(); diagnosis_localization.Creation_Timestamp = DateTime.Now; diagnosis_localization.Diagnosis_RefID = Parameter.diagnose_id; diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID = Guid.NewGuid(); diagnosis_localization.Modification_Timestamp = DateTime.Now; diagnosis_localization.Tenant_RefID = securityTicket.TenantID; diagnosis_localization.LocalizationCode = Parameter.diagnose_id == Guid.Empty ? "-" : Parameter.is_left_eye ? "L" : "R"; diagnosis_localization.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate initial_performed_action_diagnose = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); initial_performed_action_diagnose.Creation_Timestamp = DateTime.Now; initial_performed_action_diagnose.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); initial_performed_action_diagnose.HEC_ACT_PerformedAction_RefID = Parameter.initial_performed_action_id; initial_performed_action_diagnose.IsDiagnosisConfirmed = Parameter.is_confirmed; initial_performed_action_diagnose.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose.PotentialDiagnosis_RefID = Parameter.diagnose_id; initial_performed_action_diagnose.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose.HEC_Patient_Diagnosis_RefID = patient_diagnosis.HEC_Patient_DiagnosisID; initial_performed_action_diagnose.IM_PotentialDiagnosis_Code = diagnose_details.diagnose_icd_10; initial_performed_action_diagnose.IM_PotentialDiagnosis_Name = diagnose_details.diagnose_name; initial_performed_action_diagnose.IM_PotentialDiagnosisCatalog_Name = diagnose_details.catalog_display_name; initial_performed_action_diagnose.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization initial_performed_action_diagnose_localization = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization(); initial_performed_action_diagnose_localization.Creation_Timestamp = DateTime.Now; initial_performed_action_diagnose_localization.HEC_ACT_PerformedAction_DiagnosisUpdate_LocalizationID = Guid.NewGuid(); initial_performed_action_diagnose_localization.HEX_EXC_Action_DiagnosisUpdate_RefID = initial_performed_action_diagnose.HEC_ACT_PerformedAction_DiagnosisUpdateID; initial_performed_action_diagnose_localization.HEC_DIA_Diagnosis_Localization_RefID = diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID; initial_performed_action_diagnose_localization.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose_localization.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose_localization.IM_PotentialDiagnosisLocalization_Code = Parameter.diagnose_id == Guid.Empty ? "-" : Parameter.is_left_eye ? "L" : "R"; initial_performed_action_diagnose_localization.Save(Connection, Transaction); ORM_HEC_Patient_Diagnosis_Localization patient_diagnosis_localization = new ORM_HEC_Patient_Diagnosis_Localization(); patient_diagnosis_localization.Creation_Timestamp = DateTime.Now; patient_diagnosis_localization.DIA_Diagnosis_Localization_RefID = diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID; patient_diagnosis_localization.HEC_Patient_Diagnosis_LocalizationID = Guid.NewGuid(); patient_diagnosis_localization.Patient_Diagnosis_RefID = patient_diagnosis.HEC_Patient_DiagnosisID; patient_diagnosis_localization.Tenant_RefID = securityTicket.TenantID; patient_diagnosis_localization.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2NT_AN_1402 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var typeQuery = new ORM_USR_NOT_Notification_Type.Query(); typeQuery.IsDeleted = false; typeQuery.Tenant_RefID = securityTicket.TenantID; typeQuery.NotificationType_Key = Parameter.NotificationTypeKey; var typeRes = ORM_USR_NOT_Notification_Type.Query.Search(Connection, Transaction, typeQuery).ToArray(); ORM_USR_NOT_Notification_Type notificationType; if (typeRes == null || typeRes.Count() == 0) { notificationType = new ORM_USR_NOT_Notification_Type(); notificationType.NotificationType_Key = Parameter.NotificationTypeKey; notificationType.NotificationType_Label = Parameter.NotificationTypeLabel; notificationType.Tenant_RefID = securityTicket.TenantID; notificationType.USR_NOT_Notification_TypeID = Guid.NewGuid(); notificationType.Save(Connection, Transaction); } else { notificationType = typeRes.First(); } if (Parameter.IsSingleUser) { ORM_USR_NOT_Notification_Subscription notificationSbs = null; var sbsQuery = new ORM_USR_NOT_Notification_Subscription.Query(); sbsQuery.IsDeleted = false; sbsQuery.Tenant_RefID = securityTicket.TenantID; sbsQuery.Account_RefID = Parameter.IfSingleUser_AccountID; sbsQuery.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; var sbsRes = ORM_USR_NOT_Notification_Subscription.Query.Search(Connection, Transaction, sbsQuery).ToArray(); if (sbsRes != null && sbsRes.Count() > 0) { notificationSbs = sbsRes.First(); } else if (Parameter.IsSubscribableNotification) { notificationSbs = new ORM_USR_NOT_Notification_Subscription(); notificationSbs.USR_NOT_Notification_SubscriptionID = Guid.NewGuid(); notificationSbs.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; notificationSbs.Account_RefID = Parameter.IfSingleUser_AccountID; notificationSbs.Tenant_RefID = securityTicket.TenantID; notificationSbs.Save(Connection, Transaction); } if (notificationSbs != null) { var notification = new ORM_USR_NOT_Notification(); notification.USR_NOT_NotificationID = Guid.NewGuid(); notification.NotificationSubscription_RefID = notificationSbs.USR_NOT_Notification_SubscriptionID; notification.R_Account_RefID = notificationSbs.Account_RefID; notification.R_NotificationKey = notificationType.NotificationType_Key; notification.Notification_Link = Parameter.Notification_Link; notification.Notification_Text = Parameter.Notification_Text; notification.Tenant_RefID = securityTicket.TenantID; notification.Save(Connection, Transaction); } } else if (Parameter.IsMultiUser && Parameter.IfMultiUser_AccoundIDList != null) { foreach (Guid AccountID in Parameter.IfMultiUser_AccoundIDList) { ORM_USR_NOT_Notification_Subscription notificationSbs = null; var sbsQuery = new ORM_USR_NOT_Notification_Subscription.Query(); sbsQuery.IsDeleted = false; sbsQuery.Tenant_RefID = securityTicket.TenantID; sbsQuery.Account_RefID = AccountID; sbsQuery.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; var sbsRes = ORM_USR_NOT_Notification_Subscription.Query.Search(Connection, Transaction, sbsQuery).ToArray(); if (sbsRes != null && sbsRes.Count() > 0) { notificationSbs = sbsRes.First(); } else if (Parameter.IsSubscribableNotification) { notificationSbs = new ORM_USR_NOT_Notification_Subscription(); notificationSbs.USR_NOT_Notification_SubscriptionID = Guid.NewGuid(); notificationSbs.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; notificationSbs.Account_RefID = AccountID; notificationSbs.Tenant_RefID = securityTicket.TenantID; notificationSbs.Save(Connection, Transaction); } if (notificationSbs != null) { var notification = new ORM_USR_NOT_Notification(); notification.USR_NOT_NotificationID = Guid.NewGuid(); notification.NotificationSubscription_RefID = notificationSbs.USR_NOT_Notification_SubscriptionID; notification.R_Account_RefID = notificationSbs.Account_RefID; notification.R_NotificationKey = notificationType.NotificationType_Key; notification.Notification_Link = Parameter.Notification_Link; notification.Notification_Text = Parameter.Notification_Text; notification.Tenant_RefID = securityTicket.TenantID; notification.Save(Connection, Transaction); } } } else if (Parameter.IsTenant) { var accountQery = new ORM_USR_Account.Query(); accountQery.IsDeleted = false; accountQery.Tenant_RefID = securityTicket.TenantID; var accounts = ORM_USR_Account.Query.Search(Connection, Transaction, accountQery).ToArray(); if (accounts != null) { foreach (ORM_USR_Account account in accounts) { if (!Parameter.IfTenant_IsForMeAlso && account.USR_AccountID == securityTicket.AccountID) { continue; } ORM_USR_NOT_Notification_Subscription notificationSbs = null; var sbsQuery = new ORM_USR_NOT_Notification_Subscription.Query(); sbsQuery.IsDeleted = false; sbsQuery.Tenant_RefID = securityTicket.TenantID; sbsQuery.Account_RefID = account.USR_AccountID; sbsQuery.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; var sbsRes = ORM_USR_NOT_Notification_Subscription.Query.Search(Connection, Transaction, sbsQuery).ToArray(); if (sbsRes != null && sbsRes.Count() > 0) { notificationSbs = sbsRes.First(); } else if (Parameter.IsSubscribableNotification) { notificationSbs = new ORM_USR_NOT_Notification_Subscription(); notificationSbs.USR_NOT_Notification_SubscriptionID = Guid.NewGuid(); notificationSbs.NotificationType_RefID = notificationType.USR_NOT_Notification_TypeID; notificationSbs.Account_RefID = account.USR_AccountID; notificationSbs.Tenant_RefID = securityTicket.TenantID; notificationSbs.Save(Connection, Transaction); } if (notificationSbs != null) { var notification = new ORM_USR_NOT_Notification(); notification.USR_NOT_NotificationID = Guid.NewGuid(); notification.NotificationSubscription_RefID = notificationSbs.USR_NOT_Notification_SubscriptionID; notification.R_Account_RefID = notificationSbs.Account_RefID; notification.R_NotificationKey = notificationType.NotificationType_Key; notification.Notification_Link = Parameter.Notification_Link; notification.Notification_Text = Parameter.Notification_Text; notification.Tenant_RefID = securityTicket.TenantID; notification.Save(Connection, Transaction); } } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OD_SD_1130 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); Guid accounrRefID = Guid.Empty; var doctorQuery = new ORM_HEC_Doctor.Query(); ORM_HEC_Doctor doctor; if (Parameter.HEC_DoctorID != Guid.Empty) { doctorQuery.HEC_DoctorID = Parameter.HEC_DoctorID; doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First(); accounrRefID = doctor.Account_RefID; } P_L3MD_SDBI_1349 sbdParam = new P_L3MD_SDBI_1349(); sbdParam.DoctorID = Parameter.HEC_DoctorID; sbdParam.Account_RefID = accounrRefID; sbdParam.FirstName = Parameter.FirstName; sbdParam.LastName = Parameter.LastName; sbdParam.isOphthalSave = true; sbdParam.ifOphthal_Salutation_General = Parameter.Salutation_General; sbdParam.ifOphthal_Salutation_Letter = Parameter.Salutation_Letter; sbdParam.Title = Parameter.Title; List <P_L3MD_SDBI_1349_Contacts> contactsParams = new List <P_L3MD_SDBI_1349_Contacts>(); if (Parameter.Contacts != null) { foreach (var item in Parameter.Contacts) { var c = new P_L3MD_SDBI_1349_Contacts(); c.CMN_PER_CommunicationContact_TypeID = item.CMN_PER_CommunicationContact_TypeID; c.Content = item.Content; contactsParams.Add(c); } } sbdParam.Contacts = contactsParams.ToArray(); List <P_L3MD_SDBI_1349_Practice> practicesParams = new List <P_L3MD_SDBI_1349_Practice>(); if (Parameter.Practices != null) { foreach (var item in Parameter.Practices) { var p = new P_L3MD_SDBI_1349_Practice(); p.PracticeID = item.PracticeID; p.isDeleted = item.isDeleted; p.AssociatedParticipant_FunctionName = item.AssociatedParticipant_FunctionName; practicesParams.Add(p); } } sbdParam.Practices = practicesParams.ToArray(); var docID = cls_Save_Doctor_BaseInfo.Invoke(Connection, Transaction, sbdParam, securityTicket).Result; doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.HEC_DoctorID = docID; doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First(); var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.CMN_BPT_BusinessParticipantID = doctor.BusinessParticipant_RefID; var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).First(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative SalesRepresentative; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault(); if (customer == null) { customer = new ORM_CMN_BPT_CTM_Customer(); customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Tenant_RefID = securityTicket.TenantID; SalesRepresentative = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative(); SalesRepresentative.AssignmentID = Guid.NewGuid(); SalesRepresentative.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative.Tenant_RefID = securityTicket.TenantID; customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } else { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); var SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); SalesRepresentativeQuery.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, SalesRepresentativeQuery).First(); } SalesRepresentative.SalesRepresentative_RefID = Parameter.CMN_BPT_SalesRepresentativeID; var sRepresentativeQuery = new ORM_CMN_BPT_SalesRepresentative.Query(); sRepresentativeQuery.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID; sRepresentativeQuery.IsDeleted = false; var sRepresentative = ORM_CMN_BPT_SalesRepresentative.Query.Search(Connection, Transaction, sRepresentativeQuery).FirstOrDefault(); if (sRepresentative == null) { sRepresentative = new ORM_CMN_BPT_SalesRepresentative(); sRepresentative.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID; sRepresentative.Save(Connection, Transaction); } customer.Save(Connection, Transaction); SalesRepresentative.Save(Connection, Transaction); ORM_USR_Account account; ORM_USR_Device_AccountCode code; ORM_USR_Device_AccountCode_StatusHistory codeStatus; var accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; accountQuery.AccountType = 3; var accountQueryRes = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery); if (accountQueryRes.Count == 0) { account = new ORM_USR_Account(); account.USR_AccountID = Guid.NewGuid(); account.Tenant_RefID = securityTicket.TenantID; account.AccountType = 3; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.Save(Connection, Transaction); code = new ORM_USR_Device_AccountCode(); code.Tenant_RefID = securityTicket.TenantID; code.USR_Device_AccountCodeID = Guid.NewGuid(); code.Account_RefID = account.USR_AccountID; code.AccountCode_ValidFrom = DateTime.Now; codeStatus = new ORM_USR_Device_AccountCode_StatusHistory(); codeStatus.USR_Device_AccountCode_StatusHistoryID = Guid.NewGuid(); codeStatus.Device_AccountCode_RefID = code.USR_Device_AccountCodeID; codeStatus.Tenant_RefID = securityTicket.TenantID; codeStatus.IsAccountCode_Active = true; codeStatus.Save(Connection, Transaction); code.AccountCode_CurrentStatus_RefID = codeStatus.USR_Device_AccountCode_StatusHistoryID; L3DAC_GDACFTCV_1616 checkCodeValue; P_L3DAC_GDACFTCV_1616 codeParam = new P_L3DAC_GDACFTCV_1616(); string codeValue; do { codeValue = RandomString.Generate(8); codeParam.CodeValue = codeValue; checkCodeValue = cls_GetDeviceAccountCodeForTenantAndCodeValue.Invoke(Connection, Transaction, codeParam, securityTicket).Result; } while (checkCodeValue != null); code.AccountCode_Value = codeValue; code.Save(Connection, Transaction); } returnValue.Result = docID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CAPA_1237 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 ORM_HEC_ACT_PlannedAction aftercare_planned_action = new ORM_HEC_ACT_PlannedAction(); aftercare_planned_action.Creation_Timestamp = DateTime.Now; aftercare_planned_action.HEC_ACT_PlannedActionID = Guid.NewGuid(); aftercare_planned_action.IsPerformed = false; aftercare_planned_action.MedicalPractice_RefID = Parameter.practice_id; aftercare_planned_action.Modification_Timestamp = DateTime.Now; aftercare_planned_action.Patient_RefID = Parameter.patient_id; aftercare_planned_action.PlannedFor_Date = Parameter.treatment_date; aftercare_planned_action.Tenant_RefID = securityTicket.TenantID; Guid id = Guid.Empty; var aftercare_doctor_account = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDAIDfDID_1549() { DoctorID = Parameter.aftercare_doctor_practice_id }, securityTicket).Result; if (aftercare_doctor_account != null) { id = aftercare_doctor_account.accountID; } else { var aftercare_practice_account = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPAIDfPID_1522() { PracticeID = Parameter.aftercare_doctor_practice_id }, securityTicket).Result; if (aftercare_practice_account != null) { id = aftercare_practice_account.accountID; } } ORM_USR_Account.Query aftercare_accountQ = new ORM_USR_Account.Query(); aftercare_accountQ.USR_AccountID = id; aftercare_accountQ.Tenant_RefID = securityTicket.TenantID; aftercare_accountQ.IsDeleted = false; var aftercare_account = ORM_USR_Account.Query.Search(Connection, Transaction, aftercare_accountQ).SingleOrDefault(); if (aftercare_account != null) { aftercare_planned_action.ToBePerformedBy_BusinessParticipant_RefID = aftercare_account.BusinessParticipant_RefID; } aftercare_planned_action.Save(Connection, Transaction); ORM_HEC_CAS_Case_RelevantPlannedAction aftercare_planned_action_to_case = new ORM_HEC_CAS_Case_RelevantPlannedAction(); aftercare_planned_action_to_case.Case_RefID = Parameter.case_id; aftercare_planned_action_to_case.Creation_Timestamp = DateTime.Now; aftercare_planned_action_to_case.HEC_CAS_Case_RelevantPlannedActionID = Guid.NewGuid(); aftercare_planned_action_to_case.Modification_Timestamp = DateTime.Now; aftercare_planned_action_to_case.PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_to_case.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_to_case.Save(Connection, Transaction); ORM_HEC_ACT_ActionType.Query aftercare_planned_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); aftercare_planned_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_typeQ.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_typeQ.IsDeleted = false; var aftercare_planned_action_type_id = Guid.Empty; var aftercare_planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, aftercare_planned_action_typeQ).SingleOrDefault(); if (aftercare_planned_action_type == null) { aftercare_planned_action_type = new ORM_HEC_ACT_ActionType(); Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "nachsorge" : "aftercare"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } aftercare_planned_action_type.ActionType_Name = action_type_name_dict; aftercare_planned_action_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_type.Save(Connection, Transaction); aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } else { aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PlannedAction_2_ActionType aftercare_planned_action_2_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); aftercare_planned_action_2_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_2_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_2_type.IsDeleted = false; aftercare_planned_action_2_type.HEC_ACT_ActionType_RefID = aftercare_planned_action_type_id; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_2_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_2_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_2_type.Save(Connection, Transaction); returnValue.Result = aftercare_planned_action.HEC_ACT_PlannedActionID; return(returnValue); #endregion UserCode }
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_L6US_GAMDMDfAU_1317 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6US_GAMDMDfAU_1317(); //Put your code here L6US_GAMDMDfAU_1317 tempResult = new L6US_GAMDMDfAU_1317(); Guid ApplicationID = Guid.Parse(WebConfigurationManager.AppSettings["ApplicationID"].ToString()); List <L6US_GAMDMDfAU_1317a> tempUsers = new List <L6US_GAMDMDfAU_1317a>(); //Retrieve users ORM_USR_Account.Query userQuery = new ORM_USR_Account.Query(); userQuery.Tenant_RefID = securityTicket.TenantID; userQuery.IsDeleted = false; List <ORM_USR_Account> resultUsers = ORM_USR_Account.Query.Search(Connection, Transaction, userQuery); ORM_CMN_Account_ApplicationSubscription.Query appSubscriptionQuery = new ORM_CMN_Account_ApplicationSubscription.Query(); foreach (var currentUser in resultUsers) { L6US_GAMDMDfAU_1317a tempUser = new L6US_GAMDMDfAU_1317a(); appSubscriptionQuery.Account_RefID = currentUser.USR_AccountID; appSubscriptionQuery.IsDeleted = false; appSubscriptionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Account_ApplicationSubscription> tempSubscriptionResult = ORM_CMN_Account_ApplicationSubscription.Query.Search(Connection, Transaction, appSubscriptionQuery); if (tempSubscriptionResult != null && tempSubscriptionResult.Count > 0) { tempUser.User_IsSubscribed = tempSubscriptionResult.Exists(ts => ts.Application_RefID == ApplicationID && !ts.IsDisabled); } else { tempUser.User_IsSubscribed = false; } tempUsers.Add(tempUser); } tempResult.ActiveUsers = tempUsers.ToArray(); ORM_TMS_PRO_Project.Query projectsQuery = new ORM_TMS_PRO_Project.Query(); projectsQuery.Tenant_RefID = securityTicket.TenantID; projectsQuery.IsDeleted = false; projectsQuery.IsArchived = false; tempResult.ProjectsCount = ORM_TMS_PRO_Project.Query.Search(Connection, Transaction, projectsQuery).Count; ORM_TMS_QuickTask_Type.Query quickTaskQuery = new ORM_TMS_QuickTask_Type.Query(); quickTaskQuery.Tenant_RefID = securityTicket.TenantID; quickTaskQuery.IsDeleted = false; tempResult.WorkingTimeTypesCount = ORM_TMS_QuickTask_Type.Query.Search(Connection, Transaction, quickTaskQuery).Count; ORM_TMS_PRO_DeveloperTask_Priority.Query developerTaskPrioritiesQuery = new ORM_TMS_PRO_DeveloperTask_Priority.Query(); developerTaskPrioritiesQuery.Tenant_RefID = securityTicket.TenantID; developerTaskPrioritiesQuery.IsDeleted = false; tempResult.DeveloperTaskPrioritiesCount = ORM_TMS_PRO_DeveloperTask_Priority.Query.Search(Connection, Transaction, developerTaskPrioritiesQuery).Count; ORM_TMP_PRO_ProjectMember_Type.Query projectMemberTypeQuery = new ORM_TMP_PRO_ProjectMember_Type.Query(); projectMemberTypeQuery.Tenant_RefID = securityTicket.TenantID; projectMemberTypeQuery.IsDeleted = false; tempResult.ProjectMemberTypesCount = ORM_TMP_PRO_ProjectMember_Type.Query.Search(Connection, Transaction, projectMemberTypeQuery).Count; //ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query chargingLevelQuery = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query(); //chargingLevelQuery.Tenant_RefID = securityTicket.TenantID; //chargingLevelQuery.IsDeleted = false; //tempResult.PriceGradesCount = ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query.Search(Connection, Transaction, chargingLevelQuery).Count; tempResult.PriceGradesCount = cls_Get_PriceGrades_for_Tenant.Invoke(Connection, Transaction, securityTicket).Result.ToList().Count; tempResult.PlannedProjectsCount = 6; returnValue.Result = tempResult; 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_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3NT_SN_0921 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Base(); //Put your code here ORM_USR_Account noteCreatorAccount = new ORM_USR_Account(); noteCreatorAccount.Load(Connection, Transaction, Parameter.CreatorID); if (Parameter.ProjectNoteID != Guid.Empty) { if (Parameter.IsDeleted) { ORM_CMN_NoteRevision.Query noteRevisionsQuery = new ORM_CMN_NoteRevision.Query(); noteRevisionsQuery.Note_RefID = Parameter.NoteID; noteRevisionsQuery.IsDeleted = false; List <ORM_CMN_NoteRevision> existingRevisions = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, noteRevisionsQuery); if (existingRevisions.Count > 1) { existingRevisions = existingRevisions.Where(er => er.CMN_NoteRevisionID != Parameter.NoteRevisionID).OrderBy(er => er.Version).ToList(); noteRevisionsQuery.CMN_NoteRevisionID = Parameter.NoteRevisionID; ORM_CMN_NoteRevision.Query.SoftDelete(Connection, Transaction, noteRevisionsQuery); ORM_CMN_Note parentNote = new ORM_CMN_Note(); parentNote.Load(Connection, Transaction, Parameter.NoteID); parentNote.Current_NoteRevision_RefID = existingRevisions.Last().CMN_NoteRevisionID; parentNote.Save(Connection, Transaction); } else { ORM_CMN_Note.Query cmnNoteQuery = new ORM_CMN_Note.Query(); cmnNoteQuery.CMN_NoteID = Parameter.NoteID; ORM_CMN_Note.Query.SoftDelete(Connection, Transaction, cmnNoteQuery); ORM_TMS_PRO_Project_Notes.Query projectNotesQuery = new ORM_TMS_PRO_Project_Notes.Query(); projectNotesQuery.Ext_CMN_Note_RefID = Parameter.NoteID; ORM_TMS_PRO_Project_Notes.Query.SoftDelete(Connection, Transaction, projectNotesQuery); ORM_CMN_NoteRevision.Query.SoftDelete(Connection, Transaction, noteRevisionsQuery); ORM_TMS_PRO_Project_Note_Collaborators.Query notesCollaboratorQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); notesCollaboratorQuery.ProjectNote_RefID = Parameter.ProjectNoteID; ORM_TMS_PRO_Project_Note_Collaborators.Query.SoftDelete(Connection, Transaction, notesCollaboratorQuery); ORM_TMS_PRO_Project_Note_2_Tag.Query note2tagQuery = new ORM_TMS_PRO_Project_Note_2_Tag.Query(); note2tagQuery.Project_Note_RefID = Parameter.ProjectNoteID; ORM_TMS_PRO_Project_Note_2_Tag.Query.SoftDelete(Connection, Transaction, note2tagQuery); } } else { ORM_TMS_PRO_Project_Notes existingProjectNote = new ORM_TMS_PRO_Project_Notes(); existingProjectNote.Load(Connection, Transaction, Parameter.ProjectNoteID); ORM_CMN_NoteRevision existingNoteVersion = new ORM_CMN_NoteRevision(); existingNoteVersion.Load(Connection, Transaction, Parameter.NoteRevisionID); if (Parameter.SaveAsNewVersion) { ORM_CMN_NoteRevision.Query RevisionCountQuery = new ORM_CMN_NoteRevision.Query(); RevisionCountQuery.Note_RefID = Parameter.NoteID; ORM_CMN_NoteRevision newNoteVersion = new ORM_CMN_NoteRevision(); newNoteVersion.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newNoteVersion.Content = Parameter.Content; newNoteVersion.Note_RefID = Parameter.NoteID; newNoteVersion.Tenant_RefID = securityTicket.TenantID; newNoteVersion.Version = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, RevisionCountQuery).Count + 1; newNoteVersion.Title = Parameter.Title; newNoteVersion.Save(Connection, Transaction); if (Parameter.ReplaceCreator) { //Find current creator of note and make him a collaborator to this note ORM_USR_Account.Query currentCreatorQuery = new ORM_USR_Account.Query(); currentCreatorQuery.BusinessParticipant_RefID = existingNoteVersion.CreatedBy_BusinessParticipant_RefID; currentCreatorQuery.IsDeleted = false; currentCreatorQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Account currentCreator = ORM_USR_Account.Query.Search(Connection, Transaction, currentCreatorQuery).FirstOrDefault(); ORM_TMS_PRO_Project_Note_Collaborators.Query noteCollaboratorQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); noteCollaboratorQuery.ProjectNote_RefID = Parameter.ProjectNoteID; noteCollaboratorQuery.IsDeleted = false; noteCollaboratorQuery.Account_RefID = noteCreatorAccount.USR_AccountID; if (ORM_TMS_PRO_Project_Note_Collaborators.Query.Exists(Connection, Transaction, noteCollaboratorQuery)) { //If current creator was collaborator on existing note, delete him, because he has the role of creator now, and //old creator will be added to collaborators. ORM_TMS_PRO_Project_Note_Collaborators.Query.SoftDelete(Connection, Transaction, noteCollaboratorQuery); } ORM_TMS_PRO_Project_Note_Collaborators newNoteCollaborator = new ORM_TMS_PRO_Project_Note_Collaborators(); newNoteCollaborator.Account_RefID = currentCreator.USR_AccountID; newNoteCollaborator.ProjectNote_RefID = Parameter.ProjectNoteID; newNoteCollaborator.Tenant_RefID = securityTicket.TenantID; newNoteCollaborator.Save(Connection, Transaction); ORM_CMN_Note.Query cmnNoteCreatorUpdateFind = new ORM_CMN_Note.Query(); cmnNoteCreatorUpdateFind.CMN_NoteID = Parameter.NoteID; ORM_CMN_Note.Query cmnNoteCreatorUpdate = new ORM_CMN_Note.Query(); cmnNoteCreatorUpdate.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; ORM_CMN_Note.Query.Update(Connection, Transaction, cmnNoteCreatorUpdateFind, cmnNoteCreatorUpdate); } } else { existingNoteVersion.Content = Parameter.Content; existingNoteVersion.Title = Parameter.Title; existingNoteVersion.Save(Connection, Transaction); if (existingProjectNote.Project_RefID != Parameter.ProjectID) { existingProjectNote.Project_RefID = Parameter.ProjectID; existingProjectNote.Save(Connection, Transaction); } } //Update note tags (Delete existing ones and save new ones) P_L3TG_ATtN_1738 tagParameter = new P_L3TG_ATtN_1738(); tagParameter.ProjectNoteID = Parameter.ProjectNoteID; List <P_L3TG_ATtN_1738a> tagListParameter = new List <P_L3TG_ATtN_1738a>(); foreach (var currentTag in Parameter.Tags) { P_L3TG_ATtN_1738a tempTag = new P_L3TG_ATtN_1738a(); tempTag.TagValue = currentTag.TagValue; tempTag.TMS_PRO_TagID = currentTag.TagID; tagListParameter.Add(tempTag); } tagParameter.NoteTags = tagListParameter.ToArray(); cls_Add_Tags_to_Note.Invoke(Connection, Transaction, tagParameter, securityTicket); } } else { ORM_CMN_Note newCmnNote = new ORM_CMN_Note(); ORM_CMN_NoteRevision newNoteRevision = new ORM_CMN_NoteRevision(); ORM_TMS_PRO_Project_Notes newProjectNote = new ORM_TMS_PRO_Project_Notes(); newNoteRevision.Note_RefID = newCmnNote.CMN_NoteID; newNoteRevision.Content = Parameter.Content; newNoteRevision.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newNoteRevision.Tenant_RefID = securityTicket.TenantID; newNoteRevision.Title = Parameter.Title; newNoteRevision.Version = 1; newNoteRevision.Save(Connection, Transaction); newCmnNote.Current_NoteRevision_RefID = newNoteRevision.CMN_NoteRevisionID; newCmnNote.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newCmnNote.Tenant_RefID = securityTicket.TenantID; newCmnNote.Save(Connection, Transaction); newProjectNote.Ext_CMN_Note_RefID = newCmnNote.CMN_NoteID; newProjectNote.Project_RefID = Parameter.ProjectID; newProjectNote.Tenant_RefID = securityTicket.TenantID; newProjectNote.Save(Connection, Transaction); //Update note tags (Delete existing ones and save new ones) P_L3TG_ATtN_1738 tagParameter = new P_L3TG_ATtN_1738(); tagParameter.ProjectNoteID = newProjectNote.TMS_PRO_Project_NoteID; List <P_L3TG_ATtN_1738a> tagListParameter = new List <P_L3TG_ATtN_1738a>(); foreach (var currentTag in Parameter.Tags) { P_L3TG_ATtN_1738a tempTag = new P_L3TG_ATtN_1738a(); tempTag.TagValue = currentTag.TagValue; tempTag.TMS_PRO_TagID = currentTag.TagID; tagListParameter.Add(tempTag); } tagParameter.NoteTags = tagListParameter.ToArray(); cls_Add_Tags_to_Note.Invoke(Connection, Transaction, tagParameter, securityTicket); } return(returnValue); #endregion UserCode }
protected static FR_CAS_CDO_1202 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CDO_1202 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_CAS_CDO_1202(); returnValue.Result = new CAS_CDO_1202(); //Put your code here var statusCodePrefix = "MO"; var statusCode = 0; var drugOrderStatus = String.Format("{0}{1}", statusCodePrefix, statusCode); var hec_drugQ = new ORM_HEC_Product.Query(); hec_drugQ.Tenant_RefID = securityTicket.TenantID; hec_drugQ.IsDeleted = false; hec_drugQ.HEC_ProductID = Parameter.drug_id; var hec_drug = ORM_HEC_Product.Query.Search(Connection, Transaction, hec_drugQ).SingleOrDefault(); if (hec_drug != null) { var ord_drug_order_header = new ORM_ORD_PRC_ProcurementOrder_Header(); ord_drug_order_header.CreatedBy_BusinessParticipant_RefID = Parameter.created_by_bpt; ord_drug_order_header.ProcurementOrder_Date = DateTime.Now; ord_drug_order_header.Tenant_RefID = securityTicket.TenantID; ord_drug_order_header.ProcurementOrder_Number = cls_Get_Next_Order_Number.Invoke(Connection, Transaction, securityTicket).Result.order_number; returnValue.Result.procurement_order_header_id = ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID; var drug_order_status = new ORM_ORD_PRC_ProcurementOrder_Status(); drug_order_status.GlobalPropertyMatchingID = String.Format("mm.doc.connect.drug.order.status.{0}", drugOrderStatus.ToLower()); drug_order_status.Status_Code = statusCode; drug_order_status.Tenant_RefID = securityTicket.TenantID; drug_order_status.Status_Name = new Dict(ORM_ORD_PRC_ProcurementOrder_Status.TableName); foreach (var lang in Parameter.all_languagesL) { drug_order_status.Status_Name.AddEntry(lang.CMN_LanguageID, drugOrderStatus); } drug_order_status.Save(Connection, Transaction); ord_drug_order_header.Current_ProcurementOrderStatus_RefID = drug_order_status.ORD_PRC_ProcurementOrder_StatusID; ord_drug_order_header.Save(Connection, Transaction); var drug_order_status_history = new ORM_ORD_PRC_ProcurementOrder_StatusHistory(); drug_order_status_history.ProcurementOrder_Header_RefID = ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID; drug_order_status_history.ProcurementOrder_Status_RefID = drug_order_status.ORD_PRC_ProcurementOrder_StatusID; drug_order_status_history.Tenant_RefID = securityTicket.TenantID; drug_order_status_history.IsStatus_Created = true; drug_order_status_history.TriggeredAt_Date = DateTime.Now; drug_order_status_history.TriggeredBy_BusinessParticipant_RefID = Parameter.created_by_bpt; drug_order_status_history.Save(Connection, Transaction); var ord_drug_order_position = new ORM_ORD_PRC_ProcurementOrder_Position(); ord_drug_order_position.CMN_PRO_Product_RefID = hec_drug.Ext_PRO_Product_RefID; ord_drug_order_position.Position_RequestedDateOfDelivery = Parameter.delivery_date; ord_drug_order_position.ProcurementOrder_Header_RefID = ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID; ord_drug_order_position.Tenant_RefID = securityTicket.TenantID; ord_drug_order_position.RequestedDateOfDelivery_TimeFrame_From = Parameter.is_alternative_delivery_date ? Parameter.alternative_delivery_date_from : Parameter.treatment_date.AddHours(08).AddMinutes(00).AddSeconds(00); ord_drug_order_position.RequestedDateOfDelivery_TimeFrame_To = Parameter.is_alternative_delivery_date ? Parameter.alternative_delivery_date_to : Parameter.treatment_date.AddHours(17).AddMinutes(59).AddSeconds(59); ord_drug_order_position.IsProFormaOrderPosition = Parameter.is_label_only; ord_drug_order_position.Position_Comment = Parameter.order_comment; if (Parameter.is_send_invoice_to_practice) { var id = Guid.Empty; var practice_account = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPAIDfPID_1351() { PracticeID = Parameter.practice_id }, securityTicket).Result; if (practice_account != null) { id = practice_account.accountID; } var invoice_practice_accountQ = new ORM_USR_Account.Query(); invoice_practice_accountQ.USR_AccountID = id; invoice_practice_accountQ.Tenant_RefID = securityTicket.TenantID; invoice_practice_accountQ.IsDeleted = false; var invoice_practice_account = ORM_USR_Account.Query.Search(Connection, Transaction, invoice_practice_accountQ).SingleOrDefault(); if (invoice_practice_account != null) { ord_drug_order_position.BillTo_BusinessParticipant_RefID = invoice_practice_account.BusinessParticipant_RefID; } } ord_drug_order_position.Save(Connection, Transaction); var ord_drug_order_history = new ORM_ORD_PRC_ProcurementOrder_Position_History(); ord_drug_order_history.Creation_Timestamp = DateTime.Now; ord_drug_order_history.IsCreated = true; ord_drug_order_history.Modification_Timestamp = DateTime.Now; ord_drug_order_history.Tenant_RefID = securityTicket.TenantID; ord_drug_order_history.TriggeredBy_BusinessParticipant_RefID = Parameter.created_by_bpt; ord_drug_order_history.ProcurementOrder_Position_RefID = ord_drug_order_position.ORD_PRC_ProcurementOrder_PositionID; ord_drug_order_history.Save(Connection, Transaction); var hec_drug_order_position = new ORM_HEC_PRC_ProcurementOrder_Position(); hec_drug_order_position.Creation_Timestamp = DateTime.Now; hec_drug_order_position.Ext_ORD_PRC_ProcurementOrder_Position_RefID = ord_drug_order_position.ORD_PRC_ProcurementOrder_PositionID; hec_drug_order_position.Modification_Timestamp = DateTime.Now; hec_drug_order_position.OrderedFor_Patient_RefID = Parameter.patient_id; hec_drug_order_position.Tenant_RefID = securityTicket.TenantID; hec_drug_order_position.IfProFormaOrderPosition_PrintLabelOnly = Parameter.is_label_only; hec_drug_order_position.IsOrderForPatient_PatientFeeWaived = Parameter.is_patient_fee_waived; if (Parameter.treatment_doctor_id != Guid.Empty) { hec_drug_order_position.OrderedFor_Doctor_RefID = Parameter.treatment_doctor_id; hec_drug_order_position.OrderedForDoctor_DisplayName = GenericUtils.GetDoctorName(Parameter.treatment_doctor_details); } else { var doctor_id = cls_Get_DoctorID_for_AccountID.Invoke(Connection, Transaction, securityTicket).Result; if (doctor_id != null) { var doctor = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = doctor_id.DoctorID }, securityTicket).Result.SingleOrDefault(); if (doctor != null) { hec_drug_order_position.OrderedFor_Doctor_RefID = doctor.id; hec_drug_order_position.OrderedForDoctor_DisplayName = GenericUtils.GetDoctorName(doctor); } } } hec_drug_order_position.OrderedForPatient_DisplayName = Parameter.patient_details.patient_last_name + " " + Parameter.patient_details.patient_first_name; hec_drug_order_position.Save(Connection, Transaction); returnValue.Result.procurement_order_position_id = hec_drug_order_position.HEC_PRC_ProcurementOrder_PositionID; var practice_invoice_universal_property = ORM_HEC_CAS_Case_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case_UniversalProperty.Query() { GlobalPropertyMatchingID = "mm.doc.connect.case.practice.invoice", Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (practice_invoice_universal_property == null) { practice_invoice_universal_property = new ORM_HEC_CAS_Case_UniversalProperty(); practice_invoice_universal_property.Tenant_RefID = securityTicket.TenantID; practice_invoice_universal_property.PropertyName = "Send Invoice to Practice"; practice_invoice_universal_property.IsValue_Boolean = true; practice_invoice_universal_property.GlobalPropertyMatchingID = "mm.doc.connect.case.practice.invoice"; practice_invoice_universal_property.Modification_Timestamp = DateTime.Now; practice_invoice_universal_property.Save(Connection, Transaction); } var practice_invoice_universal_property_value = ORM_HEC_CAS_Case_UniversalPropertyValue.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case_UniversalPropertyValue.Query() { HEC_CAS_Case_RefID = Parameter.case_id, HEC_CAS_Case_UniversalProperty_RefID = practice_invoice_universal_property.HEC_CAS_Case_UniversalPropertyID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (practice_invoice_universal_property_value == null) { practice_invoice_universal_property_value = new ORM_HEC_CAS_Case_UniversalPropertyValue(); practice_invoice_universal_property_value.Tenant_RefID = securityTicket.TenantID; practice_invoice_universal_property_value.HEC_CAS_Case_RefID = Parameter.case_id; practice_invoice_universal_property_value.HEC_CAS_Case_UniversalProperty_RefID = practice_invoice_universal_property.HEC_CAS_Case_UniversalPropertyID; } practice_invoice_universal_property_value.Modification_Timestamp = DateTime.Now; practice_invoice_universal_property_value.Value_Boolean = Parameter.is_send_invoice_to_practice; practice_invoice_universal_property_value.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEFT_0959_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEFT_0959_Array(); List <L5EM_GEFT_0959> employeeResultList = new List <L5EM_GEFT_0959>(); ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery); foreach (var employeeItem in employeeList) { L5EM_GEFT_0959 result = new L5EM_GEFT_0959(); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, employeeItem.CMN_BPT_EMP_EmployeeID); result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.Staff_Number = employee.Staff_Number; result.StandardFunction = employee.StandardFunction; ORM_USR_Account.Query accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = employee.BusinessParticipant_RefID; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.IsDeleted = false; ORM_USR_Account account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).FirstOrDefault(); if (account != null) { result.USR_AccountID = account.USR_AccountID; } ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); result.CMN_BPT_BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; result.DisplayName = businessParticipant.DisplayName; ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); result.CMN_PER_PersonInfoID = personInfo.CMN_PER_PersonInfoID; result.FirstName = personInfo.FirstName; result.LastName = personInfo.LastName; result.PrimaryEmail = personInfo.PrimaryEmail; result.Title = personInfo.Title; result.ProfileImage_Document_RefID = personInfo.ProfileImage_Document_RefID; result.BirthDate = personInfo.BirthDate; ORM_CMN_BPT_EMP_EmploymentRelationship.Query workingContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query(); workingContractQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; workingContractQuery.IsDeleted = false; workingContractQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, workingContractQuery).FirstOrDefault(); result.CMN_BPT_EMP_EmploymentRelationshipID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; result.Work_StartDate = employmentRelationship.Work_StartDate; result.Work_EndDate = employmentRelationship.Work_EndDate; //Address if (personInfo.Address_RefID != Guid.Empty) { ORM_CMN_Address address = new ORM_CMN_Address(); address.Load(Connection, Transaction, personInfo.Address_RefID); result.CMN_AddressID = address.CMN_AddressID; result.Street_Name = address.Street_Name; result.Street_Number = address.Street_Number; result.City_AdministrativeDistrict = address.City_AdministrativeDistrict; result.City_Region = address.City_Region; result.City_Name = address.City_Name; result.City_PostalCode = address.City_PostalCode; result.Province_Name = address.Province_Name; result.Country_Name = address.Country_Name; result.Country_ISOCode = address.Country_ISOCode; } //Contacts ORM_CMN_PER_CommunicationContact.Query comunicationContactQuery = new ORM_CMN_PER_CommunicationContact.Query(); comunicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; comunicationContactQuery.Tenant_RefID = securityTicket.TenantID; comunicationContactQuery.IsDeleted = false; List <ORM_CMN_PER_CommunicationContact> comunicationContacts = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, comunicationContactQuery); List <L5EM_GEFT_0959_Contacts> resultComunicationContacts = new List <L5EM_GEFT_0959_Contacts>(); foreach (var comunicationContact in comunicationContacts) { ORM_CMN_PER_CommunicationContact_Type contactType = new ORM_CMN_PER_CommunicationContact_Type(); contactType.Load(Connection, Transaction, comunicationContact.CMN_PER_CommunicationContactID); L5EM_GEFT_0959_Contacts resultComunicationContact = new L5EM_GEFT_0959_Contacts(); resultComunicationContact.CMN_PER_CommunicationContact_TypeID = contactType.CMN_PER_CommunicationContact_TypeID; resultComunicationContact.CMN_PER_CommunicationContactID = comunicationContact.CMN_PER_CommunicationContactID; resultComunicationContact.Content = comunicationContact.Content; resultComunicationContact.Type = contactType.Type; resultComunicationContacts.Add(resultComunicationContact); } result.Contacts = resultComunicationContacts.ToArray(); //Employee workplace history ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID; employeeWorkplaceAssignmentsQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery); List <L5EM_GEFT_0959_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEFT_0959_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GEFT_0959_EmployeeWorkplaceHistory item = new L5EM_GEFT_0959_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); //Contracts ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query contractTermQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); contractTermQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; contractTermQuery.IsDeleted = false; contractTermQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> contracts = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, contractTermQuery); List <L5EM_GEFT_0959_WorkingContracts> resultContracts = new List <L5EM_GEFT_0959_WorkingContracts>(); foreach (var contractToRelationship in contracts) { L5EM_GEFT_0959_WorkingContracts resultContract = new L5EM_GEFT_0959_WorkingContracts(); ORM_CMN_BPT_EMP_WorkingContract workingContract = new ORM_CMN_BPT_EMP_WorkingContract(); workingContract.Load(Connection, Transaction, contractToRelationship.WorkingContract_RefID); if (!workingContract.IsDeleted) { resultContract.CMN_BPT_EMP_WorkingContractID = workingContract.CMN_BPT_EMP_WorkingContractID; resultContract.EmploymentRelationshipToWorkingContractAssignmentID = contractToRelationship.AssignmentID; resultContract.IsWorkingContract_Active = contractToRelationship.IsContract_Active; resultContract.Contract_StartDate = workingContract.Contract_StartDate; resultContract.Contract_EndDate = workingContract.Contract_EndDate; resultContract.IsContractEndDateDefined = workingContract.IsContractEndDateDefined; resultContract.IsWorkTimeCalculated_InDays = workingContract.IsWorkTimeCalculated_InDays; resultContract.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours; resultContract.R_WorkTime_DaysPerWeek = workingContract.R_WorkTime_DaysPerWeek; resultContract.R_WorkTime_HoursPerWeek = workingContract.R_WorkTime_HoursPerWeek; //Office hours ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractTermToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query(); workingContractTermToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContract.CMN_BPT_EMP_WorkingContractID; workingContractTermToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID; workingContractTermToWorkingDayQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractTermToWorkingDayQuery); List <L5EM_GEFT_0959_WeeklyOfficeHours> resultWeeklyOfficeHours = new List <L5EM_GEFT_0959_WeeklyOfficeHours>(); foreach (var workingDayAssigment in workingDayAssigments) { ORM_CMN_CAL_WeeklyOfficeHours_Interval interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval(); interval.Load(Connection, Transaction, workingDayAssigment.CMN_CAL_WeeklyOfficeHours_Interval_RefID); L5EM_GEFT_0959_WeeklyOfficeHours resultOfficeHour = new L5EM_GEFT_0959_WeeklyOfficeHours(); resultOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = interval.CMN_CAL_WeeklyOfficeHours_IntervalID; resultOfficeHour.IsFriday = interval.IsFriday; resultOfficeHour.IsMonday = interval.IsMonday; resultOfficeHour.IsSaturday = interval.IsSaturday; resultOfficeHour.IsSunday = interval.IsSunday; resultOfficeHour.IsThursday = interval.IsThursday; resultOfficeHour.IsTuesday = interval.IsTuesday; resultOfficeHour.IsWednesday = interval.IsWednesday; resultOfficeHour.IsWholeDay = interval.IsWholeDay; resultOfficeHour.TimeFrom_InMinutes = interval.TimeFrom_InMinutes; resultOfficeHour.TimeTo_InMinutes = interval.TimeTo_InMinutes; resultWeeklyOfficeHours.Add(resultOfficeHour); } resultContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray(); //Allowed absence reasons ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query(); AllowedAbsenceReasonQuery.WorkingContract_RefID = resultContract.CMN_BPT_EMP_WorkingContractID; AllowedAbsenceReasonQuery.Tenant_RefID = securityTicket.TenantID; AllowedAbsenceReasonQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason> allowedAbsenceReasons = ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query.Search(Connection, Transaction, AllowedAbsenceReasonQuery); List <L5EM_GEFT_0959_WorkingContractToLeaveRequest> resultAllowedAbsenceReasons = new List <L5EM_GEFT_0959_WorkingContractToLeaveRequest>(); foreach (var allowedAbsenceReason in allowedAbsenceReasons) { ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason(); absenceReason.Load(Connection, Transaction, allowedAbsenceReason.STA_AbsenceReason_RefID); L5EM_GEFT_0959_WorkingContractToLeaveRequest resultReasonresultReason = new L5EM_GEFT_0959_WorkingContractToLeaveRequest(); resultReasonresultReason.CMN_BPT_EMP_Employee_WorkingContract_AllowedAbsenceReasonID = allowedAbsenceReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID; resultReasonresultReason.STA_AbsenceReason_RefID = absenceReason.CMN_BPT_STA_AbsenceReasonID; resultReasonresultReason.IsAbsenceCalculated_InDays = allowedAbsenceReason.IsAbsenceCalculated_InDays; resultReasonresultReason.IsAbsenceCalculated_InHours = allowedAbsenceReason.IsAbsenceCalculated_InHours; resultReasonresultReason.ContractAllowedAbsence_per_Month = allowedAbsenceReason.ContractAllowedAbsence_per_Month; resultAllowedAbsenceReasons.Add(resultReasonresultReason); } resultContract.WorkingContractToLeaveRequest = resultAllowedAbsenceReasons.ToArray(); resultContracts.Add(resultContract); } } result.WorkingContracts = resultContracts.ToArray(); employeeResultList.Add(result); } returnValue.Result = employeeResultList.ToArray(); //Put your code here return(returnValue); #endregion UserCode }
protected static FR_CAS_SPE_1805 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_SPE_1805 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_CAS_SPE_1805(); returnValue.Result = new CAS_SPE_1805(); //Put your code here var case_id = Parameter.case_id; #region DATA var patient_details = cls_Get_Patient_Details_for_PatientID.Invoke(Connection, Transaction, new P_P_PA_GPDfPID_1124() { PatientID = Parameter.patient_id }, securityTicket).Result; if (patient_details == null) { throw new Exception("Patient details not found for ID: " + Parameter.patient_id); } var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, new ORM_HEC_Doctor.Query() { Tenant_RefID = securityTicket.TenantID, HEC_DoctorID = Parameter.doctor_id, IsDeleted = false }).SingleOrDefault(); if (doctor == null) { throw new Exception("Doctor not found for ID: " + Parameter.doctor_id); } var doctor_details = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823() { DoctorID = Parameter.doctor_id }, securityTicket).Result.FirstOrDefault(); if (doctor_details == null) { throw new Exception("Doctor details not found for ID: " + Parameter.doctor_id); } var practice_details = cls_Get_Practice_Details_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPDfPID_1432() { PracticeID = doctor_details.practice_id }, securityTicket).Result.FirstOrDefault(); if (practice_details == null) { throw new Exception("Practice details not found for ID: " + doctor_details.practice_id); } var shouldDownloadReportProperty = cls_Get_Practice_PropertyValue_for_PropertyName_and_PracticeID.Invoke(Connection, Transaction, new P_DO_GPPVfPNaPID_0916() { PracticeID = doctor_details.practice_id, PropertyName = "Download Report Upon Submission" }, securityTicket).Result; var shouldDownloadReport = shouldDownloadReportProperty == null ? false : shouldDownloadReportProperty.BooleanValue; ORM_USR_Account.Query trigger_accQ = new ORM_USR_Account.Query(); trigger_accQ.Tenant_RefID = securityTicket.TenantID; trigger_accQ.USR_AccountID = securityTicket.AccountID; trigger_accQ.IsDeleted = false; ORM_USR_Account trigger_acc = ORM_USR_Account.Query.Search(Connection, Transaction, trigger_accQ).Single(); ORM_CMN_Language.Query all_languagesQ = new ORM_CMN_Language.Query(); all_languagesQ.Tenant_RefID = securityTicket.TenantID; all_languagesQ.IsDeleted = false; var all_languagesL = ORM_CMN_Language.Query.Search(Connection, Transaction, all_languagesQ).ToArray(); var intraocular_procedure_id = Guid.Empty; #endregion if (!Parameter.isResubmit) { #region NEW CASE ORM_HEC_CAS_Case new_case = new ORM_HEC_CAS_Case(); new_case.HEC_CAS_CaseID = Guid.NewGuid(); new_case.Creation_Timestamp = DateTime.Now; new_case.CreatedBy_BusinessParticipant_RefID = trigger_acc.BusinessParticipant_RefID; new_case.Patient_RefID = Parameter.patient_id; new_case.Patient_FirstName = patient_details.patient_first_name; new_case.Patient_LastName = patient_details.patient_last_name; new_case.Patient_Gender = patient_details.gender; new_case.Patient_BirthDate = patient_details.birthday; new_case.CaseNumber = cls_Get_Next_Case_Number.Invoke(Connection, Transaction, securityTicket).Result.case_number; new_case.Modification_Timestamp = DateTime.Now; DateTime today = DateTime.Today; int age = today.Year - patient_details.birthday.Year; if (patient_details.birthday > today.AddYears(-age)) { age--; } new_case.Patient_Age = age; new_case.Tenant_RefID = securityTicket.TenantID; new_case.Save(Connection, Transaction); case_id = new_case.HEC_CAS_CaseID; #endregion NEW CASE #region INITIAL PERFORMED ACTION var initial_performed_action_id = cls_Create_Initial_Performed_Action.Invoke(Connection, Transaction, new P_CAS_CIPA_1140() { all_languagesL = all_languagesL, case_id = new_case.HEC_CAS_CaseID, created_by_bpt = trigger_acc.BusinessParticipant_RefID, patient_id = Parameter.patient_id, practice_id = doctor_details.practice_id, action_type_gpmid = "mm.docconect.doc.app.performed.action.preexamination" }, securityTicket).Result; #endregion INITIAL PERFORMED ACTION #region LOCALIZATION ORM_HEC_DIA_Diagnosis_Localization diagnosis_localization = new ORM_HEC_DIA_Diagnosis_Localization(); diagnosis_localization.Modification_Timestamp = DateTime.Now; diagnosis_localization.Tenant_RefID = securityTicket.TenantID; diagnosis_localization.LocalizationCode = Parameter.localization; diagnosis_localization.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate initial_performed_action_diagnose = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); initial_performed_action_diagnose.HEC_ACT_PerformedAction_RefID = initial_performed_action_id; initial_performed_action_diagnose.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization initial_performed_action_diagnose_localization = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization(); initial_performed_action_diagnose_localization.HEX_EXC_Action_DiagnosisUpdate_RefID = initial_performed_action_diagnose.HEC_ACT_PerformedAction_DiagnosisUpdateID; initial_performed_action_diagnose_localization.HEC_DIA_Diagnosis_Localization_RefID = diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID; initial_performed_action_diagnose_localization.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose_localization.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose_localization.IM_PotentialDiagnosisLocalization_Code = Parameter.localization; initial_performed_action_diagnose_localization.Save(Connection, Transaction); #endregion #region PLANNED ACTION var action_gpmid = "mm.docconect.doc.app.planned.action.preexamination"; var planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, new ORM_HEC_ACT_ActionType.Query() { GlobalPropertyMatchingID = action_gpmid, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (planned_action_type == null) { planned_action_type = new ORM_HEC_ACT_ActionType(); planned_action_type.GlobalPropertyMatchingID = action_gpmid; planned_action_type.Modification_Timestamp = DateTime.Now; planned_action_type.Tenant_RefID = securityTicket.TenantID; planned_action_type.Save(Connection, Transaction); } // circular reference to same performed action in order to be compatible with treatment planned actions, // so that it can be accessed in the same way var preexamination_planned_action = new ORM_HEC_ACT_PlannedAction(); preexamination_planned_action.IfPlannedFollowup_PreviousAction_RefID = initial_performed_action_id; preexamination_planned_action.IsPerformed = true; preexamination_planned_action.IfPerformed_PerformedAction_RefID = initial_performed_action_id; preexamination_planned_action.MedicalPractice_RefID = doctor_details.practice_id; preexamination_planned_action.Modification_Timestamp = DateTime.Now; preexamination_planned_action.Patient_RefID = Parameter.patient_id; preexamination_planned_action.PlannedFor_Date = Parameter.date; preexamination_planned_action.ToBePerformedBy_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; preexamination_planned_action.Tenant_RefID = securityTicket.TenantID; preexamination_planned_action.Save(Connection, Transaction); var action_to_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); action_to_type.HEC_ACT_ActionType_RefID = planned_action_type.HEC_ACT_ActionTypeID; action_to_type.HEC_ACT_PlannedAction_RefID = preexamination_planned_action.HEC_ACT_PlannedActionID; action_to_type.Modification_Timestamp = DateTime.Now; action_to_type.Tenant_RefID = securityTicket.TenantID; action_to_type.Save(Connection, Transaction); #endregion #region GPOS var patient_consent = ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query.Search(Connection, Transaction, new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query() { Patient_RefID = Parameter.patient_id, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Where(t => { var ctrParameter = cls_Get_Contract_Parameter_Value_for_InsuranceToBrokerContractID.Invoke(Connection, Transaction, new P_MD_GCPVfITBCID_1647() { ParameterName = "Duration of participation consent – Month", InsuranceToBrokerContractID = t.InsuranceToBrokerContract_RefID }, securityTicket).Result; var validThrough = ctrParameter == null || ctrParameter.ConsentValidForMonths == double.MaxValue ? DateTime.MaxValue : t.ValidFrom.AddMonths(Convert.ToInt32(ctrParameter.ConsentValidForMonths)); return(t.ValidFrom <= Parameter.date && validThrough >= Parameter.date); }).OrderBy(t => t.ValidFrom).FirstOrDefault(); if (patient_consent == null) { throw new Exception("No patients consents found for selected date: " + Parameter.date.ToString("dd.MM.yyyy") + " and patient id: " + Parameter.patient_id); } var gpos_gpmid = "mm.docconnect.gpos.catalog.voruntersuchung"; var preexamination_gpos_catalog = ORM_HEC_BIL_PotentialCode_Catalog.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_Catalog.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, GlobalPropertyMatchingID = gpos_gpmid }).SingleOrDefault(); if (preexamination_gpos_catalog == null) { throw new Exception("Preexamination catalog not found."); } var gpos_connections_to_drugs = ORM_HEC_BIL_PotentialCode_2_HealthcareProduct.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_2_HealthcareProduct.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).GroupBy(t => t.HEC_BIL_PotentialCode_RefID); var gpos_connections_to_diagnoses = ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).GroupBy(t => t.HEC_BIL_PotentialCode_RefID); var preexamination_gposes = ORM_HEC_BIL_PotentialCode.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, PotentialCode_Catalog_RefID = preexamination_gpos_catalog.HEC_BIL_PotentialCode_CatalogID }); var covered_gposes = ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query.Search(Connection, Transaction, new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, InsuranceToBrokerContract_RefID = patient_consent.InsuranceToBrokerContract_RefID }); preexamination_gposes = preexamination_gposes.Where(t => covered_gposes.Any(c => c.PotentialBillCode_RefID == t.HEC_BIL_PotentialCodeID)).ToList(); var bill_header = new ORM_BIL_BillHeader(); bill_header.Modification_Timestamp = DateTime.Now; bill_header.Tenant_RefID = securityTicket.TenantID; foreach (var gpos in preexamination_gposes) { if (!gpos_connections_to_diagnoses.Any(t => t.Key == gpos.HEC_BIL_PotentialCodeID) && !gpos_connections_to_drugs.Any(t => t.Key == gpos.HEC_BIL_PotentialCodeID)) { var price_value = ORM_CMN_Price_Value.Query.Search(Connection, Transaction, new ORM_CMN_Price_Value.Query() { Price_RefID = gpos.Price_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (price_value == null) { throw new Exception("Price value not found for GPOS: " + gpos.BillingCode); } ORM_BIL_BillPosition gpos_position = new ORM_BIL_BillPosition(); gpos_position.BIL_BilHeader_RefID = bill_header.BIL_BillHeaderID; gpos_position.Modification_Timestamp = DateTime.Now; gpos_position.Tenant_RefID = securityTicket.TenantID; gpos_position.PositionValue_IncludingTax = Convert.ToDecimal(price_value.PriceValue_Amount); gpos_position.PositionNumber = cls_Get_Next_Bill_Position_Number.Invoke(Connection, Transaction, securityTicket).Result.bill_position_number; gpos_position.Save(Connection, Transaction); ORM_BIL_BillPosition_TransmitionStatus fs_status = new ORM_BIL_BillPosition_TransmitionStatus(); fs_status.BillPosition_RefID = gpos_position.BIL_BillPositionID; fs_status.IsActive = true; fs_status.Modification_Timestamp = DateTime.Now; fs_status.Tenant_RefID = securityTicket.TenantID; fs_status.TransmitionCode = 1; fs_status.TransmitionStatusKey = "preexamination"; fs_status.TransmittedOnDate = DateTime.Now; fs_status.Save(Connection, Transaction); ORM_HEC_BIL_BillPosition hec_gpos_position = new ORM_HEC_BIL_BillPosition(); hec_gpos_position.Ext_BIL_BillPosition_RefID = gpos_position.BIL_BillPositionID; hec_gpos_position.Modification_Timestamp = DateTime.Now; hec_gpos_position.Tenant_RefID = securityTicket.TenantID; hec_gpos_position.PositionFor_Patient_RefID = Parameter.patient_id; hec_gpos_position.Save(Connection, Transaction); ORM_HEC_BIL_BillPosition_BillCode hec_gpos_position_code = new ORM_HEC_BIL_BillPosition_BillCode(); hec_gpos_position_code.BillPosition_RefID = hec_gpos_position.HEC_BIL_BillPositionID; hec_gpos_position_code.IM_BillingCode = gpos.BillingCode; hec_gpos_position_code.Modification_Timestamp = DateTime.Now; hec_gpos_position_code.PotentialCode_RefID = gpos.HEC_BIL_PotentialCodeID; hec_gpos_position_code.Tenant_RefID = securityTicket.TenantID; hec_gpos_position_code.Save(Connection, Transaction); ORM_HEC_CAS_Case_BillCode hec_gpos_case_code = new ORM_HEC_CAS_Case_BillCode(); hec_gpos_case_code.HEC_BIL_BillPosition_BillCode_RefID = hec_gpos_position_code.HEC_BIL_BillPosition_BillCodeID; hec_gpos_case_code.HEC_CAS_Case_RefID = new_case.HEC_CAS_CaseID; hec_gpos_case_code.Modification_Timestamp = DateTime.Now; hec_gpos_case_code.Tenant_RefID = securityTicket.TenantID; hec_gpos_case_code.Save(Connection, Transaction); ORM_BIL_BillPosition_PropertyValue gpos_management_fee_property_value = new ORM_BIL_BillPosition_PropertyValue(); gpos_management_fee_property_value.BIL_BillPosition_RefID = gpos_position.BIL_BillPositionID; gpos_management_fee_property_value.BIL_BillPosition_PropertyValueID = Guid.NewGuid(); gpos_management_fee_property_value.Creation_Timestamp = DateTime.Now; gpos_management_fee_property_value.Modification_Timestamp = DateTime.Now; gpos_management_fee_property_value.PropertyKey = "mm.doc.connect.management.fee"; gpos_management_fee_property_value.PropertyValue = "waived"; gpos_management_fee_property_value.Tenant_RefID = securityTicket.TenantID; gpos_management_fee_property_value.Save(Connection, Transaction); bill_header.TotalValue_IncludingTax += Convert.ToDecimal(price_value.PriceValue_Amount); } } bill_header.Save(Connection, Transaction); #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CC_1641 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 var case_to_cancel = cls_Get_Case_Details_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GCDfCID_1435() { CaseID = Parameter.case_id }, securityTicket).Result; returnValue.Result = case_to_cancel.patient_id; var drug_order_details = cls_Get_DrugOrderIDs_for_PlannedActionID.Invoke(Connection, Transaction, new P_CAS_GDOIDsfPAID_1243() { PlannedActionID = case_to_cancel.treatment_planned_action_id }, securityTicket).Result; var all_languagesQ = new ORM_CMN_Language.Query(); all_languagesQ.Tenant_RefID = securityTicket.TenantID; all_languagesQ.IsDeleted = false; var all_languagesL = ORM_CMN_Language.Query.Search(Connection, Transaction, all_languagesQ).ToArray(); var trigger_accQ = new ORM_USR_Account.Query(); trigger_accQ.Tenant_RefID = securityTicket.TenantID; trigger_accQ.USR_AccountID = securityTicket.AccountID; trigger_accQ.IsDeleted = false; var delete_drug_order = false; var cancel_order = false; var drug_order_header_id = Guid.Empty; var trigger_acc = ORM_USR_Account.Query.Search(Connection, Transaction, trigger_accQ).SingleOrDefault(); var op_planned_action_id = Guid.Empty; string previous_status = ""; var planned_action = cls_Get_Treatment_Planned_Action_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GTPAfCID_0946() { CaseID = Parameter.case_id }, securityTicket).Result; if (planned_action != null) { op_planned_action_id = planned_action.planned_action_id; var drug_order_ids = cls_Get_DrugOrderIDs_for_PlannedActionID.Invoke(Connection, Transaction, new P_CAS_GDOIDsfPAID_1243() { PlannedActionID = planned_action.planned_action_id }, securityTicket).Result; if (drug_order_ids != null) { var ord_drug_order_headerQ = new ORM_ORD_PRC_ProcurementOrder_Header.Query(); ord_drug_order_headerQ.Tenant_RefID = securityTicket.TenantID; ord_drug_order_headerQ.IsDeleted = false; ord_drug_order_headerQ.ORD_PRC_ProcurementOrder_HeaderID = drug_order_ids.ORD_PRC_ProcurementOrder_HeaderID; var ord_drug_order_header = ORM_ORD_PRC_ProcurementOrder_Header.Query.Search(Connection, Transaction, ord_drug_order_headerQ).SingleOrDefault(); var existing_treatment_planned_action_required_product = ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query() { HEC_ACT_PlannedAction_PotentialProcedure_RequiredProductID = drug_order_ids.HEC_ACT_PlannedAction_PotentialProcedure_RequiredProductID }).Single(); if (Parameter.cancel_drug_order) { if (ord_drug_order_header != null) { drug_order_header_id = ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID; var drug_order_status_latest = ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, new ORM_ORD_PRC_ProcurementOrder_Status.Query() { ORD_PRC_ProcurementOrder_StatusID = ord_drug_order_header.Current_ProcurementOrderStatus_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); previous_status = cls_Cancel_Drug_Order.Invoke(Connection, Transaction, new P_CAS_CDO_1250() { all_languagesL = all_languagesL, created_by_bpt = trigger_acc.BusinessParticipant_RefID, ord_drug_order_header = ord_drug_order_header, procurement_order_position_id = drug_order_ids.HEC_PRC_ProcurementOrder_PositionID, case_id = Parameter.case_id }, securityTicket).Result.previous_status; delete_drug_order = previous_status == "MO0"; cancel_order = !delete_drug_order && previous_status != "MO9"; } } } } if (Parameter.cancel_treatment) { var treatment_planned_actionQ = new ORM_HEC_ACT_PlannedAction.Query(); treatment_planned_actionQ.HEC_ACT_PlannedActionID = case_to_cancel.treatment_planned_action_id; treatment_planned_actionQ.IsDeleted = false; treatment_planned_actionQ.IsCancelled = false; treatment_planned_actionQ.IsPerformed = false; treatment_planned_actionQ.Tenant_RefID = securityTicket.TenantID; var treatment_planned_action = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, treatment_planned_actionQ).SingleOrDefault(); if (treatment_planned_action != null) { treatment_planned_action.IsCancelled = true; treatment_planned_action.Save(Connection, Transaction); } var aftercare_planned_actionQ = new ORM_HEC_ACT_PlannedAction.Query(); aftercare_planned_actionQ.HEC_ACT_PlannedActionID = case_to_cancel.aftercare_planned_action_id; aftercare_planned_actionQ.IsDeleted = false; aftercare_planned_actionQ.IsCancelled = false; aftercare_planned_actionQ.IsPerformed = false; aftercare_planned_actionQ.Tenant_RefID = securityTicket.TenantID; var aftercare_planned_action = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, treatment_planned_actionQ).SingleOrDefault(); if (aftercare_planned_action != null) { aftercare_planned_action.IsCancelled = true; aftercare_planned_action.Save(Connection, Transaction); } var cancelled_caseQ = new ORM_HEC_CAS_Case.Query(); cancelled_caseQ.HEC_CAS_CaseID = Parameter.case_id; cancelled_caseQ.Tenant_RefID = securityTicket.TenantID; cancelled_caseQ.IsDeleted = false; var cancelled_case = ORM_HEC_CAS_Case.Query.Search(Connection, Transaction, cancelled_caseQ).SingleOrDefault(); if (cancelled_case != null) { cls_Withdraw_OCT_or_Send_Email.Invoke(Connection, Transaction, new P_CAS_WOctoSE_0938() { case_id = Parameter.case_id, op_doctor_id = case_to_cancel.op_doctor_id, patient_id = case_to_cancel.patient_id, localization = case_to_cancel.localization, diagnose_id = case_to_cancel.diagnose_id, drug_id = case_to_cancel.drug_id, oct_doctor_id = case_to_cancel.oct_doctor_id, treatment_date = case_to_cancel.treatment_date }, securityTicket); cancelled_case.IsDeleted = true; cancelled_case.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MD_DDbID_1031 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var doctor = new ORM_HEC_Doctor(); if (Parameter.DoctorID != Guid.Empty) { var result = doctor.Load(Connection, Transaction, Parameter.DoctorID); if (result.Status != FR_Status.Success || doctor.HEC_DoctorID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } doctor.IsDeleted = true; doctor.Save(Connection, Transaction); //bussinessParticipant var query1 = new ORM_CMN_BPT_BusinessParticipant.Query(); query1.CMN_BPT_BusinessParticipantID = doctor.BusinessParticipant_RefID; var bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query1).First(); bussinessParticipant.IsDeleted = true; bussinessParticipant.Save(Connection, Transaction); if (doctor.Account_RefID != Guid.Empty) { var account2personInfoQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); account2personInfoQuery.USR_Account_RefID = doctor.Account_RefID; account2personInfoQuery.Tenant_RefID = securityTicket.TenantID; var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, account2personInfoQuery).FirstOrDefault(); if (account2personInfo != null) { account2personInfo.IsDeleted = true; account2personInfo.Save(Connection, Transaction); 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, query2).First(); personInfo.IsDeleted = true; personInfo.Save(Connection, Transaction); } var query4 = new ORM_CMN_PER_CommunicationContact.Query(); query4.PersonInfo_RefID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var communicationContactsList = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query4).ToList(); foreach (var contact in communicationContactsList) { contact.IsDeleted = true; contact.Save(Connection, Transaction); } } var query3 = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); query3.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; query3.IsDeleted = false; var abpRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, query3); foreach (ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant assigned in abpRes) { assigned.IsDeleted = true; assigned.Save(Connection, Transaction); } #endregion ORM_CMN_BPT_CTM_Customer customer; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative SalesRepresentative; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count != 0) { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); var SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); SalesRepresentativeQuery.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; SalesRepresentative = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, SalesRepresentativeQuery).First(); customer.IsDeleted = true; customer.Save(Connection, Transaction); SalesRepresentative.IsDeleted = true; SalesRepresentative.Save(Connection, Transaction); } var accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; accountQuery.AccountType = 3; var accountQueryRes = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery); if (accountQueryRes.Count != 0) { var account = accountQueryRes.First(); account.IsDeleted = true; account.Save(Connection, Transaction); var codeQuery = new ORM_USR_Device_AccountCode.Query(); codeQuery.Account_RefID = account.USR_AccountID; var code = ORM_USR_Device_AccountCode.Query.Search(Connection, Transaction, codeQuery).First(); code.IsDeleted = true; code.Save(Connection, Transaction); var codeStatusQuery = new ORM_USR_Device_AccountCode_StatusHistory.Query(); codeStatusQuery.Device_AccountCode_RefID = code.USR_Device_AccountCodeID; var codeStatus = ORM_USR_Device_AccountCode_StatusHistory.Query.Search(Connection, Transaction, codeStatusQuery).First(); codeStatus.IsDeleted = true; codeStatus.Save(Connection, Transaction); } } returnValue.Result = doctor.HEC_DoctorID; return(returnValue); }