protected static FR_L5MD_GDwPfID_1414 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MD_GDwPfID_1414 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5MD_GDwPfID_1414(); P_L3MD_GDBIfID_1150 biParam = new P_L3MD_GDBIfID_1150(); biParam.DoctorID = Parameter.DoctorID; var baseInfo = cls_Get_Doctor_BaseInfo_byID.Invoke(Connection, Transaction, biParam, securityTicket).Result; returnValue.Result = new L5MD_GDwPfID_1414(); returnValue.Result.BaseInfo = baseInfo; P_L3DAC_RACDbBPID_1056 aiParam = new P_L3DAC_RACDbBPID_1056(); aiParam.BPrticipantID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; var accInfo = cls_Retrive_Account_Code_Details_byBParticipantID.Invoke(Connection, Transaction, aiParam, securityTicket).Result; if (accInfo != null) { var AccountInfo = new L5MD_GDwPfID_1414_AccountInfo(); AccountInfo.AccountCode_ValidFrom = accInfo.AccountCode_ValidFrom; AccountInfo.AccountCode_Value = accInfo.AccountCode_Value; AccountInfo.USR_AccountID = baseInfo.Account_RefID; AccountInfo.USR_Device_AccountCodeID = accInfo.USR_Device_AccountCodeID; returnValue.Result.AccountInfo = AccountInfo; } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; customerQuery.IsDeleted = false; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count > 0) { var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.Customer_RefID = customerRes.First().CMN_BPT_CTM_CustomerID; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.IsDeleted = false; var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1 = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery).First(); returnValue.Result.SalesRepresentative = new L5MD_GDwPfID_1414_SalesRepresentative(); returnValue.Result.SalesRepresentative.SalesRepresentative_RefID = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1.SalesRepresentative_RefID; } var assocBPQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); assocBPQuery.BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; assocBPQuery.IsDeleted = false; var assocBPQs = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, assocBPQuery).ToArray(); if (assocBPQs.Length > 0) { assocBPQs = assocBPQs.OrderBy(a => a.Creation_Timestamp).ToArray(); var assocBPQ = assocBPQs.First(); var practiceBPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceBPQuery.CMN_BPT_BusinessParticipantID = assocBPQ.AssociatedBusinessParticipant_RefID; var practiceBP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceBPQuery).First(); var companInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companInfoQuery.CMN_COM_CompanyInfoID = practiceBP.IfCompany_CMN_COM_CompanyInfo_RefID; var companInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companInfoQuery).First(); var practiceQuery = new ORM_HEC_MedicalPractis.Query(); practiceQuery.Ext_CompanyInfo_RefID = companInfo.CMN_COM_CompanyInfoID; var prac = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practiceQuery).First(); P_L3MP_GPfID_1222 pbiParam = new P_L3MP_GPfID_1222(); pbiParam.HEC_MedicalPractiseID = prac.HEC_MedicalPractiseID; var practiceBasInfo = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, pbiParam, securityTicket).Result; if (practiceBasInfo != null) { L5MD_GDwPfID_1414_Practice practice = new L5MD_GDwPfID_1414_Practice(); practice.AssociatedParticipant_FunctionName = assocBPQ.AssociatedParticipant_FunctionName; practice.CMN_BPT_BusinessParticipantID = practiceBasInfo.BaseInfo.CMN_BPT_BusinessParticipantID; if (practiceBasInfo.OtherOphthal_PracticeData != null) { practice.HealthAssociation_Name = practiceBasInfo.OtherOphthal_PracticeData.HealthAssociation_Name; } practice.PracticeID = practiceBasInfo.BaseInfo.HEC_MedicalPractiseID; practice.PracticeName = practiceBasInfo.BaseInfo.PracticeName; practice.Region_Name = practiceBasInfo.BaseInfo.Region_Name; practice.Street_Name = practiceBasInfo.BaseInfo.Street_Name; practice.Street_Number = practiceBasInfo.BaseInfo.Street_Number; practice.Town = practiceBasInfo.BaseInfo.Town; practice.ZIP = practiceBasInfo.BaseInfo.ZIP; returnValue.Result.Practice = practice; } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MP_DPBID_1026 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L3MP_GPfID_1222 param = new P_L3MP_GPfID_1222(); param.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; var practice = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, param, securityTicket).Result; if (practice != null) { ORM_CMN_UniversalContactDetail contactDetails = new ORM_CMN_UniversalContactDetail(); if (practice.BaseInfo.CMN_UniversalContactDetailID != Guid.Empty) { var result = contactDetails.Load(Connection, Transaction, practice.BaseInfo.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } contactDetails.IsDeleted = true; contactDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo info = new ORM_CMN_COM_CompanyInfo(); if (practice.BaseInfo.CMN_COM_CompanyInfoID != Guid.Empty) { var result = info.Load(Connection, Transaction, practice.BaseInfo.CMN_COM_CompanyInfoID); if (result.Status != FR_Status.Success || info.CMN_COM_CompanyInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } info.IsDeleted = true; info.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (practice.BaseInfo.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, practice.BaseInfo.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } bParticipant.IsDeleted = true; bParticipant.Save(Connection, Transaction); } ORM_HEC_MedicalPractis practis = new ORM_HEC_MedicalPractis(); if (practice.BaseInfo.HEC_MedicalPractiseID != Guid.Empty) { var result = practis.Load(Connection, Transaction, practice.BaseInfo.HEC_MedicalPractiseID); if (result.Status != FR_Status.Success || practis.HEC_MedicalPractiseID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } practis.IsDeleted = true; practis.Save(Connection, Transaction); } if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklyOfficeHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.BaseInfo.WeeklySurgeryHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklySurgeryHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.ShippingAddress != null) { ORM_CMN_UniversalContactDetail shippingDetails = new ORM_CMN_UniversalContactDetail(); if (practice.ShippingAddress.CMN_UniversalContactDetailID != Guid.Empty) { var result = shippingDetails.Load(Connection, Transaction, practice.ShippingAddress.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingDetails.IsDeleted = true; shippingDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo_Address shippingAddress = new ORM_CMN_COM_CompanyInfo_Address(); if (practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID != Guid.Empty) { var result = shippingAddress.Load(Connection, Transaction, practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID); if (result.Status != FR_Status.Success || shippingAddress.CMN_COM_CompanyInfo_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingAddress.IsDeleted = true; shippingAddress.Save(Connection, Transaction); } } var associatedBussinessParticipantsQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associatedBussinessParticipantsQuery.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; associatedBussinessParticipantsQuery.IsDeleted = false; var associatedBussinessParticipants = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associatedBussinessParticipantsQuery); if (associatedBussinessParticipants.Count != 0) { foreach (var assBussiness in associatedBussinessParticipants) { assBussiness.IsDeleted = true; assBussiness.Save(Connection, Transaction); //brisanje doktora ako je imao jednu praksu //var d2pAssignmentQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); //d2pAssignmentQuery.IsDeleted = false; //d2pAssignmentQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; //var d2pAssignmentRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, d2pAssignmentQuery).ToArray(); //if (d2pAssignmentRes.Length == 0) //{ // var docQuery = new ORM_HEC_Doctor.Query(); // docQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; // var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, docQuery).First(); // P_L3MD_DDbID_1031 delDoc = new P_L3MD_DDbID_1031(); // delDoc.DoctorID = doctor.HEC_DoctorID; // var delRes = cls_Delete_Doctor_byID.Invoke(Connection, Transaction, delDoc, securityTicket).Result; //} } } if (practice.OtherOphthal_PracticeData != null) { ORM_HEC_PublicHealthcare_PhysitianAssociation association = new ORM_HEC_PublicHealthcare_PhysitianAssociation(); if (practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID != Guid.Empty) { var result = association.Load(Connection, Transaction, practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (result.Status != FR_Status.Success || association.HEC_PublicHealthcare_PhysitianAssociationID == Guid.Empty) { var item = STLD_MedicalAssociation.associationItems.FirstOrDefault(a => a.Value == practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (item != null) { association.IsDeleted = true; association.HealthAssociation_Name = item.Text; association.Save(Connection, Transaction); } } } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = practice.BaseInfo.CMN_BPT_BusinessParticipantID; var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault(); if (customer != null) { customer.IsDeleted = true; customer.Save(Connection, Transaction); } var companyTypeQuery = new ORM_CMN_COM_CompanyInfo_Type.Query(); companyTypeQuery.IsDeleted = false; companyTypeQuery.CMN_COM_CompanyInfo_TypeID = practice.OtherOphthal_PracticeData.CMN_COM_CompanyInfo_TypeID; var companyType = ORM_CMN_COM_CompanyInfo_Type.Query.Search(Connection, Transaction, companyTypeQuery).First(); var pHealthcareQuery = new ORM_HEC_PublicHealthcare_PhysitianAssociation.Query(); pHealthcareQuery.HEC_PublicHealthcare_PhysitianAssociationID = practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID; var pHealthcare = ORM_HEC_PublicHealthcare_PhysitianAssociation.Query.Search(Connection, Transaction, pHealthcareQuery).First(); pHealthcare.IsDeleted = true; pHealthcare.Save(Connection, Transaction); if (customer != null) { var affinityStatusQuery = new ORM_CMN_BPT_CTM_AffinityStatus.Query(); affinityStatusQuery.CMN_BPT_CTM_AffinityStatusID = customer.CustomerAffinityStatus_RefID; var affinityStatus = ORM_CMN_BPT_CTM_AffinityStatus.Query.Search(Connection, Transaction, affinityStatusQuery).First(); if (affinityStatus != null) { affinityStatus.IsDeleted = true; affinityStatus.Save(Connection, Transaction); } } } } return(returnValue); #endregion UserCode }