protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3TX_DTO_1148 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Base(); ORM_ACC_TAX_TaxOffice taxOffice = new ORM_ACC_TAX_TaxOffice(); if (Parameter.ACC_TAX_TaxOfficeID != Guid.Empty) { var result = taxOffice.Load(Connection, Transaction, Parameter.ACC_TAX_TaxOfficeID); if (result.Status != FR_Status.Success || taxOffice.ACC_TAX_TaxOfficeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID."; error.Status = FR_Status.Error_Internal; return(error); } } taxOffice.IsDeleted = true; taxOffice.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant.Query bptQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bptQuery.CMN_BPT_BusinessParticipantID = taxOffice.CMN_BPT_BusinessParticipant_RefID; bptQuery.IsDeleted = false; bptQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bparticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bptQuery).FirstOrDefault(); bparticipant.IsDeleted = true; bparticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo.Query cmpInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); cmpInfoQuery.CMN_COM_CompanyInfoID = bparticipant.IfCompany_CMN_COM_CompanyInfo_RefID; cmpInfoQuery.IsDeleted = false; cmpInfoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_COM_CompanyInfo companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, cmpInfoQuery).FirstOrDefault(); companyInfo.IsDeleted = true; companyInfo.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3CA_CoUSfIC_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); /* * @See if Supplier already exists in database * */ ORM_CMN_BPT_Supplier supplier = new ORM_CMN_BPT_Supplier(); var supplierQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); supplierQuery.BusinessParticipantITL = Parameter.SupplierITL; supplierQuery.Tenant_RefID = securityTicket.TenantID; supplierQuery.IsDeleted = false; var supplier_bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, supplierQuery).FirstOrDefault(); #region if supplier does not exist if (supplier_bussinessParticipant == null) { /* * @Make Supplier Data * */ var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); } supplier.CMN_BPT_SupplierID = Guid.NewGuid(); supplier.Ext_BusinessParticipant_RefID = Guid.NewGuid();//supplierBussinessParticipant.CMN_BPT_BusinessParticipantID supplier.Creation_Timestamp = DateTime.Now; supplier.IsDeleted = false; supplier.Tenant_RefID = securityTicket.TenantID; supplier.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant supplierBussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBussinessParticipant.CMN_BPT_BusinessParticipantID = supplier.Ext_BusinessParticipant_RefID; supplierBussinessParticipant.DisplayName = Parameter.Supplier_Name; supplierBussinessParticipant.BusinessParticipantITL = Parameter.SupplierITL; supplierBussinessParticipant.Creation_Timestamp = DateTime.Now; supplierBussinessParticipant.Tenant_RefID = securityTicket.TenantID; supplierBussinessParticipant.IsCompany = true; supplierBussinessParticipant.IsTenant = true; supplierBussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid();//companyInfo.CMN_COM_CompanyInfoID supplierBussinessParticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfo.Creation_Timestamp = DateTime.Now; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Contact_UCD_RefID = Guid.NewGuid();//universalContactDetail.CMN_UniversalContactDetailID companyInfo.Save(Connection, Transaction); ORM_CMN_UniversalContactDetail universalContactDetail = new ORM_CMN_UniversalContactDetail(); universalContactDetail.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetail.IsCompany = true; universalContactDetail.Country_639_1_ISOCode = Parameter.CountryISO; universalContactDetail.Street_Name = Parameter.Supplier_Name; universalContactDetail.Street_Number = Parameter.Street_Number; universalContactDetail.ZIP = Parameter.ZIP; universalContactDetail.Town = Parameter.Town; universalContactDetail.Region_Code = Parameter.Region_Code; universalContactDetail.Tenant_RefID = securityTicket.TenantID; universalContactDetail.Creation_Timestamp = DateTime.Now; universalContactDetail.Save(Connection, Transaction); } #endregion #region if supplier exists , check if its data is changed else { var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.TenantITL, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }; ORM_CMN_Tenant supplierTenant; if (ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).Count > 1) { supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).First(); //QUICKFIX } else { supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); } if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); supplier_bussinessParticipant.IsTenant = true; supplier_bussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; } supplier_bussinessParticipant.DisplayName = Parameter.Supplier_Name; supplier_bussinessParticipant.Save(Connection, Transaction); var query = new ORM_CMN_BPT_Supplier.Query(); query.Ext_BusinessParticipant_RefID = supplier_bussinessParticipant.CMN_BPT_BusinessParticipantID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; supplier = ORM_CMN_BPT_Supplier.Query.Search(Connection, Transaction, query).First(); //edit universal contact details var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = supplier_bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfoQuery.Tenant_RefID = securityTicket.TenantID; companyInfoQuery.IsDeleted = false; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var universalContactDetailQuery = new ORM_CMN_UniversalContactDetail.Query(); universalContactDetailQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetailQuery.Tenant_RefID = securityTicket.TenantID; universalContactDetailQuery.IsDeleted = false; var universalContactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, universalContactDetailQuery).First(); universalContactDetail.Country_639_1_ISOCode = Parameter.CountryISO; universalContactDetail.Street_Name = Parameter.Supplier_Name; universalContactDetail.Street_Number = Parameter.Street_Number; universalContactDetail.ZIP = Parameter.ZIP; universalContactDetail.Town = Parameter.Town; universalContactDetail.Region_Code = Parameter.Region_Code; universalContactDetail.Save(Connection, Transaction); } #endregion returnValue.Result = supplier.CMN_BPT_SupplierID; return(returnValue); #endregion UserCode }
protected static FR_L6TR_BT_2204 Execute(DbConnection Connection, DbTransaction Transaction, P_L6TR_BT_2204 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6TR_BT_2204(); returnValue.Result = new L6TR_BT_2204(); ORM_BIL_BillHeader header = new ORM_BIL_BillHeader(); long previousMaxPositionIndex = Parameter.previousMaxPositionIndex; #region persistHeader if (Parameter.isNewBilling) { header.Tenant_RefID = securityTicket.TenantID; header.BIL_BillHeaderID = Guid.NewGuid(); var tenantHeaders = ORM_BIL_BillHeader.Query.Search(Connection, Transaction, new ORM_BIL_BillHeader.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).ToArray(); tenantHeaders = tenantHeaders.OrderBy(t => t.Creation_Timestamp).ToArray(); var headersForThisYear = tenantHeaders.Where(h => h.Creation_Timestamp.Year == DateTime.Now.Year).ToArray(); int prevMaxHeaderNumber = 0; if (headersForThisYear.Length > 0) { ORM_BIL_BillHeader prevHeader = null; foreach (var headerTY in headersForThisYear) { int hn = 0; if (int.TryParse(headerTY.BillNumber, out hn) && prevMaxHeaderNumber <= hn) { prevMaxHeaderNumber = hn; prevHeader = headerTY; } } if (prevHeader != null) { var positionQuery = new ORM_BIL_BillPosition.Query(); positionQuery.Tenant_RefID = securityTicket.TenantID; positionQuery.BIL_BilHeader_RefID = prevHeader.BIL_BillHeaderID; var prevPositions = ORM_BIL_BillPosition.Query.Search(Connection, Transaction, positionQuery).ToArray(); if (prevPositions != null && prevPositions.Length > 0) { foreach (var prevPosition in prevPositions) { long number = 0; if (long.TryParse(prevPosition.External_PositionReferenceField, out number) && previousMaxPositionIndex < number) { previousMaxPositionIndex = number; } } } } } header.BillNumber = prevMaxHeaderNumber + 1 + ""; if (Parameter.billTreatments) { header.Save(Connection, Transaction); } } else { header.Tenant_RefID = securityTicket.TenantID; header.BIL_BillHeaderID = Parameter.ifOldBillingHeaderID; header.BillNumber = Parameter.ifOldBillingHeaderNumber; } //new edifact entry ORM_BIL_BillHeaderExtension_EDIFACT.Query edifactQuery = new ORM_BIL_BillHeaderExtension_EDIFACT.Query(); edifactQuery.Tenant_RefID = securityTicket.TenantID; var edifactRes = ORM_BIL_BillHeaderExtension_EDIFACT.Query.Search(Connection, Transaction, edifactQuery); edifactRes = edifactRes.Where(e => e.Creation_Timestamp.Year == DateTime.Now.Year).ToList(); ORM_BIL_BillHeaderExtension_EDIFACT edifact = new ORM_BIL_BillHeaderExtension_EDIFACT(); edifact.BIL_BillHeader_RefID = header.BIL_BillHeaderID; edifact.BIL_BillHeaderExtension_EDIFACTID = Guid.NewGuid(); edifact.EDIFACTCounter = edifactRes.Count + 1; edifact.Tenant_RefID = securityTicket.TenantID; if (Parameter.billTreatments) { edifact.Save(Connection, Transaction); } #endregion //positions List <L6TR_BT_2204_Position> positions = new List <L6TR_BT_2204_Position>(); List <Guid> patientsIDlist = new List <Guid>(); Dictionary <Guid, Guid> treatment2patient = new Dictionary <Guid, Guid>(); Dictionary <Guid, int> positionCountPerPatient = new Dictionary <Guid, int>(); foreach (var id in Parameter.TreatmentID_List) { var item = new ORM_HEC_Patient_Treatment(); item.Load(Connection, Transaction, id); if (item.IsTreatmentFollowup) { throw new Exception("This treatment, ID: " + id + ", is followup!"); } var patient2treatmentQuery = new ORM_HEC_Patient_2_PatientTreatment.Query(); patient2treatmentQuery.Tenant_RefID = securityTicket.TenantID; patient2treatmentQuery.HEC_Patient_Treatment_RefID = id; var patient2treatmentRes = ORM_HEC_Patient_2_PatientTreatment.Query.Search(Connection, Transaction, patient2treatmentQuery).First(); if (!patientsIDlist.Contains(patient2treatmentRes.HEC_Patient_RefID)) { patientsIDlist.Add(patient2treatmentRes.HEC_Patient_RefID); } treatment2patient.Add(id, patient2treatmentRes.HEC_Patient_RefID); if (!positionCountPerPatient.ContainsKey(patient2treatmentRes.HEC_Patient_RefID)) { positionCountPerPatient.Add(patient2treatmentRes.HEC_Patient_RefID, 0); } } //log.Debug("first loop finished after: " + sw.ElapsedMilliseconds); P_L6PA_GPBIfPID_1155 patParam = new P_L6PA_GPBIfPID_1155(); patParam.PatientID = patientsIDlist.ToArray(); var patients = cls_Get_PatientBillInfo_for_PatientID.Invoke(Connection, Transaction, patParam, securityTicket).Result; P_L6TR_GTaRDfBIbT_1204 tretParam = new P_L6TR_GTaRDfBIbT_1204(); tretParam.TreatmentID = Parameter.TreatmentID_List; var treatments = cls_Get_Treatment_and_RelevantDiagnosis_for_BillInfo_by_TreatmentID.Invoke(Connection, Transaction, tretParam, securityTicket).Result; List <Guid> followTretIDs = new List <Guid>(); if (treatments != null) { foreach (var t in treatments) { followTretIDs.Add(t.HEC_Patient_TreatmentID); } } P_L6TR_GFTfRbIDs_1646 followParam = new P_L6TR_GFTfRbIDs_1646(); followParam.TreatmentIDs = followTretIDs.ToArray(); var followups = cls_Get_Followups_for_Report_byIDs.Invoke(Connection, Transaction, followParam, securityTicket).Result; ///counter bill P_L5TR_GTCfPID_1152 tcParam = new P_L5TR_GTCfPID_1152(); tcParam.PatientID = patientsIDlist.ToArray(); var tretRes = cls_Get_TreatmentCount_for_PatientIDlist.Invoke(Connection, Transaction, tcParam, securityTicket).Result; int i = 1; foreach (var id in Parameter.TreatmentID_List) { #region collectPositionDataForReport var patient = patients.FirstOrDefault(p => p.HEC_PatientID == treatment2patient[id]); if (patient == null) { //throw new Exception("No patient for ID: " + treatment2patient[id]); } var treatment = treatments.FirstOrDefault(t => t.HEC_Patient_TreatmentID == id); if (treatment == null) { throw new Exception("No treatment for ID: " + id); } var followupsForThisThreatment = followups.Where(f => f.IfTreatmentFollowup_FromTreatment_RefID == treatment.HEC_Patient_TreatmentID).ToArray(); #region changeFlag if (Parameter.billTreatments) { var item = new ORM_HEC_Patient_Treatment(); item.Load(Connection, Transaction, id); item.IsTreatmentBilled = true; item.IfTreatmentBilled_Date = DateTime.Now; item.Save(Connection, Transaction); } #endregion #region persistPosition ORM_BIL_BillPosition position = new ORM_BIL_BillPosition(); position.Tenant_RefID = securityTicket.TenantID; position.PositionIndex = i; position.BIL_BilHeader_RefID = header.BIL_BillHeaderID; position.BIL_BillPositionID = Guid.NewGuid(); if (Parameter.billTreatments) { position.Save(Connection, Transaction); } ORM_BIL_BillPosition_2_PatientTreatment p2t = new ORM_BIL_BillPosition_2_PatientTreatment(); p2t.AssignmentID = Guid.NewGuid(); p2t.Tenant_RefID = securityTicket.TenantID; p2t.BIL_BillPosition_RefID = position.BIL_BillPositionID; p2t.HEC_Patient_Treatment_RefID = treatment.HEC_Patient_TreatmentID; if (Parameter.billTreatments) { p2t.Save(Connection, Transaction); } #endregion ORM_HEC_Doctor doctor = new ORM_HEC_Doctor(); if (treatment.IfTreatmentPerformed_ByDoctor_RefID != Guid.Empty) { var doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.HEC_DoctorID = treatment.IfTreatmentPerformed_ByDoctor_RefID; doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).FirstOrDefault(); } var practiceQuery = new ORM_HEC_MedicalPractis.Query(); practiceQuery.HEC_MedicalPractiseID = treatment.TreatmentPractice_RefID; practiceQuery.Tenant_RefID = securityTicket.TenantID; var practice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practiceQuery).FirstOrDefault(); string BSNR = "x"; if (practice != null) { var practiceInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); practiceInfoQuery.CMN_COM_CompanyInfoID = practice.Ext_CompanyInfo_RefID; practiceInfoQuery.Tenant_RefID = securityTicket.TenantID; var practiceInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, practiceInfoQuery).First(); BSNR = practiceInfo.CompanyInfo_EstablishmentNumber; } L6TR_BT_2204_Position pos = new L6TR_BT_2204_Position(); pos.ORM_BIL_BillPositionID = position.BIL_BillPositionID; pos.strDoctorLANR = (doctor != null) ? doctor.DoctorIDNumber : "HEC_Doctor is null!!!!"; pos.TreatmentID = treatment.HEC_Patient_TreatmentID; pos.bTreatmentIsFollowup = treatment.IsTreatmentFollowup; pos.strPracticeBSNR = BSNR; pos.dtTreatment = treatment.IfTreatmentPerformed_Date; if (patient != null) { pos.iTreatmentNumber = tretRes.FirstOrDefault(t => t.HEC_PatientID == patient.HEC_PatientID).treatmentCount + positionCountPerPatient[treatment2patient[id]]; pos.iPatientSex = patient.Gender; pos.iPatientInsuranceState = (patient.InsuranceStateCode != null) ? patient.InsuranceStateCode : String.Empty; pos.dtPatientBirthDate = patient.Birthdate; pos.PatientFirstName = patient.FirstName; pos.PatientLastName = patient.LastName; pos.PatientInsuranceNumber = (patient.HealthInsurance_Number != null) ? patient.HealthInsurance_Number : String.Empty; } else { pos.iTreatmentNumber = -1; pos.iPatientSex = 0; pos.iPatientInsuranceState = "xxxxx"; pos.dtPatientBirthDate = DateTime.MinValue; pos.PatientFirstName = "x"; pos.PatientLastName = "x"; pos.PatientInsuranceNumber = "x"; } pos.cTreatmentLocalization = (treatment.IsTreatmentOfLeftEye) ? "L" : "R"; pos.strFollowupPractice = "-"; pos.strFollowupDoctor = "-"; pos.strFollowupStatus = "Keine Nachuntersuchung geplant."; if (followupsForThisThreatment != null && followupsForThisThreatment.Length > 0) { var performedF = followupsForThisThreatment.Where(f => f.IsTreatmentPerformed == true).ToArray(); if (performedF != null && performedF.Length > 0) { performedF = performedF.OrderBy(f => f.IfTreatmentPerformed_Date).ToArray(); var firstPF = performedF.First(); pos.strFollowupDoctor = firstPF.DoctorFirstName + " " + firstPF.DoctorLastname; pos.dtFollowup = firstPF.IfTreatmentPerformed_Date; pos.strFollowupPractice = firstPF.DisplayName; pos.strFollowupStatus = (firstPF.IsTreatmentPerformed) ? "durchgeführt" : "geplant"; } else { var scheduledF = followupsForThisThreatment.Where(f => f.IsScheduled == true).ToArray(); if (scheduledF != null && scheduledF.Length > 0) { scheduledF = scheduledF.OrderBy(f => f.IfSheduled_Date).ToArray(); var firstSF = scheduledF.First(); pos.strFollowupDoctor = firstSF.DoctorFirstName + " " + firstSF.DoctorLastname; pos.dtFollowup = firstSF.IfTreatmentPerformed_Date; pos.strFollowupPractice = firstSF.DisplayName; pos.strFollowupStatus = (firstSF.IsTreatmentPerformed) ? "durchgeführt" : "geplant"; } } } var articles = new List <L6TR_BT_2204_ArticleInfo>(); foreach (var art in treatment.Article) { var article = new L6TR_BT_2204_ArticleInfo(); article.ArticleID = art.CMN_PRO_ProductID; article.Name = art.Product_Name; article.PZN = art.Product_Number; article.Quantity = art.Quantity; articles.Add(article); } pos.ArticleInfo = articles.ToArray(); var diagnosies = new List <L6TR_BT_2204_DiagnosisInfo>(); foreach (var diag in treatment.RelevantDiagnosis) { var diagnose = new L6TR_BT_2204_DiagnosisInfo(); diagnose.cDiagnosisState = diag.DiagnosisState_Abbreviation; diagnose.DiagnosisID = diag.HEC_Patient_Treatment_RelevantDiagnosisID; diagnose.strDiagnosisICD10 = diag.ICD10_Code; diagnose.PatientInsuranceState = diag.DiagnosisState_Name; diagnosies.Add(diagnose); } pos.DiagnosisInfo = diagnosies.ToArray(); positions.Add(pos); #endregion positionCountPerPatient[treatment2patient[id]] = positionCountPerPatient[treatment2patient[id]] + 1; i++; } returnValue.Result.Positions = positions.ToArray(); returnValue.Result.EDIFACTCounter = edifact.EDIFACTCounter; returnValue.Result.HeaderNumber = header.BillNumber; returnValue.Result.HeaderID = header.BIL_BillHeaderID; returnValue.Result.previousMaxPositionIndex = previousMaxPositionIndex; 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_L5ACACU_SCC_1051 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.InternalCustomerNumber = Parameter.Number; 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.IsCompany = true; customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } bParticipant.DisplayName = Parameter.FirmName; ORM_CMN_COM_CompanyInfo company; if (bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID != Guid.Empty) { var companyQ = new ORM_CMN_COM_CompanyInfo.Query(); companyQ.Tenant_RefID = securityTicket.TenantID; companyQ.IsDeleted = false; companyQ.CMN_COM_CompanyInfoID = bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; company = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyQ).First(); } else { company = new ORM_CMN_COM_CompanyInfo(); company.Tenant_RefID = securityTicket.TenantID; company.CMN_COM_CompanyInfoID = Guid.NewGuid(); bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = company.CMN_COM_CompanyInfoID; } ORM_CMN_UniversalContactDetail ucd; if (company.Contact_UCD_RefID != Guid.Empty) { var ucdQ = new ORM_CMN_UniversalContactDetail.Query(); ucdQ.Tenant_RefID = securityTicket.TenantID; ucdQ.IsDeleted = false; ucdQ.CMN_UniversalContactDetailID = company.Contact_UCD_RefID; ucd = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, ucdQ).First(); } else { ucd = new ORM_CMN_UniversalContactDetail(); ucd.Tenant_RefID = securityTicket.TenantID; ucd.CMN_UniversalContactDetailID = Guid.NewGuid(); ucd.IsCompany = true; company.Contact_UCD_RefID = ucd.CMN_UniversalContactDetailID; } ucd.CompanyName_Line1 = Parameter.FirmName; ucd.CompanyName_Line2 = Parameter.Additional; ucd.IsDeleted = Parameter.IsDelete; company.IsDeleted = Parameter.IsDelete; bParticipant.IsDeleted = Parameter.IsDelete; customer.IsDeleted = Parameter.IsDelete; ucd.Save(Connection, Transaction); company.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_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OM_SM_0951 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var doctorQuery = new ORM_HEC_Doctor.Query(); doctorQuery.HEC_DoctorID = Parameter.Doctor_ID; var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First(); var practicesQuery = new ORM_HEC_MedicalPractis.Query(); practicesQuery.HEC_MedicalPractiseID = Parameter.Practice_ID; var practices = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practicesQuery).First(); var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = practices.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var practice_bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).FirstOrDefault(); ORM_CMN_BPT_Memo memo = new ORM_CMN_BPT_Memo(); if (Parameter.CMN_BPT_MemoID != Guid.Empty) { var result = memo.Load(Connection, Transaction, Parameter.CMN_BPT_MemoID); if (result.Status != FR_Status.Success || memo.CMN_BPT_MemoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } memo.UpdatedBy_Account_RefID = securityTicket.AccountID; memo.UpdatedOn = Parameter.Creation_Timestamp; } else { ORM_DOC_Structure_Header docHeader = new ORM_DOC_Structure_Header(); docHeader.Label = Parameter.Memo_Abbreviation + "_Header_Label"; docHeader.Tenant_RefID = securityTicket.TenantID; docHeader.Save(Connection, Transaction); ORM_DOC_Structure docStructure = new ORM_DOC_Structure(); docStructure.Label = Parameter.Memo_Abbreviation + "_Structure"; docStructure.Tenant_RefID = securityTicket.TenantID; docStructure.Structure_Header_RefID = docHeader.DOC_Structure_HeaderID; docStructure.Save(Connection, Transaction); memo.DocumentStructureHeader_RefID = docHeader.DOC_Structure_HeaderID; memo.CreatedBy_Account_RefID = securityTicket.AccountID; memo.Creation_Timestamp = Parameter.Creation_Timestamp; memo.UpdatedOn = memo.Creation_Timestamp; } memo.Memo_Text = Parameter.Memo_Text; memo.Memo_Title = Parameter.Memo_Title; memo.Memo_Abbreviation = Parameter.Memo_Abbreviation; memo.Tenant_RefID = securityTicket.TenantID; memo.Save(Connection, Transaction); if (Parameter.AdditionalFields != null) { foreach (var AdditionalField in Parameter.AdditionalFields) { ORM_CMN_BPT_Memo_AdditionalField addFieldItem = new ORM_CMN_BPT_Memo_AdditionalField(); if (AdditionalField.CMN_BPT_Memo_AdditionalFieldID != Guid.Empty) { var result = addFieldItem.Load(Connection, Transaction, AdditionalField.CMN_BPT_Memo_AdditionalFieldID); if (result.Status != FR_Status.Success || addFieldItem.CMN_BPT_Memo_AdditionalFieldID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } addFieldItem.Memo_RefID = memo.CMN_BPT_MemoID; addFieldItem.Field_Key = AdditionalField.Field_Key; addFieldItem.Field_Value = AdditionalField.Field_Value; addFieldItem.Tenant_RefID = securityTicket.TenantID; addFieldItem.Save(Connection, Transaction); } } var memo2DocQuery = new ORM_CMN_BPT_Memo_RelatedParticipant.Query(); memo2DocQuery.CMN_BPT_Memo_RefID = memo.CMN_BPT_MemoID; memo2DocQuery.CMN_BPT_Memo_RelatedParticipantID = doctor.BusinessParticipant_RefID; var memo2DocQueryRes = ORM_CMN_BPT_Memo_RelatedParticipant.Query.Search(Connection, Transaction, memo2DocQuery).FirstOrDefault(); ORM_CMN_BPT_Memo_RelatedParticipant memo2Doc; if (memo2DocQueryRes != null) { memo2Doc = memo2DocQueryRes; } else { memo2Doc = new ORM_CMN_BPT_Memo_RelatedParticipant(); memo2Doc.CMN_BPT_Memo_RelatedParticipantID = Guid.NewGuid(); } memo2Doc.Tenant_RefID = securityTicket.TenantID; memo2Doc.CMN_BPT_Memo_RefID = memo.CMN_BPT_MemoID; memo2Doc.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID; memo2Doc.Save(Connection, Transaction); var memo2PracticeQuery = new ORM_CMN_BPT_Memo_RelatedParticipant.Query(); memo2DocQuery.CMN_BPT_Memo_RefID = memo.CMN_BPT_MemoID; memo2DocQuery.CMN_BPT_Memo_RelatedParticipantID = practice_bParticipant.CMN_BPT_BusinessParticipantID; var memo2PracticeQueryRes = ORM_CMN_BPT_Memo_RelatedParticipant.Query.Search(Connection, Transaction, memo2DocQuery).FirstOrDefault(); ORM_CMN_BPT_Memo_RelatedParticipant memo2Practice; if (memo2DocQueryRes != null) { memo2Practice = memo2DocQueryRes; } else { memo2Practice = new ORM_CMN_BPT_Memo_RelatedParticipant(); memo2Practice.CMN_BPT_Memo_RelatedParticipantID = Guid.NewGuid(); } memo2Practice.Tenant_RefID = securityTicket.TenantID; memo2Practice.CMN_BPT_Memo_RefID = memo.CMN_BPT_MemoID; memo2Practice.CMN_BPT_BusinessParticipant_RefID = practice_bParticipant.CMN_BPT_BusinessParticipantID; memo2Practice.Save(Connection, Transaction); returnValue.Result = memo.CMN_BPT_MemoID; 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_L3CCfTaIC_1526_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3CCfTaIC_1526 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3CCfTaIC_1526_Array(); //Put your code here List <L3CCfTaIC_1526> ProductList = new List <L3CCfTaIC_1526>(); returnValue.Result = ProductList.ToArray(); var _service = CatalogServiceFactory.GetSubscriptionService(); //make data to send to Architecture so that they will know which catalog to update var subscriptionRequest = new SubscriptionRequest(); subscriptionRequest.CatalogCode = Parameter.CatalogCodeITL; Customer customer = new Customer(); // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { customer.BusinessParticipantITL = Parameter.SubscribedBy_BusinessParticipant_RefID.ToString(); } else { customer.BusinessParticipantITL = securityTicket.TenantID.ToString(); } customer.TenantITL = securityTicket.TenantID.ToString(); customer.Name = Parameter.ClientName; // customer.SourceRealm = BOp.Infrastructure.PropertyRepository.Instance.RealmID.ToString(); subscriptionRequest.Customer = customer; /* * @see if catalog with the same ITL for that bussinessParticipant exists * */ var subscribedCatalogQuery = new ORM_CMN_PRO_SubscribedCatalog.Query(); subscribedCatalogQuery.Tenant_RefID = securityTicket.TenantID; subscribedCatalogQuery.CatalogCodeITL = Parameter.CatalogCodeITL; if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { subscribedCatalogQuery.SubscribedBy_BusinessParticipant_RefID = Parameter.SubscribedBy_BusinessParticipant_RefID; } subscribedCatalogQuery.IsDeleted = false; var subscribedCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, subscribedCatalogQuery).FirstOrDefault(); #region Get VAT var defaultCountryISOCode = cls_Get_DefaultCountryISOCode_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; var param = new P_L3TX_GTfCICaT_1359(); param.CountryISOCode = "DE"; var taxes = cls_Get_Taxes_for_CountryISOCode_and_TenantID.Invoke(Connection, Transaction, param, securityTicket).Result; //if there are no taxes for tenant Guid countryID = Guid.Empty; if (taxes.Length == 0) { var country = cls_Get_AllCountries_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result.FirstOrDefault(); if (country != null) { countryID = country.CMN_CountryID; } } else { countryID = taxes.First().CMN_CountryID; // ti slucajni posmatracu ovog koda nemoj zameriti na ovakvom resenju. } #endregion #region save if (subscribedCatalog == null) { /* * @save ORM_CMN_PRO_SubscribedCatalog * */ subscribedCatalog = new ORM_CMN_PRO_SubscribedCatalog(); subscribedCatalog.CMN_PRO_SubscribedCatalogID = Guid.NewGuid(); subscribedCatalog.CatalogCodeITL = Parameter.CatalogCodeITL; subscribedCatalog.SubscribedCatalog_Name = Parameter.CatalogName; subscribedCatalog.SubscribedBy_BusinessParticipant_RefID = Parameter.SubscribedBy_BusinessParticipant_RefID; subscribedCatalog.Tenant_RefID = securityTicket.TenantID; subscribedCatalog.SubscribedCatalog_ValidFrom = Parameter.ValidFrom_Date; subscribedCatalog.SubscribedCatalog_ValidThrough = Parameter.ValidTo_Date; subscribedCatalog.SubscribedCatalog_Description = Parameter.CatalogDescription; subscribedCatalog.Creation_Timestamp = DateTime.Now; subscribedCatalog.IsDeleted = false; subscribedCatalog.SubscribedCatalog_CurrentRevision = Parameter.CatalogVersion; subscribedCatalog.IsCatalogPublic = Parameter.IsCatalogPublic; // check if language with that ISO exists for Tenant (Lower, exmpl de) var languageQuery = new ORM_CMN_Language.Query(); languageQuery.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes.ToLower(); languageQuery.Tenant_RefID = securityTicket.TenantID; languageQuery.IsDeleted = false; var language = ORM_CMN_Language.Query.Search(Connection, Transaction, languageQuery).FirstOrDefault(); // if language does not exist for that Tenant if (language == null) { //check if language with that ISO exists for Tenant (Upper exmpl DE) languageQuery = new ORM_CMN_Language.Query(); languageQuery.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes.ToUpper(); languageQuery.Tenant_RefID = securityTicket.TenantID; languageQuery.IsDeleted = false; language = ORM_CMN_Language.Query.Search(Connection, Transaction, languageQuery).FirstOrDefault(); // if language does not exist for that Tenant if (language == null) { ORM_CMN_Language newLanguage = new ORM_CMN_Language(); newLanguage.CMN_LanguageID = Guid.NewGuid(); newLanguage.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes; newLanguage.Creation_Timestamp = DateTime.Now; newLanguage.Tenant_RefID = securityTicket.TenantID; newLanguage.IsDeleted = false; newLanguage.Save(Connection, Transaction); subscribedCatalog.SubscribedCatalog_Language_RefID = newLanguage.CMN_LanguageID; } else { subscribedCatalog.SubscribedCatalog_Language_RefID = language.CMN_LanguageID; } } else { subscribedCatalog.SubscribedCatalog_Language_RefID = language.CMN_LanguageID; } // check if currency with that ISO exists for Tenant var currencyQuery = new ORM_CMN_Currency.Query(); currencyQuery.ISO4127 = Parameter.CatalogCurrency_ISO_4217; currencyQuery.Tenant_RefID = securityTicket.TenantID; currencyQuery.IsDeleted = false; var currency = ORM_CMN_Currency.Query.Search(Connection, Transaction, currencyQuery).FirstOrDefault(); if (currency == null) { ORM_CMN_Currency newCurrency = new ORM_CMN_Currency(); newCurrency.CMN_CurrencyID = Guid.NewGuid(); newCurrency.ISO4127 = Parameter.CatalogCurrency_ISO_4217; newCurrency.Tenant_RefID = securityTicket.TenantID; newCurrency.Creation_Timestamp = DateTime.Now; newCurrency.Save(Connection, Transaction); subscribedCatalog.SubscribedCatalog_Currency_RefID = newCurrency.CMN_CurrencyID; } else { subscribedCatalog.SubscribedCatalog_Currency_RefID = currency.CMN_CurrencyID; } #region product group /* * @Search product group * */ ORM_CMN_PRO_ProductGroup productGroup = new ORM_CMN_PRO_ProductGroup(); var productGroupQuery = new ORM_CMN_PRO_ProductGroup.Query(); productGroupQuery.Tenant_RefID = securityTicket.TenantID; productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); //if (Parameter.IsCatalogPublic == false) //{ // productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); //} //else //{ // productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.ABDA); //} // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { productGroupQuery.GlobalPropertyMatchingID += Parameter.SubscribedBy_BusinessParticipant_RefID; } productGroupQuery.IsDeleted = false; productGroup = ORM_CMN_PRO_ProductGroup.Query.Search(Connection, Transaction, productGroupQuery).FirstOrDefault(); if (productGroup == null) { /* * @Create product group for products if product group for that BP and Tenent does not exist * */ productGroup = new ORM_CMN_PRO_ProductGroup(); productGroup.Tenant_RefID = securityTicket.TenantID; productGroup.Creation_Timestamp = DateTime.Now; productGroup.CMN_PRO_ProductGroupID = Guid.NewGuid(); productGroup.ProductGroup_Name = new Dict(ORM_CMN_PRO_ProductGroup.TableName); productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "Treatment Group"); //if (Parameter.IsCatalogPublic == false) //{ // productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); // productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "HauseList Group"); //} //else //{ // productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.ABDA); // productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "ABDA Group"); //} // for only Tenant specific cases add Business Participant ID if (Parameter.SubscribedBy_BusinessParticipant_RefID != Guid.Empty) { productGroup.GlobalPropertyMatchingID += Parameter.SubscribedBy_BusinessParticipant_RefID; productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "Treatment Group"); } productGroup.Save(Connection, Transaction); } #endregion #region create priceList for Catalog /* * @create pricelist_Release * */ ORM_CMN_SLS_Pricelist_Release pricelist_Release = new ORM_CMN_SLS_Pricelist_Release(); pricelist_Release.CMN_SLS_Pricelist_ReleaseID = Guid.NewGuid(); pricelist_Release.Release_Version = "v1"; if (Parameter.IsCatalogPublic == false) { pricelist_Release.PricelistRelease_ValidFrom = Parameter.ValidFrom_Date; pricelist_Release.PricelistRelease_ValidTo = Parameter.ValidTo_Date; } else { pricelist_Release.IsPricelistAlwaysActive = true; } pricelist_Release.Tenant_RefID = securityTicket.TenantID; pricelist_Release.Creation_Timestamp = DateTime.Now; pricelist_Release.Pricelist_RefID = Guid.NewGuid();//priceList.CMN_SLS_PricelistID pricelist_Release.Save(Connection, Transaction); /* * @create pricelist * */ ORM_CMN_SLS_Pricelist priceList = new ORM_CMN_SLS_Pricelist(); priceList.CMN_SLS_PricelistID = pricelist_Release.Pricelist_RefID; var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict nameDict = new Dict("cmn_sls_pricelist"); if (Parameter.IsCatalogPublic == false) { for (int i = 0; i < DBLanguages.Count; i++) { nameDict.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.CatalogName + "_" + Parameter.ValidFrom_Date.ToShortDateString() + "_" + Parameter.ValidTo_Date.ToShortDateString()); } } else { for (int i = 0; i < DBLanguages.Count; i++) { nameDict.AddEntry(DBLanguages[i].CMN_LanguageID, "ABDA_PriceList"); } } priceList.Pricelist_Name = nameDict; priceList.Tenant_RefID = securityTicket.TenantID; priceList.Creation_Timestamp = DateTime.Now; priceList.Save(Connection, Transaction); #endregion if (Parameter.IsCatalogPublic == false) { #region create and save products in product group and give product its price , product amout and measure unit /* * @create and save products in product group * */ bool isAlreadyInABDA = false; foreach (var item in Parameter.Products) { ORM_CMN_PRO_Product product = new ORM_CMN_PRO_Product(); // only for Tenant specific cases add Business Participant ID (!Lucentis) if (Parameter.SubscribedBy_BusinessParticipant_RefID == Guid.Empty) { var productQuery = new ORM_CMN_PRO_Product.Query(); productQuery.ProductITL = item.ProductITL; productQuery.Tenant_RefID = securityTicket.TenantID; productQuery.IsDeleted = false; productQuery.IsProductAvailableForOrdering = true; product = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, productQuery).FirstOrDefault(); //if it is not in ABDA if (product == null) { product = new ORM_CMN_PRO_Product(); product.CMN_PRO_ProductID = Guid.NewGuid(); product.Creation_Timestamp = DateTime.Now; product.Tenant_RefID = securityTicket.TenantID; product.ProductITL = item.ProductITL; product.Product_Name = item.Product_Name; product.Product_Description = item.Product_Description; product.Product_Number = item.Product_Number; product.IsProduct_Article = item.IsProduct_Article; product.IsProductAvailableForOrdering = true; product.PackageInfo_RefID = Guid.NewGuid();//packageInfo.CMN_PRO_PAC_PackageInfoID isAlreadyInABDA = false; } else { isAlreadyInABDA = true; } } else { product.CMN_PRO_ProductID = Guid.NewGuid(); product.Creation_Timestamp = DateTime.Now; product.Tenant_RefID = securityTicket.TenantID; product.ProductITL = item.ProductITL; product.Product_Name = item.Product_Name; product.Product_Description = item.Product_Description; product.Product_Number = item.Product_Number; product.IsProduct_Article = item.IsProduct_Article; product.IsProductAvailableForOrdering = true; product.PackageInfo_RefID = Guid.NewGuid();//packageInfo.CMN_PRO_PAC_PackageInfoID isAlreadyInABDA = false; } product.IfImportedFromExternalCatalog_CatalogSubscription_RefID = subscribedCatalog.CMN_PRO_SubscribedCatalogID; product.Save(Connection, Transaction); L3CCfTaIC_1526 pro = new L3CCfTaIC_1526(); pro.ProductID = product.CMN_PRO_ProductID; if (product.IsProduct_Article) { pro.Dosage = item.Dosage; } pro.isEdit = false; ProductList.Add(pro); ORM_CMN_PRO_Product_2_ProductGroup product_2_productGroup = new ORM_CMN_PRO_Product_2_ProductGroup(); product_2_productGroup.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; product_2_productGroup.CMN_PRO_ProductGroup_RefID = productGroup.CMN_PRO_ProductGroupID; product_2_productGroup.Tenant_RefID = securityTicket.TenantID; product_2_productGroup.Creation_Timestamp = DateTime.Now; product_2_productGroup.Save(Connection, Transaction); if (isAlreadyInABDA == false) { ORM_CMN_SLS_Price price = new ORM_CMN_SLS_Price(); price.CMN_SLS_PriceID = Guid.NewGuid(); price.Tenant_RefID = securityTicket.TenantID; price.Creation_Timestamp = DateTime.Now; price.PricelistRelease_RefID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; price.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; price.PriceAmount = item.Price; price.CMN_Currency_RefID = subscribedCatalog.SubscribedCatalog_Currency_RefID; price.Save(Connection, Transaction); //add amount and Measure ORM_CMN_PRO_PAC_PackageInfo packageInfo = new ORM_CMN_PRO_PAC_PackageInfo(); packageInfo.CMN_PRO_PAC_PackageInfoID = product.PackageInfo_RefID; packageInfo.Tenant_RefID = securityTicket.TenantID; packageInfo.Creation_Timestamp = DateTime.Now; packageInfo.PackageContent_Amount = item.Amount; //check if MeasureUnit exists for this Tenant var unitsQuery = new ORM_CMN_Unit.Query(); unitsQuery.Tenant_RefID = securityTicket.TenantID; unitsQuery.ISOCode = item.MeasuredInUnit_ISO_um_ums; unitsQuery.IsDeleted = false; var measuredInUnit = ORM_CMN_Unit.Query.Search(Connection, Transaction, unitsQuery).FirstOrDefault(); if (measuredInUnit == null) { ORM_CMN_Unit newMeasuredInUnit = new ORM_CMN_Unit(); newMeasuredInUnit.Tenant_RefID = securityTicket.TenantID; newMeasuredInUnit.Creation_Timestamp = DateTime.Now; newMeasuredInUnit.ISOCode = item.MeasuredInUnit_ISO_um_ums; newMeasuredInUnit.CMN_UnitID = Guid.NewGuid(); newMeasuredInUnit.Save(Connection, Transaction); packageInfo.PackageContent_MeasuredInUnit_RefID = newMeasuredInUnit.CMN_UnitID; } else { packageInfo.PackageContent_MeasuredInUnit_RefID = measuredInUnit.CMN_UnitID; } packageInfo.Save(Connection, Transaction); if (countryID != Guid.Empty)// if there is a country for this Tenant { #region Create Taxes double productVAT = 0; Double.TryParse(item.VAT, out productVAT); var tax = taxes.Where(i => i.TaxRate == productVAT).SingleOrDefault(); if (tax == default(L3TX_GTfCICaT_1359)) { #region CreateTax var saveTaxParam = new P_L3TX_STX_1119(); saveTaxParam.ACC_TAX_TaxeID = Guid.Empty; saveTaxParam.TaxName = new Dict(ORM_ACC_TAX_Tax.TableName); saveTaxParam.TaxName.AddEntry(language.CMN_LanguageID, productVAT.ToString()); saveTaxParam.TaxRate = productVAT; if (taxes.Length != 0) { saveTaxParam.EconomicRegion_RefID = taxes.First().CMN_EconomicRegionID; saveTaxParam.Country_RefID = taxes.First().CMN_CountryID; } else { saveTaxParam.EconomicRegion_RefID = Guid.Empty; saveTaxParam.Country_RefID = countryID; } var saveTaxResult = cls_Save_Tax.Invoke(Connection, Transaction, saveTaxParam, securityTicket).Result; #endregion #region Update Available taxes param = new P_L3TX_GTfCICaT_1359(); param.CountryISOCode = "DE"; taxes = cls_Get_Taxes_for_CountryISOCode_and_TenantID.Invoke(Connection, Transaction, param, securityTicket).Result; tax = taxes.Where(i => i.TaxRate == productVAT).SingleOrDefault(); #endregion } var salesTax = new ORM_CMN_PRO_Product_SalesTaxAssignmnet(); salesTax.CMN_PRO_Product_SalesTaxAssignmnetID = Guid.NewGuid(); salesTax.Product_RefID = product.CMN_PRO_ProductID; salesTax.ApplicableSalesTax_RefID = tax.ACC_TAX_TaxeID; salesTax.Creation_Timestamp = DateTime.Now; salesTax.Tenant_RefID = securityTicket.TenantID; salesTax.Save(Connection, Transaction); #endregion } } } #endregion } /* * @See if Supplier already exists in database * */ ORM_CMN_BPT_Supplier supplier = new ORM_CMN_BPT_Supplier(); var supplierQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); supplierQuery.BusinessParticipantITL = Parameter.SupplierData.SupplierITL; supplierQuery.Tenant_RefID = securityTicket.TenantID; supplierQuery.IsDeleted = false; var supplier_bussinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, supplierQuery).FirstOrDefault(); #region if supplier does not exist if (supplier_bussinessParticipant == null) { /* * @Make Supplier Data * */ var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.SupplierData.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.SupplierData.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); } supplier.CMN_BPT_SupplierID = Guid.NewGuid(); supplier.Ext_BusinessParticipant_RefID = Guid.NewGuid();//supplierBussinessParticipant.CMN_BPT_BusinessParticipantID supplier.Creation_Timestamp = DateTime.Now; supplier.IsDeleted = false; supplier.Tenant_RefID = securityTicket.TenantID; supplier.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant supplierBussinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBussinessParticipant.CMN_BPT_BusinessParticipantID = supplier.Ext_BusinessParticipant_RefID; supplierBussinessParticipant.DisplayName = Parameter.SupplierData.Supplier_Name; supplierBussinessParticipant.BusinessParticipantITL = Parameter.SupplierData.SupplierITL; supplierBussinessParticipant.Creation_Timestamp = DateTime.Now; supplierBussinessParticipant.Tenant_RefID = securityTicket.TenantID; supplierBussinessParticipant.IsCompany = true; supplierBussinessParticipant.IsTenant = true; supplierBussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = Guid.NewGuid();//companyInfo.CMN_COM_CompanyInfoID supplierBussinessParticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = supplierBussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfo.Creation_Timestamp = DateTime.Now; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Contact_UCD_RefID = Guid.NewGuid();//universalContactDetail.CMN_UniversalContactDetailID companyInfo.Save(Connection, Transaction); ORM_CMN_UniversalContactDetail universalContactDetail = new ORM_CMN_UniversalContactDetail(); universalContactDetail.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetail.IsCompany = true; universalContactDetail.Country_639_1_ISOCode = Parameter.SupplierData.CountryISO; universalContactDetail.Street_Name = Parameter.SupplierData.Supplier_Name; universalContactDetail.Street_Number = Parameter.SupplierData.Street_Number; universalContactDetail.ZIP = Parameter.SupplierData.ZIP; universalContactDetail.Town = Parameter.SupplierData.Town; universalContactDetail.Region_Code = Parameter.SupplierData.Region_Code; universalContactDetail.Tenant_RefID = securityTicket.TenantID; universalContactDetail.Creation_Timestamp = DateTime.Now; universalContactDetail.Save(Connection, Transaction); } #endregion #region if supplier exists , check if its data is changed else { var tenantQuery = new ORM_CMN_Tenant.Query() { TenantITL = Parameter.SupplierData.TenantITL, Tenant_RefID = securityTicket.TenantID }; var supplierTenant = ORM_CMN_Tenant.Query.Search(Connection, Transaction, tenantQuery).SingleOrDefault(); if (supplierTenant == default(ORM_CMN_Tenant)) { supplierTenant = new ORM_CMN_Tenant(); supplierTenant.CMN_TenantID = Guid.NewGuid(); supplierTenant.TenantITL = Parameter.SupplierData.TenantITL; supplierTenant.Tenant_RefID = securityTicket.TenantID; supplierTenant.Creation_Timestamp = DateTime.Now; supplierTenant.Save(Connection, Transaction); supplier_bussinessParticipant.IsTenant = true; supplier_bussinessParticipant.IfTenant_Tenant_RefID = supplierTenant.CMN_TenantID; } supplier_bussinessParticipant.DisplayName = Parameter.SupplierData.Supplier_Name; supplier_bussinessParticipant.Save(Connection, Transaction); var query = new ORM_CMN_BPT_Supplier.Query(); query.Ext_BusinessParticipant_RefID = supplier_bussinessParticipant.CMN_BPT_BusinessParticipantID; query.Tenant_RefID = securityTicket.TenantID; query.IsDeleted = false; supplier = ORM_CMN_BPT_Supplier.Query.Search(Connection, Transaction, query).First(); //edit universal contact details var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = supplier_bussinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; companyInfoQuery.Tenant_RefID = securityTicket.TenantID; companyInfoQuery.IsDeleted = false; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var universalContactDetailQuery = new ORM_CMN_UniversalContactDetail.Query(); universalContactDetailQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; universalContactDetailQuery.Tenant_RefID = securityTicket.TenantID; universalContactDetailQuery.IsDeleted = false; var universalContactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, universalContactDetailQuery).First(); universalContactDetail.Country_639_1_ISOCode = Parameter.SupplierData.CountryISO; universalContactDetail.Street_Name = Parameter.SupplierData.Supplier_Name; universalContactDetail.Street_Number = Parameter.SupplierData.Street_Number; universalContactDetail.ZIP = Parameter.SupplierData.ZIP; universalContactDetail.Town = Parameter.SupplierData.Town; universalContactDetail.Region_Code = Parameter.SupplierData.Region_Code; universalContactDetail.Save(Connection, Transaction); } #endregion subscribedCatalog.SubscribedCatalog_PricelistRelease_RefID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; subscribedCatalog.PublishingSupplier_RefID = supplier.CMN_BPT_SupplierID; subscribedCatalog.Save(Connection, Transaction); /* * @send Kika information which catalog has been subscribed to who * */ var result = _service.SubscribeToCatalog(subscriptionRequest); if (result.ResponseStatus != ResponseStatus.OK) { throw new Exception("Catalog subscription failed!"); } } #endregion returnValue.Result = ProductList.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3TX_STXO_0929 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_ACC_TAX_TaxOffice(); if (Parameter.ACC_TAX_TaxOfficeID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.ACC_TAX_TaxOfficeID); if (result.Status != FR_Status.Success || item.ACC_TAX_TaxOfficeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } ORM_CMN_BPT_BusinessParticipant.Query bptQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bptQuery.CMN_BPT_BusinessParticipantID = item.CMN_BPT_BusinessParticipant_RefID; bptQuery.Tenant_RefID = securityTicket.TenantID; bptQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipant bparticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bptQuery).FirstOrDefault(); bparticipant.DisplayName = Parameter.DisplayName; bparticipant.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo.Query cmpInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); cmpInfoQuery.CMN_COM_CompanyInfoID = bparticipant.IfCompany_CMN_COM_CompanyInfo_RefID; cmpInfoQuery.IsDeleted = false; cmpInfoQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_COM_CompanyInfo companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, cmpInfoQuery).FirstOrDefault(); companyInfo.VATIdentificationNumber = Parameter.VATIdentificationNumber; companyInfo.Save(Connection, Transaction); returnValue.Result = item.ACC_TAX_TaxOfficeID; if (companyInfo.Contact_UCD_RefID != Guid.Empty) { var countries = cls_Get_AllCountries.Invoke(Connection, Transaction, securityTicket).Result; ORM_CMN_UniversalContactDetail.Query ucdQuery = new ORM_CMN_UniversalContactDetail.Query(); ucdQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; ucdQuery.Tenant_RefID = securityTicket.TenantID; ucdQuery.IsDeleted = false; ORM_CMN_UniversalContactDetail ucd = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, ucdQuery).FirstOrDefault(); ucd.Country_639_1_ISOCode = Parameter.Country_ISO; ucd.Save(Connection, Transaction); } } else { ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.VATIdentificationNumber = Parameter.VATIdentificationNumber; companyInfo.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bparticipant = new ORM_CMN_BPT_BusinessParticipant(); bparticipant.DisplayName = Parameter.DisplayName; bparticipant.IsCompany = true; bparticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; bparticipant.Tenant_RefID = securityTicket.TenantID; bparticipant.Save(Connection, Transaction); ORM_ACC_TAX_TaxOffice taxOffice = new ORM_ACC_TAX_TaxOffice(); taxOffice.CMN_BPT_BusinessParticipant_RefID = bparticipant.CMN_BPT_BusinessParticipantID; taxOffice.Tenant_RefID = securityTicket.TenantID; taxOffice.Save(Connection, Transaction); returnValue.Result = taxOffice.ACC_TAX_TaxOfficeID; if (Parameter.Country_ISO != "") { var countries = cls_Get_AllCountries.Invoke(Connection, Transaction, securityTicket).Result; ORM_CMN_UniversalContactDetail ucd = new ORM_CMN_UniversalContactDetail(); ucd.Country_639_1_ISOCode = Parameter.Country_ISO; ucd.Tenant_RefID = securityTicket.TenantID; ucd.Save(Connection, Transaction); companyInfo.Contact_UCD_RefID = ucd.CMN_UniversalContactDetailID; } companyInfo.Save(Connection, Transaction); } //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OP_SP_1602 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var languages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; P_L3MP_SPBI_1602 basePracticeParam = new P_L3MP_SPBI_1602(); basePracticeParam.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; basePracticeParam.Contact_EmergencyPhoneNumber = Parameter.PhoneNumber; basePracticeParam.Contact_Website_URL = Parameter.HomepageURL; basePracticeParam.PracticeEmail = Parameter.ContactEmail; basePracticeParam.PracticeName = Parameter.DisplyName; basePracticeParam.Region_Name = Parameter.AddressRegion; basePracticeParam.Street_Name = Parameter.AddressStreetName; basePracticeParam.Street_Number = Parameter.AddressStreetNumber; basePracticeParam.Town = Parameter.AddressCity; basePracticeParam.ZIP = Parameter.AddressZipCode; var practiceID = cls_Save_Practice_BaseInfo.Invoke(Connection, Transaction, basePracticeParam, securityTicket).Result; var practicesQuery = new ORM_HEC_MedicalPractis.Query(); practicesQuery.HEC_MedicalPractiseID = practiceID; var practices = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practicesQuery).First(); var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = practices.Ext_CompanyInfo_RefID; var companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).First(); ORM_CMN_BPT_BusinessParticipant bpContctPerson; if (practices.ContactPerson_RefID != Guid.Empty) { var bpContctPersonQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bpContctPersonQuery.CMN_BPT_BusinessParticipantID = practices.ContactPerson_RefID; bpContctPerson = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bpContctPersonQuery).First(); } else { bpContctPerson = new ORM_CMN_BPT_BusinessParticipant(); bpContctPerson.Tenant_RefID = securityTicket.TenantID; bpContctPerson.IsNaturalPerson = true; } bpContctPerson.DisplayName = Parameter.ContactPerson_Name; bpContctPerson.Save(Connection, Transaction); practices.ContactPerson_RefID = bpContctPerson.CMN_BPT_BusinessParticipantID; ORM_CMN_CAL_WeeklyOfficeHours_Template officeHours; ORM_CMN_CAL_WeeklyOfficeHours_Template consultingHours; if (practices.WeeklyOfficeHours_Template_RefID != Guid.Empty && practices.WeeklySurgeryHours_Template_RefID != Guid.Empty) { var officeHoursQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Template.Query(); officeHoursQuery.CMN_CAL_WeeklyOfficeHours_TemplateID = practices.WeeklyOfficeHours_Template_RefID; officeHours = ORM_CMN_CAL_WeeklyOfficeHours_Template.Query.Search(Connection, Transaction, officeHoursQuery).First(); officeHoursQuery.CMN_CAL_WeeklyOfficeHours_TemplateID = practices.WeeklySurgeryHours_Template_RefID; consultingHours = ORM_CMN_CAL_WeeklyOfficeHours_Template.Query.Search(Connection, Transaction, officeHoursQuery).First(); } else { officeHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); officeHours.CMN_CAL_WeeklyOfficeHours_TemplateID = Guid.NewGuid(); consultingHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); consultingHours.CMN_CAL_WeeklyOfficeHours_TemplateID = Guid.NewGuid(); practices.WeeklyOfficeHours_Template_RefID = officeHours.CMN_CAL_WeeklyOfficeHours_TemplateID; practices.WeeklySurgeryHours_Template_RefID = consultingHours.CMN_CAL_WeeklyOfficeHours_TemplateID; } consultingHours.Tenant_RefID = securityTicket.TenantID; officeHours.Tenant_RefID = securityTicket.TenantID; consultingHours.FormattedOfficeHours = Parameter.Consultation_FormattedOfficeHours; officeHours.FormattedOfficeHours = Parameter.Working_FormattedOfficeHours; consultingHours.Save(Connection, Transaction); officeHours.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo_Type companyType; var companyTypeQuery = new ORM_CMN_COM_CompanyInfo_Type.Query(); companyTypeQuery.IsDeleted = false; companyTypeQuery.CMN_COM_CompanyInfo_TypeID = Parameter.PracticeType_RefID; companyType = ORM_CMN_COM_CompanyInfo_Type.Query.Search(Connection, Transaction, companyTypeQuery).FirstOrDefault(); if (companyType == null) { companyType = new ORM_CMN_COM_CompanyInfo_Type(); companyType.CMN_COM_CompanyInfo_TypeID = Parameter.PracticeType_RefID; companyType.CompanyType_Name = new Dict(); companyType.CompanyType_Name.DictionaryID = Guid.NewGuid(); if (languages != null) { foreach (var item in languages) { companyType.CompanyType_Name.AddEntry(item.CMN_LanguageID, STLD_PracticeType.typesItems.First(t => t.Value == Parameter.PracticeType_RefID).Text); } } } companyInfo.CompanyType_RefID = Parameter.PracticeType_RefID; ORM_HEC_PublicHealthcare_PhysitianAssociation pHealthcare; var pHealthcareQuery = new ORM_HEC_PublicHealthcare_PhysitianAssociation.Query(); pHealthcareQuery.HEC_PublicHealthcare_PhysitianAssociationID = Parameter.HealthAssociation_RefID; pHealthcare = ORM_HEC_PublicHealthcare_PhysitianAssociation.Query.Search(Connection, Transaction, pHealthcareQuery).FirstOrDefault(); if (pHealthcare == null) { pHealthcare = new ORM_HEC_PublicHealthcare_PhysitianAssociation(); pHealthcare.HEC_PublicHealthcare_PhysitianAssociationID = Parameter.HealthAssociation_RefID; pHealthcare.HealthAssociation_Name = STLD_MedicalAssociation.associationItems.First(t => t.Value == Parameter.HealthAssociation_RefID).Text; pHealthcare.Save(Connection, Transaction); } practices.AssociatedWith_PhysitianAssociation_RefID = Parameter.HealthAssociation_RefID; ORM_CMN_BPT_CTM_Customer customer; var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count == 0) { customer = new ORM_CMN_BPT_CTM_Customer(); customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; } else { customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First(); } var affinityStatusQuery = new ORM_CMN_BPT_CTM_AffinityStatus.Query(); affinityStatusQuery.CMN_BPT_CTM_AffinityStatusID = Parameter.AffinityStatus_RefID; var affinityStatus = ORM_CMN_BPT_CTM_AffinityStatus.Query.Search(Connection, Transaction, affinityStatusQuery).FirstOrDefault(); if (affinityStatus == null) { affinityStatus = new ORM_CMN_BPT_CTM_AffinityStatus(); affinityStatus.CMN_BPT_CTM_AffinityStatusID = Parameter.AffinityStatus_RefID; affinityStatus.AffinityStatus_Name = new Dict(); affinityStatus.AffinityStatus_Name.DictionaryID = Guid.NewGuid(); if (languages != null) { foreach (var item in languages) { affinityStatus.AffinityStatus_Name.AddEntry(item.CMN_LanguageID, STLD_AffinityStatus.affinityItems.First(t => t.Value == Parameter.AffinityStatus_RefID).Text); } } affinityStatus.Save(Connection, Transaction); } customer.CustomerAffinityStatus_RefID = Parameter.AffinityStatus_RefID; customer.Tenant_RefID = securityTicket.TenantID; customer.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo_Address compAddress; ORM_CMN_UniversalContactDetail address; var compAddressQuery = new ORM_CMN_COM_CompanyInfo_Address.Query(); compAddressQuery.Tenant_RefID = securityTicket.TenantID; compAddressQuery.CompanyInfo_RefID = practices.Ext_CompanyInfo_RefID; var compAddressRes = ORM_CMN_COM_CompanyInfo_Address.Query.Search(Connection, Transaction, compAddressQuery); if (compAddressRes.Count > 0) { compAddress = compAddressRes.First(); var addressQuery = new ORM_CMN_UniversalContactDetail.Query(); addressQuery.CMN_UniversalContactDetailID = compAddress.Address_UCD_RefID; address = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, addressQuery).First(); } else { compAddress = new ORM_CMN_COM_CompanyInfo_Address(); compAddress.CMN_COM_CompanyInfo_AddressID = Guid.NewGuid(); compAddress.IsShipping = true; compAddress.CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; address = new ORM_CMN_UniversalContactDetail(); address.CMN_UniversalContactDetailID = Guid.NewGuid(); compAddress.Address_UCD_RefID = address.CMN_UniversalContactDetailID; } address.Town = Parameter.ShippingAddressCity; address.Street_Number = Parameter.ShippingAddressStreetNumber; address.Street_Name = Parameter.ShippingAddressStreetName; address.ZIP = Parameter.ShippingAddressZipCode; address.Region_Name = Parameter.ShippingAddressRegion; address.Tenant_RefID = securityTicket.TenantID; address.Save(Connection, Transaction); compAddress.Tenant_RefID = securityTicket.TenantID; compAddress.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant contactPBP; if (practices.ContactPerson_RefID != Guid.Empty) { var contactPBPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); contactPBPQuery.CMN_BPT_BusinessParticipantID = practices.ContactPerson_RefID; contactPBP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, contactPBPQuery).First(); } else { contactPBP = new ORM_CMN_BPT_BusinessParticipant(); contactPBP.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); contactPBP.IsCompany = true; practices.ContactPerson_RefID = contactPBP.CMN_BPT_BusinessParticipantID; } contactPBP.DisplayName = Parameter.ContactPerson_Name; contactPBP.Tenant_RefID = securityTicket.TenantID; contactPBP.Save(Connection, Transaction); companyInfo.Save(Connection, Transaction); practices.Save(Connection, Transaction); returnValue.Result = practices.HEC_MedicalPractiseID; 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_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 }
public static void Save_practices_to_DB(Practice_Model_from_xlsx Parameter, string connectionString, SessionSecurityTicket securityTicket) { DbConnection Connection = null; DbTransaction Transaction = null; bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; 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"); var returnValue = new FR_Guid(); Guid companyInfoID = Guid.NewGuid(); Guid BusinessParticipantID = Guid.NewGuid(); Guid PracticeAddressID = Guid.NewGuid(); Guid practice_id = Guid.NewGuid(); if (!String.IsNullOrEmpty(Parameter.LoginEmail)) //uncomment this if you've created account // if(false) { string[] stringUser = Parameter.LoginEmail.Split('@'); string usernameStr = stringUser[0]; try { var practiceAccountInfo = ORM_USR_Account.Query.Search(Connection, Transaction, new ORM_USR_Account.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, AccountSignInEmailAddress = Parameter.LoginEmail, }).Single(); var accountGroupQuery = new ORM_USR_Account_FunctionLevelRights_Group.Query(); accountGroupQuery.Tenant_RefID = securityTicket.TenantID; accountGroupQuery.IsDeleted = false; accountGroupQuery.GlobalPropertyMatchingID = "mm.docconect.doc.app.group"; var accountGroup = ORM_USR_Account_FunctionLevelRights_Group.Query.Search(Connection, Transaction, accountGroupQuery).SingleOrDefault(); if (accountGroup == null) { accountGroup = new ORM_USR_Account_FunctionLevelRights_Group(); accountGroup.Tenant_RefID = securityTicket.TenantID; accountGroup.Label = "mm.docconect.doc.app.group"; accountGroup.GlobalPropertyMatchingID = "mm.docconect.doc.app.group"; accountGroup.Creation_Timestamp = DateTime.Now; accountGroup.USR_Account_FunctionLevelRights_GroupID = Guid.NewGuid(); accountGroup.Save(Connection, Transaction); } var functionLevelRightQ = new ORM_USR_Account_FunctionLevelRight.Query(); functionLevelRightQ.Tenant_RefID = securityTicket.TenantID; functionLevelRightQ.IsDeleted = false; functionLevelRightQ.GlobalPropertyMatchingID = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; var existingunctionLevelRight = ORM_USR_Account_FunctionLevelRight.Query.Search(Connection, Transaction, functionLevelRightQ).SingleOrDefault(); Guid tempFunctionLevelRightID = Guid.Empty; if (existingunctionLevelRight == null) { ORM_USR_Account_FunctionLevelRight functionLevelRight = new ORM_USR_Account_FunctionLevelRight(); functionLevelRight.USR_Account_FunctionLevelRightID = Guid.NewGuid(); functionLevelRight.FunctionLevelRights_Group_RefID = accountGroup.USR_Account_FunctionLevelRights_GroupID; functionLevelRight.Tenant_RefID = securityTicket.TenantID; functionLevelRight.Creation_Timestamp = DateTime.Now; functionLevelRight.RightName = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; functionLevelRight.GlobalPropertyMatchingID = Parameter.IsSurgeryPractice ? "mm.docconect.doc.app.op.practice" : "mm.docconect.doc.app.ac.practice"; functionLevelRight.Save(Connection, Transaction); tempFunctionLevelRightID = functionLevelRight.USR_Account_FunctionLevelRightID; } else { tempFunctionLevelRightID = existingunctionLevelRight.USR_Account_FunctionLevelRightID; } var accountToFunctionLevelRight = new ORM_USR_Account_2_FunctionLevelRight(); accountToFunctionLevelRight.Tenant_RefID = securityTicket.TenantID; accountToFunctionLevelRight.Creation_Timestamp = DateTime.Now; accountToFunctionLevelRight.AssignmentID = Guid.NewGuid(); accountToFunctionLevelRight.Account_RefID = practiceAccountInfo.USR_AccountID; accountToFunctionLevelRight.FunctionLevelRight_RefID = tempFunctionLevelRightID; // USR_Account_FunctionLevelRightID accountToFunctionLevelRight.Save(Connection, Transaction); var businessParticipantQ = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQ.IsDeleted = false; businessParticipantQ.Tenant_RefID = securityTicket.TenantID; businessParticipantQ.CMN_BPT_BusinessParticipantID = practiceAccountInfo.BusinessParticipant_RefID; BusinessParticipantID = practiceAccountInfo.BusinessParticipant_RefID; var practiceinfoinBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQ).Single(); practiceinfoinBusinessParticipant.DisplayName = Parameter.PracticeName; practiceinfoinBusinessParticipant.IsCompany = true; practiceinfoinBusinessParticipant.Modification_Timestamp = DateTime.Now; practiceinfoinBusinessParticipant.Save(Connection, Transaction); companyInfoID = practiceinfoinBusinessParticipant.IfCompany_CMN_COM_CompanyInfo_RefID; var companyInfo = new ORM_CMN_COM_CompanyInfo.Query(); companyInfo.IsDeleted = false; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.CMN_COM_CompanyInfoID = companyInfoID; var companyInfoPractice = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfo).Single(); companyInfoPractice.CompanyInfo_EstablishmentNumber = Parameter.BSNR; companyInfoPractice.Save(Connection, Transaction); var companyInfoAddressPractice = new ORM_CMN_COM_CompanyInfo_Address(); companyInfoAddressPractice.CompanyInfo_RefID = companyInfoID; companyInfoAddressPractice.IsDefault = true; companyInfoAddressPractice.IsShipping = true; companyInfoAddressPractice.IsBilling = true; companyInfoAddressPractice.Tenant_RefID = securityTicket.TenantID; companyInfoAddressPractice.Address_UCD_RefID = Guid.NewGuid(); companyInfoAddressPractice.Address_Description = "Standard address for billing, shipping"; companyInfoAddressPractice.Save(Connection, Transaction); PracticeAddressID = companyInfoAddressPractice.Address_UCD_RefID; var universlContactPractice = new ORM_CMN_UniversalContactDetail(); universlContactPractice.IsDeleted = false; universlContactPractice.Tenant_RefID = securityTicket.TenantID; universlContactPractice.CMN_UniversalContactDetailID = PracticeAddressID; universlContactPractice.CompanyName_Line1 = Parameter.PracticeName; universlContactPractice.IsCompany = true; universlContactPractice.Street_Name = Parameter.Street; universlContactPractice.Street_Number = Parameter.No; universlContactPractice.ZIP = Parameter.Zip; universlContactPractice.Town = Parameter.City; universlContactPractice.Contact_Email = Parameter.MainEmail; universlContactPractice.Contact_Telephone = Parameter.MainPhone; universlContactPractice.Contact_Fax = Parameter.Fax; universlContactPractice.Creation_Timestamp = DateTime.Now; universlContactPractice.Modification_Timestamp = DateTime.Now; universlContactPractice.Save(Connection, Transaction); } catch (Exception ex) { throw new Exception("Exception occured durng data retrieval in method cls_Save_Practice", ex); //Log the error (uncomment dex variable name and add a line here to write a log. } } // else{ var companyInfoAddress2 = new ORM_CMN_COM_CompanyInfo_Address(); companyInfoAddress2.IsDeleted = false; companyInfoAddress2.Tenant_RefID = securityTicket.TenantID; companyInfoAddress2.CompanyInfo_RefID = companyInfoID; companyInfoAddress2.IsDefault = true; companyInfoAddress2.IsContact = true; companyInfoAddress2.Address_UCD_RefID = Guid.NewGuid(); companyInfoAddress2.Address_Description = "Standard contact person data"; companyInfoAddress2.Creation_Timestamp = DateTime.Now; companyInfoAddress2.Save(Connection, Transaction); string personInfo = Parameter.ContactPerson; string PersonFirstName = ""; string PersonLastName = ""; int i = personInfo.IndexOf(' '); if (i > 1) { PersonFirstName = personInfo.Substring(0, i); PersonLastName = personInfo.Substring(i + 1); } else { PersonFirstName = Parameter.ContactPerson; PersonLastName = " "; } var universlContactPractice2 = new ORM_CMN_UniversalContactDetail(); universlContactPractice2.CMN_UniversalContactDetailID = companyInfoAddress2.Address_UCD_RefID; universlContactPractice2.IsDeleted = false; universlContactPractice2.Tenant_RefID = securityTicket.TenantID; universlContactPractice2.IsCompany = false; universlContactPractice2.First_Name = PersonFirstName; universlContactPractice2.Last_Name = PersonLastName; universlContactPractice2.Contact_Email = Parameter.Email; universlContactPractice2.Contact_Telephone = Parameter.Phone; universlContactPractice2.Creation_Timestamp = DateTime.Now; universlContactPractice2.Modification_Timestamp = DateTime.Now; universlContactPractice2.Save(Connection, Transaction); var business2bankAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount(); business2bankAccount.IsDeleted = false; business2bankAccount.Tenant_RefID = securityTicket.TenantID; business2bankAccount.CMN_BPT_BusinessParticipant_RefID = BusinessParticipantID; business2bankAccount.ACC_BNK_BankAccount_RefID = Guid.NewGuid(); business2bankAccount.Creation_Timestamp = DateTime.Now; business2bankAccount.Save(Connection, Transaction); var bankAccountPractice = new ORM_ACC_BNK_BankAccount(); bankAccountPractice.IsDeleted = false; bankAccountPractice.Tenant_RefID = securityTicket.TenantID; bankAccountPractice.ACC_BNK_BankAccountID = business2bankAccount.ACC_BNK_BankAccount_RefID; bankAccountPractice.OwnerText = Parameter.AccountHolder; bankAccountPractice.IBAN = Parameter.IBAN; bankAccountPractice.Bank_RefID = Guid.NewGuid(); bankAccountPractice.Creation_Timestamp = DateTime.Now; bankAccountPractice.Save(Connection, Transaction); var bank = new ORM_ACC_BNK_Bank(); bank.IsDeleted = false; bank.Tenant_RefID = securityTicket.TenantID; bank.ACC_BNK_BankID = bankAccountPractice.Bank_RefID; bank.BICCode = Parameter.Bic; bank.BankName = Parameter.Bank; bank.Creation_Timestamp = DateTime.Now; bank.Save(Connection, Transaction); var customer = new ORM_CMN_BPT_CTM_Customer(); customer.IsDeleted = false; customer.Tenant_RefID = securityTicket.TenantID; customer.Ext_BusinessParticipant_RefID = BusinessParticipantID; customer.CMN_BPT_CTM_CustomerID = Guid.NewGuid(); customer.Creation_Timestamp = DateTime.Now; customer.Save(Connection, Transaction); var organizationalUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit(); organizationalUnit.IsDeleted = false; organizationalUnit.Tenant_RefID = securityTicket.TenantID; organizationalUnit.Customer_RefID = customer.CMN_BPT_CTM_CustomerID; organizationalUnit.IsMedicalPractice = true; organizationalUnit.IfMedicalPractise_HEC_MedicalPractice_RefID = Guid.NewGuid(); organizationalUnit.Creation_Timestamp = DateTime.Now; organizationalUnit.Modification_Timestamp = DateTime.Now; organizationalUnit.Save(Connection, Transaction); var medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.IsDeleted = false; medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.HEC_MedicalPractiseID = organizationalUnit.IfMedicalPractise_HEC_MedicalPractice_RefID; medicalPractice.Creation_Timestamp = DateTime.Now; medicalPractice.Modification_Timestamp = DateTime.Now; medicalPractice.Save(Connection, Transaction); practice_id = medicalPractice.HEC_MedicalPractiseID; var medicalPRactice2Universal = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal.IsDeleted = false; medicalPRactice2Universal.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal.Value_Boolean = Parameter.IsSurgeryPractice; medicalPRactice2Universal.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal.Save(Connection, Transaction); var practiceUniversal = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal.IsDeleted = false; practiceUniversal.Tenant_RefID = securityTicket.TenantID; practiceUniversal.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal.PropertyName = "Surgery Practice"; practiceUniversal.IsValue_Boolean = true; practiceUniversal.Creation_Timestamp = DateTime.Now; practiceUniversal.Modification_Timestamp = DateTime.Now; practiceUniversal.Save(Connection, Transaction); var medicalPRactice2Universal2 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal2.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal2.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal2.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal2.Value_Boolean = Parameter.IsOrderDrugs; medicalPRactice2Universal2.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal2.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal2.Save(Connection, Transaction); var practiceUniversal2 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal2.IsDeleted = false; practiceUniversal2.Tenant_RefID = securityTicket.TenantID; practiceUniversal2.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal2.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal2.PropertyName = "Order Drugs"; practiceUniversal2.IsValue_Boolean = true; practiceUniversal2.Creation_Timestamp = DateTime.Now; practiceUniversal2.Modification_Timestamp = DateTime.Now; practiceUniversal2.Save(Connection, Transaction); // default shipping date offset var medicalPRactice2Universal3 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal3.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal3.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal3.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal3.Value_Number = double.Parse(Parameter.DefaultShippingDateOffset); medicalPRactice2Universal3.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal3.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal3.Save(Connection, Transaction); var practiceUniversal3 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal3.IsDeleted = false; practiceUniversal3.Tenant_RefID = securityTicket.TenantID; practiceUniversal3.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal3.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal3.PropertyName = "Default Shipping Date Offset"; practiceUniversal3.IsValue_Number = true; practiceUniversal3.Creation_Timestamp = DateTime.Now; practiceUniversal3.Modification_Timestamp = DateTime.Now; practiceUniversal3.Save(Connection, Transaction); var medicalPRactice2Universal4 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal4.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal4.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal4.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal4.Value_Boolean = Parameter.IsOnlyLabelRequired; medicalPRactice2Universal4.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal4.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal4.Save(Connection, Transaction); var practiceUniversal4 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal4.IsDeleted = false; practiceUniversal4.Tenant_RefID = securityTicket.TenantID; practiceUniversal4.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal4.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal4.PropertyName = "Only Label Required"; practiceUniversal4.IsValue_Boolean = true; practiceUniversal4.Creation_Timestamp = DateTime.Now; practiceUniversal4.Modification_Timestamp = DateTime.Now; practiceUniversal4.Save(Connection, Transaction); var medicalPRactice2Universal5 = new ORM_HEC_MedicalPractice_2_UniversalProperty(); medicalPRactice2Universal5.Tenant_RefID = securityTicket.TenantID; medicalPRactice2Universal5.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPRactice2Universal5.HEC_MedicalPractice_UniversalProperty_RefID = Guid.NewGuid(); medicalPRactice2Universal5.Value_Boolean = Parameter.isWaiveServiceFee; medicalPRactice2Universal5.Creation_Timestamp = DateTime.Now; medicalPRactice2Universal5.Modification_Timestamp = DateTime.Now; medicalPRactice2Universal5.Save(Connection, Transaction); var practiceUniversal5 = new ORM_HEC_MedicalPractice_UniversalProperty(); practiceUniversal5.IsDeleted = false; practiceUniversal5.Tenant_RefID = securityTicket.TenantID; practiceUniversal5.HEC_MedicalPractice_UniversalPropertyID = medicalPRactice2Universal5.HEC_MedicalPractice_UniversalProperty_RefID; practiceUniversal5.PropertyName = "Waive Service Fee"; practiceUniversal5.IsValue_Boolean = true; practiceUniversal5.Creation_Timestamp = DateTime.Now; practiceUniversal5.Modification_Timestamp = DateTime.Now; practiceUniversal5.Save(Connection, Transaction); // } Practice_Doctors_Model DPModel = new Practice_Doctors_Model(); DPModel.account_status = "aktiv"; DPModel.id = practice_id.ToString(); DPModel.name = Parameter.PracticeName; DPModel.name_untouched = Parameter.PracticeName; DPModel.salutation = ""; DPModel.type = "Practice"; DPModel.autocomplete_name = Parameter.PracticeName; DPModel.address = Parameter.Street + " " + Parameter.No; DPModel.zip = Parameter.Zip; DPModel.city = Parameter.City; DPModel.bank_untouched = Parameter.Bank != null ? Parameter.Bank : ""; DPModel.bank = Parameter.Bank != null ? Parameter.Bank : ""; if (Parameter.Email != null) { DPModel.email = Parameter.MainEmail; } DPModel.phone = Parameter.MainPhone; if (Parameter.IBAN != null) { DPModel.iban = Parameter.IBAN; } if (Parameter.Bic != null) { DPModel.bic = Parameter.Bic; } DPModel.bsnr_lanr = Parameter.BSNR; DPModel.aditional_info = ""; DPModel.contract = 0; DPModel.tenantid = securityTicket.TenantID.ToString(); DPModel.role = Parameter.IsSurgeryPractice ? "op" : "ac"; List <Practice_Doctors_Model> DPModelL = new List <Practice_Doctors_Model>(); DPModelL.Add(DPModel); Add_Practice_Doctors_to_Elastic.Import_Practice_Data_to_ElasticDB(DPModelL, securityTicket.TenantID.ToString()); //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; } }
protected static FR_L5MD_GDwPfID_1414 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MD_GDwPfID_1414 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5MD_GDwPfID_1414(); P_L3MD_GDBIfID_1150 biParam = new P_L3MD_GDBIfID_1150(); biParam.DoctorID = Parameter.DoctorID; var baseInfo = cls_Get_Doctor_BaseInfo_byID.Invoke(Connection, Transaction, biParam, securityTicket).Result; returnValue.Result = new L5MD_GDwPfID_1414(); returnValue.Result.BaseInfo = baseInfo; P_L3DAC_RACDbBPID_1056 aiParam = new P_L3DAC_RACDbBPID_1056(); aiParam.BPrticipantID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; var accInfo = cls_Retrive_Account_Code_Details_byBParticipantID.Invoke(Connection, Transaction, aiParam, securityTicket).Result; if (accInfo != null) { var AccountInfo = new L5MD_GDwPfID_1414_AccountInfo(); AccountInfo.AccountCode_ValidFrom = accInfo.AccountCode_ValidFrom; AccountInfo.AccountCode_Value = accInfo.AccountCode_Value; AccountInfo.USR_AccountID = baseInfo.Account_RefID; AccountInfo.USR_Device_AccountCodeID = accInfo.USR_Device_AccountCodeID; returnValue.Result.AccountInfo = AccountInfo; } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; customerQuery.IsDeleted = false; var customerRes = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery); if (customerRes.Count > 0) { var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query(); ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.Customer_RefID = customerRes.First().CMN_BPT_CTM_CustomerID; ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery.IsDeleted = false; var ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1 = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, ORM_CMN_BPT_CTM_Customer_2_SalesRepresentativeQuery).First(); returnValue.Result.SalesRepresentative = new L5MD_GDwPfID_1414_SalesRepresentative(); returnValue.Result.SalesRepresentative.SalesRepresentative_RefID = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative1.SalesRepresentative_RefID; } var assocBPQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); assocBPQuery.BusinessParticipant_RefID = baseInfo.Doctor_CMN_BPT_BusinessParticipantID; assocBPQuery.IsDeleted = false; var assocBPQs = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, assocBPQuery).ToArray(); if (assocBPQs.Length > 0) { assocBPQs = assocBPQs.OrderBy(a => a.Creation_Timestamp).ToArray(); var assocBPQ = assocBPQs.First(); var practiceBPQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); practiceBPQuery.CMN_BPT_BusinessParticipantID = assocBPQ.AssociatedBusinessParticipant_RefID; var practiceBP = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, practiceBPQuery).First(); var companInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companInfoQuery.CMN_COM_CompanyInfoID = practiceBP.IfCompany_CMN_COM_CompanyInfo_RefID; var companInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companInfoQuery).First(); var practiceQuery = new ORM_HEC_MedicalPractis.Query(); practiceQuery.Ext_CompanyInfo_RefID = companInfo.CMN_COM_CompanyInfoID; var prac = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practiceQuery).First(); P_L3MP_GPfID_1222 pbiParam = new P_L3MP_GPfID_1222(); pbiParam.HEC_MedicalPractiseID = prac.HEC_MedicalPractiseID; var practiceBasInfo = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, pbiParam, securityTicket).Result; if (practiceBasInfo != null) { L5MD_GDwPfID_1414_Practice practice = new L5MD_GDwPfID_1414_Practice(); practice.AssociatedParticipant_FunctionName = assocBPQ.AssociatedParticipant_FunctionName; practice.CMN_BPT_BusinessParticipantID = practiceBasInfo.BaseInfo.CMN_BPT_BusinessParticipantID; if (practiceBasInfo.OtherOphthal_PracticeData != null) { practice.HealthAssociation_Name = practiceBasInfo.OtherOphthal_PracticeData.HealthAssociation_Name; } practice.PracticeID = practiceBasInfo.BaseInfo.HEC_MedicalPractiseID; practice.PracticeName = practiceBasInfo.BaseInfo.PracticeName; practice.Region_Name = practiceBasInfo.BaseInfo.Region_Name; practice.Street_Name = practiceBasInfo.BaseInfo.Street_Name; practice.Street_Number = practiceBasInfo.BaseInfo.Street_Number; practice.Town = practiceBasInfo.BaseInfo.Town; practice.ZIP = practiceBasInfo.BaseInfo.ZIP; returnValue.Result.Practice = practice; } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MP_SPBI_1602 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_MedicalPractis practices; if (Parameter.HEC_MedicalPractiseID != Guid.Empty) { var practicesQuery = new ORM_HEC_MedicalPractis.Query(); practicesQuery.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; practices = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, practicesQuery).First(); } else { practices = new ORM_HEC_MedicalPractis(); practices.HEC_MedicalPractiseID = Guid.NewGuid(); } practices.Tenant_RefID = securityTicket.TenantID; if (Parameter.isLucentis == false) { practices.Contact_EmergencyPhoneNumber = Parameter.Contact_EmergencyPhoneNumber; } ORM_CMN_COM_CompanyInfo companyInfo; if (practices.Ext_CompanyInfo_RefID != Guid.Empty) { var companyInfoQuery = new ORM_CMN_COM_CompanyInfo.Query(); companyInfoQuery.CMN_COM_CompanyInfoID = practices.Ext_CompanyInfo_RefID; companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, companyInfoQuery).First(); } else { companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = Guid.NewGuid(); practices.Ext_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; } companyInfo.Tenant_RefID = securityTicket.TenantID; if (Parameter.isLucentis) { companyInfo.CompanyInfo_EstablishmentNumber = Parameter.ifLucentis_BSNR; } ORM_CMN_BPT_BusinessParticipant bParticipant; var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bParticipantQuery.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; var bpRes = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery); if (bpRes.Count == 0) { bParticipant = new ORM_CMN_BPT_BusinessParticipant(); bParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bParticipant.IsCompany = true; bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; } else { bParticipant = bpRes.First(); } bParticipant.DisplayName = Parameter.PracticeName; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_UniversalContactDetail contactDetails; if (companyInfo.Contact_UCD_RefID != Guid.Empty) { var ucdQuery = new ORM_CMN_UniversalContactDetail.Query(); ucdQuery.CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID; contactDetails = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, ucdQuery).First(); } else { contactDetails = new ORM_CMN_UniversalContactDetail(); contactDetails.CMN_UniversalContactDetailID = Guid.NewGuid(); companyInfo.Contact_UCD_RefID = contactDetails.CMN_UniversalContactDetailID; contactDetails.IsCompany = true; } contactDetails.Tenant_RefID = securityTicket.TenantID; if (Parameter.isLucentis == false) { contactDetails.Contact_Website_URL = Parameter.Contact_Website_URL; } contactDetails.Contact_Email = Parameter.PracticeEmail; contactDetails.Town = Parameter.Town; contactDetails.Street_Number = Parameter.Street_Number; contactDetails.Street_Name = Parameter.Street_Name; contactDetails.ZIP = Parameter.ZIP; if (Parameter.isLucentis == false) { contactDetails.Region_Name = Parameter.Region_Name; } if (Parameter.isLucentis) { contactDetails.Street_Name_Line2 = Parameter.Street_Name_Line2; } companyInfo.Save(Connection, Transaction); bParticipant.Save(Connection, Transaction); contactDetails.Save(Connection, Transaction); practices.Save(Connection, Transaction); returnValue.Result = practices.HEC_MedicalPractiseID; return(returnValue); #endregion UserCode }