public static void Save_Patients_to_DB(Patient_Model_xls Parameter, bool create_consents, string connectionString, SessionSecurityTicket securityTicket) { DbConnection Connection = null; DbTransaction Transaction = null; bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; Guid patient_id = Guid.NewGuid(); if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } try { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); ORM_HEC_Patient patients = new ORM_HEC_Patient(); patients.HEC_PatientID = Guid.NewGuid(); patients.Tenant_RefID = securityTicket.TenantID; patients.Creation_Timestamp = DateTime.Now; patients.Modification_Timestamp = DateTime.Now; patients.CMN_BPT_BusinessParticipant_RefID = Guid.NewGuid(); patients.Save(Connection, Transaction); patient_id = patients.HEC_PatientID; ORM_CMN_BPT_BusinessParticipant businesParticipantPatient = new ORM_CMN_BPT_BusinessParticipant(); businesParticipantPatient.CMN_BPT_BusinessParticipantID = patients.CMN_BPT_BusinessParticipant_RefID; businesParticipantPatient.Tenant_RefID = securityTicket.TenantID; businesParticipantPatient.Creation_Timestamp = DateTime.Now; businesParticipantPatient.Modification_Timestamp = DateTime.Now; businesParticipantPatient.IsNaturalPerson = true; businesParticipantPatient.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); businesParticipantPatient.Save(Connection, Transaction); int PatientSex = 0; switch (Parameter.sex) { case "M": PatientSex = 0; break; case "W": PatientSex = 1; break; case "o.A.": PatientSex = 2; break; } ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = businesParticipantPatient.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Modification_Timestamp = DateTime.Now; personInfo.FirstName = Parameter.name; personInfo.LastName = Parameter.LastName; personInfo.BirthDate = Parameter.birthday; personInfo.Gender = PatientSex; personInfo.Save(Connection, Transaction); ORM_HEC_Patient_MedicalPractice medical_practice_to_patient = new ORM_HEC_Patient_MedicalPractice(); medical_practice_to_patient.HEC_Patient_MedicalPracticeID = Guid.NewGuid(); medical_practice_to_patient.HEC_Patient_RefID = patients.HEC_PatientID; medical_practice_to_patient.HEC_MedicalPractices_RefID = Guid.Parse(Parameter.practice_id);// medical_practice_to_patient.Tenant_RefID = securityTicket.TenantID; medical_practice_to_patient.Creation_Timestamp = DateTime.Now; medical_practice_to_patient.Save(Connection, Transaction); var medicalPracticeQuery = new ORM_HEC_HIS_HealthInsurance_Company.Query(); medicalPracticeQuery.IsDeleted = false; medicalPracticeQuery.Tenant_RefID = securityTicket.TenantID; var HIPList = ORM_HEC_HIS_HealthInsurance_Company.Query.Search(Connection, Transaction, medicalPracticeQuery).ToList(); if (Parameter.isPrivatelyInsured) { Parameter.health_insurance_providerNumber = "000000000"; } var GetHip = HIPList.Where(hp => hp.HealthInsurance_IKNumber == Parameter.health_insurance_providerNumber).SingleOrDefault(); if (GetHip == null) { var businessParticipantHIP = new ORM_CMN_BPT_BusinessParticipant(); businessParticipantHIP.IsCompany = true; businessParticipantHIP.Tenant_RefID = securityTicket.TenantID; businessParticipantHIP.Modification_Timestamp = DateTime.Now; businessParticipantHIP.DisplayName = Parameter.health_insurance_provider; businessParticipantHIP.Save(Connection, Transaction); GetHip = new ORM_HEC_HIS_HealthInsurance_Company(); GetHip.Tenant_RefID = securityTicket.TenantID; GetHip.CMN_BPT_BusinessParticipant_RefID = businessParticipantHIP.CMN_BPT_BusinessParticipantID; GetHip.HealthInsurance_IKNumber = String.IsNullOrEmpty(Parameter.health_insurance_provider) ? "privat versichert" : Parameter.health_insurance_provider; GetHip.Save(Connection, Transaction); } ORM_HEC_Patient_HealthInsurance patientHealthInsurance = new ORM_HEC_Patient_HealthInsurance(); patientHealthInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid(); patientHealthInsurance.Patient_RefID = patients.HEC_PatientID; patientHealthInsurance.HealthInsurance_Number = Parameter.insurance_id; // patientHealthInsurance.Tenant_RefID = securityTicket.TenantID; patientHealthInsurance.InsuranceStateCode = Parameter.insurance_status; // patientHealthInsurance.HIS_HealthInsurance_Company_RefID = GetHip.HEC_HealthInsurance_CompanyID; patientHealthInsurance.Save(Connection, Transaction); #region import Patient to Elastic Patient_Model patientModel = new Patient_Model(); patientModel.birthday = Parameter.birthday; patientModel.birthday_string = Parameter.birthday.ToString("dd.MM.yyyy"); patientModel.name = Parameter.LastName + ", " + Parameter.name; patientModel.health_insurance_provider = String.IsNullOrEmpty(Parameter.health_insurance_provider) ? "privat versichert" : Parameter.health_insurance_provider; patientModel.name_with_birthdate = Parameter.name + " " + Parameter.LastName + " (" + Parameter.birthday.ToString("dd.MM.yyyy") + ")"; patientModel.id = patients.HEC_PatientID.ToString(); patientModel.insurance_id = String.IsNullOrEmpty(Parameter.insurance_id) ? "-" : Parameter.insurance_id; patientModel.insurance_status = String.IsNullOrEmpty(Parameter.insurance_status) ? "-" : Parameter.insurance_status; patientModel.practice_id = Parameter.practice_id.ToString(); if (PatientSex == 0) { patientModel.sex = "M"; } else if (PatientSex == 1) { patientModel.sex = "W"; } else if (PatientSex == 2) { patientModel.sex = "o.A."; } Add_New_Patient.Import_Patients_to_ElasticDB(patientModel, securityTicket.TenantID.ToString()); if (create_consents) { #region Participation Consent var contractIvi = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, ContractName = "IVI-Vertrag" }).SingleOrDefault(); if (contractIvi != null) { var InsuranceToBrokerContractQuery = new ORM_HEC_CRT_InsuranceToBrokerContract.Query(); InsuranceToBrokerContractQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContractQuery.IsDeleted = false; InsuranceToBrokerContractQuery.Ext_CMN_CTR_Contract_RefID = contractIvi.CMN_CTR_ContractID; ORM_HEC_CRT_InsuranceToBrokerContract InsuranceToBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, InsuranceToBrokerContractQuery).Single(); List <DateTime> TimeFrom = new List <DateTime>(); DateTime time1 = new DateTime(2013, 6, 15); DateTime time2 = new DateTime(2014, 6, 15); DateTime time3 = new DateTime(2015, 6, 15); TimeFrom.Add(time1); TimeFrom.Add(time2); TimeFrom.Add(time3); foreach (var date in TimeFrom) { ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient InsuranceToBrokerContract_ParticipatingPatient = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient(); InsuranceToBrokerContract_ParticipatingPatient.HEC_CRT_InsuranceToBrokerContract_ParticipatingPatientID = Guid.NewGuid(); InsuranceToBrokerContract_ParticipatingPatient.InsuranceToBrokerContract_RefID = InsuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; InsuranceToBrokerContract_ParticipatingPatient.Creation_Timestamp = DateTime.Now; InsuranceToBrokerContract_ParticipatingPatient.Modification_Timestamp = DateTime.Now; InsuranceToBrokerContract_ParticipatingPatient.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContract_ParticipatingPatient.ValidFrom = date; InsuranceToBrokerContract_ParticipatingPatient.ValidThrough = DateTime.MinValue; InsuranceToBrokerContract_ParticipatingPatient.Patient_RefID = patient_id; InsuranceToBrokerContract_ParticipatingPatient.Save(Connection, Transaction); Patient_Model patientModel2 = new Patient_Model(); patientModel2 = Retrieve_Patients.Get_Patient_for_PatientID(patient_id.ToString(), securityTicket); var InsuranceToBrokerContract_ParticipatingPatientQuery = new ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query(); InsuranceToBrokerContract_ParticipatingPatientQuery.IsDeleted = false; InsuranceToBrokerContract_ParticipatingPatientQuery.Tenant_RefID = securityTicket.TenantID; InsuranceToBrokerContract_ParticipatingPatientQuery.Patient_RefID = patient_id; var allInsuranceToBrokerContract_ParticipatingPatient = ORM_HEC_CRT_InsuranceToBrokerContract_ParticipatingPatient.Query.Search(Connection, Transaction, InsuranceToBrokerContract_ParticipatingPatientQuery).ToList(); var latest_participation_date = allInsuranceToBrokerContract_ParticipatingPatient.OrderByDescending(m => m.ValidFrom).FirstOrDefault(); patientModel2.participation_consent_from = latest_participation_date.ValidFrom; patientModel2.participation_consent_to = latest_participation_date.ValidThrough; patientModel2.has_participation_consent = true; Add_New_Patient.Import_Patients_to_ElasticDB(patientModel2, securityTicket.TenantID.ToString()); } } } #endregion //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw ex; } #endregion }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_SESS_1534 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_HEC_Patient patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, new ORM_HEC_Patient.Query() { IsDeleted = false, CMN_BPT_BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID, Tenant_RefID = securityTicket.TenantID }).FirstOrDefault(); if (patient == null || patient.HEC_PatientID == Guid.Empty) { patient = new ORM_HEC_Patient(); } patient.Tenant_RefID = securityTicket.TenantID; patient.CMN_BPT_BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance patientHI = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, new ORM_HEC_Patient_HealthInsurance.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Patient_RefID = patient.HEC_PatientID }).FirstOrDefault(); if (patientHI == null || patientHI.HEC_Patient_HealthInsurancesID == Guid.Empty) { patientHI = new ORM_HEC_Patient_HealthInsurance(); } patientHI.Tenant_RefID = securityTicket.TenantID; patientHI.Patient_RefID = patient.HEC_PatientID; patientHI.HealthInsurance_Number = Parameter.HealthInsurance_Number; patientHI.HIS_HealthInsurance_Company_RefID = Parameter.HEC_HealthInsurance_CompanyID; patientHI.Save(Connection, Transaction); ORM_CMN_BPT_EMP_Employee_2_Profession employeeToProffession = ORM_CMN_BPT_EMP_Employee_2_Profession.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Profession.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Employee_RefID = Parameter.CMN_BPT_EMP_EmployeeID }).FirstOrDefault(); if (employeeToProffession == null || employeeToProffession.AssignmentID == Guid.Empty) { employeeToProffession = new ORM_CMN_BPT_EMP_Employee_2_Profession(); } employeeToProffession.Employee_RefID = Parameter.CMN_BPT_EMP_EmployeeID; employeeToProffession.Profession_RefID = Parameter.CMN_STR_ProfessionID; employeeToProffession.Tenant_RefID = securityTicket.TenantID; employeeToProffession.Save(Connection, Transaction); ORM_CMN_PER_Person_2_CompulsorySocialSecurityStatus personSecurityStatus = ORM_CMN_PER_Person_2_CompulsorySocialSecurityStatus.Query.Search(Connection, Transaction, new ORM_CMN_PER_Person_2_CompulsorySocialSecurityStatus.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_PER_PersonInfo_RefID = Parameter.CMN_PER_PersonInfoID }).FirstOrDefault(); if (personSecurityStatus == null || personSecurityStatus.AssignmentID == Guid.Empty) { personSecurityStatus = new ORM_CMN_PER_Person_2_CompulsorySocialSecurityStatus(); } personSecurityStatus.CMN_PER_PersonInfo_RefID = Parameter.CMN_PER_PersonInfoID; personSecurityStatus.CMN_PER_CompulsorySocialSecurityStatus_RefID = Parameter.CMN_PER_CompulsorySocialSecurityStatusID; personSecurityStatus.Tenant_RefID = securityTicket.TenantID; personSecurityStatus.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SBBVP_1223 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); returnValue.Result = patient.HEC_PatientID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SMSP_1548 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); ORM_USR_Account account; ORM_USR_Account.Query ORM_USR_AccountQuery = new ORM_USR_Account.Query(); ORM_USR_AccountQuery.IsDeleted = false; ORM_USR_AccountQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_AccountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var accountRes = ORM_USR_Account.Query.Search(Connection, Transaction, ORM_USR_AccountQuery); if (accountRes.Count == 1) { account = accountRes[0]; } else { account = new ORM_USR_Account(); account.Tenant_RefID = securityTicket.TenantID; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.AccountType = 3; account.Save(Connection, Transaction); } ORM_USR_Device_AccountCode.Query ORM_USR_Device_AccountCodeQuery = new ORM_USR_Device_AccountCode.Query(); ORM_USR_Device_AccountCodeQuery.IsDeleted = false; ORM_USR_Device_AccountCodeQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Device_AccountCodeQuery.Account_RefID = account.USR_AccountID; var accountCodeRes = ORM_USR_Device_AccountCode.Query.Search(Connection, Transaction, ORM_USR_Device_AccountCodeQuery); if (accountCodeRes.Count == 0) { P_L2DC_GUDCfT_1505 codeParam = new P_L2DC_GUDCfT_1505(); codeParam.codeLength = 8; var checkCodeValue = cls_GetUniqueDeviceCodeForTenant.Invoke(Connection, Transaction, codeParam, securityTicket).Result; ORM_USR_Device_AccountCode_StatusHistory AccountCode_StatusHistory = new ORM_USR_Device_AccountCode_StatusHistory(); AccountCode_StatusHistory.Tenant_RefID = securityTicket.TenantID; AccountCode_StatusHistory.IsAccountCode_Active = true; AccountCode_StatusHistory.Save(Connection, Transaction); ORM_USR_Device_AccountCode devoceAccpimtCpde = new ORM_USR_Device_AccountCode(); devoceAccpimtCpde.Account_RefID = account.USR_AccountID; devoceAccpimtCpde.Tenant_RefID = securityTicket.TenantID; devoceAccpimtCpde.AccountCode_Value = checkCodeValue.CodeValue; devoceAccpimtCpde.IsAccountCode_Expirable = false; devoceAccpimtCpde.AccountCode_CurrentStatus_RefID = AccountCode_StatusHistory.USR_Device_AccountCode_StatusHistoryID; devoceAccpimtCpde.Save(Connection, Transaction); AccountCode_StatusHistory.Device_AccountCode_RefID = devoceAccpimtCpde.USR_Device_AccountCodeID; AccountCode_StatusHistory.Save(Connection, Transaction); } returnValue.Result = patient.HEC_PatientID; return(returnValue); #endregion UserCode }
public static void ImportTestPatients(DbConnection Connection, DbTransaction Transaction, SessionSecurityTicket securityTicket, Guid medical_practice_id) { List <Patient_Model_xls> patientList = new List <Patient_Model_xls>(); List <Patient_Model> elasticPatientList = new List <Patient_Model>(); IFormatProvider culture = new System.Globalization.CultureInfo("de", true); string folder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; string filePath = Path.Combine(folder, "Excel\\german_names_sheet.xlsx"); bool hasHeader = true; System.Data.DataTable excelData = ExcelUtils.getDataFromExcelFile(filePath, hasHeader); foreach (System.Data.DataRow item in excelData.Rows) { if (item.ItemArray[0].ToString() == "") { break; } Patient_Model_xls patientModel = new Patient_Model_xls(); patientModel.name = item.ItemArray[0].ToString(); patientModel.LastName = item.ItemArray[1].ToString(); patientModel.sex = item.ItemArray[2].ToString(); patientModel.birthday = DateTime.Parse(item.ItemArray[3].ToString(), culture, System.Globalization.DateTimeStyles.AssumeLocal); patientList.Add(patientModel); } List <string> StateCode_first_Caracter = new List <string>(); StateCode_first_Caracter.Add("1"); StateCode_first_Caracter.Add("3"); StateCode_first_Caracter.Add("5"); List <string> StateCode_fift_Caracter = new List <string>(); StateCode_fift_Caracter.Add("1"); StateCode_fift_Caracter.Add("4"); StateCode_fift_Caracter.Add("6"); StateCode_fift_Caracter.Add("7"); StateCode_fift_Caracter.Add("8"); StateCode_fift_Caracter.Add("9"); StateCode_fift_Caracter.Add("D"); StateCode_fift_Caracter.Add("F"); StateCode_fift_Caracter.Add("A"); StateCode_fift_Caracter.Add("C"); StateCode_fift_Caracter.Add("S"); StateCode_fift_Caracter.Add("P"); StateCode_fift_Caracter.Add("E"); StateCode_fift_Caracter.Add("N"); StateCode_fift_Caracter.Add("M"); StateCode_fift_Caracter.Add("X"); StateCode_fift_Caracter.Add("L"); StateCode_fift_Caracter.Add("K"); int status_code_counter = 0; int status_fift_counter = 0; int counter = 0; var medicalPracticeQuery = new ORM_HEC_HIS_HealthInsurance_Company.Query(); medicalPracticeQuery.IsDeleted = false; medicalPracticeQuery.Tenant_RefID = securityTicket.TenantID; var HIPList = ORM_HEC_HIS_HealthInsurance_Company.Query.Search(Connection, Transaction, medicalPracticeQuery).ToList(); int i = 0; foreach (var item in patientList) { ORM_HEC_Patient patients = new ORM_HEC_Patient(); patients.HEC_PatientID = Guid.NewGuid(); patients.Tenant_RefID = securityTicket.TenantID; patients.Creation_Timestamp = DateTime.Now; patients.Modification_Timestamp = DateTime.Now; patients.CMN_BPT_BusinessParticipant_RefID = Guid.NewGuid(); patients.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant businesParticipantPatient = new ORM_CMN_BPT_BusinessParticipant(); businesParticipantPatient.CMN_BPT_BusinessParticipantID = patients.CMN_BPT_BusinessParticipant_RefID; businesParticipantPatient.Tenant_RefID = securityTicket.TenantID; businesParticipantPatient.Creation_Timestamp = DateTime.Now; businesParticipantPatient.Modification_Timestamp = DateTime.Now; businesParticipantPatient.IsNaturalPerson = true; businesParticipantPatient.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); businesParticipantPatient.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = businesParticipantPatient.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Creation_Timestamp = DateTime.Now; personInfo.Modification_Timestamp = DateTime.Now; personInfo.FirstName = item.name; // personInfo.LastName = item.LastName; // personInfo.BirthDate = item.birthday; // personInfo.Gender = int.Parse(item.sex); // personInfo.Save(Connection, Transaction); ORM_HEC_Patient_MedicalPractice medical_practice_to_patient = new ORM_HEC_Patient_MedicalPractice(); medical_practice_to_patient.HEC_Patient_MedicalPracticeID = Guid.NewGuid(); medical_practice_to_patient.HEC_Patient_RefID = patients.HEC_PatientID; medical_practice_to_patient.HEC_MedicalPractices_RefID = medical_practice_id;// medical_practice_to_patient.Tenant_RefID = securityTicket.TenantID; medical_practice_to_patient.Creation_Timestamp = DateTime.Now; medical_practice_to_patient.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance patientHealthInsurance = new ORM_HEC_Patient_HealthInsurance(); patientHealthInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid(); patientHealthInsurance.Patient_RefID = patients.HEC_PatientID; Random rnd = new Random(); int random_insurance_number = rnd.Next(10000000, 99999999); int genre = 0; switch (int.Parse(item.sex)) { case 0: genre = 2; break; case 1: genre = 1; break; case 2: genre = 0; break; } var birth = item.birthday.Year.ToString().Substring(2); patientHealthInsurance.HealthInsurance_Number = random_insurance_number.ToString(); // patientHealthInsurance.Tenant_RefID = securityTicket.TenantID; patientHealthInsurance.InsuranceStateCode = StateCode_first_Caracter[status_code_counter] + genre.ToString() + birth + StateCode_fift_Caracter[status_fift_counter]; // patientHealthInsurance.HIS_HealthInsurance_Company_RefID = HIPList[i].HEC_HealthInsurance_CompanyID; patientHealthInsurance.Save(Connection, Transaction); if (status_code_counter == 2) { status_code_counter = 0; } else { status_code_counter++; } if (status_fift_counter == 17) { status_fift_counter = 0; } else { status_fift_counter++; } if (i == HIPList.Count - 1) { i = 0; } else { i++; } var businesParticipantHIPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businesParticipantHIPQuery.IsDeleted = false; businesParticipantHIPQuery.Tenant_RefID = securityTicket.TenantID; businesParticipantHIPQuery.CMN_BPT_BusinessParticipantID = HIPList[i].CMN_BPT_BusinessParticipant_RefID; var businesParticipantHIP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businesParticipantHIPQuery).Single();; Patient_Model patientModel = new Patient_Model(); patientModel.birthday = DateTime.Parse(item.birthday.ToString("dd.MM.yyyy"), culture, System.Globalization.DateTimeStyles.AssumeLocal); patientModel.birthday_string = item.birthday.ToString("dd.MM.yyyy"); patientModel.name = item.LastName + ", " + item.name; patientModel.health_insurance_provider = businesParticipantHIP.DisplayName; patientModel.name_with_birthdate = item.name + " " + item.LastName + " (" + item.birthday.ToString("dd.MM.yyyy") + ")"; patientModel.id = patients.HEC_PatientID.ToString(); patientModel.insurance_id = patientHealthInsurance.HealthInsurance_Number; patientModel.insurance_status = patientHealthInsurance.InsuranceStateCode; patientModel.practice_id = medical_practice_id.ToString(); if (int.Parse(item.sex) == 0) { patientModel.sex = "M"; } else if (int.Parse(item.sex) == 1) { patientModel.sex = "W"; } else if (int.Parse(item.sex) == 2) { patientModel.sex = "o.A."; } elasticPatientList.Add(patientModel); counter++; Console.WriteLine(counter + "________________________" + patientList.Count); } string indexElastic = securityTicket.TenantID.ToString(); var serializer = new JsonNetSerializer(); var connection = Elastic_Utils.ElsaticConnection(); bool checkIndex = Elastic_Utils.IfIndexOrTypeExists(indexElastic, connection); if (!checkIndex) { string settings = Elastic_Utils.BuildIndexSettings(); connection.Put(indexElastic, settings); string jsonProductMapping = Add_New_Patient.BuildPatientMapping(); string resultProductMapping = connection.Put(new PutMappingCommand(indexElastic, "patient"), jsonProductMapping); } bool checkTupe = Elastic_Utils.IfIndexOrTypeExists(indexElastic + "/patient", connection); if (!checkTupe) { string jsonProductMapping = Add_New_Patient.BuildPatientMapping(); string resultProductMapping = connection.Put(new PutMappingCommand(indexElastic, "patient"), jsonProductMapping); } Elastic_Utils.BulkType_Generic <Patient_Model>(elasticPatientList, connection, serializer, indexElastic, "patient"); }
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_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 }