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. "); }
protected static FR_L5DD_GDDFDD_1402 Execute(DbConnection Connection, DbTransaction Transaction, P_L5DD_GDDFDD_1402 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5DD_GDDFDD_1402(); L5DD_GDDFDD_1402 result = new L5DD_GDDFDD_1402(); ORM_RES_DUD_RevisionGroup revisionGroup = new ORM_RES_DUD_RevisionGroup(); revisionGroup.Load(Connection, Transaction, Parameter.RevisionGroupID); ORM_CMN_PER_PersonInfo_2_Account.Query infoToAccountQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); infoToAccountQuery.IsDeleted = false; infoToAccountQuery.Tenant_RefID = securityTicket.TenantID; infoToAccountQuery.USR_Account_RefID = revisionGroup.RevisionGroup_SubmittedBy_Account_RefID; List <ORM_CMN_PER_PersonInfo_2_Account> infoToAccountList = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, infoToAccountQuery); ORM_CMN_PER_PersonInfo.Query personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.IsDeleted = false; personInfoQuery.Tenant_RefID = securityTicket.TenantID; personInfoQuery.CMN_PER_PersonInfoID = infoToAccountList[0].CMN_PER_PersonInfo_RefID; List <ORM_CMN_PER_PersonInfo> personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery); result.Creation_Timestamp = revisionGroup.Creation_Timestamp; result.FirstName = personInfo[0].FirstName; result.LastName = personInfo[0].LastName; result.RealestateProperty_RefID = revisionGroup.RealestateProperty_RefID; result.RES_DUD_Revision_GroupID = revisionGroup.RES_DUD_Revision_GroupID; result.RevisionGroup_Comment = revisionGroup.RevisionGroup_Comment; result.RevisionGroup_Name = revisionGroup.RevisionGroup_Name; result.RevisionGroup_SubmittedBy_Account_RefID = revisionGroup.RevisionGroup_SubmittedBy_Account_RefID; result.Tenant_RefID = securityTicket.TenantID; returnValue.Result = result; //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, PL5DO_RDAA_1434 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var account2personInfoQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); account2personInfoQuery.USR_Account_RefID = Parameter.Account_RefID; account2personInfoQuery.Tenant_RefID = securityTicket.TenantID; account2personInfoQuery.IsDeleted = false; var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, account2personInfoQuery).First(); 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.PrimaryEmail = null; personInfo.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MD_SDBI_1349 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #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); } #region Edit bool bopAccIsChenged = (doctor.Account_RefID == Parameter.Account_RefID) ? false : true; doctor.Account_RefID = Parameter.Account_RefID; if (Parameter.isLucentisSave) { doctor.DoctorIDNumber = Parameter.ifLucentis_LANR; } 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(); if (!bopAccIsChenged) { //personInfo var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query2).First(); personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.Title = Parameter.Title; if (Parameter.isOphthalSave) { personInfo.Salutation_General = Parameter.ifOphthal_Salutation_General; personInfo.Salutation_Letter = Parameter.ifOphthal_Salutation_Letter; } if (Parameter.isLucentisSave) { personInfo.PrimaryEmail = Parameter.ifLucentis_LoginEmail; } personInfo.Save(Connection, Transaction); var query4 = new ORM_CMN_PER_CommunicationContact.Query(); query4.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; var communicationContactsList = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query4).ToList(); if (Parameter.Contacts != null) { foreach (var parContact in Parameter.Contacts) { ORM_CMN_PER_CommunicationContact communicationContacts = communicationContactsList.FirstOrDefault(c => c.Contact_Type == parContact.CMN_PER_CommunicationContact_TypeID); if (communicationContacts != null) { communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Content = parContact.Content; communicationContacts.Save(Connection, Transaction); } else { communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContacts.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; communicationContacts.Content = parContact.Content; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); } } } } else { var account2personInfoQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); account2personInfoQuery.USR_Account_RefID = Parameter.Account_RefID; account2personInfoQuery.Tenant_RefID = securityTicket.TenantID; account2personInfoQuery.IsDeleted = false; var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, account2personInfoQuery).First(); 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.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.Title = Parameter.Title; 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(); if (communicationContactsList != null) { foreach (var c in communicationContactsList) { c.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; c.Save(Connection, Transaction); } } if (Parameter.Contacts != null) { foreach (var parContact in Parameter.Contacts) { ORM_CMN_PER_CommunicationContact communicationContacts = communicationContactsList.FirstOrDefault(c => c.Contact_Type == parContact.CMN_PER_CommunicationContact_TypeID); if (communicationContacts != null) { communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Content = parContact.Content; communicationContacts.Save(Connection, Transaction); } else { communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContacts.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; communicationContacts.Content = parContact.Content; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); } } } bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; bussinessParticipant.Save(Connection, Transaction); } if (Parameter.isLucentisSave) { foreach (var practice in Parameter.Practices) { //if (practice.PracticeID != Guid.Empty) { var medPract = new ORM_HEC_MedicalPractis.Query(); medPract.HEC_MedicalPractiseID = practice.PracticeID; var medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, medPract).First(); var queryCompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); queryCompanyInfo.CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, queryCompanyInfo).First(); var practiceQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var practiceBPT = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceQuery).First(); var query3 = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); query3.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; query3.AssociatedBusinessParticipant_RefID = practiceBPT.CMN_BPT_BusinessParticipantID; query3.IsDeleted = false; var associatedbusinessparticipantsOriginal = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, query3).FirstOrDefault(); if (associatedbusinessparticipantsOriginal != null) { associatedbusinessparticipantsOriginal.IsDeleted = practice.isDeleted; associatedbusinessparticipantsOriginal.Save(Connection, Transaction); } else { var associatedbusinessparticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedbusinessparticipants.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedBusinessParticipant_RefID = practiceBPT.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedParticipant_FunctionName = practice.AssociatedParticipant_FunctionName; associatedbusinessparticipants.Creation_Timestamp = DateTime.Now; associatedbusinessparticipants.Tenant_RefID = securityTicket.TenantID; associatedbusinessparticipants.Save(Connection, Transaction); // } } } } if (Parameter.isOphthalSave && Parameter.Practices.Length == 1) { var query3 = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); query3.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; query3.IsDeleted = false; var associatedbusinessparticipantsRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, query3); ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant firstPractice; var medPract = new ORM_HEC_MedicalPractis.Query(); medPract.HEC_MedicalPractiseID = Parameter.Practices[0].PracticeID; var medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, medPract).First(); var queryCompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); queryCompanyInfo.CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, queryCompanyInfo).First(); var practiceQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var practiceBPT = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceQuery).First(); if (associatedbusinessparticipantsRes.Count > 0) { associatedbusinessparticipantsRes = associatedbusinessparticipantsRes.OrderBy(a => a.Creation_Timestamp).ToList(); firstPractice = associatedbusinessparticipantsRes.First(); foreach (var item in associatedbusinessparticipantsRes) { if (item != firstPractice && item.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID == practiceBPT.CMN_BPT_BusinessParticipantID) { item.IsDeleted = true; item.Save(Connection, Transaction); } } } else { firstPractice = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); firstPractice.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID = Guid.NewGuid(); firstPractice.Tenant_RefID = securityTicket.TenantID; firstPractice.BusinessParticipant_RefID = bussinessParticipant.CMN_BPT_BusinessParticipantID; } firstPractice.AssociatedParticipant_FunctionName = Parameter.Practices[0].AssociatedParticipant_FunctionName; firstPractice.AssociatedBusinessParticipant_RefID = practiceBPT.CMN_BPT_BusinessParticipantID; firstPractice.Save(Connection, Transaction); } #endregion } else { #region Save //personInfo Guid personInfoID; if (Parameter.Account_RefID == Guid.Empty) { var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = Guid.NewGuid(); personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; if (Parameter.isLucentisSave) { personInfo.PrimaryEmail = Parameter.ifLucentis_LoginEmail; } personInfo.Title = Parameter.Title; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; if (Parameter.isOphthalSave) { personInfo.Salutation_Letter = Parameter.ifOphthal_Salutation_Letter; personInfo.Salutation_General = Parameter.ifOphthal_Salutation_General; } personInfo.Save(Connection, Transaction); personInfoID = personInfo.CMN_PER_PersonInfoID; } else { var account2personInfoQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); account2personInfoQuery.USR_Account_RefID = Parameter.Account_RefID; account2personInfoQuery.Tenant_RefID = securityTicket.TenantID; account2personInfoQuery.IsDeleted = false; var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, account2personInfoQuery).First(); 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.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.Title = Parameter.Title; personInfo.Save(Connection, Transaction); personInfoID = personInfo.CMN_PER_PersonInfoID; } //bussinessParticipants var bussinessParticipantTable = new ORM_CMN_BPT_BusinessParticipant(); bussinessParticipantTable.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bussinessParticipantTable.IsNaturalPerson = true; bussinessParticipantTable.IsTenant = false; bussinessParticipantTable.IsCompany = false; bussinessParticipantTable.IsDeleted = false; bussinessParticipantTable.Creation_Timestamp = DateTime.Now; bussinessParticipantTable.Tenant_RefID = securityTicket.TenantID; bussinessParticipantTable.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; bussinessParticipantTable.Save(Connection, Transaction); doctor.HEC_DoctorID = Guid.NewGuid(); if (Parameter.isLucentisSave) { doctor.DoctorIDNumber = Parameter.ifLucentis_LANR; } doctor.Creation_Timestamp = DateTime.Now; doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; doctor.Account_RefID = Parameter.Account_RefID; doctor.Save(Connection, Transaction); if (Parameter.Contacts != null) { foreach (var contact in Parameter.Contacts) { ORM_CMN_PER_CommunicationContact communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfoID; communicationContacts.Contact_Type = contact.CMN_PER_CommunicationContact_TypeID; communicationContacts.Content = contact.Content; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); } } foreach (var practice in Parameter.Practices) { if (practice.isDeleted == true) { continue; } var medPract = new ORM_HEC_MedicalPractis.Query(); medPract.HEC_MedicalPractiseID = practice.PracticeID; var medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, medPract).First(); var queryCompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); queryCompanyInfo.CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, queryCompanyInfo).First(); var practiceQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var practiceBPT = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceQuery).First(); //associatedbusinessparticipants var associatedbusinessparticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedbusinessparticipants.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedBusinessParticipant_RefID = practiceBPT.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedParticipant_FunctionName = practice.AssociatedParticipant_FunctionName; associatedbusinessparticipants.Creation_Timestamp = DateTime.Now; associatedbusinessparticipants.Tenant_RefID = securityTicket.TenantID; associatedbusinessparticipants.Save(Connection, Transaction); } #endregion } returnValue.Result = doctor.HEC_DoctorID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CL5CO_SC_1724 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here Guid personInfoID = Guid.Empty; ORM_CMN_BPT_CTM_Customer.Query customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.CMN_BPT_CTM_CustomerID = Parameter.CustomerID; customerQuery.IsDeleted = false; ORM_CMN_BPT_CTM_Customer customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).Single(); ORM_CMN_BPT_BusinessParticipant.Query businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQuery.CMN_BPT_BusinessParticipantID = customer.Ext_BusinessParticipant_RefID; businessParticipantQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipant businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single(); if (businessParticipant.IsNaturalPerson) { personInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; } else { ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query associationQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associationQuery.AssociatedBusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; associationQuery.IsDeleted = false; List <ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant> associations = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associationQuery); foreach (var association in associations) { ORM_CMN_BPT_BusinessParticipant.Query bpQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bpQuery.CMN_BPT_BusinessParticipantID = association.BusinessParticipant_RefID; bpQuery.IsDeleted = false; bpQuery.IsNaturalPerson = true; ORM_CMN_BPT_BusinessParticipant bp = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bpQuery).First(); if (bp != null) { personInfoID = bp.IfNaturalPerson_CMN_PER_PersonInfo_RefID; break; } } } if (personInfoID != Guid.Empty) { if (Parameter.Correspondences.Any(x => x.IsDefaultCorrespondence) && !Parameter.Correspondences.Any(x => x.IsDeleted)) { var findDefaultCorrespondenceQuery = ORM_CMN_PER_PersonInfo_Correspondence.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_Correspondence.Query { CMN_PER_PersonInfo_RefID = personInfoID, IsDefaultCorrespondence = true, IsDeleted = false, Tenant_RefID = customer.Tenant_RefID }); if (findDefaultCorrespondenceQuery != null && findDefaultCorrespondenceQuery.Any()) { foreach (var item in findDefaultCorrespondenceQuery) { item.IsDefaultCorrespondence = false; item.Save(Connection, Transaction); } } } foreach (var item in Parameter.Correspondences) { ORM_CMN_PER_PersonInfo_Correspondence.Query correspondenceQuery = new ORM_CMN_PER_PersonInfo_Correspondence.Query(); correspondenceQuery.IsDeleted = false; correspondenceQuery.CMN_PER_PersonInfo_CorrespondenceID = item.CorrespondenceID; List <ORM_CMN_PER_PersonInfo_Correspondence> correspondences = ORM_CMN_PER_PersonInfo_Correspondence.Query.Search(Connection, Transaction, correspondenceQuery); if (item.IsDeleted && correspondences.Count > 0) { correspondences.First().IsDeleted = true; correspondences.First().Save(Connection, Transaction); } else if (!item.IsDeleted) { if (correspondences.Count > 0) { correspondences.First().CorrespondenceText = item.CorrespondenceText; correspondences.First().IsDefaultCorrespondence = item.IsDefaultCorrespondence; correspondences.First().CorrespondenceType_RefID = item.CorrespondenceTypeRefId; correspondences.First().Save(Connection, Transaction); // save name in correspodencetype //var correspodenceTypeQuery = ORM_CMN_PER_PersonInfo_CorrespondenceType.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_CorrespondenceType.Query{ // CMN_PER_PersonInfo_CorrespondenceTypeID = correspondences.First().CorrespondenceType_RefID, // Tenant_RefID = customer.Tenant_RefID //}).SingleOrDefault() //if (correspodenceTypeQuery != null) //{ // correspodenceTypeQuery.DisplayName = item.CorrespondenceName; // correspodenceTypeQuery.Save(Connection, Transaction); //} } else { ORM_CMN_PER_PersonInfo.Query personQuery = new ORM_CMN_PER_PersonInfo.Query(); personQuery.CMN_PER_PersonInfoID = personInfoID; personQuery.IsDeleted = false; ORM_CMN_PER_PersonInfo person = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personQuery).First(); ORM_CMN_PER_PersonInfo_Correspondence newCorrespondance = new ORM_CMN_PER_PersonInfo_Correspondence(); newCorrespondance.CorrespondenceText = item.CorrespondenceText; newCorrespondance.IsDefaultCorrespondence = item.IsDefaultCorrespondence; newCorrespondance.CorrespondenceType_RefID = item.CorrespondenceTypeRefId; newCorrespondance.IsDeleted = false; newCorrespondance.Creation_Timestamp = DateTime.Now; newCorrespondance.CMN_PER_PersonInfo_CorrespondenceID = Guid.NewGuid(); newCorrespondance.CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; newCorrespondance.Tenant_RefID = customer.Tenant_RefID; newCorrespondance.Save(Connection, Transaction); // We will need some of this code later //var correspodenceTypeQuery = ORM_CMN_PER_PersonInfo_CorrespondenceType.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_CorrespondenceType.Query{ // CMN_PER_PersonInfo_CorrespondenceTypeID = newCorrespondance.CorrespondenceType_RefID, // Tenant_RefID = customer.Tenant_RefID //}).SingleOrDefault() //if (correspodenceTypeQuery != null) //{ // correspodenceTypeQuery.DisplayName = item.CorrespondenceName; // correspodenceTypeQuery.Save(Connection,Transaction); //} //else //{ // ORM_CMN_PER_PersonInfo_CorrespondenceType newCorrespodenceType = new ORM_CMN_PER_PersonInfo_CorrespondenceType(); // newCorrespodenceType.Tenant_RefID = customer.Tenant_RefID; // newCorrespodenceType.CMN_PER_PersonInfo_CorrespondenceTypeID = newCorrespondance.CorrespondenceType_RefID; // newCorrespodenceType.DisplayName = item.CorrespondenceName; //} } } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SP__1122 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_MedicalPractis item = new ORM_HEC_MedicalPractis(); if (Parameter.PracticeID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.PracticeID); if (result.Status != FR_Status.Success || item.HEC_MedicalPractiseID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } #region Delete if (Parameter.isDeleted == true) { var query_BP_ContactPerson_del = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BP_ContactPerson_del.CMN_BPT_BusinessParticipantID = item.ContactPerson_RefID; query_BP_ContactPerson_del.Tenant_RefID = securityTicket.TenantID; var found_BP_ContactPerson_del = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BP_ContactPerson_del).First(); found_BP_ContactPerson_del.IsDeleted = true; var query_PersonInfo_del = new ORM_CMN_PER_PersonInfo.Query(); query_PersonInfo_del.CMN_PER_PersonInfoID = found_BP_ContactPerson_del.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var found_PersonInfo_del = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query_PersonInfo_del).First(); found_PersonInfo_del.IsDeleted = true; found_PersonInfo_del.Save(Connection, Transaction); var query_CommunicationContact_del = new ORM_CMN_PER_CommunicationContact.Query(); query_CommunicationContact_del.PersonInfo_RefID = found_PersonInfo_del.CMN_PER_PersonInfoID; var found_CommunicationContact_del = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query_CommunicationContact_del).First(); found_CommunicationContact_del.IsDeleted = true; found_CommunicationContact_del.Save(Connection, Transaction); var query_CompanyInfo_del = new ORM_CMN_COM_CompanyInfo.Query(); query_CompanyInfo_del.CMN_COM_CompanyInfoID = item.Ext_CompanyInfo_RefID; var found_CompanyInfo_del = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, query_CompanyInfo_del).First(); found_CompanyInfo_del.IsDeleted = true; found_CompanyInfo_del.Save(Connection, Transaction); var query_BP_Company_del = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BP_Company_del.IfCompany_CMN_COM_CompanyInfo_RefID = found_CompanyInfo_del.CMN_COM_CompanyInfoID; var found_BP_Company_del = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BP_Company_del).First(); found_BP_Company_del.IsDeleted = true; found_BP_Company_del.Save(Connection, Transaction); var query_UniversalContactDetails_del = new ORM_CMN_UniversalContactDetail.Query(); query_UniversalContactDetails_del.CMN_UniversalContactDetailID = found_CompanyInfo_del.Contact_UCD_RefID; var found_UniversalCompanyDetails_del = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, query_UniversalContactDetails_del).First(); found_UniversalCompanyDetails_del.IsDeleted = true; found_UniversalCompanyDetails_del.Save(Connection, Transaction); item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.HEC_MedicalPractiseID)); } #endregion #region Edit var query1 = new ORM_CMN_BPT_BusinessParticipant.Query(); query1.CMN_BPT_BusinessParticipantID = item.ContactPerson_RefID; query1.Tenant_RefID = securityTicket.TenantID; query1.IsCompany = false; query1.IsNaturalPerson = true; query1.IsTenant = false; var bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query1).First(); var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query2).First(); personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.PrimaryEmail = Parameter.ContactPersonEmail; personInfo.Save(Connection, Transaction); var query3 = new ORM_CMN_PER_CommunicationContact.Query(); query3.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; var communicationContacts = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query3).First(); communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPersonPhoneNumber; communicationContacts.Save(Connection, Transaction); var query4 = new ORM_CMN_COM_CompanyInfo.Query(); query4.CMN_COM_CompanyInfoID = item.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, query4).First(); companyInfo.CompanyInfo_EstablishmentNumber = Parameter.BSNR; companyInfo.Save(Connection, Transaction); var query5 = new ORM_CMN_BPT_BusinessParticipant.Query(); query5.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var extCompany = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query5).First(); extCompany.DisplayName = Parameter.PracticeName; extCompany.Save(Connection, Transaction); var query6 = new ORM_CMN_UniversalContactDetail.Query(); query6.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; var companyDetails = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, query6).First(); companyDetails.ZIP = Parameter.ZIP; companyDetails.Town = Parameter.Town; companyDetails.Street_Name = Parameter.PracticeStreet; companyDetails.Street_Number = Parameter.PracticeNumber; companyDetails.Contact_Email = Parameter.PracitceEmail; companyDetails.Street_Name_Line2 = Parameter.PracticeStreet2; companyDetails.Save(Connection, Transaction); #endregion } else { #region Save item.HEC_MedicalPractiseID = Guid.NewGuid(); item.Creation_Timestamp = DateTime.Now; item.Tenant_RefID = securityTicket.TenantID; //business Participants ORM_CMN_BPT_BusinessParticipant contactPerson = new ORM_CMN_BPT_BusinessParticipant(); Guid businessParticipantsID = Guid.NewGuid(); contactPerson.CMN_BPT_BusinessParticipantID = businessParticipantsID; contactPerson.IsCompany = false; contactPerson.IsNaturalPerson = true; contactPerson.IsTenant = false; contactPerson.Creation_Timestamp = DateTime.Now; contactPerson.Tenant_RefID = securityTicket.TenantID; item.ContactPerson_RefID = businessParticipantsID; //person info ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); Guid personInfoID = Guid.NewGuid(); contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; contactPerson.Save(Connection, Transaction); personInfo.CMN_PER_PersonInfoID = personInfoID; personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.PrimaryEmail = Parameter.ContactPersonEmail; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); //Communication Contact ORM_CMN_PER_CommunicationContact communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfoID; communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPersonPhoneNumber; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); Guid companyInfoID = Guid.NewGuid(); companyInfo.CMN_COM_CompanyInfoID = companyInfoID; companyInfo.Creation_Timestamp = DateTime.Now; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.CompanyInfo_EstablishmentNumber = Parameter.BSNR; item.Ext_CompanyInfo_RefID = companyInfoID; ORM_CMN_BPT_BusinessParticipant extCompany = new ORM_CMN_BPT_BusinessParticipant(); extCompany.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); extCompany.Creation_Timestamp = DateTime.Now; extCompany.Tenant_RefID = securityTicket.TenantID; extCompany.DisplayName = Parameter.PracticeName; extCompany.IsCompany = true; extCompany.IsNaturalPerson = false; extCompany.IsTenant = false; extCompany.IsDeleted = false; extCompany.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfoID; extCompany.Save(Connection, Transaction); ORM_CMN_UniversalContactDetail companyDetails = new ORM_CMN_UniversalContactDetail(); Guid companyDetailsID = Guid.NewGuid(); companyInfo.Contact_UCD_RefID = companyDetailsID; companyInfo.Save(Connection, Transaction); companyDetails.CMN_UniversalContactDetailID = companyDetailsID; companyDetails.Tenant_RefID = securityTicket.TenantID; companyDetails.Creation_Timestamp = DateTime.Now; companyDetails.IsCompany = true; companyDetails.ZIP = Parameter.ZIP; companyDetails.Town = Parameter.Town; companyDetails.Street_Name = Parameter.PracticeStreet; companyDetails.Street_Number = Parameter.PracticeNumber; companyDetails.Contact_Email = Parameter.PracitceEmail; companyDetails.Street_Name_Line2 = Parameter.PracticeStreet2; companyDetails.IsDeleted = false; companyDetails.Save(Connection, Transaction); item.Save(Connection, Transaction); #endregion } returnValue.Result = item.HEC_MedicalPractiseID; 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_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PH_SP_1226 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Pharmacy item = new ORM_HEC_Pharmacy(); if (Parameter.PharmacyID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.PharmacyID); if (result.Status != FR_Status.Success) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } #region Delete if (Parameter.IsDeleted) { //Contact person data finding and deleting var query_BusinessParticipant_ContactPerson_del = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BusinessParticipant_ContactPerson_del.CMN_BPT_BusinessParticipantID = item.ContactPerson_BusinessParticipant_RefID; query_BusinessParticipant_ContactPerson_del.Tenant_RefID = item.Tenant_RefID; ORM_CMN_BPT_BusinessParticipant found_BusinessParticipant_ContactPerson_del = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BusinessParticipant_ContactPerson_del).First(); found_BusinessParticipant_ContactPerson_del.IsDeleted = true; var query_PersonInfo_del = new ORM_CMN_PER_PersonInfo.Query(); query_PersonInfo_del.CMN_PER_PersonInfoID = found_BusinessParticipant_ContactPerson_del.IfNaturalPerson_CMN_PER_PersonInfo_RefID; ORM_CMN_PER_PersonInfo found_PersonInfo_del = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query_PersonInfo_del).First(); found_PersonInfo_del.IsDeleted = true; var query_CommunicationContact_del = new ORM_CMN_PER_CommunicationContact.Query(); query_CommunicationContact_del.PersonInfo_RefID = found_PersonInfo_del.CMN_PER_PersonInfoID; ORM_CMN_PER_CommunicationContact found_CommunicationContact_del = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query_CommunicationContact_del).First(); found_CommunicationContact_del.IsDeleted = true; found_BusinessParticipant_ContactPerson_del.Save(Connection, Transaction); found_CommunicationContact_del.Save(Connection, Transaction); found_PersonInfo_del.Save(Connection, Transaction); //Company (pharmacy) finding and deleting var query_CompanyInfo_del = new ORM_CMN_COM_CompanyInfo.Query(); query_CompanyInfo_del.CMN_COM_CompanyInfoID = item.Ext_CompanyInfo_RefID; ORM_CMN_COM_CompanyInfo found_CompanyInfo_del = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, query_CompanyInfo_del).First(); found_CompanyInfo_del.IsDeleted = true; var query_CompanyContactDetails_del = new ORM_CMN_UniversalContactDetail.Query(); query_CompanyContactDetails_del.CMN_UniversalContactDetailID = found_CompanyInfo_del.Contact_UCD_RefID; ORM_CMN_UniversalContactDetail found_CompanyContactDetails_del = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, query_CompanyContactDetails_del).First(); found_CompanyContactDetails_del.IsDeleted = true; var query_BusinessParticipant_Company_del = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BusinessParticipant_Company_del.IfCompany_CMN_COM_CompanyInfo_RefID = found_CompanyInfo_del.CMN_COM_CompanyInfoID; ORM_CMN_BPT_BusinessParticipant found_BusinessParticipant_Company_del = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BusinessParticipant_Company_del).First(); found_BusinessParticipant_Company_del.IsDeleted = true; found_CompanyInfo_del.Save(Connection, Transaction); found_CompanyContactDetails_del.Save(Connection, Transaction); found_BusinessParticipant_Company_del.Save(Connection, Transaction); item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.HEC_PharmacyID)); } #endregion #region Edit //Contact person data finding and edit var query_BusinessParticipant_ContactPerson = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BusinessParticipant_ContactPerson.CMN_BPT_BusinessParticipantID = item.ContactPerson_BusinessParticipant_RefID; query_BusinessParticipant_ContactPerson.Tenant_RefID = item.Tenant_RefID; ORM_CMN_BPT_BusinessParticipant found_BusinessParticipant_ContactPerson = new ORM_CMN_BPT_BusinessParticipant(); if (item.ContactPerson_BusinessParticipant_RefID != null && item.ContactPerson_BusinessParticipant_RefID != Guid.Empty) { found_BusinessParticipant_ContactPerson = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BusinessParticipant_ContactPerson).First(); } else { found_BusinessParticipant_ContactPerson = null; } if (found_BusinessParticipant_ContactPerson != null) { var query_PersonInfo = new ORM_CMN_PER_PersonInfo.Query(); query_PersonInfo.CMN_PER_PersonInfoID = found_BusinessParticipant_ContactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID; ORM_CMN_PER_PersonInfo found_PersonInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query_PersonInfo).First(); found_PersonInfo.FirstName = Parameter.ContactFirstName; found_PersonInfo.LastName = Parameter.ContactLastName; found_PersonInfo.PrimaryEmail = Parameter.ContactEmail; var query_CommunicationContact = new ORM_CMN_PER_CommunicationContact.Query(); query_CommunicationContact.PersonInfo_RefID = found_PersonInfo.CMN_PER_PersonInfoID; ORM_CMN_PER_CommunicationContact found_CommunicationContact = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query_CommunicationContact).First(); found_CommunicationContact.Content = Parameter.ContactPhoneNumber; found_CommunicationContact.Save(Connection, Transaction); found_PersonInfo.Save(Connection, Transaction); } else { ORM_CMN_BPT_BusinessParticipant contactPerson = new ORM_CMN_BPT_BusinessParticipant(); Guid businessParticipantID = Guid.NewGuid(); contactPerson.CMN_BPT_BusinessParticipantID = businessParticipantID; contactPerson.IsCompany = false; contactPerson.IsNaturalPerson = true; contactPerson.IsTenant = false; contactPerson.Creation_Timestamp = DateTime.Now; contactPerson.Tenant_RefID = securityTicket.TenantID; item.ContactPerson_BusinessParticipant_RefID = businessParticipantID; //person info ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); Guid personInfoID = Guid.NewGuid(); contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; contactPerson.Save(Connection, Transaction); personInfo.CMN_PER_PersonInfoID = personInfoID; personInfo.FirstName = Parameter.ContactFirstName; personInfo.LastName = Parameter.ContactLastName; personInfo.PrimaryEmail = Parameter.ContactEmail; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); //Communication Contact ORM_CMN_PER_CommunicationContact communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfoID; communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPhoneNumber; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); item.ContactPerson_BusinessParticipant_RefID = businessParticipantID; item.Save(Connection, Transaction); } //Company (pharmacy) finding and edit var query_CompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); query_CompanyInfo.CMN_COM_CompanyInfoID = item.Ext_CompanyInfo_RefID; ORM_CMN_COM_CompanyInfo found_CompanyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, query_CompanyInfo).First(); var query_CompanyContactDetails = new ORM_CMN_UniversalContactDetail.Query(); query_CompanyContactDetails.CMN_UniversalContactDetailID = found_CompanyInfo.Contact_UCD_RefID; ORM_CMN_UniversalContactDetail found_CompanyContactDetails = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, query_CompanyContactDetails).FirstOrDefault(); if (found_CompanyContactDetails != null) { found_CompanyContactDetails.CompanyName_Line1 = Parameter.PharmacyName; found_CompanyContactDetails.Contact_Email = Parameter.MainEmail; found_CompanyContactDetails.Street_Name = Parameter.Street; found_CompanyContactDetails.Street_Number = Parameter.Number; found_CompanyContactDetails.Street_Name_Line2 = Parameter.Street2; found_CompanyContactDetails.Town = Parameter.Town; found_CompanyContactDetails.ZIP = Parameter.ZIP; found_CompanyContactDetails.Save(Connection, Transaction); } else { ORM_CMN_UniversalContactDetail universalContactDetails = new ORM_CMN_UniversalContactDetail(); universalContactDetails.CMN_UniversalContactDetailID = Guid.NewGuid(); universalContactDetails.IsCompany = true; universalContactDetails.CompanyName_Line1 = Parameter.PharmacyName; universalContactDetails.Street_Name = Parameter.Street; universalContactDetails.Street_Name_Line2 = Parameter.Street2; universalContactDetails.Street_Number = Parameter.Number; universalContactDetails.Contact_Email = Parameter.MainEmail; universalContactDetails.ZIP = Parameter.ZIP; universalContactDetails.Town = Parameter.Town; universalContactDetails.Tenant_RefID = securityTicket.TenantID; universalContactDetails.Save(Connection, Transaction); found_CompanyInfo.Contact_UCD_RefID = universalContactDetails.CMN_UniversalContactDetailID; found_CompanyInfo.Save(Connection, Transaction); } var query_BusinessParticipant_Company = new ORM_CMN_BPT_BusinessParticipant.Query(); query_BusinessParticipant_Company.IfCompany_CMN_COM_CompanyInfo_RefID = found_CompanyInfo.CMN_COM_CompanyInfoID; ORM_CMN_BPT_BusinessParticipant found_BusinessParticipant_Company = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query_BusinessParticipant_Company).First(); found_BusinessParticipant_Company.DisplayName = Parameter.PharmacyName; found_BusinessParticipant_Company.Save(Connection, Transaction); #endregion } else { #region Save item.HEC_PharmacyID = Guid.NewGuid(); item.Creation_Timestamp = DateTime.Now; item.Tenant_RefID = securityTicket.TenantID; //business Participants ORM_CMN_BPT_BusinessParticipant contactPerson = new ORM_CMN_BPT_BusinessParticipant(); Guid businessParticipantID = Guid.NewGuid(); contactPerson.CMN_BPT_BusinessParticipantID = businessParticipantID; contactPerson.IsCompany = false; contactPerson.IsNaturalPerson = true; contactPerson.IsTenant = false; contactPerson.Creation_Timestamp = DateTime.Now; contactPerson.Tenant_RefID = securityTicket.TenantID; item.ContactPerson_BusinessParticipant_RefID = businessParticipantID; //person info ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); Guid personInfoID = Guid.NewGuid(); contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; contactPerson.Save(Connection, Transaction); personInfo.CMN_PER_PersonInfoID = personInfoID; personInfo.FirstName = Parameter.ContactFirstName; personInfo.LastName = Parameter.ContactLastName; personInfo.PrimaryEmail = Parameter.ContactEmail; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); //Communication Contact ORM_CMN_PER_CommunicationContact communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfoID; communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPhoneNumber; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); //ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); //Guid companyInfoID = Guid.NewGuid(); ORM_CMN_COM_CompanyInfo extCompanyInfo = new ORM_CMN_COM_CompanyInfo(); Guid extCompanyInfoID = Guid.NewGuid(); extCompanyInfo.CMN_COM_CompanyInfoID = extCompanyInfoID; Guid contactUCDID = Guid.NewGuid(); extCompanyInfo.Contact_UCD_RefID = contactUCDID; extCompanyInfo.Creation_Timestamp = DateTime.Now; extCompanyInfo.Tenant_RefID = securityTicket.TenantID; item.Ext_CompanyInfo_RefID = extCompanyInfoID; ORM_CMN_UniversalContactDetail universalContactDetails = new ORM_CMN_UniversalContactDetail(); universalContactDetails.CMN_UniversalContactDetailID = contactUCDID; universalContactDetails.IsCompany = true; universalContactDetails.CompanyName_Line1 = Parameter.PharmacyName; universalContactDetails.Street_Name = Parameter.Street; universalContactDetails.Street_Name_Line2 = Parameter.Street2; universalContactDetails.Street_Number = Parameter.Number; universalContactDetails.Contact_Email = Parameter.MainEmail; universalContactDetails.ZIP = Parameter.ZIP; universalContactDetails.Town = Parameter.Town; universalContactDetails.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant extCompany = new ORM_CMN_BPT_BusinessParticipant(); extCompany.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); extCompany.Creation_Timestamp = DateTime.Now; extCompany.Tenant_RefID = securityTicket.TenantID; extCompany.DisplayName = Parameter.PharmacyName; extCompany.IsCompany = true; extCompany.IsNaturalPerson = false; extCompany.IsTenant = false; extCompany.IsDeleted = false; extCompany.IfCompany_CMN_COM_CompanyInfo_RefID = extCompanyInfoID; extCompany.Save(Connection, Transaction); extCompanyInfo.Save(Connection, Transaction); universalContactDetails.Save(Connection, Transaction); item.Save(Connection, Transaction); returnValue.Result = item.HEC_PharmacyID; #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5ACACU_SPC_1047 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); if (Parameter.IsDelete && (Parameter.CMN_BPT_CTM_CustomerID == Guid.Empty)) { return(returnValue); } ORM_CMN_BPT_CTM_Customer customer; if (Parameter.CMN_BPT_CTM_CustomerID != Guid.Empty) { var customerQ = new ORM_CMN_BPT_CTM_Customer.Query(); customerQ.Tenant_RefID = securityTicket.TenantID; customerQ.IsDeleted = false; customerQ.CMN_BPT_CTM_CustomerID = Parameter.CMN_BPT_CTM_CustomerID; customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQ).First(); customer.IsCustomerOrderAutomaticallyApprovedOnReceipt = Parameter.IsCustomerOrderAutomaticallyApprovedOnReceipt; } else { customer = new ORM_CMN_BPT_CTM_Customer(); customer.Tenant_RefID = securityTicket.TenantID; customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.InternalCustomerNumber = Parameter.Number; customer.IsCustomerOrderAutomaticallyApprovedOnReceipt = Parameter.IsCustomerOrderAutomaticallyApprovedOnReceipt; } ORM_CMN_BPT_CTM_AvailablePaymentType customer2PaymentType; var customer2PaymentTypeQ = new ORM_CMN_BPT_CTM_AvailablePaymentType.Query(); customer2PaymentTypeQ.Tenant_RefID = securityTicket.TenantID; customer2PaymentTypeQ.IsDeleted = false; customer2PaymentTypeQ.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; customer2PaymentType = ORM_CMN_BPT_CTM_AvailablePaymentType.Query.Search(Connection, Transaction, customer2PaymentTypeQ).FirstOrDefault(); if (customer2PaymentType == null) { customer2PaymentType = new ORM_CMN_BPT_CTM_AvailablePaymentType(); customer2PaymentType.ACC_PAY_Type_RefID = Guid.NewGuid(); customer2PaymentType.Tenant_RefID = securityTicket.TenantID; customer2PaymentType.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; } customer2PaymentType.ACC_PAY_Type_RefID = Parameter.PaymentTypeID; customer2PaymentType.Save(Connection, Transaction); #region payment condition ORM_CMN_BPT_CTM_AvailablePaymentCondition customer2PaymentCondition; var customer2PaymentConditionQ = new ORM_CMN_BPT_CTM_AvailablePaymentCondition.Query(); customer2PaymentConditionQ.Tenant_RefID = securityTicket.TenantID; customer2PaymentConditionQ.IsDeleted = false; customer2PaymentConditionQ.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; customer2PaymentCondition = ORM_CMN_BPT_CTM_AvailablePaymentCondition.Query.Search(Connection, Transaction, customer2PaymentConditionQ).FirstOrDefault(); if (customer2PaymentCondition == null) { customer2PaymentCondition = new ORM_CMN_BPT_CTM_AvailablePaymentCondition(); customer2PaymentCondition.ACC_PAY_Condition_RefID = Guid.NewGuid(); customer2PaymentCondition.Tenant_RefID = securityTicket.TenantID; customer2PaymentCondition.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; } customer2PaymentCondition.ACC_PAY_Condition_RefID = Parameter.PaymentConditionID; customer2PaymentCondition.Save(Connection, Transaction); #endregion ORM_CMN_BPT_BusinessParticipant bParticipant; if (customer.Ext_BusinessParticipant_RefID != Guid.Empty) { var bParticipantQ = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQ.Tenant_RefID = securityTicket.TenantID; bParticipantQ.IsDeleted = false; bParticipantQ.CMN_BPT_BusinessParticipantID = customer.Ext_BusinessParticipant_RefID; bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQ).First(); } else { bParticipant = new ORM_CMN_BPT_BusinessParticipant(); bParticipant.Tenant_RefID = securityTicket.TenantID; bParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bParticipant.IsNaturalPerson = true; customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } bParticipant.DisplayName = Parameter.FirstName + " " + Parameter.LastName; ORM_CMN_PER_PersonInfo personInfo; if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var personInfoQ = new ORM_CMN_PER_PersonInfo.Query(); personInfoQ.Tenant_RefID = securityTicket.TenantID; personInfoQ.IsDeleted = false; personInfoQ.CMN_PER_PersonInfoID = bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQ).First(); } else { personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.CMN_PER_PersonInfoID = Guid.NewGuid(); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; } #region connection with legal guardian //checking is there allready legal guardian associated with this business participant ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query LGCheckQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); LGCheckQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; LGCheckQuery.IsDeleted = false; Boolean oldLegalGuardianConnectionExist = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Exists(Connection, Transaction, LGCheckQuery); if (Parameter.IsRepresentedByLegalGuardian) { if (oldLegalGuardianConnectionExist) { ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant oldLegalGuardianConnection = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, LGCheckQuery).First(); ORM_CMN_BPT_BusinessParticipant.Query oldLegalGuardianQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); oldLegalGuardianQuery.CMN_BPT_BusinessParticipantID = oldLegalGuardianConnection.AssociatedBusinessParticipant_RefID; oldLegalGuardianQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipant oldLegalGuardian = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, oldLegalGuardianQuery).First(); oldLegalGuardian.DisplayName = Parameter.LegalGuardianName; oldLegalGuardian.Save(Connection, Transaction); } else { // creating a new legal guardian ORM_CMN_BPT_BusinessParticipant newLegalGuardian = new ORM_CMN_BPT_BusinessParticipant(); ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant legalGuardianLink = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); newLegalGuardian.DisplayName = Parameter.LegalGuardianName; legalGuardianLink.AssociatedBusinessParticipant_RefID = newLegalGuardian.CMN_BPT_BusinessParticipantID; legalGuardianLink.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; newLegalGuardian.Save(Connection, Transaction); legalGuardianLink.Save(Connection, Transaction); } } else { //delete old legal guardian if there is an old legal guardian if (oldLegalGuardianConnectionExist) { ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant oldLegalGuardianConnection = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, LGCheckQuery).First(); ORM_CMN_BPT_BusinessParticipant.Query oldLegalGuardianQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); oldLegalGuardianQuery.CMN_BPT_BusinessParticipantID = oldLegalGuardianConnection.AssociatedBusinessParticipant_RefID; oldLegalGuardianQuery.IsDeleted = false; //deleting old legal guardian from business participant table if (ORM_CMN_BPT_BusinessParticipant.Query.Exists(Connection, Transaction, oldLegalGuardianQuery)) { ORM_CMN_BPT_BusinessParticipant oldLegalGuardian = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, oldLegalGuardianQuery).First(); oldLegalGuardian.IsDeleted = true; oldLegalGuardian.Save(Connection, Transaction); } // deleting connenction beetwen customer and legal guardian oldLegalGuardianConnection.IsDeleted = true; oldLegalGuardianConnection.Save(Connection, Transaction); } } #endregion personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.BirthDate; personInfo.IsRepresentedByLegalGuardian = Parameter.IsRepresentedByLegalGuardian; personInfo.IsDeleted = Parameter.IsDelete; bParticipant.IsDeleted = Parameter.IsDelete; customer.IsDeleted = Parameter.IsDelete; personInfo.Save(Connection, Transaction); bParticipant.Save(Connection, Transaction); customer.Save(Connection, Transaction); returnValue.Result = customer.CMN_BPT_CTM_CustomerID; return(returnValue); #endregion UserCode }
protected static FR_L5PA_SP__1607 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SP__1607 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PA_SP__1607(); returnValue.Result = new L5PA_SP__1607(); ORM_HEC_Patient item = new ORM_HEC_Patient(); bool isOK = true; #region Save if (Parameter.IsEdit == false) { P_L5PA_CIPEIP_1213 healthInsuranceParam = new P_L5PA_CIPEIP_1213(); healthInsuranceParam.PracticeID = Parameter.PracticeID; healthInsuranceParam.HealthInsuranceNumber = Parameter.HealthInsuranceNumber; var hInsurance = cls_CheckIfPatientExistsInPractice.Invoke(Connection, Transaction, healthInsuranceParam, securityTicket).Result; //var healtInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); //healtInsuranceQuery.HealthInsurance_Number = Parameter.HealthInsuranceNumber; //healtInsuranceQuery.Tenant_RefID = securityTicket.TenantID; //healtInsuranceQuery.IsDeleted = false; //var hInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healtInsuranceQuery).FirstOrDefault(); if (hInsurance.numberofID == 0) { Guid patientID = Parameter.PatientID; Guid CMN_BPT_BusinessParticipantID = Guid.NewGuid(); item.HEC_PatientID = patientID; item.CMN_BPT_BusinessParticipant_RefID = CMN_BPT_BusinessParticipantID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); #region save CMN_BPT_BusinessParticipant ORM_CMN_BPT_BusinessParticipant bussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); bussinessParticipant.CMN_BPT_BusinessParticipantID = CMN_BPT_BusinessParticipantID; bussinessParticipant.DisplayName = Parameter.Name + Parameter.LastName; bussinessParticipant.IsNaturalPerson = true; bussinessParticipant.IsCompany = false; Guid NaturalPerson_CMN_PER_PersonInfoID = Guid.NewGuid(); bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = NaturalPerson_CMN_PER_PersonInfoID; bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.Empty; bussinessParticipant.IsTenant = false; bussinessParticipant.IfTenant_Tenant_RefID = Guid.Empty; bussinessParticipant.Tenant_RefID = securityTicket.TenantID; bussinessParticipant.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = NaturalPerson_CMN_PER_PersonInfoID; personInfo.FirstName = Parameter.Name; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.Birthdate; personInfo.Gender = Parameter.Gender; personInfo.ProfileImage_Document_RefID = Guid.Empty; personInfo.Modification_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); ORM_HEC_Patient_MedicalPractice medicalPractice = new ORM_HEC_Patient_MedicalPractice(); medicalPractice.HEC_Patient_MedicalPracticeID = Guid.NewGuid(); medicalPractice.HEC_Patient_RefID = patientID; medicalPractice.HEC_MedicalPractices_RefID = Parameter.PracticeID; medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance healtInsurance = new ORM_HEC_Patient_HealthInsurance(); healtInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid(); healtInsurance.HealthInsurance_Number = Parameter.HealthInsuranceNumber; healtInsurance.Patient_RefID = patientID; healtInsurance.HealthInsurance_State_RefID = Guid.Empty; healtInsurance.InsuranceStateCode = Parameter.InsuranceStateCode; healtInsurance.Tenant_RefID = securityTicket.TenantID; //TODO healtInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HealthInsuranceCompanyID; healtInsurance.Save(Connection, Transaction); #endregion } else { isOK = false; } } #endregion #region Edit else { var result = item.Load(Connection, Transaction, Parameter.PatientID); if (result.Status != FR_Status.Success || item.HEC_PatientID == Guid.Empty) { //var error = new FR_Guid(); //error.ErrorMessage = "No Such ID"; //error.Status = FR_Status.Error_Internal; //return error; } //bussinessParticipant var query1 = new ORM_CMN_BPT_BusinessParticipant.Query(); query1.CMN_BPT_BusinessParticipantID = item.CMN_BPT_BusinessParticipant_RefID; var bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, query1).First(); //personInfo var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = bussinessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, query2).FirstOrDefault(); //medicalPractice var query3 = new ORM_HEC_Patient_MedicalPractice.Query(); query3.HEC_Patient_RefID = Parameter.PatientID; var medicalPractice = ORM_HEC_Patient_MedicalPractice.Query.Search(Connection, Transaction, query3).First(); //healthInsurance var query4 = new ORM_HEC_Patient_HealthInsurance.Query(); query4.Patient_RefID = Parameter.PatientID; var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, query4).First(); #region Delete Patient if (Parameter.IsDeleted == true) { item.IsDeleted = true; item.Save(Connection, Transaction); } #endregion else { //edit person info personInfo.FirstName = Parameter.Name; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.Birthdate; personInfo.Gender = Parameter.Gender; personInfo.Save(Connection, Transaction); //edit medical practise medicalPractice.HEC_MedicalPractices_RefID = Parameter.PracticeID; medicalPractice.Save(Connection, Transaction); // health insurance healthInsurance.HealthInsurance_State_RefID = Guid.Empty; healthInsurance.InsuranceStateCode = Parameter.InsuranceStateCode; healthInsurance.HealthInsurance_Number = Parameter.HealthInsuranceNumber; //TODO healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HealthInsuranceCompanyID; healthInsurance.Save(Connection, Transaction); item.Save(Connection, Transaction); } } #endregion returnValue.Result.isOK = isOK; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_GPBD_1613 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); returnValue.Result = new Guid(); var patient = new ORM_HEC_Patient(); //var serializer = new JsonNetSerializer(); //var connection = new ElasticConnection((String)HttpContext.GetGlobalResourceObject("Global", "ElasticConnection"), 9200); #region Save if (Parameter.ID == null || Parameter.ID == Guid.Empty) { //ORM_HEC_Patient patient.HEC_PatientID = Guid.NewGuid(); patient.Tenant_RefID = securityTicket.TenantID; patient.Creation_Timestamp = DateTime.Now; patient.CMN_BPT_BusinessParticipant_RefID = Guid.NewGuid(); patient.Save(Connection, Transaction); //ORM_CMN_BPT_BusinessParticipant var businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipant.IsNaturalPerson = true; businessParticipant.Tenant_RefID = securityTicket.TenantID; businessParticipant.Creation_Timestamp = DateTime.Now; businessParticipant.Modification_Timestamp = DateTime.Now; businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); businessParticipant.Save(Connection, Transaction); //ORM_CMN_PER_PersonInfo var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.PrimaryEmail = Parameter.PrimaryEmail; personInfo.Title = Parameter.Title; personInfo.ProfileImage_Document_RefID = Parameter.ProfileImage_Document_RefID; personInfo.BirthDate = Parameter.BirthDate; personInfo.Gender = Int32.Parse(Parameter.Gender); personInfo.Salutation_General = Parameter.AcademicTitle; personInfo.Address_RefID = Guid.NewGuid(); personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Modification_Timestamp = DateTime.Now; personInfo.AgeCalculation_YearOfBirth = DateTime.Now.Year - personInfo.BirthDate.Year; personInfo.Save(Connection, Transaction); //ORM_CMN_Address var address = new ORM_CMN_Address(); address.CMN_AddressID = personInfo.Address_RefID; address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.City_Name; address.City_PostalCode = Parameter.City_PostalCode; address.Country_ISOCode = Parameter.Country_ISOCode; address.Tenant_RefID = securityTicket.TenantID; address.Creation_Timestamp = DateTime.Now; address.Save(Connection, Transaction); //ORM_CMN_PER_PersonInfo_SocialSecurityNumber var socialSecurityNumber = new ORM_CMN_PER_PersonInfo_SocialSecurityNumber(); socialSecurityNumber.CMN_PER_PersonInfo_SocialSecurityNumberID = Guid.NewGuid(); socialSecurityNumber.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; socialSecurityNumber.SocialSecurityNumber = Parameter.SocialSecurityNumber; socialSecurityNumber.Tenant_RefID = securityTicket.TenantID; socialSecurityNumber.Creation_Timestamp = DateTime.Now; socialSecurityNumber.Save(Connection, Transaction); var TelephoneCompanyType = CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, new CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query() { Type = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Phone), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); var MobileCompanyType = CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, new CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query() { Type = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Mobile), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var EmailType = CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, new CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query() { Type = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Email), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); //add into database //var UrlType = CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, // new CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query() // { // Type = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.URL), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false // }).Single(); var FaxType = CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, new CL1_CMN_PER.ORM_CMN_PER_CommunicationContact_Type.Query() { Type = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Fax), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_CMN_PER_CommunicationContact communicationContactsPhone = new ORM_CMN_PER_CommunicationContact(); communicationContactsPhone.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContactsPhone.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContactsPhone.Contact_Type = TelephoneCompanyType.CMN_PER_CommunicationContact_TypeID; communicationContactsPhone.Content = Parameter.ContactTypes.Where(p => p.Type == DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Phone)).Single().Content; communicationContactsPhone.Creation_Timestamp = DateTime.Now; communicationContactsPhone.Modification_Timestamp = DateTime.Now; communicationContactsPhone.Tenant_RefID = securityTicket.TenantID; communicationContactsPhone.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact communicationContactsMobile = new ORM_CMN_PER_CommunicationContact(); communicationContactsMobile.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContactsMobile.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContactsMobile.Contact_Type = MobileCompanyType.CMN_PER_CommunicationContact_TypeID; communicationContactsMobile.Content = Parameter.ContactTypes.Where(p => p.Type == DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Mobile)).Single().Content; communicationContactsMobile.Creation_Timestamp = DateTime.Now; communicationContactsMobile.Modification_Timestamp = DateTime.Now; communicationContactsMobile.Tenant_RefID = securityTicket.TenantID; communicationContactsMobile.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact communicationContactsEmail = new ORM_CMN_PER_CommunicationContact(); communicationContactsEmail.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContactsEmail.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContactsEmail.Contact_Type = EmailType.CMN_PER_CommunicationContact_TypeID; communicationContactsEmail.Content = Parameter.ContactTypes.Where(p => p.Type == DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Email)).Single().Content; communicationContactsEmail.Creation_Timestamp = DateTime.Now; communicationContactsEmail.Modification_Timestamp = DateTime.Now; communicationContactsEmail.Tenant_RefID = securityTicket.TenantID; communicationContactsEmail.Save(Connection, Transaction); //*******************Save languages to patient************************ if (Parameter.Languages != null && Parameter.Languages.Count() != 0) { foreach (var language in Parameter.Languages) { ORM_CMN_BPT_BusinessParticipant_SpokenLanguage bpLanguage = new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage(); bpLanguage.CMN_BPT_BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; bpLanguage.CMN_BPT_BusinessParticipant_SpokenLanguageID = Guid.NewGuid(); bpLanguage.CMN_Language_RefID = language.CMN_Language_RefID; bpLanguage.IsDeleted = false; bpLanguage.Tenant_RefID = securityTicket.TenantID; bpLanguage.Save(Connection, Transaction); } } //#region Upload To Elastic //bool indexExists = true; //#region set Mapping //string jsonPatientMapping = new MapBuilder<Patient>() // .RootObject("patient", ro => ro // .Properties(pr => pr // .MultiField("name", mfp => mfp.Fields(f => f // .String("name", sp => sp.IndexAnalyzer("autocomplete").SearchAnalyzer(DefaultAnalyzers.standard)) // .String("lower_case_sort", sp => sp.Analyzer("caseinsensitive")) // ) // ) // .MultiField("last_name", mfp => mfp.Fields(f => f // .String("last_name", sp => sp.IndexAnalyzer("autocomplete").SearchAnalyzer(DefaultAnalyzers.standard)) // .String("lower_case_sort", sp => sp.Analyzer("caseinsensitive")) // ) // ) // .MultiField("birthday", mfp => mfp.Fields(f => f // .String("birthday", sp => sp.IndexAnalyzer("autocomplete").SearchAnalyzer(DefaultAnalyzers.standard)) // .String("lower_case_sort", sp => sp.Analyzer("caseinsensitive")) // ) // ) // .MultiField("age", mfp => mfp.Fields(f => f // .String("age", sp => sp.IndexAnalyzer("autocomplete").SearchAnalyzer(DefaultAnalyzers.standard)) // .String("lower_case_sort", sp => sp.Analyzer("caseinsensitive")) // ) // ) // )).BuildBeautified(); //#endregion //try //{ // connection.Head(new IndexExistsCommand(securityTicket.TenantID.ToString())); //} //catch (OperationException ex) //{ // if (ex.HttpStatusCode == 404) // indexExists = false; //} //if (!indexExists) //{ // #region set index settings // string settings = new IndexSettingsBuilder() // .Analysis(anl => anl // .Filter(fil => fil // .EdgeNGram("autocomplete_filter", gr => gr.MinGram(1).MaxGram(20))) // .Analyzer(a => a // .Custom("caseinsensitive", custom => custom // .Tokenizer(DefaultTokenizers.keyword) // .Filter("lowercase") // ) // .Custom("autocomplete", custom => custom // .Tokenizer(DefaultTokenizers.standard) // .Filter("lowercase", "autocomplete_filter") // ) // ) // ) // .BuildBeautified(); // #endregion // connection.Put(securityTicket.TenantID.ToString(), settings); //} //#region check if type exists //bool typeExists = true; //try //{ // connection.Head(new IndexExistsCommand(securityTicket.TenantID.ToString() + "/patient")); //} //catch (OperationException ex) //{ // if (ex.HttpStatusCode == 404) // typeExists = false; //} //#endregion //if (!typeExists) // connection.Put(new PutMappingCommand(securityTicket.TenantID.ToString(), "patient"), jsonPatientMapping); //string bulkCommand = new BulkCommand(index: securityTicket.TenantID.ToString(), type: "patient").Refresh(); //List<Patient> patientList = new List<Patient>(); //Patient patient_elastic = new Patient(); //patient_elastic.id = patient.HEC_PatientID.ToString(); //patient_elastic.age = (DateTime.Today.Year - Parameter.BirthDate.Year).ToString(); //patient_elastic.birthday = Parameter.BirthDate.ToShortDateString(); //patient_elastic.last_name = Parameter.LastName; //patient_elastic.name = Parameter.FirstName; //patientList.Add(patient_elastic); //string bulkJson = new BulkBuilder(serializer) // .BuildCollection(patientList, (builder, pro) => builder.Index(data: pro, id: pro.id) // ); //connection.Post(bulkCommand, bulkJson); //#endregion } #endregion else { #region Delete if (Parameter.isDeleted) { var patientQuery = new ORM_HEC_Patient.Query(); patientQuery.HEC_PatientID = Parameter.ID; patientQuery.IsDeleted = false; patientQuery.Tenant_RefID = securityTicket.TenantID; patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single(); patient.IsDeleted = true; patient.Save(Connection, Transaction); var businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQuery.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipantQuery.IsDeleted = false; businessParticipantQuery.Tenant_RefID = securityTicket.TenantID; var businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single(); businessParticipant.IsDeleted = true; businessParticipant.Save(Connection, Transaction); var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.CMN_PER_PersonInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfoQuery.IsDeleted = false; personInfoQuery.Tenant_RefID = securityTicket.TenantID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).Single(); personInfo.IsDeleted = true; personInfo.Save(Connection, Transaction); var addressQuery = new ORM_CMN_Address.Query(); addressQuery.CMN_AddressID = personInfo.Address_RefID; addressQuery.IsDeleted = false; addressQuery.Tenant_RefID = securityTicket.TenantID; var address = ORM_CMN_Address.Query.Search(Connection, Transaction, addressQuery).Single(); address.IsDeleted = true; address.Save(Connection, Transaction); var socialSecurityNumberQuery = new ORM_CMN_PER_PersonInfo_SocialSecurityNumber.Query(); socialSecurityNumberQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; socialSecurityNumberQuery.IsDeleted = false; socialSecurityNumberQuery.Tenant_RefID = securityTicket.TenantID; var socialSecurityNumber = ORM_CMN_PER_PersonInfo_SocialSecurityNumber.Query.Search(Connection, Transaction, socialSecurityNumberQuery).Single(); socialSecurityNumber.IsDeleted = true; socialSecurityNumber.Save(Connection, Transaction); var communicationContactQuery = new ORM_CMN_PER_CommunicationContact.Query(); communicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContactQuery.IsDeleted = false; communicationContactQuery.Tenant_RefID = securityTicket.TenantID; var communicationContactList = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, communicationContactQuery).ToList(); ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query.SoftDelete(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query { CMN_BPT_BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); //// delete on Elastic //connection.Delete(securityTicket.TenantID.ToString() + "/patient/" + Parameter.ID.ToString()); } #endregion #region Edit else { var patientQuery = new ORM_HEC_Patient.Query(); patientQuery.HEC_PatientID = Parameter.ID; patientQuery.IsDeleted = false; patientQuery.Tenant_RefID = securityTicket.TenantID; patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single(); var businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQuery.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipant_RefID; businessParticipantQuery.IsDeleted = false; businessParticipantQuery.Tenant_RefID = securityTicket.TenantID; var businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single(); var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.CMN_PER_PersonInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfoQuery.IsDeleted = false; personInfoQuery.Tenant_RefID = securityTicket.TenantID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).Single(); personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.PrimaryEmail = Parameter.PrimaryEmail; personInfo.Title = Parameter.Title; personInfo.Gender = Int32.Parse(Parameter.Gender); personInfo.ProfileImage_Document_RefID = Parameter.ProfileImage_Document_RefID; personInfo.BirthDate = Parameter.BirthDate; personInfo.Salutation_General = Parameter.AcademicTitle; personInfo.Modification_Timestamp = DateTime.Now; personInfo.AgeCalculation_YearOfBirth = DateTime.Now.Year - personInfo.BirthDate.Year; personInfo.Save(Connection, Transaction); if (personInfo.Address_RefID != Guid.Empty) { var addressQuery = new ORM_CMN_Address.Query(); addressQuery.CMN_AddressID = personInfo.Address_RefID; addressQuery.IsDeleted = false; addressQuery.Tenant_RefID = securityTicket.TenantID; var address = ORM_CMN_Address.Query.Search(Connection, Transaction, addressQuery).Single(); address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.City_Name; address.City_PostalCode = Parameter.City_PostalCode; address.Country_ISOCode = Parameter.Country_ISOCode; address.Save(Connection, Transaction); } else { var address = new ORM_CMN_Address(); address.CMN_AddressID = Guid.NewGuid(); address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.City_Name; address.City_PostalCode = Parameter.City_PostalCode; address.Country_ISOCode = Parameter.Country_ISOCode; address.Tenant_RefID = securityTicket.TenantID; address.Creation_Timestamp = DateTime.Now; address.Save(Connection, Transaction); personInfo.Address_RefID = address.CMN_AddressID; personInfo.Save(Connection, Transaction); } var socialSecurityNumberQuery = new ORM_CMN_PER_PersonInfo_SocialSecurityNumber.Query(); socialSecurityNumberQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; socialSecurityNumberQuery.IsDeleted = false; socialSecurityNumberQuery.Tenant_RefID = securityTicket.TenantID; var socialSecurityNumber = ORM_CMN_PER_PersonInfo_SocialSecurityNumber.Query.Search(Connection, Transaction, socialSecurityNumberQuery).SingleOrDefault(); if (socialSecurityNumber == null) { socialSecurityNumber = new ORM_CMN_PER_PersonInfo_SocialSecurityNumber(); socialSecurityNumber.CMN_PER_PersonInfo_SocialSecurityNumberID = Guid.NewGuid(); socialSecurityNumber.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; socialSecurityNumber.Tenant_RefID = securityTicket.TenantID; } socialSecurityNumber.SocialSecurityNumber = Parameter.SocialSecurityNumber; socialSecurityNumber.Save(Connection, Transaction); var communicationContactQuery = new ORM_CMN_PER_CommunicationContact.Query(); communicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContactQuery.IsDeleted = false; communicationContactQuery.Tenant_RefID = securityTicket.TenantID; var communicationContactList = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, communicationContactQuery).ToList(); List <string> unusedTypes = new List <string>() { DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.URL), DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Mobile), DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Phone), DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Email) }; foreach (var communicationContact in communicationContactList) { var communicationContact_TypeQuery = new ORM_CMN_PER_CommunicationContact_Type.Query(); communicationContact_TypeQuery.CMN_PER_CommunicationContact_TypeID = communicationContact.Contact_Type; communicationContact_TypeQuery.IsDeleted = false; communicationContact_TypeQuery.Tenant_RefID = securityTicket.TenantID; var communicationContact_Type = ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, communicationContact_TypeQuery).Single(); var newType = Parameter.ContactTypes.Where(i => i.Type == communicationContact_Type.Type).Single(); communicationContact.Content = newType.Content; communicationContact.Modification_Timestamp = DateTime.Now; communicationContact.Save(Connection, Transaction); if (unusedTypes.Contains(communicationContact_Type.Type)) { unusedTypes.Remove(communicationContact_Type.Type); } } var contactTypes = cls_Get_AllComunicationContactTypes.Invoke(Connection, Transaction, securityTicket).Result.ToList(); foreach (var type in unusedTypes) { ORM_CMN_PER_CommunicationContact communicationContactsPhone = new ORM_CMN_PER_CommunicationContact(); communicationContactsPhone.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContactsPhone.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; P_L2CN_GCTIDfGPMID_1359 contantTypeParam = new P_L2CN_GCTIDfGPMID_1359(); contantTypeParam.Type = type; var contantTypeID = cls_Get_ContantTypeID_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, contantTypeParam, securityTicket).Result.ContactTypeID; communicationContactsPhone.Contact_Type = contantTypeID; communicationContactsPhone.Content = Parameter.ContactTypes.Where(p => p.Type == DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(CL2_Contact.DomainManagement.EComunactionContactType.Phone)).Single().Content; communicationContactsPhone.Creation_Timestamp = DateTime.Now; communicationContactsPhone.Modification_Timestamp = DateTime.Now; communicationContactsPhone.Tenant_RefID = securityTicket.TenantID; communicationContactsPhone.Save(Connection, Transaction); } //connection.Delete(securityTicket.TenantID.ToString() + "/patient/" + Parameter.ID.ToString()); //string bulkCommand = new BulkCommand(index: securityTicket.TenantID.ToString(), type: "patient").Refresh(); //List<Patient> patientList = new List<Patient>(); //Patient patient_elastic = new Patient(); //patient_elastic.id = patient.HEC_PatientID.ToString(); //patient_elastic.age = (DateTime.Today.Year - Parameter.BirthDate.Year).ToString(); //patient_elastic.birthday = Parameter.BirthDate.ToShortDateString(); //patient_elastic.last_name = Parameter.LastName; //patient_elastic.name = Parameter.FirstName; //patientList.Add(patient_elastic); //string bulkJson = new BulkBuilder(serializer) // .BuildCollection(patientList, (builder, pro) => builder.Index(data: pro, id: pro.id) // ); //connection.Post(bulkCommand, bulkJson); #region languages if (Parameter.Languages == null || Parameter.Languages.Count() == 0) { P_L5PA_GPBD_1613_Languages Languages = new P_L5PA_GPBD_1613_Languages(); Languages.CMN_Language_RefID = Guid.Empty; } else if (Parameter.Languages != null || Parameter.Languages.Count() != 0) { foreach (var language in Parameter.Languages) { var languageToPatient = ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query { CMN_Language_RefID = language.CMN_Language_RefID, CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).FirstOrDefault(); if (languageToPatient == null) { ORM_CMN_BPT_BusinessParticipant_SpokenLanguage bpLanguage = new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage(); bpLanguage.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID; bpLanguage.CMN_BPT_BusinessParticipant_SpokenLanguageID = Guid.NewGuid(); bpLanguage.CMN_Language_RefID = language.CMN_Language_RefID; bpLanguage.IsDeleted = false; bpLanguage.Tenant_RefID = securityTicket.TenantID; bpLanguage.Save(Connection, Transaction); } } // deleting languages to patient that were deleted during edit List <ORM_CMN_BPT_BusinessParticipant_SpokenLanguage> languageToDoctorList = ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query { CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var languageToDoctor in languageToDoctorList) { if (Parameter.Languages.FirstOrDefault(x => x.CMN_Language_RefID == languageToDoctor.CMN_Language_RefID) == null) { languageToDoctor.IsDeleted = true; languageToDoctor.Save(Connection, Transaction); } } } else { List <ORM_CMN_BPT_BusinessParticipant_SpokenLanguage> languageToDoctorList = ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_SpokenLanguage.Query { CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); if (languageToDoctorList != null || languageToDoctorList.Count() != 0) { foreach (var language in languageToDoctorList) { language.IsDeleted = true; language.Save(Connection, Transaction); } } } #endregion } #endregion } returnValue.Result = patient.HEC_PatientID; 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); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OU_DOUGD_1221 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); foreach (var OrgUnitID in Parameter.OrgUnitID) { //delete office var officeQuery = new ORM_CMN_STR_Office.Query(); officeQuery.Tenant_RefID = securityTicket.TenantID; officeQuery.IsDeleted = false; officeQuery.CMN_STR_OfficeID = OrgUnitID; var office = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Single(); //delete Medical practice type ORM_HEC_MedicalPractice_2_PracticeType.Query.SoftDelete(Connection, Transaction, new ORM_HEC_MedicalPractice_2_PracticeType.Query { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_MedicalPractice_RefID = office.IfMedicalPractise_HEC_MedicalPractice_RefID }); office.IsDeleted = true; office.Save(Connection, Transaction); //delete Addresses var addressQuery = new ORM_CMN_STR_Office_Address.Query(); addressQuery.IsDeleted = false; addressQuery.Tenant_RefID = securityTicket.TenantID; addressQuery.Office_RefID = OrgUnitID; var addressList = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, addressQuery).ToList(); foreach (var address in addressList) { address.IsDeleted = true; address.Save(Connection, Transaction); var addressDataQuery = new ORM_CMN_Address.Query(); addressDataQuery.IsDeleted = false; addressDataQuery.CMN_AddressID = address.CMN_Address_RefID; var addressData = ORM_CMN_Address.Query.Search(Connection, Transaction, addressDataQuery).Single(); addressData.IsDeleted = true; addressData.Save(Connection, Transaction); } //delete Unit Speciality //var office_2_officeTypeQuery = new ORM_CMN_STR_Office_2_OfficeType.Query(); //office_2_officeTypeQuery.IsDeleted = false; //office_2_officeTypeQuery.Office_RefID = OrgUnitID; //var office_2_officeType = ORM_CMN_STR_Office_2_OfficeType.Query.Search(Connection, Transaction, office_2_officeTypeQuery).First(); //office_2_officeType.IsDeleted = true; //office_2_officeType.Save(Connection, Transaction); //delete contact person data var responsiblePersonQuery = new ORM_CMN_STR_Office_ResponsiblePerson.Query(); responsiblePersonQuery.Office_RefID = OrgUnitID; responsiblePersonQuery.IsDeleted = false; var responsiblePerson = ORM_CMN_STR_Office_ResponsiblePerson.Query.Search(Connection, Transaction, responsiblePersonQuery).First(); responsiblePerson.IsDeleted = true; responsiblePerson.Save(Connection, Transaction); var employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID; var employee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery).Single(); employee.IsDeleted = true; employee.Save(Connection, Transaction); var businessParticpantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticpantQuery.CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID; businessParticpantQuery.IsDeleted = false; var businessParticpant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticpantQuery).Single(); businessParticpant.IsDeleted = true; businessParticpant.Save(Connection, Transaction); var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.CMN_PER_PersonInfoID = businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfoQuery.IsDeleted = false; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).Single(); personInfo.IsDeleted = true; personInfo.Save(Connection, Transaction); //delete all children var officeQueryChildren = new ORM_CMN_STR_Office.Query(); officeQueryChildren.Tenant_RefID = securityTicket.TenantID; officeQueryChildren.IsDeleted = false; officeQueryChildren.Parent_RefID = OrgUnitID; //delete connection to appointmetn types var orgUnitToAppointmentTypeQuery = new ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query(); orgUnitToAppointmentTypeQuery.CMN_STR_Office_RefID = OrgUnitID; orgUnitToAppointmentTypeQuery.Tenant_RefID = securityTicket.TenantID; orgUnitToAppointmentTypeQuery.IsDeleted = false; var orgUnitToAppointmentTypeList = ORM_PPS_TSK_Task_Template_OrganizationalUnitAvailability.Query.Search(Connection, Transaction, orgUnitToAppointmentTypeQuery).ToList(); foreach (var item in orgUnitToAppointmentTypeList) { item.IsDeleted = true; item.Save(Connection, Transaction); } var officeChildrenList = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQueryChildren).ToList(); if (officeChildrenList.Count > 0) { List <Guid> guidList = new List <Guid>(); foreach (var officeChildren in officeChildrenList) { guidList.Add(officeChildren.CMN_STR_OfficeID); } cls_Delete_OrgsUnitsGeneralData.Invoke(Connection, Transaction, new P_L5OU_DOUGD_1221 { OrgUnitID = guidList.ToArray() }, securityTicket); } } return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEWPGFSD_1437_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEWPGFSD_1437 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEWPGFSD_1437_Array(); //Put your code here ORM_CMN_BPT_EMP_Employee.Query empQuery = new ORM_CMN_BPT_EMP_Employee.Query(); empQuery.IsDeleted = false; empQuery.Tenant_RefID = securityTicket.TenantID; var allEmployees = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, empQuery); List <L5EM_GEWPGFSD_1437> resultList = new List <L5EM_GEWPGFSD_1437>(); foreach (var employee in allEmployees) { L5EM_GEWPGFSD_1437 resultItem = new L5EM_GEWPGFSD_1437(); resultItem.EmployeeID = employee.CMN_BPT_EMP_EmployeeID; ORM_CMN_BPT_BusinessParticipant.Query bptQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bptQuery.CMN_BPT_BusinessParticipantID = employee.BusinessParticipant_RefID; bptQuery.IsDeleted = false; bptQuery.Tenant_RefID = securityTicket.TenantID; var bpt = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bptQuery).FirstOrDefault(); ORM_CMN_PER_PersonInfo.Query infoQuery = new ORM_CMN_PER_PersonInfo.Query(); infoQuery.CMN_PER_PersonInfoID = bpt.IfNaturalPerson_CMN_PER_PersonInfo_RefID; infoQuery.IsDeleted = false; infoQuery.Tenant_RefID = securityTicket.TenantID; var info = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, infoQuery).FirstOrDefault(); int age = Parameter.SelectedDate.Year - info.BirthDate.Year; if (Parameter.SelectedDate < info.BirthDate.AddYears(age)) { age--; } resultItem.Age = age; resultItem.FirstName = info.FirstName; resultItem.LastName = info.LastName; ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query wpaQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); wpaQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; wpaQuery.IsDeleted = false; wpaQuery.Tenant_RefID = securityTicket.TenantID; var allWorkPlaceAssignements = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, wpaQuery); var workPlaceAssignementsForSelectedDate = allWorkPlaceAssignements.Where(x => x.WorkplaceAssignment_StartDate.Date.CompareTo(Parameter.SelectedDate) <= 0).ToArray(); if (workPlaceAssignementsForSelectedDate.Count() != 0) { var resultingWorkPlaceAssignement = workPlaceAssignementsForSelectedDate.OrderByDescending(x => x.WorkplaceAssignment_StartDate.Ticks).FirstOrDefault(); if (resultingWorkPlaceAssignement.CMN_BPT_EMP_Employee_PlanGroup_RefID == Guid.Empty) { resultItem.PlanGroupID = Guid.Empty; resultItem.PlanGroupName = new Dict(); resultItem.Position = -1; } else { ORM_CMN_BPT_EMP_Employee_PlanGroup.Query pgQuery = new ORM_CMN_BPT_EMP_Employee_PlanGroup.Query(); pgQuery.CMN_BPT_EMP_Employee_PlanGroupID = resultingWorkPlaceAssignement.CMN_BPT_EMP_Employee_PlanGroup_RefID; pgQuery.IsDeleted = false; pgQuery.Tenant_RefID = securityTicket.TenantID; var selectedPlanGroup = ORM_CMN_BPT_EMP_Employee_PlanGroup.Query.Search(Connection, Transaction, pgQuery).FirstOrDefault(); if (selectedPlanGroup == null) { resultItem.PlanGroupID = Guid.Empty; resultItem.PlanGroupName = new Dict(); resultItem.Position = -1; } else { resultItem.PlanGroupID = selectedPlanGroup.CMN_BPT_EMP_Employee_PlanGroupID; resultItem.PlanGroupName = selectedPlanGroup.PlanGroup_Name; resultItem.Position = resultingWorkPlaceAssignement.SequenceNumber; } resultItem.IsBreakTimeCalculated_Planning = resultingWorkPlaceAssignement.IsBreakTimeCalculated_Planning; resultItem.IsBreakTimeCalculated_Actual = resultingWorkPlaceAssignement.IsBreakTimeCalculated_Actual; } } else { continue; } ORM_CMN_BPT_EMP_EmploymentRelationship.Query employmentRelationshipQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query(); employmentRelationshipQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employmentRelationshipQuery.Tenant_RefID = securityTicket.TenantID; employmentRelationshipQuery.IsDeleted = false; ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, employmentRelationshipQuery).FirstOrDefault(); ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query er2wcQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); er2wcQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; er2wcQuery.Tenant_RefID = securityTicket.TenantID; er2wcQuery.IsContract_Active = true; er2wcQuery.IsDeleted = false; ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract er2wc = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, er2wcQuery).FirstOrDefault(); if (er2wc != null) { ORM_CMN_BPT_EMP_WorkingContract.Query workingContractQuery = new ORM_CMN_BPT_EMP_WorkingContract.Query(); workingContractQuery.CMN_BPT_EMP_WorkingContractID = er2wc.WorkingContract_RefID; workingContractQuery.IsDeleted = false; workingContractQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_EMP_WorkingContract workingContract = ORM_CMN_BPT_EMP_WorkingContract.Query.Search(Connection, Transaction, workingContractQuery).FirstOrDefault(); resultItem.IsWorkTimeCalculated_InDays = workingContract.IsWorkTimeCalculated_InDays; resultItem.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours; ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query wc2wdQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query(); wc2wdQuery.CMN_BPT_EMP_WorkingContract_RefID = er2wc.WorkingContract_RefID; wc2wdQuery.Tenant_RefID = securityTicket.TenantID; wc2wdQuery.IsDeleted = false; ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay[] workingContract2workingDays = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, wc2wdQuery).ToArray(); resultItem.ContractSpecifiedWorkTime_InMinutes = 0; List <WeeklyOfficeHours> listOfWeeklyOfficeHours = new List <WeeklyOfficeHours>(); foreach (var workingContract2workingDay in workingContract2workingDays) { ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query weeklyOfficeHoursQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query(); weeklyOfficeHoursQuery.CMN_CAL_WeeklyOfficeHours_IntervalID = workingContract2workingDay.CMN_CAL_WeeklyOfficeHours_Interval_RefID; weeklyOfficeHoursQuery.Tenant_RefID = securityTicket.TenantID; weeklyOfficeHoursQuery.IsDeleted = false; ORM_CMN_CAL_WeeklyOfficeHours_Interval weeklyOfficeHours = ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query.Search(Connection, Transaction, weeklyOfficeHoursQuery).FirstOrDefault(); switch (Parameter.SelectedDate.DayOfWeek) { case DayOfWeek.Monday: if (weeklyOfficeHours.IsMonday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Tuesday: if (weeklyOfficeHours.IsTuesday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Wednesday: if (weeklyOfficeHours.IsWednesday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Thursday: if (weeklyOfficeHours.IsThursday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Friday: if (weeklyOfficeHours.IsFriday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Saturday: if (weeklyOfficeHours.IsSaturday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; case DayOfWeek.Sunday: if (weeklyOfficeHours.IsSunday) { resultItem.ContractSpecifiedWorkTime_InMinutes = (int)(weeklyOfficeHours.TimeTo_InMinutes - weeklyOfficeHours.TimeFrom_InMinutes); } break; } WeeklyOfficeHours newWeeklyOfficeHour = new WeeklyOfficeHours(); newWeeklyOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = weeklyOfficeHours.CMN_CAL_WeeklyOfficeHours_IntervalID; newWeeklyOfficeHour.IsFriday = weeklyOfficeHours.IsFriday; newWeeklyOfficeHour.IsMonday = weeklyOfficeHours.IsMonday; newWeeklyOfficeHour.IsSaturday = weeklyOfficeHours.IsSaturday; newWeeklyOfficeHour.IsSunday = weeklyOfficeHours.IsSunday; newWeeklyOfficeHour.IsThursday = weeklyOfficeHours.IsThursday; newWeeklyOfficeHour.IsTuesday = weeklyOfficeHours.IsTuesday; newWeeklyOfficeHour.IsWednesday = weeklyOfficeHours.IsWednesday; newWeeklyOfficeHour.IsWholeDay = weeklyOfficeHours.IsWholeDay; newWeeklyOfficeHour.TimeFrom_InMinutes = weeklyOfficeHours.TimeFrom_InMinutes; newWeeklyOfficeHour.TimeTo_InMinutes = weeklyOfficeHours.TimeTo_InMinutes; listOfWeeklyOfficeHours.Add(newWeeklyOfficeHour); } resultItem.WeeklyOfficeHours = listOfWeeklyOfficeHours.ToArray(); } else { continue; } ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query relationShipToContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); relationShipToContractQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; relationShipToContractQuery.IsDeleted = false; relationShipToContractQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> relationShipToContracts = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, relationShipToContractQuery); List <L5EM_GEFE_1150_WorkingContract> resultWorkingContracts = new List <L5EM_GEFE_1150_WorkingContract>(); foreach (var relationShipToContract in relationShipToContracts) { L5EM_GEFE_1150_WorkingContract resultWorkingContract = new L5EM_GEFE_1150_WorkingContract(); ORM_CMN_BPT_EMP_WorkingContract workingContractItem = new ORM_CMN_BPT_EMP_WorkingContract(); workingContractItem.Load(Connection, Transaction, relationShipToContract.WorkingContract_RefID); resultWorkingContract.CMN_BPT_EMP_WorkingContractID = workingContractItem.CMN_BPT_EMP_WorkingContractID; resultWorkingContract.EmploymentRelationship_2_WorkingContractAssigmentID = relationShipToContract.AssignmentID; resultWorkingContract.IsContract_Active = relationShipToContract.IsContract_Active; resultWorkingContract.Contract_StartDate = workingContractItem.Contract_StartDate; resultWorkingContract.Contract_EndDate = workingContractItem.Contract_EndDate; resultWorkingContract.IsContractEndDateDefined = workingContractItem.IsContractEndDateDefined; resultWorkingContract.IsWorkTimeCalculated_InDays = workingContractItem.IsWorkTimeCalculated_InDays; resultWorkingContract.IsWorkTimeCalculated_InHours = workingContractItem.IsWorkTimeCalculated_InHours; resultWorkingContract.R_WorkTime_DaysPerWeek = workingContractItem.R_WorkTime_DaysPerWeek; resultWorkingContract.R_WorkTime_HoursPerWeek = workingContractItem.R_WorkTime_HoursPerWeek; resultWorkingContract.WorkingContract_InCurrency_RefID = workingContractItem.WorkingContract_InCurrency_RefID; resultWorkingContract.ExtraWorkCalculation_RefID = workingContractItem.ExtraWorkCalculation_RefID; resultWorkingContract.IsWorktimeChecked_Weekly = workingContractItem.IsWorktimeChecked_Weekly; resultWorkingContract.IsWorktimeChecked_Monthly = workingContractItem.IsWorktimeChecked_Monthly; resultWorkingContract.SurchargeCalculation_UseMaximum = workingContractItem.SurchargeCalculation_UseMaximum; resultWorkingContract.SurchargeCalculation_UseAccumulated = workingContractItem.SurchargeCalculation_UseAccumulated; resultWorkingContract.IsMealAllowanceProvided = workingContractItem.IsMealAllowanceProvided; resultWorkingContract.WorkingContract_Comment = workingContractItem.WorkingContract_Comment; ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query contractToExtraWorkSurchargeQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query(); contractToExtraWorkSurchargeQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID; contractToExtraWorkSurchargeQuery.IsDeleted = false; contractToExtraWorkSurchargeQuery.Tenant_RefID = securityTicket.TenantID; var contractToExtraWorkSurchargeResult = ORM_CMN_BPT_EMP_WorkingContract_2_ExtraWorkSurcharge.Query.Search(Connection, Transaction, contractToExtraWorkSurchargeQuery); if (contractToExtraWorkSurchargeResult.Count != 0) { var nightTimeSurcharge = contractToExtraWorkSurchargeResult.FirstOrDefault(x => x.R_IsNightTimeSurcharge && !x.R_IsSpecialEventSurcharge); var specialEventSurcharge = contractToExtraWorkSurchargeResult.FirstOrDefault(x => x.R_IsSpecialEventSurcharge && !x.R_IsNightTimeSurcharge); if (nightTimeSurcharge != null) { resultWorkingContract.NightTime_Surcharge_RefID = nightTimeSurcharge.CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_RefID; resultWorkingContract.MaximumAllowedNightTimeSurchargeTime_in_mins = nightTimeSurcharge.MaximumAllowedSurchargeTime_in_mins; } if (specialEventSurcharge != null) { resultWorkingContract.SpecialEvent_Surcharge_RefID = specialEventSurcharge.CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_RefID; resultWorkingContract.MaximumAllowedSpecialEventSurchargeTime_in_mins = specialEventSurcharge.MaximumAllowedSurchargeTime_in_mins; } } //Office hours ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query(); workingContractToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID; //workingContractToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID; workingContractToWorkingDayQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractToWorkingDayQuery); List <L5EM_GEFE_1150_WeeklyOfficeHours> resultWeeklyOfficeHours = new List <L5EM_GEFE_1150_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_GEFE_1150_WeeklyOfficeHours resultOfficeHour = new L5EM_GEFE_1150_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); } resultWorkingContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray(); ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query workingContractTypeQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query(); workingContractTypeQuery.CMN_BPT_EMP_Employee_WorkingContract_RefID = workingContractItem.CMN_BPT_EMP_WorkingContractID; workingContractTypeQuery.Tenant_RefID = securityTicket.TenantID; workingContractTypeQuery.IsDeleted = false; ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType workingContract_2_ContractEmploymentType = ORM_CMN_BPT_EMP_WorkingContract_2_ContractEmploymentType.Query.Search(Connection, Transaction, workingContractTypeQuery).FirstOrDefault(); if (workingContract_2_ContractEmploymentType != null) { ORM_CMN_BPT_EMP_WorkingContract_EmploymentType EmploymentType = new ORM_CMN_BPT_EMP_WorkingContract_EmploymentType(); EmploymentType.Load(Connection, Transaction, workingContract_2_ContractEmploymentType.CMN_BPT_EMP_WorkingContract_EmploymentTypeID); if (EmploymentType.CMN_BPT_EMP_Employee_WorkingContract_EmploymentTypeID != Guid.Empty) { resultWorkingContract.TypeOfEmployment = int.Parse(EmploymentType.GlobalPropertyMatchingID); } } //Allowed absence reasons ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query(); AllowedAbsenceReasonQuery.WorkingContract_RefID = resultWorkingContract.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_GEFE_1150_WorkingContractToLeaveRequest> resultAllowedAbsenceReasons = new List <L5EM_GEFE_1150_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_GEFE_1150_WorkingContractToLeaveRequest resultReasonresultReason = new L5EM_GEFE_1150_WorkingContractToLeaveRequest(); resultReasonresultReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID = allowedAbsenceReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID; resultReasonresultReason.CMN_BPT_STA_AbsenceReasonID = 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; resultReasonresultReason.AbsenceReasonName = absenceReason.Name; resultReasonresultReason.CMN_BPT_EMP_EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; resultAllowedAbsenceReasons.Add(resultReasonresultReason); } resultWorkingContract.WorkingContractToLeaveRequest = resultAllowedAbsenceReasons.ToArray(); resultWorkingContracts.Add(resultWorkingContract); } resultItem.AllWorkingContracts = resultWorkingContracts.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_GEFE_1150_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEFE_1150_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GEFE_1150_EmployeeWorkplaceHistory item = new L5EM_GEFE_1150_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); } resultItem.AllWorkplaceHistories = employeeWorkplaceAssignments.ToArray(); //employee qualifications ORM_CMN_BPT_EMP_Employee_2_Skill.Query qualificationQuary = new ORM_CMN_BPT_EMP_Employee_2_Skill.Query(); qualificationQuary.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; qualificationQuary.Tenant_RefID = securityTicket.TenantID; qualificationQuary.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_2_Skill> qualificationList = ORM_CMN_BPT_EMP_Employee_2_Skill.Query.Search(Connection, Transaction, qualificationQuary); List <L5EM_GEFE_1150_EmployeeQualification> employeeQualifications = new List <L5EM_GEFE_1150_EmployeeQualification>(); L5EM_GEFE_1150_EmployeeQualification employeeQualification; ORM_CMN_STR_Skill skillORM; foreach (var qualification in qualificationList) { employeeQualification = new L5EM_GEFE_1150_EmployeeQualification(); employeeQualification.QualificationAssignmentID = qualification.AssignmentID; employeeQualification.ProfessionObtainedAtDate = qualification.QualificationObtainedAtDate; employeeQualification.SkillName = new Dict(); if (qualification.Skill_RefID != Guid.Empty) { skillORM = new ORM_CMN_STR_Skill(); skillORM.Load(Connection, Transaction, qualification.Skill_RefID); employeeQualification.Skill_RefID = skillORM.CMN_STR_SkillID; employeeQualification.SkillName = skillORM.Skill_Name; } employeeQualifications.Add(employeeQualification); } resultItem.AllQualification = employeeQualifications.ToArray(); resultList.Add(resultItem); } returnValue.Result = resultList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SMP__1122 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); if (Parameter.isDeleted == true) { P_L3MP_DPBID_1026 param = new P_L3MP_DPBID_1026(); param.HEC_MedicalPractiseID = Parameter.PracticeID; cls_Delete_Practice_By_ID.Invoke(Connection, Transaction, param, securityTicket); } else { #region Save if (Parameter.PracticeID == Guid.Empty) { /********************************* * Save ContactPerson ********************************/ //business Participants ORM_CMN_BPT_BusinessParticipant contactPerson = new ORM_CMN_BPT_BusinessParticipant(); Guid businessParticipantsID = Guid.NewGuid(); contactPerson.CMN_BPT_BusinessParticipantID = businessParticipantsID; contactPerson.IsCompany = false; contactPerson.IsNaturalPerson = true; contactPerson.IsTenant = false; contactPerson.Creation_Timestamp = DateTime.Now; contactPerson.Tenant_RefID = securityTicket.TenantID; //person info ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); Guid personInfoID = Guid.NewGuid(); contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; contactPerson.Save(Connection, Transaction); personInfo.CMN_PER_PersonInfoID = personInfoID; personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.PrimaryEmail = Parameter.ContactPersonEmail; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); //Communication Contact ORM_CMN_PER_CommunicationContact communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfoID; communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPersonPhoneNumber; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; communicationContacts.Save(Connection, Transaction); /********************************* * Save Practice ********************************/ P_L3MP_SPBI_1602 param = new P_L3MP_SPBI_1602(); param.Street_Number = Parameter.PracticeNumber; param.Street_Name = Parameter.PracticeStreet; param.Street_Name_Line2 = Parameter.PracticeStreet2; param.PracticeName = Parameter.PracticeName; param.isLucentis = true; param.ifLucentis_BSNR = Parameter.BSNR; param.PracticeEmail = Parameter.PracitceEmail; param.Town = Parameter.Town; param.ZIP = Parameter.ZIP; param.HEC_MedicalPractiseID = Parameter.PracticeID; Guid HEC_MedicalPractiseID = cls_Save_Practice_BaseInfo.Invoke(Connection, Transaction, param, securityTicket).Result; /********************************* * Save Cooperating Practices ********************************/ var queryMedicalPractice = new ORM_HEC_MedicalPractis.Query(); queryMedicalPractice.HEC_MedicalPractiseID = HEC_MedicalPractiseID; queryMedicalPractice.IsDeleted = false; var medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, queryMedicalPractice).FirstOrDefault(); if (medicalPractice != null) { medicalPractice.ContactPerson_RefID = businessParticipantsID; medicalPractice.Save(Connection, Transaction); var queryCompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); queryCompanyInfo.CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID; queryCompanyInfo.IsDeleted = false; var CompanyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, queryCompanyInfo).FirstOrDefault(); if (CompanyInfo != null) { var queryBussinessParticipients = new ORM_CMN_BPT_BusinessParticipant.Query(); queryBussinessParticipients.IfCompany_CMN_COM_CompanyInfo_RefID = CompanyInfo.CMN_COM_CompanyInfoID; queryBussinessParticipients.IsDeleted = false; var bussinessParticipants = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, queryBussinessParticipients).FirstOrDefault(); if (bussinessParticipants != null) { foreach (var cooperatingPractice in Parameter.CooperatingPractices) { ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant associatedBussinessParticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedBussinessParticipants.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID = Guid.NewGuid(); associatedBussinessParticipants.IsDeleted = cooperatingPractice.isDeleted; associatedBussinessParticipants.BusinessParticipant_RefID = bussinessParticipants.CMN_BPT_BusinessParticipantID; associatedBussinessParticipants.AssociatedBusinessParticipant_RefID = cooperatingPractice.PracticeID; associatedBussinessParticipants.Creation_Timestamp = DateTime.Now; associatedBussinessParticipants.Tenant_RefID = bussinessParticipants.Tenant_RefID; associatedBussinessParticipants.Save(Connection, Transaction); } } } returnValue.Result = medicalPractice.HEC_MedicalPractiseID; } } #endregion else { /********************************* * Edit Practice ********************************/ P_L3MP_SPBI_1602 param = new P_L3MP_SPBI_1602(); param.Street_Number = Parameter.PracticeNumber; param.Street_Name = Parameter.PracticeStreet; param.Street_Name_Line2 = Parameter.PracticeStreet2; param.PracticeName = Parameter.PracticeName; param.isLucentis = true; param.ifLucentis_BSNR = Parameter.BSNR; param.PracticeEmail = Parameter.PracitceEmail; param.Town = Parameter.Town; param.ZIP = Parameter.ZIP; param.HEC_MedicalPractiseID = Parameter.PracticeID; Guid HEC_MedicalPractiseID = cls_Save_Practice_BaseInfo.Invoke(Connection, Transaction, param, securityTicket).Result; var medicalPracticeQuery = new ORM_HEC_MedicalPractis.Query(); medicalPracticeQuery.IsDeleted = false; medicalPracticeQuery.HEC_MedicalPractiseID = HEC_MedicalPractiseID; var medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, medicalPracticeQuery).FirstOrDefault(); if (medicalPractice != null) { /********************************* * Edit Contact Person ********************************/ //contact person var contactPerson = new ORM_CMN_BPT_BusinessParticipant(); var contactPersonQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); contactPersonQuery.IsDeleted = false; if (medicalPractice.ContactPerson_RefID != Guid.Empty) { contactPersonQuery.CMN_BPT_BusinessParticipantID = medicalPractice.ContactPerson_RefID; contactPerson = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, contactPersonQuery).FirstOrDefault(); } else { contactPerson = null; } Guid personInfoID = Guid.NewGuid(); if (contactPerson == null) { contactPerson = new ORM_CMN_BPT_BusinessParticipant(); contactPerson.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); contactPerson.IsCompany = false; contactPerson.IsNaturalPerson = true; contactPerson.IsTenant = false; contactPerson.Creation_Timestamp = DateTime.Now; contactPerson.Tenant_RefID = securityTicket.TenantID; contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfoID; contactPerson.Save(Connection, Transaction); medicalPractice.ContactPerson_RefID = contactPerson.CMN_BPT_BusinessParticipantID; medicalPractice.Save(Connection, Transaction); } var personInfo = new ORM_CMN_PER_PersonInfo(); //person info var personInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); personInfoQuery.IsDeleted = false; personInfoQuery.CMN_PER_PersonInfoID = contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, personInfoQuery).FirstOrDefault(); if (personInfo == null) { personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = Guid.NewGuid(); personInfo.Creation_Timestamp = DateTime.Now; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.CMN_PER_PersonInfoID = personInfoID; contactPerson.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; contactPerson.Save(Connection, Transaction); } personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.PrimaryEmail = Parameter.ContactPersonEmail; personInfo.Save(Connection, Transaction); //Communication Contact var communicationContacts = new ORM_CMN_PER_CommunicationContact(); var communicationContactsQuery = new ORM_CMN_PER_CommunicationContact.Query(); communicationContactsQuery.IsDeleted = false; communicationContactsQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContacts = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, communicationContactsQuery).FirstOrDefault(); if (communicationContacts == null) { communicationContacts = new ORM_CMN_PER_CommunicationContact(); communicationContacts.CMN_PER_CommunicationContactID = Guid.NewGuid(); communicationContacts.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; communicationContacts.Creation_Timestamp = DateTime.Now; communicationContacts.Tenant_RefID = securityTicket.TenantID; } communicationContacts.Contact_Type = Parameter.ContactTypePhone; communicationContacts.Content = Parameter.ContactPersonPhoneNumber; communicationContacts.Save(Connection, Transaction); /********************************* * Edit Cooperating Practices ********************************/ var queryCompanyInfo = new ORM_CMN_COM_CompanyInfo.Query(); queryCompanyInfo.CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID; queryCompanyInfo.IsDeleted = false; var CompanyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, queryCompanyInfo).FirstOrDefault(); if (CompanyInfo != null) { var queryBussinessParticipients = new ORM_CMN_BPT_BusinessParticipant.Query(); queryBussinessParticipients.IfCompany_CMN_COM_CompanyInfo_RefID = CompanyInfo.CMN_COM_CompanyInfoID; queryBussinessParticipients.IsDeleted = false; var bussinessParticipants = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, queryBussinessParticipients).FirstOrDefault(); if (bussinessParticipants != null) { foreach (var cooperatingPractice in Parameter.CooperatingPractices) { var associatedBussinessParticipantsQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associatedBussinessParticipantsQuery.AssociatedBusinessParticipant_RefID = cooperatingPractice.PracticeID; associatedBussinessParticipantsQuery.Tenant_RefID = bussinessParticipants.Tenant_RefID; associatedBussinessParticipantsQuery.BusinessParticipant_RefID = bussinessParticipants.CMN_BPT_BusinessParticipantID; var associtePractice = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associatedBussinessParticipantsQuery).FirstOrDefault(); if (associtePractice != null) { associtePractice.IsDeleted = cooperatingPractice.isDeleted; associtePractice.AssociatedBusinessParticipant_RefID = cooperatingPractice.PracticeID; associtePractice.Save(Connection, Transaction); } else { ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant associatedBussinessParticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedBussinessParticipants.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID = Guid.NewGuid(); associatedBussinessParticipants.IsDeleted = cooperatingPractice.isDeleted; associatedBussinessParticipants.BusinessParticipant_RefID = bussinessParticipants.CMN_BPT_BusinessParticipantID; associatedBussinessParticipants.AssociatedBusinessParticipant_RefID = cooperatingPractice.PracticeID; associatedBussinessParticipants.Creation_Timestamp = DateTime.Now; associatedBussinessParticipants.Tenant_RefID = bussinessParticipants.Tenant_RefID; associatedBussinessParticipants.Save(Connection, Transaction); } } } } returnValue.Result = medicalPractice.HEC_MedicalPractiseID; } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var practice = new ORM_HEC_MedicalPractis() { HEC_MedicalPractiseID = Guid.NewGuid(), Tenant_RefID = securityTicket.TenantID, Ext_CompanyInfo_RefID = Guid.NewGuid() }; practice.Save(Connection, Transaction); var companyInfo = new ORM_CMN_COM_CompanyInfo() { CMN_COM_CompanyInfoID = practice.Ext_CompanyInfo_RefID, Tenant_RefID = securityTicket.TenantID, CompanyInfo_EstablishmentNumber = Parameter.Practice_BSNR }; companyInfo.Save(Connection, Transaction); var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, IsTenant = true }).Single(); bParticipant.IsCompany = true; bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; bParticipant.Save(Connection, Transaction); if (Parameter.Doctor != null) { var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_2_Account.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, USR_Account_RefID = Parameter.Doctor.AccountID }).Single(); var query2 = new ORM_CMN_PER_PersonInfo.Query(); query2.CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID; var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID }).First(); personInfo.FirstName = Parameter.Doctor.FirstName; personInfo.LastName = Parameter.Doctor.LastName; personInfo.Title = Parameter.Doctor.Title; personInfo.Save(Connection, Transaction); var bussinessParticipantTable = new ORM_CMN_BPT_BusinessParticipant(); bussinessParticipantTable.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bussinessParticipantTable.IsNaturalPerson = true; bussinessParticipantTable.Tenant_RefID = securityTicket.TenantID; bussinessParticipantTable.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; bussinessParticipantTable.Save(Connection, Transaction); var doctor = new ORM_HEC_Doctor(); doctor.Tenant_RefID = securityTicket.TenantID; doctor.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; doctor.Account_RefID = Parameter.Doctor.AccountID; doctor.DoctorIDNumber = Parameter.Doctor.LANR; doctor.Save(Connection, Transaction); var associatedbusinessparticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); associatedbusinessparticipants.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; associatedbusinessparticipants.Tenant_RefID = securityTicket.TenantID; associatedbusinessparticipants.Save(Connection, Transaction); if (Parameter.Doctor.BankData != null) { ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); bussiness_2_BankaAccount.AssignmentID = Guid.NewGuid(); bussiness_2_BankaAccount.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); bussiness_2_BankaAccount.Tenant_RefID = securityTicket.TenantID; bussiness_2_BankaAccount.Save(Connection, Transaction); ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount(); bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID; bankAccount.Tenant_RefID = securityTicket.TenantID; bankAccount.OwnerText = Parameter.Doctor.BankData.AccountHolder; bankAccount.AccountNumber = Parameter.Doctor.BankData.AccountNumber; bankAccount.IBAN = Parameter.Doctor.BankData.IBAN; bankAccount.Bank_RefID = Guid.NewGuid(); bankAccount.Save(Connection, Transaction); ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank(); bank.ACC_BNK_BankID = bankAccount.Bank_RefID; bank.Tenant_RefID = securityTicket.TenantID; bank.BankName = Parameter.Doctor.BankData.BankName; bank.BICCode = Parameter.Doctor.BankData.BIC; bank.BankNumber = Parameter.Doctor.BankData.BankNumber; bank.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_DBBVP_1711 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L6PA_GBBVPfID_1714 getParam = new P_L6PA_GBBVPfID_1714(); getParam.HEC_PatientID = Parameter.HEC_PatientID; var patient = cls_Get_BBV_Patients_For_ID.Invoke(Connection, Transaction, getParam, securityTicket).Result; if (patient != null) { if (patient.Addresses != null) { foreach (var address in patient.Addresses) { P_L6PA_DBBVAFP_1703 delAddressPar = new P_L6PA_DBBVAFP_1703(); delAddressPar.CMN_AddressID = address.CMN_AddressID; cls_Delete_BBV_AddressForPatient.Invoke(Connection, Transaction, delAddressPar, securityTicket); } } if (patient.Contacts != null) { foreach (var contact in patient.Contacts) { ORM_CMN_PER_CommunicationContact.Query cQuery = new ORM_CMN_PER_CommunicationContact.Query(); cQuery.CMN_PER_CommunicationContactID = contact.CMN_PER_CommunicationContactID; cQuery.IsDeleted = false; cQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_CommunicationContact.Query.SoftDelete(Connection, Transaction, cQuery); } } ORM_CMN_PER_PersonInfo.Query ORM_CMN_PER_PersonInfoQuery = new ORM_CMN_PER_PersonInfo.Query(); ORM_CMN_PER_PersonInfoQuery.CMN_PER_PersonInfoID = patient.CMN_PER_PersonInfoID; ORM_CMN_PER_PersonInfoQuery.IsDeleted = false; ORM_CMN_PER_PersonInfoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo.Query.SoftDelete(Connection, Transaction, ORM_CMN_PER_PersonInfoQuery); ORM_CMN_BPT_BusinessParticipant.Query ORM_CMN_BPT_BusinessParticipantoQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); ORM_CMN_BPT_BusinessParticipantoQuery.CMN_BPT_BusinessParticipantID = patient.CMN_BPT_BusinessParticipantID; ORM_CMN_BPT_BusinessParticipantoQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipantoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant.Query.SoftDelete(Connection, Transaction, ORM_CMN_BPT_BusinessParticipantoQuery); ORM_HEC_Patient.Query ORM_HEC_PatientQuery = new ORM_HEC_Patient.Query(); ORM_HEC_PatientQuery.HEC_PatientID = patient.HEC_PatientID; ORM_HEC_PatientQuery.IsDeleted = false; ORM_HEC_PatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient.Query.SoftDelete(Connection, Transaction, ORM_HEC_PatientQuery); ORM_HEC_Patient_HealthInsurance.Query ORM_HEC_Patient_HealthInsuranceoQuery = new ORM_HEC_Patient_HealthInsurance.Query(); ORM_HEC_Patient_HealthInsuranceoQuery.HEC_Patient_HealthInsurancesID = patient.HEC_Patient_HealthInsurancesID; ORM_HEC_Patient_HealthInsuranceoQuery.IsDeleted = false; ORM_HEC_Patient_HealthInsuranceoQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_Patient_HealthInsurance.Query.SoftDelete(Connection, Transaction, ORM_HEC_Patient_HealthInsuranceoQuery); ORM_HEC_STU_Study_ParticipatingPatient.Query ORM_HEC_STU_Study_ParticipatingPatientQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); ORM_HEC_STU_Study_ParticipatingPatientQuery.HEC_STU_Study_ParticipatingPatientID = patient.HEC_STU_Study_ParticipatingPatientID; ORM_HEC_STU_Study_ParticipatingPatientQuery.IsDeleted = false; ORM_HEC_STU_Study_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_STU_Study_ParticipatingPatient.Query.SoftDelete(Connection, Transaction, ORM_HEC_STU_Study_ParticipatingPatientQuery); var transactionsQuery = new ORM_HEC_Patient_Prescription_Transaction.Query(); transactionsQuery.PrescriptionTransaction_Patient_RefID = patient.HEC_PatientID; transactionsQuery.IsDeleted = false; ORM_HEC_Patient_Prescription_Transaction.Query.SoftDelete(Connection, Transaction, transactionsQuery); } return(returnValue); #endregion UserCode }