///<summary> /// Get Dict objects for the list of items from Resource.xml file and list of languages ///</summary> ///<param name="enumValues">Specified enum values for type</param> ///<param name="path">Path to file</param> ///<param name="tableName">Table name of type in DB </param> ///<param name="languages">LanguageID values for current tenant</param> public Dictionary <String, Dict> GetDictObjectsFromResourceFile(List <String> enumValues, XmlDocument resourceFile, String tableName, List <ISOLanguage> languages) { var result = new Dictionary <String, Dict>(); var resourceItems = ReadResourceItemsFromResourceFile(resourceFile); foreach (var item in enumValues) { var labels = resourceItems.Where(i => i.ItemName == item).FirstOrDefault(); var dict = new Dict(tableName); foreach (var label in labels.Translations) { var language = languages.Where(i => i.ISO.ToLower() == label.ISO.ToLower()).FirstOrDefault(); if (language == null) { continue; } dict.AddEntry(language.LanguageID, label.Content); } result.Add(item, dict); } return(result); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2IC_SICR_0943 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here Dict nameDict = new Dict("log_wrh_inventorychangereasons"); Dict descriptionDict = new Dict("log_wrh_inventorychangereasons"); foreach (var langID in Parameter.Languages) { nameDict.AddEntry(langID, Parameter.Name); descriptionDict.AddEntry(langID, Parameter.Description); } ORM_LOG_WRH_InventoryChangeReason reason = new ORM_LOG_WRH_InventoryChangeReason(); if (Parameter.InventoryChangeReasonID == Guid.Empty) { reason.LOG_WRH_InventoryChangeReasonID = Guid.NewGuid(); // new } else { reason.Load(Connection, Transaction, Parameter.InventoryChangeReasonID); // edit } reason.InventoryChange_Description = descriptionDict; reason.InventoryChange_Name = nameDict; reason.Creation_Timestamp = DateTime.Now; reason.Tenant_RefID = securityTicket.TenantID; reason.GlobalPropertyMatchingID = Guid.Empty.ToString(); reason.IsDeleted = false; reason.Save(Connection, Transaction); returnValue.Result = reason.LOG_WRH_InventoryChangeReasonID; return(returnValue); #endregion UserCode }
public static void Setup_for_new_Tenant(string connectionString, SessionSecurityTicket securityTicket) { DbConnection Connection = null; DbTransaction Transaction = null; bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } //add default currency for Tenant used for GPOSes var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict currencyName = new Dict(ORM_CMN_Currency.TableName); for (int i = 0; i < DBLanguages.Count; i++) { currencyName.AddEntry(DBLanguages[i].CMN_LanguageID, "Euro"); } var currencyGeneral = new ORM_CMN_Currency(); currencyGeneral.CMN_CurrencyID = Guid.NewGuid(); currencyGeneral.ISO4127 = "EUR"; currencyGeneral.Symbol = "€"; currencyGeneral.Tenant_RefID = securityTicket.TenantID; currencyGeneral.IsDeleted = false; currencyGeneral.Name = currencyName; currencyGeneral.Creation_Timestamp = DateTime.Now; currencyGeneral.Save(Connection, Transaction); var contract = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).ToList(); if (contract.Count() == 0) { Precreaton_of_First_Contract.Create_Contract_With_Private_HIP(Connection, Transaction, securityTicket); //first run this -adding contract with private hIP Precreaton_of_First_Contract.Create_Contract_Ivi_Vertrag(Connection, Transaction, securityTicket); //second, run this- contract with diagnoses Add_GPOSes_to_Contract.Create_data_for_GPOSes(Connection, Transaction, securityTicket); } //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_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_MC_SM_1132 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here //save new medication if (Parameter.MedicationID == Guid.Empty) { var hecProducts = new ORM_HEC_Product(); hecProducts.IsDeleted = false; hecProducts.Tenant_RefID = securityTicket.TenantID; hecProducts.Creation_Timestamp = DateTime.Now; hecProducts.Modification_Timestamp = DateTime.Now; hecProducts.Ext_PRO_Product_RefID = Guid.NewGuid(); hecProducts.Save(Connection, Transaction); var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict ProductNameDict = new Dict(ORM_CMN_PRO_Product.TableName); for (int i = 0; i < DBLanguages.Count; i++) { ProductNameDict.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Medication); } var products = new ORM_CMN_PRO_Product(); products.CMN_PRO_ProductID = hecProducts.Ext_PRO_Product_RefID; products.IsDeleted = false; products.Tenant_RefID = securityTicket.TenantID; products.Creation_Timestamp = DateTime.Now; products.Product_Name = ProductNameDict; products.IsProducable_Internally = Parameter.ProprietaryDrug; products.Product_Number = Parameter.PZNScheme; products.Save(Connection, Transaction); //dosage and unit!!! } else { //edit medication var medication = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Product.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_PRO_ProductID = Parameter.MedicationID }).SingleOrDefault(); if (medication != null) { var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict ProductNameDict = new Dict(ORM_CMN_PRO_Product.TableName); for (int i = 0; i < DBLanguages.Count; i++) { ProductNameDict.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Medication); } medication.Modification_Timestamp = DateTime.Now; medication.Product_Name = ProductNameDict; medication.IsProducable_Internally = Parameter.ProprietaryDrug; medication.Product_Number = Parameter.PZNScheme; medication.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CAPA_1237 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_HEC_ACT_PlannedAction aftercare_planned_action = new ORM_HEC_ACT_PlannedAction(); aftercare_planned_action.Creation_Timestamp = DateTime.Now; aftercare_planned_action.HEC_ACT_PlannedActionID = Guid.NewGuid(); aftercare_planned_action.IsPerformed = false; aftercare_planned_action.Modification_Timestamp = DateTime.Now; aftercare_planned_action.Patient_RefID = Parameter.patient_id; aftercare_planned_action.PlannedFor_Date = Parameter.treatment_date; aftercare_planned_action.Tenant_RefID = securityTicket.TenantID; Guid id = Guid.Empty; var aftercare_doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, new ORM_HEC_Doctor.Query() { HEC_DoctorID = Parameter.aftercare_doctor_practice_id, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (aftercare_doctor != null) { id = aftercare_doctor.BusinessParticipant_RefID; } else { var aftercare_practice = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query() { IfMedicalPractise_HEC_MedicalPractice_RefID = Parameter.aftercare_doctor_practice_id, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (aftercare_practice != null) { var aftercare_customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { CMN_BPT_CTM_CustomerID = aftercare_practice.Customer_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (aftercare_customer != null) { id = aftercare_customer.Ext_BusinessParticipant_RefID; } } } aftercare_planned_action.ToBePerformedBy_BusinessParticipant_RefID = id; aftercare_planned_action.Save(Connection, Transaction); ORM_HEC_CAS_Case_RelevantPlannedAction aftercare_planned_action_to_case = new ORM_HEC_CAS_Case_RelevantPlannedAction(); aftercare_planned_action_to_case.Case_RefID = Parameter.case_id; aftercare_planned_action_to_case.Creation_Timestamp = DateTime.Now; aftercare_planned_action_to_case.HEC_CAS_Case_RelevantPlannedActionID = Guid.NewGuid(); aftercare_planned_action_to_case.Modification_Timestamp = DateTime.Now; aftercare_planned_action_to_case.PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_to_case.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_to_case.Save(Connection, Transaction); ORM_HEC_ACT_ActionType.Query aftercare_planned_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); aftercare_planned_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_typeQ.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_typeQ.IsDeleted = false; var aftercare_planned_action_type_id = Guid.Empty; var aftercare_planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, aftercare_planned_action_typeQ).SingleOrDefault(); if (aftercare_planned_action_type == null) { aftercare_planned_action_type = new ORM_HEC_ACT_ActionType(); Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "nachsorge" : "aftercare"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } aftercare_planned_action_type.ActionType_Name = action_type_name_dict; aftercare_planned_action_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_type.Save(Connection, Transaction); aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } else { aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PlannedAction_2_ActionType aftercare_planned_action_2_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); aftercare_planned_action_2_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_2_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_2_type.IsDeleted = false; aftercare_planned_action_2_type.HEC_ACT_ActionType_RefID = aftercare_planned_action_type_id; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_2_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_2_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_2_type.Save(Connection, Transaction); returnValue.Result = aftercare_planned_action.HEC_ACT_PlannedActionID; return(returnValue); #endregion UserCode }
public static void Add_GPOSes_to_ContractTables(List <GPOS_Model> parameter, DbConnection Connection, DbTransaction Transaction, SessionSecurityTicket securityTicket) { var accountforTenant = ORM_USR_Account.Query.Search(Connection, Transaction, new ORM_USR_Account.Query() { IsDeleted = false, USR_AccountID = securityTicket.AccountID, Tenant_RefID = securityTicket.TenantID }).Single(); var businessParticipantForTenant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_BPT_BusinessParticipantID = accountforTenant.BusinessParticipant_RefID }).Single(); var searchContractParties = ORM_CMN_CTR_Contract_Party.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract_Party.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Undersigning_BusinessParticipant_RefID = businessParticipantForTenant.CMN_BPT_BusinessParticipantID }).ToList(); Guid contractID = Guid.NewGuid(); var catalog1 = new ORM_HEC_BIL_PotentialCode_Catalog(); catalog1.IsDeleted = false; catalog1.Tenant_RefID = securityTicket.TenantID; catalog1.HEC_BIL_PotentialCode_CatalogID = Guid.NewGuid(); catalog1.GlobalPropertyMatchingID = "mm.docconnect.gpos.catalog.operation"; catalog1.Creation_Timestamp = DateTime.Now; catalog1.Save(Connection, Transaction); var catalog2 = new ORM_HEC_BIL_PotentialCode_Catalog(); catalog2.IsDeleted = false; catalog2.Tenant_RefID = securityTicket.TenantID; catalog2.HEC_BIL_PotentialCode_CatalogID = Guid.NewGuid(); catalog2.GlobalPropertyMatchingID = "mm.docconnect.gpos.catalog.nachsorge"; catalog2.Creation_Timestamp = DateTime.Now; catalog2.Save(Connection, Transaction); var catalog3 = new ORM_HEC_BIL_PotentialCode_Catalog(); catalog3.IsDeleted = false; catalog3.Tenant_RefID = securityTicket.TenantID; catalog3.HEC_BIL_PotentialCode_CatalogID = Guid.NewGuid(); catalog3.GlobalPropertyMatchingID = "mm.docconnect.gpos.catalog.zusatzposition.bevacizumab"; catalog3.Creation_Timestamp = DateTime.Now; catalog3.Save(Connection, Transaction); var catalog4 = new ORM_HEC_BIL_PotentialCode_Catalog(); catalog4.IsDeleted = false; catalog4.Tenant_RefID = securityTicket.TenantID; catalog4.HEC_BIL_PotentialCode_CatalogID = Guid.NewGuid(); catalog4.GlobalPropertyMatchingID = "mm.docconnect.gpos.catalog.wartezeitenmanagement"; catalog4.Creation_Timestamp = DateTime.Now; catalog4.Save(Connection, Transaction); foreach (var partie in searchContractParties) { var searchContract = ORM_CMN_CTR_Contract.Query.Search(Connection, Transaction, new ORM_CMN_CTR_Contract.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_CTR_ContractID = partie.Contract_RefID, ContractName = "IVI-Vertrag", }).SingleOrDefault(); if (searchContract != null) { contractID = searchContract.CMN_CTR_ContractID; } } var hecContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, new ORM_HEC_CRT_InsuranceToBrokerContract.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Ext_CMN_CTR_Contract_RefID = contractID }).Single(); foreach (var GPOSData in parameter) { var contract2BillCodes = new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode(); contract2BillCodes.IsDeleted = false; contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID = Guid.NewGuid(); contract2BillCodes.Tenant_RefID = securityTicket.TenantID; contract2BillCodes.InsuranceToBrokerContract_RefID = hecContract.HEC_CRT_InsuranceToBrokerContractID; contract2BillCodes.PotentialBillCode_RefID = Guid.NewGuid(); contract2BillCodes.Creation_Timestamp = DateTime.Now; contract2BillCodes.Modification_Timestamp = DateTime.Now; contract2BillCodes.Save(Connection, Transaction); var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); Dict PotentialCodeName = new Dict(ORM_HEC_BIL_PotentialCode.TableName); for (int i = 0; i < DBLanguages.Count; i++) { PotentialCodeName.AddEntry(DBLanguages[i].CMN_LanguageID, GPOSData.GPOSTitle); } Guid billCatalogID = Guid.NewGuid(); switch (GPOSData.GPOSTitle) { case "Operation": billCatalogID = catalog1.HEC_BIL_PotentialCode_CatalogID; break; case "Nachsorge": billCatalogID = catalog2.HEC_BIL_PotentialCode_CatalogID; break; case "Zusatzposition Bevacizumab": billCatalogID = catalog3.HEC_BIL_PotentialCode_CatalogID; break; case "Wartezeitenmanagement": billCatalogID = catalog4.HEC_BIL_PotentialCode_CatalogID; break; } ; var potentialBillCode = new ORM_HEC_BIL_PotentialCode(); potentialBillCode.IsDeleted = false; potentialBillCode.Tenant_RefID = securityTicket.TenantID; potentialBillCode.HEC_BIL_PotentialCodeID = contract2BillCodes.PotentialBillCode_RefID; potentialBillCode.Creation_Timestamp = DateTime.Now; potentialBillCode.Modification_Timestamp = DateTime.Now; potentialBillCode.CodeName = PotentialCodeName; potentialBillCode.BillingCode = GPOSData.BillingCode; potentialBillCode.Price_RefID = Guid.NewGuid(); potentialBillCode.PotentialCode_Catalog_RefID = billCatalogID; potentialBillCode.Save(Connection, Transaction); var hecBillCodes2UniversalProperty = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); hecBillCodes2UniversalProperty.IsDeleted = false; hecBillCodes2UniversalProperty.Tenant_RefID = securityTicket.TenantID; hecBillCodes2UniversalProperty.Creation_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty.Modification_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty.AssignmentID = Guid.NewGuid(); hecBillCodes2UniversalProperty.CoveredPotentialBillCode_RefID = contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; hecBillCodes2UniversalProperty.CoveredPotentialBillCode_UniversalProperty_RefID = Guid.NewGuid(); hecBillCodes2UniversalProperty.Value_String = GPOSData.Case_Type; hecBillCodes2UniversalProperty.Save(Connection, Transaction); var billCodesUniversalProperty = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); billCodesUniversalProperty.IsDeleted = false; billCodesUniversalProperty.Tenant_RefID = securityTicket.TenantID; billCodesUniversalProperty.Creation_Timestamp = DateTime.Now; billCodesUniversalProperty.Modification_Timestamp = DateTime.Now; billCodesUniversalProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = hecBillCodes2UniversalProperty.CoveredPotentialBillCode_RefID; billCodesUniversalProperty.PropertyName = GPOSData.Case_Type_Value; billCodesUniversalProperty.IsValue_Number = true; billCodesUniversalProperty.Save(Connection, Transaction); var hecBillCodes2UniversalProperty2 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); hecBillCodes2UniversalProperty2.IsDeleted = false; hecBillCodes2UniversalProperty2.Tenant_RefID = securityTicket.TenantID; hecBillCodes2UniversalProperty2.Creation_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty2.CoveredPotentialBillCode_RefID = contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; hecBillCodes2UniversalProperty2.CoveredPotentialBillCode_UniversalProperty_RefID = Guid.NewGuid(); hecBillCodes2UniversalProperty2.Value_Number = GPOSData.From_inj_No; hecBillCodes2UniversalProperty2.Save(Connection, Transaction); var billCodesUniversalProperty2 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); billCodesUniversalProperty2.IsDeleted = false; billCodesUniversalProperty2.Tenant_RefID = securityTicket.TenantID; billCodesUniversalProperty2.Creation_Timestamp = DateTime.Now; billCodesUniversalProperty2.Modification_Timestamp = DateTime.Now; billCodesUniversalProperty2.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = hecBillCodes2UniversalProperty2.CoveredPotentialBillCode_UniversalProperty_RefID; billCodesUniversalProperty2.PropertyName = GPOSData.From_inj; billCodesUniversalProperty2.IsValue_Number = true; billCodesUniversalProperty2.Save(Connection, Transaction); var hecBillCodes2UniversalProperty3 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); hecBillCodes2UniversalProperty3.IsDeleted = false; hecBillCodes2UniversalProperty3.Tenant_RefID = securityTicket.TenantID; hecBillCodes2UniversalProperty3.Creation_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty3.CoveredPotentialBillCode_RefID = contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; hecBillCodes2UniversalProperty3.CoveredPotentialBillCode_UniversalProperty_RefID = Guid.NewGuid(); hecBillCodes2UniversalProperty3.Value_Number = GPOSData.To_inj_No; hecBillCodes2UniversalProperty3.Save(Connection, Transaction); var billCodesUniversalProperty3 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); billCodesUniversalProperty3.IsDeleted = false; billCodesUniversalProperty3.Tenant_RefID = securityTicket.TenantID; billCodesUniversalProperty3.Creation_Timestamp = DateTime.Now; billCodesUniversalProperty3.Modification_Timestamp = DateTime.Now; billCodesUniversalProperty3.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = hecBillCodes2UniversalProperty3.CoveredPotentialBillCode_UniversalProperty_RefID; billCodesUniversalProperty3.PropertyName = GPOSData.To_inj; billCodesUniversalProperty3.IsValue_String = true; billCodesUniversalProperty3.Save(Connection, Transaction); var hecBillCodes2UniversalProperty4 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); hecBillCodes2UniversalProperty4.IsDeleted = false; hecBillCodes2UniversalProperty4.Tenant_RefID = securityTicket.TenantID; hecBillCodes2UniversalProperty4.Creation_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty4.CoveredPotentialBillCode_RefID = contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; hecBillCodes2UniversalProperty4.CoveredPotentialBillCode_UniversalProperty_RefID = Guid.NewGuid(); hecBillCodes2UniversalProperty4.Value_Boolean = GPOSData.Waive_with_Order_value; hecBillCodes2UniversalProperty4.Save(Connection, Transaction); var billCodesUniversalProperty4 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); billCodesUniversalProperty4.IsDeleted = false; billCodesUniversalProperty4.Tenant_RefID = securityTicket.TenantID; billCodesUniversalProperty4.Creation_Timestamp = DateTime.Now; billCodesUniversalProperty4.Modification_Timestamp = DateTime.Now; billCodesUniversalProperty4.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = hecBillCodes2UniversalProperty4.CoveredPotentialBillCode_UniversalProperty_RefID; billCodesUniversalProperty4.PropertyName = GPOSData.Waive_with_Order; billCodesUniversalProperty4.IsValue_Boolean = true; billCodesUniversalProperty4.Save(Connection, Transaction); var hecBillCodes2UniversalProperty5 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); hecBillCodes2UniversalProperty5.IsDeleted = false; hecBillCodes2UniversalProperty5.Tenant_RefID = securityTicket.TenantID; hecBillCodes2UniversalProperty5.Creation_Timestamp = DateTime.Now; hecBillCodes2UniversalProperty5.CoveredPotentialBillCode_RefID = contract2BillCodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; hecBillCodes2UniversalProperty5.CoveredPotentialBillCode_UniversalProperty_RefID = Guid.NewGuid(); hecBillCodes2UniversalProperty5.Value_String = GPOSData.Service_fee_in_Eur_Value; hecBillCodes2UniversalProperty5.Save(Connection, Transaction); var billCodesUniversalProperty5 = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); billCodesUniversalProperty5.IsDeleted = false; billCodesUniversalProperty5.Tenant_RefID = securityTicket.TenantID; billCodesUniversalProperty5.Creation_Timestamp = DateTime.Now; billCodesUniversalProperty5.Modification_Timestamp = DateTime.Now; billCodesUniversalProperty5.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = hecBillCodes2UniversalProperty5.CoveredPotentialBillCode_UniversalProperty_RefID; billCodesUniversalProperty5.PropertyName = GPOSData.Service_fee_in_Eur; billCodesUniversalProperty5.IsValue_String = true; billCodesUniversalProperty5.Save(Connection, Transaction); var currencyforTenant = ORM_CMN_Currency.Query.Search(Connection, Transaction, new ORM_CMN_Currency.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).First(); var price = new ORM_CMN_Price(); price.CMN_PriceID = potentialBillCode.Price_RefID; price.IsDeleted = false; price.Tenant_RefID = securityTicket.TenantID; price.Creation_Timestamp = DateTime.Now; price.Save(Connection, Transaction); var priceValue = new ORM_CMN_Price_Value(); priceValue.CMN_Price_ValueID = Guid.NewGuid(); priceValue.IsDeleted = false; priceValue.Tenant_RefID = securityTicket.TenantID; priceValue.Price_RefID = price.CMN_PriceID; priceValue.PriceValue_Amount = GPOSData.Fee_in_EUR; priceValue.PriceValue_Currency_RefID = currencyforTenant.CMN_CurrencyID; priceValue.Save(Connection, Transaction); var hecContract2Diagnosis = ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialDiagnosis.Query.Search(Connection, Transaction, new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialDiagnosis.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, InsuranceToBrokerContract_RefID = hecContract.HEC_CRT_InsuranceToBrokerContractID }).ToList(); List <ORM_HEC_DIA_PotentialDiagnosis> potendialDiagnosisList = new List <ORM_HEC_DIA_PotentialDiagnosis>(); foreach (var ctr2dia in hecContract2Diagnosis) { var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, new ORM_HEC_DIA_PotentialDiagnosis.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_DIA_PotentialDiagnosisID = ctr2dia.PotentialDiagnosis_RefID }).SingleOrDefault(); potendialDiagnosisList.Add(potentialDiagnosis); } foreach (var diagnosispot in potendialDiagnosisList) { foreach (var diagnosisData in GPOSData.DiagnosisForGPOS) { var CatalogCodes = ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query.Search(Connection, Transaction, new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PotentialDiagnosis_RefID = diagnosispot.HEC_DIA_PotentialDiagnosisID }).SingleOrDefault(); if (CatalogCodes.Code != null) { if (CatalogCodes.Code == diagnosisData.DiagnoseCode || diagnosisData.DiagnoseCode == "all") { var BillCode2PotentialDiagnosis = new ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis(); BillCode2PotentialDiagnosis.HEC_BIL_PotentialCode_RefID = potentialBillCode.HEC_BIL_PotentialCodeID; BillCode2PotentialDiagnosis.HEC_DIA_PotentialDiagnosis_RefID = diagnosispot.HEC_DIA_PotentialDiagnosisID; BillCode2PotentialDiagnosis.IsDeleted = false; BillCode2PotentialDiagnosis.Tenant_RefID = securityTicket.TenantID; BillCode2PotentialDiagnosis.Creation_Timestamp = DateTime.Now; BillCode2PotentialDiagnosis.Modification_Timestamp = DateTime.Now; BillCode2PotentialDiagnosis.Save(Connection, Transaction); } } } } var hecContract2Products = ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredHealthcareProduct.Query.Search(Connection, Transaction, new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredHealthcareProduct.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, InsuranceToBrokerContract_RefID = hecContract.HEC_CRT_InsuranceToBrokerContractID }).ToList(); List <ORM_HEC_Product> HecProductList = new List <ORM_HEC_Product>(); foreach (var cont2product in hecContract2Products) { var searchProducts = ORM_HEC_Product.Query.Search(Connection, Transaction, new ORM_HEC_Product.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_ProductID = cont2product.HealthcareProduct_RefID }).SingleOrDefault(); if (searchProducts != null) { HecProductList.Add(searchProducts); } } List <ORM_CMN_PRO_Product> drugList = new List <ORM_CMN_PRO_Product>(); foreach (var hecProd in HecProductList) { var searchProd = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Product.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_PRO_ProductID = hecProd.Ext_PRO_Product_RefID }).SingleOrDefault(); if (searchProd != null) { drugList.Add(searchProd); } } if (GPOSData.DrugsForGPOS != null) { foreach (var drugsData in GPOSData.DrugsForGPOS) { foreach (var drug in HecProductList) { Dict ProductNameDict = new Dict(ORM_CMN_PRO_Product.TableName); for (int i = 0; i < DBLanguages.Count; i++) { ProductNameDict.AddEntry(DBLanguages[i].CMN_LanguageID, drugsData.Drug_name); } var searchProd = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Product.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, CMN_PRO_ProductID = drug.Ext_PRO_Product_RefID }).SingleOrDefault(); if (searchProd.Product_Name.Contents[0].Content == ProductNameDict.Contents[0].Content || drugsData.Drug_name == "all") { var billCode2product = new ORM_HEC_BIL_PotentialCode_2_HealthcareProduct(); billCode2product.IsDeleted = false; billCode2product.Tenant_RefID = securityTicket.TenantID; billCode2product.Creation_Timestamp = DateTime.Now; billCode2product.AssignmentID = Guid.NewGuid(); billCode2product.HEC_BIL_PotentialCode_RefID = potentialBillCode.HEC_BIL_PotentialCodeID; billCode2product.HEC_Product_RefID = drug.HEC_ProductID; billCode2product.Save(Connection, Transaction); } } } } else { Console.WriteLine(GPOSData); } } }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CIPA_1140 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_HEC_ACT_ActionType.Query initial_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); initial_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.performed.action.initial"; initial_action_typeQ.Tenant_RefID = securityTicket.TenantID; initial_action_typeQ.IsDeleted = false; var initial_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, initial_action_typeQ).SingleOrDefault(); var initial_action_type_id = Guid.Empty; if (initial_action_type == null) { Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); initial_action_type = new ORM_HEC_ACT_ActionType(); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "anfänglich" : "initial"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } initial_action_type.ActionType_Name = action_type_name_dict; initial_action_type.Creation_Timestamp = DateTime.Now; initial_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.performed.action.initial"; initial_action_type.Modification_Timestamp = DateTime.Now; initial_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); initial_action_type.Tenant_RefID = securityTicket.TenantID; initial_action_type.Save(Connection, Transaction); initial_action_type_id = initial_action_type.HEC_ACT_ActionTypeID; } else { initial_action_type_id = initial_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PerformedAction initial_performed_action = new ORM_HEC_ACT_PerformedAction(); initial_performed_action.HEC_ACT_PerformedActionID = Guid.NewGuid(); initial_performed_action.Creation_Timestamp = DateTime.Now; initial_performed_action.IfPerfomed_DateOfAction = DateTime.Now; initial_performed_action.IfPerformed_DateOfAction_Day = DateTime.Now.Day; initial_performed_action.IfPerformed_DateOfAction_Month = DateTime.Now.Month; initial_performed_action.IfPerformed_DateOfAction_Year = DateTime.Now.Year; initial_performed_action.Tenant_RefID = securityTicket.TenantID; initial_performed_action.IsPerformed_Internally = true; initial_performed_action.IsPerformed_MedicalPractice_RefID = Parameter.practice_id; initial_performed_action.Patient_RefID = Parameter.patient_id; initial_performed_action.IfPerformedInternaly_ResponsibleBusinessParticipant_RefID = Parameter.created_by_bpt; initial_performed_action.Save(Connection, Transaction); ORM_HEC_CAS_Case_RelevantPerformedAction initial_performed_action_to_case = new ORM_HEC_CAS_Case_RelevantPerformedAction(); initial_performed_action_to_case.Case_RefID = Parameter.case_id; initial_performed_action_to_case.Creation_Timestamp = DateTime.Now; initial_performed_action_to_case.Modification_Timestamp = DateTime.Now; initial_performed_action_to_case.PerformedAction_RefID = initial_performed_action.HEC_ACT_PerformedActionID; initial_performed_action_to_case.Tenant_RefID = securityTicket.TenantID; initial_performed_action_to_case.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_2_ActionType initial_performed_action_2_type = new ORM_HEC_ACT_PerformedAction_2_ActionType(); initial_performed_action_2_type.Tenant_RefID = securityTicket.TenantID; initial_performed_action_2_type.Creation_Timestamp = DateTime.Now; initial_performed_action_2_type.IsDeleted = false; initial_performed_action_2_type.HEC_ACT_ActionType_RefID = initial_action_type_id; initial_performed_action_2_type.HEC_ACT_PerformedAction_RefID = initial_performed_action.HEC_ACT_PerformedActionID; initial_performed_action_2_type.IM_ActionType_Name = "initial"; initial_performed_action_2_type.Modification_Timestamp = DateTime.Now; initial_performed_action_2_type.AssignmentID = Guid.NewGuid(); initial_performed_action_2_type.Save(Connection, Transaction); returnValue.Result = initial_performed_action.HEC_ACT_PerformedActionID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SL_1047 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //get languages for Tenant P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; foreach (var item in Parameter.Localization) { //Delete if (item.IsDeleted) { var localizationQuery = new ORM_HEC_DIA_Diagnosis_Localization.Query(); localizationQuery.IsDeleted = false; localizationQuery.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; localizationQuery.Diagnosis_RefID = Parameter.DiagnoseID; var localization = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, localizationQuery).SingleOrDefault(); if (localization != null) { localization.IsDeleted = true; localization.Save(Connection, Transaction); } } else { var localizationQuery = new ORM_HEC_DIA_Diagnosis_Localization.Query(); localizationQuery.IsDeleted = false; localizationQuery.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; localizationQuery.Diagnosis_RefID = Parameter.DiagnoseID; var localization = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, localizationQuery).SingleOrDefault(); //Edit if (localization != null) { Dict name = new Dict("hec_dia_diagnosis_localizations"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.LocalizationName); } localization.DiagnosisLocalization_Name = name; localization.Save(Connection, Transaction); } else // New { ORM_HEC_DIA_Diagnosis_Localization localizationNew = new ORM_HEC_DIA_Diagnosis_Localization(); localizationNew.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; Dict name = new Dict("hec_dia_diagnosis_localizations"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.LocalizationName); } localizationNew.DiagnosisLocalization_Name = name; localizationNew.Tenant_RefID = securityTicket.TenantID; localizationNew.Creation_Timestamp = DateTime.Now; localizationNew.Diagnosis_RefID = Parameter.DiagnoseID; localizationNew.Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CAPA_1237 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_HEC_ACT_PlannedAction aftercare_planned_action = new ORM_HEC_ACT_PlannedAction(); aftercare_planned_action.Creation_Timestamp = DateTime.Now; aftercare_planned_action.HEC_ACT_PlannedActionID = Guid.NewGuid(); aftercare_planned_action.IsPerformed = false; aftercare_planned_action.MedicalPractice_RefID = Parameter.practice_id; aftercare_planned_action.Modification_Timestamp = DateTime.Now; aftercare_planned_action.Patient_RefID = Parameter.patient_id; aftercare_planned_action.PlannedFor_Date = Parameter.treatment_date; aftercare_planned_action.Tenant_RefID = securityTicket.TenantID; Guid id = Guid.Empty; var aftercare_doctor_account = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDAIDfDID_1549() { DoctorID = Parameter.aftercare_doctor_practice_id }, securityTicket).Result; if (aftercare_doctor_account != null) { id = aftercare_doctor_account.accountID; } else { var aftercare_practice_account = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPAIDfPID_1522() { PracticeID = Parameter.aftercare_doctor_practice_id }, securityTicket).Result; if (aftercare_practice_account != null) { id = aftercare_practice_account.accountID; } } ORM_USR_Account.Query aftercare_accountQ = new ORM_USR_Account.Query(); aftercare_accountQ.USR_AccountID = id; aftercare_accountQ.Tenant_RefID = securityTicket.TenantID; aftercare_accountQ.IsDeleted = false; var aftercare_account = ORM_USR_Account.Query.Search(Connection, Transaction, aftercare_accountQ).SingleOrDefault(); if (aftercare_account != null) { aftercare_planned_action.ToBePerformedBy_BusinessParticipant_RefID = aftercare_account.BusinessParticipant_RefID; } aftercare_planned_action.Save(Connection, Transaction); ORM_HEC_CAS_Case_RelevantPlannedAction aftercare_planned_action_to_case = new ORM_HEC_CAS_Case_RelevantPlannedAction(); aftercare_planned_action_to_case.Case_RefID = Parameter.case_id; aftercare_planned_action_to_case.Creation_Timestamp = DateTime.Now; aftercare_planned_action_to_case.HEC_CAS_Case_RelevantPlannedActionID = Guid.NewGuid(); aftercare_planned_action_to_case.Modification_Timestamp = DateTime.Now; aftercare_planned_action_to_case.PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_to_case.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_to_case.Save(Connection, Transaction); ORM_HEC_ACT_ActionType.Query aftercare_planned_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); aftercare_planned_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_typeQ.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_typeQ.IsDeleted = false; var aftercare_planned_action_type_id = Guid.Empty; var aftercare_planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, aftercare_planned_action_typeQ).SingleOrDefault(); if (aftercare_planned_action_type == null) { aftercare_planned_action_type = new ORM_HEC_ACT_ActionType(); Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "nachsorge" : "aftercare"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } aftercare_planned_action_type.ActionType_Name = action_type_name_dict; aftercare_planned_action_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.aftercare"; aftercare_planned_action_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_type.Save(Connection, Transaction); aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } else { aftercare_planned_action_type_id = aftercare_planned_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PlannedAction_2_ActionType aftercare_planned_action_2_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); aftercare_planned_action_2_type.Tenant_RefID = securityTicket.TenantID; aftercare_planned_action_2_type.Creation_Timestamp = DateTime.Now; aftercare_planned_action_2_type.IsDeleted = false; aftercare_planned_action_2_type.HEC_ACT_ActionType_RefID = aftercare_planned_action_type_id; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_RefID = aftercare_planned_action.HEC_ACT_PlannedActionID; aftercare_planned_action_2_type.Modification_Timestamp = DateTime.Now; aftercare_planned_action_2_type.HEC_ACT_PlannedAction_2_ActionTypeID = Guid.NewGuid(); aftercare_planned_action_2_type.Save(Connection, Transaction); returnValue.Result = aftercare_planned_action.HEC_ACT_PlannedActionID; return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5TI_TI_1134 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); #region Get and update languages var init = ORM_APP_Initialization.Query.Search(Connection, Transaction, new ORM_APP_Initialization.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Application_RefID = Parameter.AppID }).SingleOrDefault(); if (init == null) { init = new ORM_APP_Initialization() { Tenant_RefID = securityTicket.TenantID, Application_RefID = Parameter.AppID, APP_InitializationID = Guid.NewGuid(), Initialization_StartedAtDate = DateTime.Now, Version = "1.0" }; } var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result; #endregion #region EComunactionContactType // Get all communication types from db. //var comunactionContactTypes = Enum.GetValues(typeof(EComunactionContactType)); // Just this communication types can be inserted, if we want all, then use line above List <EComunactionContactType> comunactionContactTypes = new List <EComunactionContactType> { EComunactionContactType.Phone, EComunactionContactType.Email, EComunactionContactType.Fax, EComunactionContactType.Mobile }; foreach (EComunactionContactType type in comunactionContactTypes) { P_L2CN_GCTIDfGPMID_1359 parameter = new P_L2CN_GCTIDfGPMID_1359(); parameter.Type = EnumUtils.GetEnumDescription(type); var contactTypeResult = cls_Get_ContantTypeID_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, parameter, securityTicket).Result; //switch (type) //{ // // Just this communication types can be inserted // case EComunactionContactType.Phone: // { // bool doesStatusExist = ORM_CMN_PER_CommunicationContact_Type.Query.Exists(Connection, Transaction, // new ORM_CMN_PER_CommunicationContact_Type.Query // { // Type = EnumUtils.GetEnumDescription(type), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false // }); // if (!doesStatusExist) // { // var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); // communicationContactType.Type = EnumUtils.GetEnumDescription(type); // communicationContactType.Tenant_RefID = securityTicket.TenantID; // communicationContactType.Save(Connection, Transaction); // } // } // break; // case EComunactionContactType.Email: // { // bool doesStatusExist = ORM_CMN_PER_CommunicationContact_Type.Query.Exists(Connection, Transaction, // new ORM_CMN_PER_CommunicationContact_Type.Query // { // Type = EnumUtils.GetEnumDescription(type), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false // }); // if (!doesStatusExist) // { // var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); // communicationContactType.Type = EnumUtils.GetEnumDescription(type); // communicationContactType.Tenant_RefID = securityTicket.TenantID; // communicationContactType.Save(Connection, Transaction); // } // } // break; // case EComunactionContactType.Fax: // { // bool doesStatusExist = ORM_CMN_PER_CommunicationContact_Type.Query.Exists(Connection, Transaction, // new ORM_CMN_PER_CommunicationContact_Type.Query // { // Type = EnumUtils.GetEnumDescription(type), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false // }); // if (!doesStatusExist) // { // var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); // communicationContactType.Type = EnumUtils.GetEnumDescription(type); // communicationContactType.Tenant_RefID = securityTicket.TenantID; // communicationContactType.Save(Connection, Transaction); // } // } // break; // case EComunactionContactType.Mobile: // { // bool doesStatusExist = ORM_CMN_PER_CommunicationContact_Type.Query.Exists(Connection, Transaction, // new ORM_CMN_PER_CommunicationContact_Type.Query // { // Type = EnumUtils.GetEnumDescription(type), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false // }); // if (!doesStatusExist) // { // var communicationContactType = new ORM_CMN_PER_CommunicationContact_Type(); // communicationContactType.Type = EnumUtils.GetEnumDescription(type); // communicationContactType.Tenant_RefID = securityTicket.TenantID; // communicationContactType.Save(Connection, Transaction); // } // } // break; //} } #endregion #region AvailabilityTypes var query = new ORM_CMN_CAL_AVA_Availability_Type.Query(); query.IsDeleted = false; query.Tenant_RefID = securityTicket.TenantID; var Availability = ORM_CMN_CAL_AVA_Availability_Type.Query.Search(Connection, Transaction, query); if (Availability.Count == 0) { ORM_CMN_CAL_AVA_Availability_Type Availability_Exceptions = new ORM_CMN_CAL_AVA_Availability_Type(); Availability_Exceptions.CMN_CAL_AVA_Availability_TypeID = Guid.NewGuid(); Availability_Exceptions.IsDefaultAvailabilityType = true; Availability_Exceptions.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(AvailabilityType.Exception); Dict name2 = new Dict("CMN_CAL_AVA_Availability_Type"); for (int i = 0; i < DBLanguages.Count(); i++) { name2.AddEntry(DBLanguages[i].CMN_LanguageID, EnumUtils.GetEnumDescription(AvailabilityType.Exception)); } Availability_Exceptions.AvailabilityTypeName = name2; Availability_Exceptions.Tenant_RefID = securityTicket.TenantID; Availability_Exceptions.Creation_Timestamp = DateTime.Now; Availability_Exceptions.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Availability_Type Availability_StandardHour = new ORM_CMN_CAL_AVA_Availability_Type(); Availability_StandardHour.CMN_CAL_AVA_Availability_TypeID = Guid.NewGuid(); Availability_StandardHour.IsDefaultAvailabilityType = true; Availability_StandardHour.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(AvailabilityType.Standard); Dict name = new Dict("CMN_CAL_AVA_Availability_Type"); for (int i = 0; i < DBLanguages.Count(); i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, EnumUtils.GetEnumDescription(AvailabilityType.Standard)); } Availability_StandardHour.AvailabilityTypeName = name; Availability_StandardHour.Tenant_RefID = securityTicket.TenantID; Availability_StandardHour.Creation_Timestamp = DateTime.Now; Availability_StandardHour.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Availability_Type Availability_WebBookingHour = new ORM_CMN_CAL_AVA_Availability_Type(); Availability_WebBookingHour.CMN_CAL_AVA_Availability_TypeID = Guid.NewGuid(); Availability_WebBookingHour.IsDefaultAvailabilityType = true; Availability_WebBookingHour.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(AvailabilityType.WebBooking); Dict name1 = new Dict("CMN_CAL_AVA_Availability_Type"); for (int i = 0; i < DBLanguages.Count(); i++) { name1.AddEntry(DBLanguages[i].CMN_LanguageID, EnumUtils.GetEnumDescription(AvailabilityType.WebBooking)); } Availability_WebBookingHour.AvailabilityTypeName = name1; Availability_WebBookingHour.Tenant_RefID = securityTicket.TenantID; Availability_WebBookingHour.Creation_Timestamp = DateTime.Now; Availability_WebBookingHour.Save(Connection, Transaction); } #endregion #region PatinetParameters var PatientParameter = cls_Get_all_PatientParameters_for_Tenant.Invoke(Connection, Transaction, securityTicket).Result; #endregion init.Initialiaztion_CompletedAtDate = DateTime.Now; init.IsInitializationComplete = true; init.Save(Connection, Transaction); returnValue.Result = true; return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SPEM_1413 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); var medPro_Credentials = cls_Get_TenantMemershipData.Invoke(Connection, Transaction, securityTicket).Result; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; var examination = ORM_HEC_ACT_PerformedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_ACT_PerformedActionID = Parameter.ExaminationID }).Single(); #region Save foreach (var item in Parameter.new_medication) { //check if dosage exists var dosageQuery = new ORM_HEC_Dosage.Query(); dosageQuery.IsDeleted = false; dosageQuery.Tenant_RefID = securityTicket.TenantID; dosageQuery.DosageText = item.dosage_text; var dosage_table = ORM_HEC_Dosage.Query.Search(Connection, Transaction, dosageQuery).SingleOrDefault(); if (dosage_table == null) { dosage_table = new ORM_HEC_Dosage(); dosage_table.HEC_DosageID = Guid.NewGuid(); dosage_table.Tenant_RefID = securityTicket.TenantID; dosage_table.Creation_Timestamp = DateTime.Now; dosage_table.Modification_Timestamp = DateTime.Now; dosage_table.DosageText = item.dosage_text; dosage_table.Save(Connection, Transaction); } ORM_HEC_ACT_PerformedAction_MedicationUpdate medicationUpdate = new ORM_HEC_ACT_PerformedAction_MedicationUpdate(); medicationUpdate.HEC_ACT_PerformedAction_MedicationUpdateID = Guid.NewGuid(); medicationUpdate.Tenant_RefID = securityTicket.TenantID; medicationUpdate.Creation_Timestamp = DateTime.Now; medicationUpdate.Modification_Timestamp = DateTime.Now; medicationUpdate.IsSubstance = !item.is_product; medicationUpdate.IsHealthcareProduct = item.is_product; medicationUpdate.IntendedApplicationDuration_in_days = item.days_valid; medicationUpdate.HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID; medicationUpdate.HEC_Patient_Medication_RefID = Guid.NewGuid(); ORM_HEC_Patient_Medication patient_medications = new ORM_HEC_Patient_Medication(); patient_medications.HEC_Patient_MedicationID = medicationUpdate.HEC_Patient_Medication_RefID; patient_medications.Patient_RefID = Parameter.PatientID; patient_medications.Creation_Timestamp = DateTime.Now; patient_medications.Tenant_RefID = securityTicket.TenantID; patient_medications.Modification_Timestamp = DateTime.Now; patient_medications.R_IsActive = true; patient_medications.R_DateOfAdding = examination.IfPerfomed_DateOfAction; patient_medications.R_IsHealthcareProduct = item.is_product; patient_medications.R_IsSubstance = !item.is_product; patient_medications.R_ActiveUntill = patient_medications.R_DateOfAdding.AddDays(item.days_valid); if (item.is_product)//medication is a product { Guid Hec_ProductID = Guid.Empty; //check if product exists var productQuery = new ORM_CMN_PRO_Product.Query(); productQuery.Tenant_RefID = securityTicket.TenantID; productQuery.IsDeleted = false; productQuery.ProductITL = item.product_itl; var product = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, productQuery).SingleOrDefault(); //if product does not exist create it if (product == null) { ORM_CMN_PRO_Product cmn_pro_product = new ORM_CMN_PRO_Product(); cmn_pro_product.CMN_PRO_ProductID = Guid.NewGuid(); cmn_pro_product.Tenant_RefID = securityTicket.TenantID; cmn_pro_product.Creation_Timestamp = DateTime.Now; cmn_pro_product.Modification_Timestamp = DateTime.Now; Dict product_name = new Dict("cmn_pro_products"); for (int i = 0; i < DBLanguages.Length; i++) { product_name.AddEntry(DBLanguages[i].CMN_LanguageID, item.product_name); } cmn_pro_product.Product_Name = product_name; cmn_pro_product.ProductITL = item.product_itl; cmn_pro_product.ProducingBusinessParticipant_RefID = Guid.NewGuid(); //manufacturer cmn_pro_product.PackageInfo_RefID = Guid.NewGuid(); // package info cmn_pro_product.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant manufacturer = new ORM_CMN_BPT_BusinessParticipant(); manufacturer.CMN_BPT_BusinessParticipantID = cmn_pro_product.ProducingBusinessParticipant_RefID; manufacturer.DisplayName = item.product_manufacturer; manufacturer.IsCompany = true; manufacturer.IsNaturalPerson = false; manufacturer.Tenant_RefID = securityTicket.TenantID; manufacturer.Creation_Timestamp = DateTime.Now; manufacturer.Modification_Timestamp = DateTime.Now; manufacturer.Save(Connection, Transaction); ORM_CMN_PRO_PAC_PackageInfo package_info = new ORM_CMN_PRO_PAC_PackageInfo(); package_info.CMN_PRO_PAC_PackageInfoID = cmn_pro_product.PackageInfo_RefID; package_info.Tenant_RefID = securityTicket.TenantID; package_info.Creation_Timestamp = DateTime.Now; package_info.Modification_Timestamp = DateTime.Now; string amount = String.Empty; string unit = String.Empty; foreach (char c in item.product_strength) { // Do not use IsDigit as it will include more than the characters 0 through to 9 if (c >= '0' && c <= '9') { amount += c; } else { unit += c; } } package_info.PackageContent_Amount = Int32.Parse(amount); package_info.PackageContent_DisplayLabel = amount; var unitQuery = new ORM_CMN_Unit.Query(); unitQuery.IsDeleted = false; unitQuery.Tenant_RefID = securityTicket.TenantID; unitQuery.ISOCode = unit; var cmn_unit = ORM_CMN_Unit.Query.Search(Connection, Transaction, unitQuery).FirstOrDefault(); if (cmn_unit == null) { cmn_unit = new ORM_CMN_Unit(); cmn_unit.CMN_UnitID = Guid.NewGuid(); cmn_unit.Tenant_RefID = securityTicket.TenantID; cmn_unit.Creation_Timestamp = DateTime.Now; cmn_unit.Modification_Timestamp = DateTime.Now; cmn_unit.ISOCode = unit; cmn_unit.Save(Connection, Transaction); } package_info.PackageContent_MeasuredInUnit_RefID = cmn_unit.CMN_UnitID; package_info.Save(Connection, Transaction); //hec_products ORM_HEC_Product hec_product = new ORM_HEC_Product(); hec_product.HEC_ProductID = Guid.NewGuid(); hec_product.Ext_PRO_Product_RefID = cmn_pro_product.CMN_PRO_ProductID; hec_product.Tenant_RefID = securityTicket.TenantID; hec_product.Creation_Timestamp = DateTime.Now; hec_product.Modification_Timestamp = DateTime.Now; Hec_ProductID = hec_product.HEC_ProductID; var dosage_formQuery = new ORM_HEC_Product_DosageForm.Query(); dosage_formQuery.Tenant_RefID = securityTicket.TenantID; dosage_formQuery.IsDeleted = false; dosage_formQuery.GlobalPropertyMatchingID = item.product_form; var dosage_form = ORM_HEC_Product_DosageForm.Query.Search(Connection, Transaction, dosage_formQuery).SingleOrDefault(); if (dosage_form == null) { dosage_form = new ORM_HEC_Product_DosageForm(); dosage_form.HEC_Product_DosageFormID = Guid.NewGuid(); dosage_form.GlobalPropertyMatchingID = item.product_form; dosage_form.Tenant_RefID = securityTicket.TenantID; dosage_form.Creation_Timestamp = DateTime.Now; dosage_form.Modification_Timestamp = DateTime.Now; Dict form_name = new Dict("hec_product_dosageforms"); for (int i = 0; i < DBLanguages.Length; i++) { form_name.AddEntry(DBLanguages[i].CMN_LanguageID, item.product_form); } dosage_form.DosageForm_Name = form_name; dosage_form.Save(Connection, Transaction); } hec_product.ProductDosageForm_RefID = dosage_form.HEC_Product_DosageFormID; //dosage form hec_product.Save(Connection, Transaction); //product component ORM_HEC_PRO_Product_Component product_component = new ORM_HEC_PRO_Product_Component(); product_component.HEC_PRO_Product_ComponentID = Guid.NewGuid(); product_component.HEC_PRO_Component_RefID = Guid.NewGuid();//pro_component product_component.HEC_PRO_Product_RefID = hec_product.HEC_ProductID; product_component.Tenant_RefID = securityTicket.TenantID; product_component.Creation_Timestamp = DateTime.Now; product_component.Modification_Timestamp = DateTime.Now; product_component.Save(Connection, Transaction); ORM_HEC_PRO_Component pro_component = new ORM_HEC_PRO_Component(); pro_component.HEC_PRO_ComponentID = product_component.HEC_PRO_Component_RefID; pro_component.Tenant_RefID = securityTicket.TenantID; pro_component.Creation_Timestamp = DateTime.Now; pro_component.Modification_Timestamp = DateTime.Now; pro_component.Save(Connection, Transaction); ORM_HEC_PRO_Component_SubstanceIngredient component_SubstanceIngredient = new ORM_HEC_PRO_Component_SubstanceIngredient(); component_SubstanceIngredient.HEC_PRO_Component_SubstanceIngredientID = Guid.NewGuid(); component_SubstanceIngredient.Component_RefID = pro_component.HEC_PRO_ComponentID; component_SubstanceIngredient.Tenant_RefID = securityTicket.TenantID; component_SubstanceIngredient.Creation_Timestamp = DateTime.Now; component_SubstanceIngredient.Modification_Timestamp = DateTime.Now; var substanceQuery = new ORM_HEC_SUB_Substance.Query(); substanceQuery.IsDeleted = false; substanceQuery.Tenant_RefID = securityTicket.TenantID; substanceQuery.HealthcareSubstanceITL = item.substance_itl; var substance = ORM_HEC_SUB_Substance.Query.Search(Connection, Transaction, substanceQuery).SingleOrDefault(); if (substance == null) { substance = new ORM_HEC_SUB_Substance(); substance.HealthcareSubstanceITL = item.substance_itl; substance.HEC_SUB_SubstanceID = Guid.NewGuid(); substance.GlobalPropertyMatchingID = item.substance_name; substance.Tenant_RefID = securityTicket.TenantID; substance.Creation_Timestamp = DateTime.Now; substance.Modification_Timestamp = DateTime.Now; substance.Save(Connection, Transaction); ORM_HEC_SUB_Substance_Name substance_name = new ORM_HEC_SUB_Substance_Name(); substance_name.HEC_SUB_Substance_NameID = Guid.NewGuid(); substance_name.HEC_SUB_Substance_RefID = substance.HEC_SUB_SubstanceID; Dict substance_name_ = new Dict("hec_sub_substance_names"); for (int i = 0; i < DBLanguages.Length; i++) { substance_name_.AddEntry(DBLanguages[i].CMN_LanguageID, item.substance_name); } substance_name.SubstanceName_Label = substance_name_; substance_name.Tenant_RefID = securityTicket.TenantID; substance_name.Creation_Timestamp = DateTime.Now; substance_name.Modification_Timestamp = DateTime.Now; substance_name.Save(Connection, Transaction); } component_SubstanceIngredient.Substance_RefID = substance.HEC_SUB_SubstanceID; component_SubstanceIngredient.Save(Connection, Transaction); } else { var hec_productQuery = new ORM_HEC_Product.Query(); hec_productQuery.IsDeleted = false; hec_productQuery.Tenant_RefID = securityTicket.TenantID; hec_productQuery.Ext_PRO_Product_RefID = product.CMN_PRO_ProductID; var hec_product = ORM_HEC_Product.Query.Search(Connection, Transaction, hec_productQuery).Single(); Hec_ProductID = hec_product.HEC_ProductID; } medicationUpdate.HEC_Product_RefID = Hec_ProductID; patient_medications.R_HEC_Product_RefID = Hec_ProductID; patient_medications.R_DosageText = item.dosage_text; medicationUpdate.DosageText = item.dosage_text; } else// medication is a substance { medicationUpdate.IfSubstance_Strength = item.substance_strength; patient_medications.R_IfSubstance_Strength = item.substance_strength; medicationUpdate.IfSubstance_Unit_RefID = item.substance_unit; patient_medications.R_IfSubstance_Unit_RefID = item.substance_unit; patient_medications.R_DosageText = item.dosage_text; medicationUpdate.DosageText = item.dosage_text; var substanceQuery = new ORM_HEC_SUB_Substance.Query(); substanceQuery.IsDeleted = false; substanceQuery.Tenant_RefID = securityTicket.TenantID; substanceQuery.HealthcareSubstanceITL = item.substance_itl; var substance = ORM_HEC_SUB_Substance.Query.Search(Connection, Transaction, substanceQuery).SingleOrDefault(); if (substance == null) { substance = new ORM_HEC_SUB_Substance(); substance.HealthcareSubstanceITL = item.substance_itl; substance.HEC_SUB_SubstanceID = Guid.NewGuid(); substance.GlobalPropertyMatchingID = item.substance_name; substance.Tenant_RefID = securityTicket.TenantID; substance.Creation_Timestamp = DateTime.Now; substance.Modification_Timestamp = DateTime.Now; substance.Save(Connection, Transaction); ORM_HEC_SUB_Substance_Name substance_name = new ORM_HEC_SUB_Substance_Name(); substance_name.HEC_SUB_Substance_NameID = Guid.NewGuid(); substance_name.HEC_SUB_Substance_RefID = substance.HEC_SUB_SubstanceID; Dict substance_name_ = new Dict("hec_sub_substance_names"); for (int i = 0; i < DBLanguages.Length; i++) { substance_name_.AddEntry(DBLanguages[i].CMN_LanguageID, item.substance_name); } substance_name.SubstanceName_Label = substance_name_; substance_name.Tenant_RefID = securityTicket.TenantID; substance_name.Creation_Timestamp = DateTime.Now; substance_name.Modification_Timestamp = DateTime.Now; substance_name.Save(Connection, Transaction); } medicationUpdate.IfSubstance_Substance_RefiD = substance.HEC_SUB_SubstanceID; patient_medications.R_IfSubstance_Substance_RefiD = substance.HEC_SUB_SubstanceID; } patient_medications.Save(Connection, Transaction); medicationUpdate.Save(Connection, Transaction); returnValue.Result = true; } #endregion #region Delete foreach (var item in Parameter.deleted_medications) { var medicationUpdateQuery = new ORM_HEC_ACT_PerformedAction_MedicationUpdate.Query(); medicationUpdateQuery.IsDeleted = false; medicationUpdateQuery.IsMedicationDeactivated = false; medicationUpdateQuery.Tenant_RefID = securityTicket.TenantID; medicationUpdateQuery.HEC_ACT_PerformedAction_MedicationUpdateID = item.performedAction_medicationUpdate_id; var medicationUpdate = ORM_HEC_ACT_PerformedAction_MedicationUpdate.Query.Search(Connection, Transaction, medicationUpdateQuery).Single(); medicationUpdate.IsMedicationDeactivated = true; medicationUpdate.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SS_1120 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here returnValue.Result = Guid.Empty; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; //var serializer = new JsonNetSerializer(); //var connection = new ElasticConnection((String)HttpContext.GetGlobalResourceObject("Global", "ElasticConnection"), 9200); #region Save if (Parameter.Substance_ID == Guid.Empty) { ORM_HEC_SUB_Substance newSubstance = new ORM_HEC_SUB_Substance(); newSubstance.HEC_SUB_SubstanceID = Guid.NewGuid(); newSubstance.GlobalPropertyMatchingID = Parameter.Substance_Name; newSubstance.Tenant_RefID = securityTicket.TenantID; newSubstance.Save(Connection, Transaction); ORM_HEC_SUB_Substance_Name newSubstanceName = new ORM_HEC_SUB_Substance_Name(); newSubstanceName.HEC_SUB_Substance_NameID = Guid.NewGuid(); newSubstanceName.HEC_SUB_Substance_RefID = newSubstance.HEC_SUB_SubstanceID; Dict name = new Dict("hec_sub_substance_name"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Substance_Name); } Dict nameOrigin = new Dict("hec_sub_substance_name"); for (int i = 0; i < DBLanguages.Length; i++) { nameOrigin.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Substance_Name); } newSubstanceName.SubstanceName_Label = name; newSubstanceName.SubstanceName_Origin = nameOrigin; newSubstanceName.Tenant_RefID = securityTicket.TenantID; newSubstanceName.Save(Connection, Transaction); //#region Upload To Elastic //bool indexExists = true; //#region set Mapping //string jsonMapping = new MapBuilder<Models.Substance>() // .RootObject("substance", ro => ro // .Properties(pr => pr // .MultiField("name", mfp => mfp.Fields(f => f // .String("name", sp => sp.IndexAnalyzer("autocomplete").SearchAnalyzer(DefaultAnalyzers.standard)) // .String("lower_case_sort", sp => sp.Analyzer("caseinsensitive")) // ) // ) // )).BuildBeautified(); //#endregion //try //{ // connection.Head(new IndexExistsCommand(securityTicket.TenantID.ToString())); //} //catch (OperationException ex) //{ // if (ex.HttpStatusCode == 404) // indexExists = false; //} //if (!indexExists) //{ // #region set index settings // string settings = new IndexSettingsBuilder() // .Analysis(anl => anl // .Filter(fil => fil // .EdgeNGram("autocomplete_filter", gr => gr.MinGram(1).MaxGram(20))) // .Analyzer(a => a // .Custom("caseinsensitive", custom => custom // .Tokenizer(DefaultTokenizers.keyword) // .Filter("lowercase") // ) // .Custom("autocomplete", custom => custom // .Tokenizer(DefaultTokenizers.standard) // .Filter("lowercase", "autocomplete_filter") // ) // ) // ) // .BuildBeautified(); // #endregion // connection.Put(securityTicket.TenantID.ToString(), settings); //} //#region check if type exists //bool typeExists = true; //try //{ // connection.Head(new IndexExistsCommand(securityTicket.TenantID.ToString() + "/substance")); //} //catch (OperationException ex) //{ // if (ex.HttpStatusCode == 404) // typeExists = false; //} //#endregion //if (!typeExists) // connection.Put(new PutMappingCommand(securityTicket.TenantID.ToString(), "substance"), jsonMapping); //string bulkCommand = new BulkCommand(index: securityTicket.TenantID.ToString(), type: "substance").Refresh(); //List<Models.Substance> substanceList = new List<Models.Substance>(); //Models.Substance substance = new Models.Substance(); //substance.id = newSubstance.HEC_SUB_SubstanceID.ToString(); //substance.name = Parameter.Substance_Name; //substanceList.Add(substance); //string bulkJson = new BulkBuilder(serializer) // .BuildCollection(substanceList, (builder, pro) => builder.Index(data: pro, id: pro.id) // ); //connection.Post(bulkCommand, bulkJson); //#endregion returnValue.Result = newSubstance.HEC_SUB_SubstanceID; } #endregion else { var substanceQuery = new ORM_HEC_SUB_Substance.Query(); substanceQuery.IsDeleted = false; substanceQuery.HEC_SUB_SubstanceID = Parameter.Substance_ID; var substance = ORM_HEC_SUB_Substance.Query.Search(Connection, Transaction, substanceQuery).Single(); var substanceNameQuery = new ORM_HEC_SUB_Substance_Name.Query(); substanceNameQuery.IsDeleted = false; substanceNameQuery.HEC_SUB_Substance_RefID = Parameter.Substance_ID; var substanceName = ORM_HEC_SUB_Substance_Name.Query.Search(Connection, Transaction, substanceNameQuery).Single(); #region Delete if (Parameter.IsDeleted) { substance.IsDeleted = true; substance.Save(Connection, Transaction); substanceName.IsDeleted = true; substanceName.Save(Connection, Transaction); //// delete on Elastic //connection.Delete(securityTicket.TenantID.ToString() + "/substance/" + Parameter.Substance_ID.ToString()); } #endregion #region Edit else { Dict name = new Dict("hec_sub_substance_name"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Substance_Name); } Dict nameOrigin = new Dict("hec_sub_substance_name"); for (int i = 0; i < DBLanguages.Length; i++) { nameOrigin.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Substance_Name); } substanceName.SubstanceName_Label = name; substanceName.SubstanceName_Origin = nameOrigin; substanceName.Save(Connection, Transaction); //string command = Commands.Index(index: securityTicket.TenantID.ToString(), type: "substance", id: Parameter.Substance_ID.ToString()).Refresh(); //Models.Substance substanceEdit = new Models.Substance(); //substanceEdit.id = Parameter.Substance_ID.ToString(); //substanceEdit.name = Parameter.Substance_Name; //string jsonData = serializer.ToJson(substanceEdit); //string response = connection.Put(command, jsonData); } returnValue.Result = substance.HEC_SUB_SubstanceID; #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DI_SD_1633 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); returnValue.Result = Guid.Empty; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; #region Save if (Parameter.DiagnoseID == Guid.Empty) { var potentialDiagnosis = new ORM_HEC_DIA_PotentialDiagnosis(); potentialDiagnosis.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); potentialDiagnosis.ICD10_Code = Parameter.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Name); } potentialDiagnosis.PotentialDiagnosis_Name = name; Dict description = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { description.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Description); } potentialDiagnosis.PotentialDiagnosis_Description = description; potentialDiagnosis.Tenant_RefID = securityTicket.TenantID; potentialDiagnosis.Creation_Timestamp = DateTime.Now; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); ORM_HEC_DIA_PotentialDiagnosis_CatalogCode catalogCode = new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode(); catalogCode.HEC_DIA_PotentialDiagnosis_CatalogCodeID = Guid.NewGuid(); catalogCode.Code = Parameter.DiagnoseICD10; catalogCode.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; catalogCode.PotentialDiagnosis_Catalog_RefID = Parameter.PotentialDiagnosis_CatalogID; catalogCode.Tenant_RefID = securityTicket.TenantID; catalogCode.Save(Connection, Transaction); returnValue.Result = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; } #endregion else { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.HEC_DIA_PotentialDiagnosisID = Parameter.DiagnoseID; var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).Single(); #region Delete if (Parameter.IsDeleted) { ORM_HEC_DIA_PotentialDiagnosis_CatalogCode catalogCode = ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query.Search(Connection, Transaction, new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query { PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); catalogCode.IsDeleted = false; catalogCode.Save(Connection, Transaction); potentialDiagnosis.IsDeleted = true; potentialDiagnosis.Save(Connection, Transaction); } #endregion #region Edit else { potentialDiagnosis.ICD10_Code = Parameter.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Name); } potentialDiagnosis.PotentialDiagnosis_Name = name; Dict description = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { description.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Description); } potentialDiagnosis.PotentialDiagnosis_Description = description; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); } returnValue.Result = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DI_SRMP_1425 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 DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; #region Save if (Parameter.HEC_MedicalPractiseID == Guid.Empty) { ORM_HEC_MedicalPractis medicalPractice = new ORM_HEC_MedicalPractis(); medicalPractice.HEC_MedicalPractiseID = Guid.NewGuid(); medicalPractice.IsHospital = Parameter.IsHospital; medicalPractice.Tenant_RefID = securityTicket.TenantID; medicalPractice.IsDeleted = false; medicalPractice.Save(Connection, Transaction); //*******************Save Medical Practice Type******************* if (Parameter.MedicalPracticeType != null && Parameter.MedicalPracticeType.Count() > 0) { foreach (var medicalPracticeTypeParam in Parameter.MedicalPracticeType) { if (!medicalPracticeTypeParam.IsDeleted) { ORM_HEC_MedicalPractice_2_PracticeType medicalPracticeType = new ORM_HEC_MedicalPractice_2_PracticeType(); medicalPracticeType.AssignmentID = Guid.NewGuid(); medicalPracticeType.HEC_MedicalPractice_Type_RefID = medicalPracticeTypeParam.HEC_MedicalPractice_TypeID; medicalPracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPracticeType.Tenant_RefID = securityTicket.TenantID; medicalPracticeType.IsDeleted = false; medicalPracticeType.Save(Connection, Transaction); } } } //*******************Save Medical Practice Service******************* //on front we must find if medical practice already exist for given service name if (Parameter.MedicalService != null && Parameter.MedicalService.Count() > 0) { //ORM_HEC_MedicalService medicalService = ORM_HEC_MedicalService.Query.Search(Connection, Transaction, new ORM_HEC_MedicalService.Query //{ // HEC_MedicalServiceID = Parameter.MedicalService.HEC_MedicalServiceID, // IsDeleted = false, // Tenant_RefID = securityTicket.TenantID //}).SingleOrDefault(); foreach (var medicalServiceParam in Parameter.MedicalService) { ORM_HEC_MedicalService medicalService = new ORM_HEC_MedicalService(); if (medicalServiceParam.NewMedicalService) { medicalService.HEC_MedicalServiceID = Guid.NewGuid(); medicalService.ServiceName = medicalServiceParam.ServiceName; medicalService.Tenant_RefID = securityTicket.TenantID; medicalService.IsDeleted = false; medicalService.Save(Connection, Transaction); } ORM_HEC_MedicalPractice_OfferedService medicalPracticeOfferedService = new ORM_HEC_MedicalPractice_OfferedService(); if (!medicalServiceParam.NewMedicalService) { medicalPracticeOfferedService.MedicalService_RefID = medicalServiceParam.HEC_MedicalServiceID; } else { medicalPracticeOfferedService.MedicalService_RefID = medicalService.HEC_MedicalServiceID; } medicalPracticeOfferedService.MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPracticeOfferedService.IsDeleted = false; medicalPracticeOfferedService.Tenant_RefID = securityTicket.TenantID; medicalPracticeOfferedService.Save(Connection, Transaction); } } //*******************Save Contact Person************************ ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = Guid.NewGuid(); personInfo.Title = Parameter.ContactPersonTitle; personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.IsDeleted = false; personInfo.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant businessParticpant = new ORM_CMN_BPT_BusinessParticipant(); businessParticpant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); businessParticpant.IsNaturalPerson = true; businessParticpant.DisplayName = Parameter.ContactPersonTitle + " " + Parameter.ContactPersonFirstName + " " + Parameter.ContactPersonLastName; businessParticpant.Tenant_RefID = securityTicket.TenantID; businessParticpant.IsDeleted = false; businessParticpant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; businessParticpant.Save(Connection, Transaction); medicalPractice.ContactPerson_RefID = businessParticpant.CMN_BPT_BusinessParticipantID; //*******************Customer OrganizationalUnit************************ ORM_CMN_BPT_CTM_OrganizationalUnit organizationalUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit(); organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID = Guid.NewGuid(); Dict medicationPracticeName = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { medicationPracticeName.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.MedicalPractiseName); } organizationalUnit.OrganizationalUnit_Name = medicationPracticeName; organizationalUnit.IsDeleted = false; organizationalUnit.Tenant_RefID = securityTicket.TenantID; organizationalUnit.Default_PhoneNumber = Parameter.Contact_Telephone; organizationalUnit.IsMedicalPractice = true; organizationalUnit.IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; organizationalUnit.Save(Connection, Transaction); //*******************AppointmentType************************ //if (Parameter.AppoitmentType != null && Parameter.AppoitmentType.Count() > 0) //{ // foreach (var item in Parameter.AppoitmentType) // { // ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability customerOrgUnitAvailability = new ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability(); // customerOrgUnitAvailability.PPS_TSK_Task_Template_CustomerOrgUnitAvailabilityID = Guid.NewGuid(); // customerOrgUnitAvailability.CMN_BPT_CTM_OrganizationalUnit_RefID = organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID; // customerOrgUnitAvailability.PPS_TSK_Task_Template_RefID = item.PPS_TSK_Task_Template_RefID; // customerOrgUnitAvailability.Tenant_RefID = securityTicket.TenantID; // customerOrgUnitAvailability.Save(Connection, Transaction); // } //} //*******************Save Address************************ ORM_CMN_UniversalContactDetail contactDetail = new ORM_CMN_UniversalContactDetail(); contactDetail.CMN_UniversalContactDetailID = Guid.NewGuid(); contactDetail.IsCompany = true; contactDetail.Street_Name = Parameter.Street_Name; contactDetail.Street_Number = Parameter.Street_Number; contactDetail.Town = Parameter.Town; contactDetail.Contact_Website_URL = Parameter.Contact_Website_URL; contactDetail.Contact_Telephone = Parameter.Contact_Telephone; contactDetail.IsDeleted = false; contactDetail.Tenant_RefID = securityTicket.TenantID; contactDetail.Save(Connection, Transaction); ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.CMN_COM_CompanyInfoID = Guid.NewGuid(); companyInfo.Contact_UCD_RefID = contactDetail.CMN_UniversalContactDetailID; companyInfo.IsDeleted = false; companyInfo.Tenant_RefID = securityTicket.TenantID; companyInfo.Save(Connection, Transaction); medicalPractice.Ext_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID; medicalPractice.Save(Connection, Transaction); //*******************Save Address************************ //ORM_CMN_UniversalContactDetail contactDetail = new ORM_CMN_UniversalContactDetail(); //contactDetail.CMN_UniversalContactDetailID = Guid.NewGuid(); //contactDetail.IsCompany = true; //contactDetail.Street_Name = Parameter.Street_Name; //contactDetail.Street_Number = Parameter.Street_Number; //contactDetail.Town = Parameter.Town; //contactDetail.Contact_Website_URL = Parameter.Contact_Website_URL; //contactDetail.Contact_Telephone = Parameter.Contact_Telephone; //contactDetail.IsDeleted = false; //contactDetail.Tenant_RefID = securityTicket.TenantID; //contactDetail.Save(Connection, Transaction); //ORM_CMN_BPT_CTM_OrganizationalUnit_Address organizationalUnitAddress = new ORM_CMN_BPT_CTM_OrganizationalUnit_Address(); //organizationalUnitAddress.UniversalContactDetail_Address_RefID = contactDetail.CMN_UniversalContactDetailID; //organizationalUnitAddress.OrganizationalUnit_RefID = organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID; //organizationalUnitAddress.IsDeleted = false; //organizationalUnitAddress.Tenant_RefID = securityTicket.TenantID; //organizationalUnitAddress.Save(Connection, Transaction); returnValue.Result = medicalPractice.HEC_MedicalPractiseID; } #endregion //=====================Edit or Delete===================== else { ORM_HEC_MedicalPractis medicalPractice = ORM_HEC_MedicalPractis.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractis.Query { HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_BPT_CTM_OrganizationalUnit organizationalUnit = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query { IfMedicalPractise_HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); #region Edit if (Parameter.IsDeleted == false) { //*******************Edit Medical Practice Service******************* if (Parameter.MedicalService != null && Parameter.MedicalService.Count() > 0) { foreach (var medicalServiceParam in Parameter.MedicalService) { ORM_HEC_MedicalPractice_OfferedService medicalPracticeOfferedService = ORM_HEC_MedicalPractice_OfferedService.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_OfferedService.Query { HEC_MedicalPractice_OfferedServiceID = medicalServiceParam.HEC_MedicalPractice_OfferedServiceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); ORM_HEC_MedicalService medicalService = ORM_HEC_MedicalService.Query.Search(Connection, Transaction, new ORM_HEC_MedicalService.Query { HEC_MedicalServiceID = medicalServiceParam.HEC_MedicalServiceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (medicalServiceParam.NewMedicalService && !medicalServiceParam.IsDeleted) { medicalService = new ORM_HEC_MedicalService(); medicalService.HEC_MedicalServiceID = Guid.NewGuid(); medicalService.ServiceName = medicalServiceParam.ServiceName; medicalService.Tenant_RefID = securityTicket.TenantID; medicalService.IsDeleted = false; medicalService.Save(Connection, Transaction); } if (medicalPracticeOfferedService == null && !medicalServiceParam.IsDeleted) { medicalPracticeOfferedService = new ORM_HEC_MedicalPractice_OfferedService(); if (!medicalServiceParam.NewMedicalService) { medicalPracticeOfferedService.MedicalService_RefID = medicalServiceParam.HEC_MedicalServiceID; } else { medicalPracticeOfferedService.MedicalService_RefID = medicalService.HEC_MedicalServiceID; } medicalPracticeOfferedService.MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPracticeOfferedService.IsDeleted = false; medicalPracticeOfferedService.Tenant_RefID = securityTicket.TenantID; medicalPracticeOfferedService.Save(Connection, Transaction); } else if (medicalPracticeOfferedService != null && !medicalServiceParam.IsDeleted) { medicalPracticeOfferedService.MedicalService_RefID = medicalService.HEC_MedicalServiceID; medicalPracticeOfferedService.Save(Connection, Transaction); } else if (medicalPracticeOfferedService != null && medicalServiceParam.IsDeleted) { medicalPracticeOfferedService.IsDeleted = true; medicalPracticeOfferedService.Save(Connection, Transaction); } } } //*******************Edit Customer OrganizationalUnit************************ Dict medicationPracticeName = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { medicationPracticeName.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.MedicalPractiseName); } organizationalUnit.OrganizationalUnit_Name = medicationPracticeName; organizationalUnit.Default_PhoneNumber = Parameter.Contact_Telephone; organizationalUnit.Save(Connection, Transaction); //*******************Edit Contact Person************************ ORM_CMN_BPT_BusinessParticipant businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query { CMN_BPT_BusinessParticipantID = medicalPractice.ContactPerson_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); businessParticipant.DisplayName = Parameter.ContactPersonTitle + " " + Parameter.ContactPersonFirstName + " " + Parameter.ContactPersonLastName; businessParticipant.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query { CMN_PER_PersonInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); personInfo.Title = Parameter.ContactPersonTitle; personInfo.FirstName = Parameter.ContactPersonFirstName; personInfo.LastName = Parameter.ContactPersonLastName; personInfo.Save(Connection, Transaction); //*******************Edit Medical Practice Type******************* foreach (var medicalPracticeTypeParam in Parameter.MedicalPracticeType) { ORM_HEC_MedicalPractice_2_PracticeType existingPracticeType = ORM_HEC_MedicalPractice_2_PracticeType.Query.Search(Connection, Transaction, new ORM_HEC_MedicalPractice_2_PracticeType.Query { HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID, HEC_MedicalPractice_Type_RefID = medicalPracticeTypeParam.HEC_MedicalPractice_TypeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (existingPracticeType == null && !medicalPracticeTypeParam.IsDeleted) { ORM_HEC_MedicalPractice_2_PracticeType medicalPracticeType = new ORM_HEC_MedicalPractice_2_PracticeType(); medicalPracticeType.AssignmentID = Guid.NewGuid(); medicalPracticeType.HEC_MedicalPractice_Type_RefID = medicalPracticeTypeParam.HEC_MedicalPractice_TypeID; medicalPracticeType.HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID; medicalPracticeType.Tenant_RefID = securityTicket.TenantID; medicalPracticeType.IsDeleted = false; medicalPracticeType.Save(Connection, Transaction); } else if (existingPracticeType != null && !medicalPracticeTypeParam.IsDeleted) { existingPracticeType.HEC_MedicalPractice_Type_RefID = medicalPracticeTypeParam.HEC_MedicalPractice_TypeID; existingPracticeType.Save(Connection, Transaction); } else if (existingPracticeType != null && medicalPracticeTypeParam.IsDeleted) { existingPracticeType.IsDeleted = true; existingPracticeType.Save(Connection, Transaction); } } //*******************Edit AppointmentType******************* //if (Parameter.AppoitmentType != null && Parameter.AppoitmentType.Count() > 0) //{ // foreach (var appointmentTypeParam in Parameter.AppoitmentType) // { // ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability existingAppointmentType = ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability.Query // { // CMN_BPT_CTM_OrganizationalUnit_RefID = organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID, // PPS_TSK_Task_Template_RefID = appointmentTypeParam.PPS_TSK_Task_Template_RefID, // IsDeleted = false, // Tenant_RefID = securityTicket.TenantID // }).SingleOrDefault(); // if (existingAppointmentType == null & !appointmentTypeParam.IsDeleted) // { // ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability customerOrgUnitAvailability = new ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability(); // customerOrgUnitAvailability.PPS_TSK_Task_Template_CustomerOrgUnitAvailabilityID = Guid.NewGuid(); // customerOrgUnitAvailability.CMN_BPT_CTM_OrganizationalUnit_RefID = organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID; // customerOrgUnitAvailability.PPS_TSK_Task_Template_RefID = appointmentTypeParam.PPS_TSK_Task_Template_RefID; // customerOrgUnitAvailability.Tenant_RefID = securityTicket.TenantID; // customerOrgUnitAvailability.Save(Connection, Transaction); // } // else if (existingAppointmentType != null & !appointmentTypeParam.IsDeleted) // { // existingAppointmentType.PPS_TSK_Task_Template_RefID = appointmentTypeParam.PPS_TSK_Task_Template_RefID; // existingAppointmentType.Save(Connection, Transaction); // } // else if (existingAppointmentType != null & !appointmentTypeParam.IsDeleted) // { // existingAppointmentType.IsDeleted = true; // existingAppointmentType.Save(Connection, Transaction); // } // } //} //*******************Edit Address and name************************ ORM_CMN_COM_CompanyInfo companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, new ORM_CMN_COM_CompanyInfo.Query { CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_UniversalContactDetail contactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query { CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); contactDetail.Street_Name = Parameter.Street_Name; contactDetail.Street_Number = Parameter.Street_Number; contactDetail.Town = Parameter.Town; contactDetail.Contact_Website_URL = Parameter.Contact_Website_URL; contactDetail.Contact_Telephone = Parameter.Contact_Telephone; contactDetail.Save(Connection, Transaction); returnValue.Result = medicalPractice.HEC_MedicalPractiseID; } #endregion #region Delete else { ORM_HEC_MedicalPractice_2_PracticeType.Query.SoftDelete(Connection, Transaction, new ORM_HEC_MedicalPractice_2_PracticeType.Query { HEC_MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability.Query.SoftDelete(Connection, Transaction, new ORM_PPS_TSK_Task_Template_CustomerOrgUnitAvailability.Query { CMN_BPT_CTM_OrganizationalUnit_RefID = organizationalUnit.CMN_BPT_CTM_OrganizationalUnitID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); ORM_HEC_MedicalPractice_OfferedService.Query.SoftDelete(Connection, Transaction, new ORM_HEC_MedicalPractice_OfferedService.Query { MedicalPractice_RefID = medicalPractice.HEC_MedicalPractiseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); ORM_CMN_BPT_BusinessParticipant businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query { CMN_BPT_BusinessParticipantID = medicalPractice.ContactPerson_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); businessParticipant.IsDeleted = true; ORM_CMN_PER_PersonInfo personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query { CMN_PER_PersonInfoID = businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); personInfo.IsDeleted = true; ORM_CMN_COM_CompanyInfo companyInfo = ORM_CMN_COM_CompanyInfo.Query.Search(Connection, Transaction, new ORM_CMN_COM_CompanyInfo.Query { CMN_COM_CompanyInfoID = medicalPractice.Ext_CompanyInfo_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); companyInfo.IsDeleted = true; ORM_CMN_UniversalContactDetail contactDetail = ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new ORM_CMN_UniversalContactDetail.Query { CMN_UniversalContactDetailID = companyInfo.Contact_UCD_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); contactDetail.IsDeleted = true; ORM_HEC_MedicalPractis.Query.SoftDelete(Connection, Transaction, new ORM_HEC_MedicalPractis.Query { HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); contactDetail.Save(Connection, Transaction); companyInfo.Save(Connection, Transaction); personInfo.Save(Connection, Transaction); businessParticipant.Save(Connection, Transaction); } #endregion returnValue.Result = medicalPractice.HEC_MedicalPractiseID; } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SP_1054 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here returnValue.Result = new Guid(); if (!Parameter.IsDeleted) { var DBLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result; Guid Hec_ProductID = Guid.Empty; //check if product exists var productQuery = new ORM_CMN_PRO_Product.Query(); productQuery.Tenant_RefID = securityTicket.TenantID; productQuery.IsDeleted = false; productQuery.CMN_PRO_ProductID = Guid.Parse(Parameter.product_itl); var product = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, productQuery).SingleOrDefault(); //save if (product == null) { ORM_CMN_PRO_Product cmn_pro_product = new ORM_CMN_PRO_Product(); cmn_pro_product.CMN_PRO_ProductID = Guid.NewGuid(); cmn_pro_product.Tenant_RefID = securityTicket.TenantID; cmn_pro_product.Creation_Timestamp = DateTime.Now; cmn_pro_product.Modification_Timestamp = DateTime.Now; Dict product_name = new Dict("cmn_pro_products"); for (int i = 0; i < DBLanguages.Length; i++) { product_name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.product_name); } cmn_pro_product.Product_Name = product_name; cmn_pro_product.ProductITL = Guid.NewGuid().ToString(); cmn_pro_product.ProducingBusinessParticipant_RefID = Guid.NewGuid(); //manufacturer cmn_pro_product.PackageInfo_RefID = Guid.NewGuid(); // package info cmn_pro_product.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant manufacturer = new ORM_CMN_BPT_BusinessParticipant(); var manufacturerQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); manufacturerQuery.Tenant_RefID = securityTicket.TenantID; manufacturerQuery.IsDeleted = false; manufacturerQuery.CMN_BPT_BusinessParticipantID = Guid.Parse(Parameter.product_manufacturer_id); if (Parameter.product_manufacturer_id == Guid.Empty.ToString()) { manufacturer.CMN_BPT_BusinessParticipantID = cmn_pro_product.ProducingBusinessParticipant_RefID; manufacturer.DisplayName = Parameter.product_manufacturer; manufacturer.IsCompany = true; manufacturer.IsNaturalPerson = false; manufacturer.Tenant_RefID = securityTicket.TenantID; manufacturer.Creation_Timestamp = DateTime.Now; manufacturer.Modification_Timestamp = DateTime.Now; manufacturer.Save(Connection, Transaction); } else { manufacturer = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, manufacturerQuery).Single(); } ORM_CMN_PRO_PAC_PackageInfo package_info = new ORM_CMN_PRO_PAC_PackageInfo(); package_info.CMN_PRO_PAC_PackageInfoID = cmn_pro_product.PackageInfo_RefID; package_info.Tenant_RefID = securityTicket.TenantID; package_info.Creation_Timestamp = DateTime.Now; package_info.Modification_Timestamp = DateTime.Now; string amount = String.Empty; string unit = String.Empty; foreach (char c in Parameter.product_strength) { // Do not use IsDigit as it will include more than the characters 0 through to 9 if (c >= '0' && c <= '9') { amount += c; } else { unit += c; } } package_info.PackageContent_Amount = Int32.Parse(amount); package_info.PackageContent_DisplayLabel = amount; var unitQuery = new ORM_CMN_Unit.Query(); unitQuery.IsDeleted = false; unitQuery.Tenant_RefID = securityTicket.TenantID; unitQuery.ISOCode = unit; var cmn_unit = ORM_CMN_Unit.Query.Search(Connection, Transaction, unitQuery).FirstOrDefault(); if (cmn_unit == null) { cmn_unit = new ORM_CMN_Unit(); cmn_unit.CMN_UnitID = Guid.NewGuid(); cmn_unit.Tenant_RefID = securityTicket.TenantID; cmn_unit.Creation_Timestamp = DateTime.Now; cmn_unit.Modification_Timestamp = DateTime.Now; cmn_unit.ISOCode = unit; cmn_unit.Save(Connection, Transaction); } package_info.PackageContent_MeasuredInUnit_RefID = cmn_unit.CMN_UnitID; package_info.Save(Connection, Transaction); //hec_products ORM_HEC_Product hec_product = new ORM_HEC_Product(); hec_product.HEC_ProductID = Guid.NewGuid(); hec_product.Ext_PRO_Product_RefID = cmn_pro_product.CMN_PRO_ProductID; hec_product.Tenant_RefID = securityTicket.TenantID; hec_product.Creation_Timestamp = DateTime.Now; hec_product.Modification_Timestamp = DateTime.Now; Hec_ProductID = hec_product.HEC_ProductID; var dosage_formQuery = new ORM_HEC_Product_DosageForm.Query(); dosage_formQuery.Tenant_RefID = securityTicket.TenantID; dosage_formQuery.IsDeleted = false; dosage_formQuery.GlobalPropertyMatchingID = Parameter.product_form; var dosage_form = ORM_HEC_Product_DosageForm.Query.Search(Connection, Transaction, dosage_formQuery).SingleOrDefault(); if (dosage_form == null) { dosage_form = new ORM_HEC_Product_DosageForm(); dosage_form.HEC_Product_DosageFormID = Guid.NewGuid(); dosage_form.GlobalPropertyMatchingID = Parameter.product_form; dosage_form.Tenant_RefID = securityTicket.TenantID; dosage_form.Creation_Timestamp = DateTime.Now; dosage_form.Modification_Timestamp = DateTime.Now; Dict form_name = new Dict("hec_product_dosageforms"); for (int i = 0; i < DBLanguages.Length; i++) { form_name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.product_form); } dosage_form.DosageForm_Name = form_name; dosage_form.Save(Connection, Transaction); } hec_product.ProductDosageForm_RefID = dosage_form.HEC_Product_DosageFormID; //dosage form hec_product.Save(Connection, Transaction); //product component ORM_HEC_PRO_Product_Component product_component = new ORM_HEC_PRO_Product_Component(); product_component.HEC_PRO_Product_ComponentID = Guid.NewGuid(); product_component.HEC_PRO_Component_RefID = Guid.NewGuid();//pro_component product_component.HEC_PRO_Product_RefID = hec_product.HEC_ProductID; product_component.Tenant_RefID = securityTicket.TenantID; product_component.Creation_Timestamp = DateTime.Now; product_component.Modification_Timestamp = DateTime.Now; product_component.Save(Connection, Transaction); ORM_HEC_PRO_Component pro_component = new ORM_HEC_PRO_Component(); pro_component.HEC_PRO_ComponentID = product_component.HEC_PRO_Component_RefID; pro_component.Tenant_RefID = securityTicket.TenantID; pro_component.Creation_Timestamp = DateTime.Now; pro_component.Modification_Timestamp = DateTime.Now; pro_component.Save(Connection, Transaction); ORM_HEC_PRO_Component_SubstanceIngredient component_SubstanceIngredient = new ORM_HEC_PRO_Component_SubstanceIngredient(); component_SubstanceIngredient.HEC_PRO_Component_SubstanceIngredientID = Guid.NewGuid(); component_SubstanceIngredient.Component_RefID = pro_component.HEC_PRO_ComponentID; component_SubstanceIngredient.Tenant_RefID = securityTicket.TenantID; component_SubstanceIngredient.Creation_Timestamp = DateTime.Now; component_SubstanceIngredient.Modification_Timestamp = DateTime.Now; var substanceQuery = new ORM_HEC_SUB_Substance.Query(); substanceQuery.IsDeleted = false; substanceQuery.Tenant_RefID = securityTicket.TenantID; substanceQuery.HEC_SUB_SubstanceID = Parameter.substance_id; var substance = ORM_HEC_SUB_Substance.Query.Search(Connection, Transaction, substanceQuery).SingleOrDefault(); component_SubstanceIngredient.Substance_RefID = substance.HEC_SUB_SubstanceID; component_SubstanceIngredient.Save(Connection, Transaction); Parameter.IsSaved = true; Parameter.product_itl = cmn_pro_product.CMN_PRO_ProductID.ToString(); returnValue.Result = cmn_pro_product.CMN_PRO_ProductID; } else { //edit Parameter.IsEdited = true; Dict product_name = new Dict("cmn_pro_products"); for (int i = 0; i < DBLanguages.Length; i++) { product_name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.product_name); } product.Product_Name = product_name; var manufacturerQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); manufacturerQuery.Tenant_RefID = securityTicket.TenantID; manufacturerQuery.IsDeleted = false; manufacturerQuery.CMN_BPT_BusinessParticipantID = Guid.Parse(Parameter.product_manufacturer_id); ORM_CMN_BPT_BusinessParticipant manufacturer = new ORM_CMN_BPT_BusinessParticipant(); if (Parameter.product_manufacturer_id == Guid.Empty.ToString()) { manufacturer.CMN_BPT_BusinessParticipantID = new Guid(); manufacturer.DisplayName = Parameter.product_manufacturer; manufacturer.IsCompany = true; manufacturer.IsNaturalPerson = false; manufacturer.Tenant_RefID = securityTicket.TenantID; manufacturer.Creation_Timestamp = DateTime.Now; manufacturer.Modification_Timestamp = DateTime.Now; manufacturer.Save(Connection, Transaction); } else { manufacturer = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, manufacturerQuery).Single(); } product.ProducingBusinessParticipant_RefID = manufacturer.CMN_BPT_BusinessParticipantID; var package_info = ORM_CMN_PRO_PAC_PackageInfo.Query.Search(Connection, Transaction, new ORM_CMN_PRO_PAC_PackageInfo.Query() { CMN_PRO_PAC_PackageInfoID = product.PackageInfo_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); string amount = String.Empty; string unit = String.Empty; foreach (char c in Parameter.product_strength) { // Do not use IsDigit as it will include more than the characters 0 through to 9 if (c >= '0' && c <= '9') { amount += c; } else { unit += c; } } package_info.PackageContent_Amount = Int32.Parse(amount); package_info.PackageContent_DisplayLabel = amount; package_info.Save(Connection, Transaction); var unitQuery = new ORM_CMN_Unit.Query(); unitQuery.IsDeleted = false; unitQuery.Tenant_RefID = securityTicket.TenantID; unitQuery.ISOCode = unit; var cmn_unit = ORM_CMN_Unit.Query.Search(Connection, Transaction, unitQuery).FirstOrDefault(); if (cmn_unit == null) { cmn_unit = new ORM_CMN_Unit(); cmn_unit.CMN_UnitID = Guid.NewGuid(); cmn_unit.Tenant_RefID = securityTicket.TenantID; cmn_unit.Creation_Timestamp = DateTime.Now; cmn_unit.Modification_Timestamp = DateTime.Now; cmn_unit.ISOCode = unit; cmn_unit.Save(Connection, Transaction); } package_info.PackageContent_MeasuredInUnit_RefID = cmn_unit.CMN_UnitID; package_info.Save(Connection, Transaction); var dosage_formQuery = new ORM_HEC_Product_DosageForm.Query(); dosage_formQuery.Tenant_RefID = securityTicket.TenantID; dosage_formQuery.IsDeleted = false; dosage_formQuery.GlobalPropertyMatchingID = Parameter.product_form; var dosage_form = ORM_HEC_Product_DosageForm.Query.Search(Connection, Transaction, dosage_formQuery).SingleOrDefault(); if (dosage_form == null) { dosage_form = new ORM_HEC_Product_DosageForm(); dosage_form.HEC_Product_DosageFormID = Guid.NewGuid(); dosage_form.GlobalPropertyMatchingID = Parameter.product_form; dosage_form.Tenant_RefID = securityTicket.TenantID; dosage_form.Creation_Timestamp = DateTime.Now; dosage_form.Modification_Timestamp = DateTime.Now; Dict form_name = new Dict("hec_product_dosageforms"); for (int i = 0; i < DBLanguages.Length; i++) { form_name.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.product_form); } dosage_form.DosageForm_Name = form_name; dosage_form.Save(Connection, Transaction); } ORM_HEC_Product hec_product = ORM_HEC_Product.Query.Search(Connection, Transaction, new ORM_HEC_Product.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Ext_PRO_Product_RefID = product.CMN_PRO_ProductID }).Single(); hec_product.ProductDosageForm_RefID = dosage_form.HEC_Product_DosageFormID; hec_product.Save(Connection, Transaction); ORM_HEC_PRO_Product_Component product_component = ORM_HEC_PRO_Product_Component.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Product_Component.Query() { HEC_PRO_Product_RefID = hec_product.HEC_ProductID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_HEC_PRO_Component pro_component = ORM_HEC_PRO_Component.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Component.Query() { HEC_PRO_ComponentID = product_component.HEC_PRO_Component_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_HEC_PRO_Component_SubstanceIngredient component_SubstanceIngredient = ORM_HEC_PRO_Component_SubstanceIngredient.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Component_SubstanceIngredient.Query() { Component_RefID = pro_component.HEC_PRO_ComponentID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); var substanceQuery = new ORM_HEC_SUB_Substance.Query(); substanceQuery.IsDeleted = false; substanceQuery.Tenant_RefID = securityTicket.TenantID; substanceQuery.HEC_SUB_SubstanceID = Parameter.substance_id; var substance = ORM_HEC_SUB_Substance.Query.Search(Connection, Transaction, substanceQuery).SingleOrDefault(); component_SubstanceIngredient.Substance_RefID = substance.HEC_SUB_SubstanceID; component_SubstanceIngredient.Save(Connection, Transaction); } } else { //delete ORM_CMN_PRO_Product product = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Product.Query() { Tenant_RefID = securityTicket.TenantID, CMN_PRO_ProductID = Guid.Parse(Parameter.product_itl), IsDeleted = false }).Single(); ORM_HEC_Product hec_product = ORM_HEC_Product.Query.Search(Connection, Transaction, new ORM_HEC_Product.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Ext_PRO_Product_RefID = product.CMN_PRO_ProductID }).Single(); ORM_CMN_PRO_PAC_PackageInfo package_info = ORM_CMN_PRO_PAC_PackageInfo.Query.Search(Connection, Transaction, new ORM_CMN_PRO_PAC_PackageInfo.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_PRO_PAC_PackageInfoID = product.PackageInfo_RefID }).Single(); ORM_HEC_PRO_Product_Component product_component = ORM_HEC_PRO_Product_Component.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Product_Component.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_PRO_Product_RefID = hec_product.HEC_ProductID }).Single(); ORM_HEC_PRO_Component pro_component = ORM_HEC_PRO_Component.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Component.Query() { HEC_PRO_ComponentID = product_component.HEC_PRO_Component_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_HEC_PRO_Component_SubstanceIngredient component_SubstanceIngredient = ORM_HEC_PRO_Component_SubstanceIngredient.Query.Search(Connection, Transaction, new ORM_HEC_PRO_Component_SubstanceIngredient.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Component_RefID = pro_component.HEC_PRO_ComponentID }).Single(); component_SubstanceIngredient.IsDeleted = true; component_SubstanceIngredient.Save(Connection, Transaction); pro_component.IsDeleted = true; pro_component.Save(Connection, Transaction); product_component.IsDeleted = true; product_component.Save(Connection, Transaction); package_info.IsDeleted = true; package_info.Save(Connection, Transaction); product.IsDeleted = true; product.Save(Connection, Transaction); returnValue.Result = product.CMN_PRO_ProductID; } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3OS_COUaMR_1344 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); #region Preload data var languages = ORM_CMN_Language.Query.Search(Connection, Transaction, new ORM_CMN_Language.Query { IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); #endregion #region Retrieve already saved org. units and addresses var retrievedOrgUnits = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query { Customer_RefID = Parameter.CustomerID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); var retrievedOrgUnitOfficeITLs = retrievedOrgUnits.Select(x => x.CustomerTenant_OfficeITL); String[] officesForDeletionITLs = retrievedOrgUnitOfficeITLs.Except(Parameter.OrganizationUnits.Select(x => x.OfficeITL)).ToArray(); String[] officesToUpdateITLs = retrievedOrgUnitOfficeITLs.Intersect(Parameter.OrganizationUnits.Select(x => x.OfficeITL)).ToArray(); String[] officesToCreateITLs = Parameter.OrganizationUnits.Select(x => x.OfficeITL).Except(officesToUpdateITLs).ToArray(); var dOffices = new Dictionary <String, Guid>(); foreach (var item in retrievedOrgUnits) { dOffices[item.CustomerTenant_OfficeITL] = item.CMN_BPT_CTM_OrganizationalUnitID; } // generate IDs for new offices foreach (var item in officesToCreateITLs) { dOffices[item] = Guid.NewGuid(); } #endregion #region Deleted Offices foreach (var deletingOfficeITL in officesForDeletionITLs) { var officeForDeletion = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query { CustomerTenant_OfficeITL = deletingOfficeITL, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); officeForDeletion.IsDeleted = true; officeForDeletion.Save(Connection, Transaction); var addressesForDeletion = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query { OrganizationalUnit_RefID = Guid.Parse(deletingOfficeITL), IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var item in addressesForDeletion) { // Delete all ORM_CMN_UniversalContactDetail connected to this Org. unit address CL1_CMN.ORM_CMN_UniversalContactDetail.Query.SoftDelete(Connection, Transaction, new CL1_CMN.ORM_CMN_UniversalContactDetail.Query { CMN_UniversalContactDetailID = item.UniversalContactDetail_Address_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); // Delete ORM_CMN_BPT_CTM_OrganizationalUnit_Address item.IsDeleted = true; item.Save(Connection, Transaction); } } #endregion CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit orgUnit = null; CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address address = null; #region Save new organizational units with addresses foreach (var item in Parameter.OrganizationUnits.Where(x => officesToCreateITLs.Contains(x.OfficeITL))) { Dict officeNameDict = new Dict(ORM_CMN_BPT_CTM_OrganizationalUnit.TableName, Guid.NewGuid()); foreach (var lang in languages) { officeNameDict.AddEntry(lang.CMN_LanguageID, item.Name); } orgUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit { CMN_BPT_CTM_OrganizationalUnitID = dOffices[item.OfficeITL], CustomerTenant_OfficeITL = item.OfficeITL, Customer_RefID = Parameter.CustomerID, Parent_OrganizationalUnit_RefID = String.IsNullOrEmpty(item.ParentOfficeITL) ? Guid.Empty : dOffices[item.ParentOfficeITL], OrganizationalUnit_SimpleName = item.Name, OrganizationalUnit_Name = officeNameDict, InternalOrganizationalUnitNumber = item.Code, InternalOrganizationalUnitSimpleName = item.Name, OrganizationalUnit_Description = new Dict(ORM_CMN_BPT_CTM_OrganizationalUnit.TableName, Guid.NewGuid()), Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID, IsDeleted = false, ExternalOrganizationalUnitNumber = item.Code, Default_PhoneNumber = item.ContactPhone, Default_FaxNumber = item.ContactFax, }; if (String.IsNullOrEmpty(item.BillingAddressITL) == false) { var billingAddress = Parameter.Addresses.SingleOrDefault(x => item.BillingAddressITL == x.AddressITL); address = new ORM_CMN_BPT_CTM_OrganizationalUnit_Address { CMN_BPT_CTM_OrganizationalUnit_AddressID = Guid.NewGuid(), AddressType = (int)OrganizationalUnitAddressType.Billing, IsPrimary = billingAddress.IsPrimaryBillingAddress, OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; var ucd = new CL1_CMN.ORM_CMN_UniversalContactDetail { CMN_UniversalContactDetailID = Guid.NewGuid(), CompanyName_Line1 = null, Street_Name = billingAddress.StreetName, Street_Number = billingAddress.StreetNumber, ZIP = billingAddress.ZipCode, Town = billingAddress.City, Country_639_1_ISOCode = billingAddress.CountryISO, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; ucd.Save(Connection, Transaction); address.UniversalContactDetail_Address_RefID = ucd.CMN_UniversalContactDetailID; address.Save(Connection, Transaction); } if (String.IsNullOrEmpty(item.ShippingAddressITL) == false) { var shippingAddress = Parameter.Addresses.SingleOrDefault(x => item.ShippingAddressITL == x.AddressITL); address = new ORM_CMN_BPT_CTM_OrganizationalUnit_Address { CMN_BPT_CTM_OrganizationalUnit_AddressID = Guid.NewGuid(), AddressType = (int)OrganizationalUnitAddressType.Shipping, IsPrimary = shippingAddress.IsPrimaryBillingAddress, OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; var ucd = new CL1_CMN.ORM_CMN_UniversalContactDetail { CMN_UniversalContactDetailID = Guid.NewGuid(), CompanyName_Line1 = null, Street_Name = shippingAddress.StreetName, Street_Number = shippingAddress.StreetNumber, ZIP = shippingAddress.ZipCode, Town = shippingAddress.City, Country_639_1_ISOCode = shippingAddress.CountryISO, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; ucd.Save(Connection, Transaction); address.UniversalContactDetail_Address_RefID = ucd.CMN_UniversalContactDetailID; address.Save(Connection, Transaction); } orgUnit.Save(Connection, Transaction); dOffices[item.OfficeITL] = orgUnit.CMN_BPT_CTM_OrganizationalUnitID; } #endregion #region Update org. units with addresses foreach (var item in Parameter.OrganizationUnits.Where(x => officesToUpdateITLs.Contains(x.OfficeITL))) { orgUnit = retrievedOrgUnits.Single(x => x.CustomerTenant_OfficeITL == item.OfficeITL); #region Addresses #region Billing Addresses if (String.IsNullOrEmpty(item.BillingAddressITL)) { ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query.SoftDelete(Connection, Transaction, new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query { OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, AddressType = (int)OrganizationalUnitAddressType.Billing }); } else { var billingAddress = Parameter.Addresses.SingleOrDefault(x => item.BillingAddressITL == x.AddressITL); var existingBillingAdress = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query.Search(Connection, Transaction, new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query { OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, AddressType = (int)OrganizationalUnitAddressType.Billing, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (existingBillingAdress == null) { #region Create New address = new ORM_CMN_BPT_CTM_OrganizationalUnit_Address { CMN_BPT_CTM_OrganizationalUnit_AddressID = Guid.NewGuid(), AddressType = (int)OrganizationalUnitAddressType.Billing, IsPrimary = billingAddress.IsPrimaryBillingAddress, OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; var ucd = new CL1_CMN.ORM_CMN_UniversalContactDetail { CMN_UniversalContactDetailID = Guid.NewGuid(), CompanyName_Line1 = null, Street_Name = billingAddress.StreetName, Street_Number = billingAddress.StreetNumber, ZIP = billingAddress.ZipCode, Town = billingAddress.City, Country_639_1_ISOCode = billingAddress.CountryISO, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; ucd.Save(Connection, Transaction); address.UniversalContactDetail_Address_RefID = ucd.CMN_UniversalContactDetailID; address.Save(Connection, Transaction); #endregion } else { #region Update existing var ucd = CL1_CMN.ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new CL1_CMN.ORM_CMN_UniversalContactDetail.Query { CMN_UniversalContactDetailID = existingBillingAdress.UniversalContactDetail_Address_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ucd.Street_Name = billingAddress.StreetName; ucd.Street_Number = billingAddress.StreetNumber; ucd.ZIP = billingAddress.ZipCode; ucd.Town = billingAddress.City; ucd.Country_639_1_ISOCode = billingAddress.CountryISO; ucd.Save(Connection, Transaction); #endregion } } #endregion #region Shipping Addresses if (String.IsNullOrEmpty(item.ShippingAddressITL)) { ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query.SoftDelete(Connection, Transaction, new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query { OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, AddressType = (int)OrganizationalUnitAddressType.Shipping }); } else { var shippingAddress = Parameter.Addresses.SingleOrDefault(x => item.ShippingAddressITL == x.AddressITL); var existingShippingAddress = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query.Search(Connection, Transaction, new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_OrganizationalUnit_Address.Query { OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, AddressType = (int)OrganizationalUnitAddressType.Shipping, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (existingShippingAddress == null) { #region Create New address = new ORM_CMN_BPT_CTM_OrganizationalUnit_Address { CMN_BPT_CTM_OrganizationalUnit_AddressID = Guid.NewGuid(), AddressType = (int)OrganizationalUnitAddressType.Shipping, IsPrimary = shippingAddress.IsPrimaryShippingAddress, OrganizationalUnit_RefID = orgUnit.CMN_BPT_CTM_OrganizationalUnitID, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; var ucd = new CL1_CMN.ORM_CMN_UniversalContactDetail { CMN_UniversalContactDetailID = Guid.NewGuid(), CompanyName_Line1 = null, Street_Name = shippingAddress.StreetName, Street_Number = shippingAddress.StreetNumber, ZIP = shippingAddress.ZipCode, Town = shippingAddress.City, Country_639_1_ISOCode = shippingAddress.CountryISO, Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID }; ucd.Save(Connection, Transaction); address.UniversalContactDetail_Address_RefID = ucd.CMN_UniversalContactDetailID; address.Save(Connection, Transaction); #endregion } else { #region Update existing var ucd = CL1_CMN.ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new CL1_CMN.ORM_CMN_UniversalContactDetail.Query { CMN_UniversalContactDetailID = existingShippingAddress.UniversalContactDetail_Address_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ucd.Street_Name = shippingAddress.StreetName; ucd.Street_Number = shippingAddress.StreetNumber; ucd.ZIP = shippingAddress.ZipCode; ucd.Town = shippingAddress.City; ucd.Country_639_1_ISOCode = shippingAddress.CountryISO; ucd.Save(Connection, Transaction); #endregion } } #endregion #endregion #region Org. unit foreach (DictEntry dictEntry in orgUnit.OrganizationalUnit_Name.Contents) { dictEntry.Content = item.Name; } orgUnit.Parent_OrganizationalUnit_RefID = String.IsNullOrEmpty(item.ParentOfficeITL) ? Guid.Empty : dOffices[item.ParentOfficeITL]; orgUnit.ExternalOrganizationalUnitNumber = item.Code; orgUnit.OrganizationalUnit_SimpleName = item.Name; orgUnit.Default_PhoneNumber = item.ContactPhone; orgUnit.Default_FaxNumber = item.ContactFax; orgUnit.Save(Connection, Transaction); #endregion } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_MD_SCGPOSD_1306 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here var insuranceToBrokerContract = ORM_HEC_CRT_InsuranceToBrokerContract.Query.Search(Connection, Transaction, new ORM_HEC_CRT_InsuranceToBrokerContract.Query() { Ext_CMN_CTR_Contract_RefID = Parameter.ContractID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (insuranceToBrokerContract == null) { insuranceToBrokerContract = new ORM_HEC_CRT_InsuranceToBrokerContract(); insuranceToBrokerContract.Creation_Timestamp = DateTime.Now; insuranceToBrokerContract.Ext_CMN_CTR_Contract_RefID = Parameter.ContractID; insuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID = Guid.NewGuid(); insuranceToBrokerContract.Modification_Timestamp = DateTime.Now; insuranceToBrokerContract.Tenant_RefID = securityTicket.TenantID; insuranceToBrokerContract.Save(Connection, Transaction); } var allLanguages = ORM_CMN_Language.Query.Search(Connection, Transaction, new ORM_CMN_Language.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).ToArray(); var currency = ORM_CMN_Currency.Query.Search(Connection, Transaction, new ORM_CMN_Currency.Query() { ISO4127 = "EUR", IsDeleted = false, Symbol = "EUR", Tenant_RefID = securityTicket.TenantID }).Single(); #region DELETE DISCONNECTED GPOS-ES var currentGposesConnectedToContract = ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query.Search(Connection, Transaction, new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query() { InsuranceToBrokerContract_RefID = insuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); var gposIDs = Parameter.GposData.Select(gpos => gpos.GposID).ToArray(); foreach (var currGpos in currentGposesConnectedToContract) { var exists = gposIDs.Any(id => currGpos.PotentialBillCode_RefID == id); if (!gposIDs.Any(id => id == currGpos.PotentialBillCode_RefID)) { cls_Delete_GPOS_Data.Invoke(Connection, Transaction, new P_MD_DGPOSD_1033() { GposID = currGpos.PotentialBillCode_RefID }, securityTicket); } } #endregion DELETE DISCONNECTED GPOS-ES foreach (var gpos in Parameter.GposData) { #region NEW GPOS DATA if (gpos.GposID == Guid.Empty) { #region GPOS CATALOG var catalog = ORM_HEC_BIL_PotentialCode_Catalog.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_Catalog.Query() { GlobalPropertyMatchingID = gpos.GposType, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (catalog == null) { catalog = new ORM_HEC_BIL_PotentialCode_Catalog(); var catalogNameDict = new Dict(ORM_HEC_BIL_PotentialCode_Catalog.TableName); var catalogNameString = gpos.GposType.Replace("mm.docconnect.gpos.catalog.", ""); catalogNameString = catalogNameString.Substring(0, 1).ToUpper() + catalogNameString.Substring(1); foreach (var lang in allLanguages) { catalogNameDict.AddEntry(lang.CMN_LanguageID, catalogNameString); } catalog.GlobalPropertyMatchingID = gpos.GposType; catalog.Modification_Timestamp = DateTime.Now; catalog.Tenant_RefID = securityTicket.TenantID; catalog.Save(Connection, Transaction); } #endregion GPOS CATALOG #region PRICE var price = new ORM_CMN_Price(); price.CMN_PriceID = Guid.NewGuid(); price.Creation_Timestamp = DateTime.Now; price.Tenant_RefID = securityTicket.TenantID; price.Save(Connection, Transaction); var priceValue = new ORM_CMN_Price_Value(); priceValue.CMN_Price_ValueID = Guid.NewGuid(); priceValue.Creation_Timestamp = DateTime.Now; priceValue.Price_RefID = price.CMN_PriceID; priceValue.PriceValue_Amount = gpos.FeeValue; priceValue.PriceValue_Currency_RefID = currency.CMN_CurrencyID; priceValue.Tenant_RefID = securityTicket.TenantID; priceValue.Save(Connection, Transaction); #endregion PRICE #region POTENTIAL CODE var newPotentialCode = new ORM_HEC_BIL_PotentialCode(); var potentialCodeName = new Dict(ORM_HEC_BIL_PotentialCode.TableName); foreach (var lang in allLanguages) { potentialCodeName.AddEntry(lang.CMN_LanguageID, gpos.GposName); } newPotentialCode.CodeName = potentialCodeName; newPotentialCode.Creation_Timestamp = DateTime.Now; newPotentialCode.HEC_BIL_PotentialCodeID = Guid.NewGuid(); newPotentialCode.PotentialCode_Catalog_RefID = catalog.HEC_BIL_PotentialCode_CatalogID; newPotentialCode.Modification_Timestamp = DateTime.Now; newPotentialCode.Price_RefID = price.CMN_PriceID; newPotentialCode.BillingCode = gpos.GposNumber; newPotentialCode.Tenant_RefID = securityTicket.TenantID; newPotentialCode.Save(Connection, Transaction); #endregion POTENTIAL CODE #region CONTRACT CONNECTION var coveredPotentialCode = new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode(); coveredPotentialCode.Creation_Timestamp = DateTime.Now; coveredPotentialCode.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID = Guid.NewGuid(); coveredPotentialCode.InsuranceToBrokerContract_RefID = insuranceToBrokerContract.HEC_CRT_InsuranceToBrokerContractID; coveredPotentialCode.Modification_Timestamp = DateTime.Now; coveredPotentialCode.PotentialBillCode_RefID = newPotentialCode.HEC_BIL_PotentialCodeID; coveredPotentialCode.Tenant_RefID = securityTicket.TenantID; coveredPotentialCode.Save(Connection, Transaction); #endregion CONTRACT CONNECTION #region POTENTIAL CODE PROPERTIES #region FROM INJECTION var fromInjectionProperty = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); fromInjectionProperty.Creation_Timestamp = DateTime.Now; fromInjectionProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = Guid.NewGuid(); fromInjectionProperty.IsValue_Number = true; fromInjectionProperty.Modification_Timestamp = DateTime.Now; fromInjectionProperty.PropertyName = "From injection no."; fromInjectionProperty.Tenant_RefID = securityTicket.TenantID; fromInjectionProperty.Save(Connection, Transaction); var fromInjectionPropertyToCode = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); fromInjectionPropertyToCode.Tenant_RefID = securityTicket.TenantID; fromInjectionPropertyToCode.AssignmentID = Guid.NewGuid(); fromInjectionPropertyToCode.CoveredPotentialBillCode_RefID = coveredPotentialCode.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; fromInjectionPropertyToCode.CoveredPotentialBillCode_UniversalProperty_RefID = fromInjectionProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID; fromInjectionPropertyToCode.Creation_Timestamp = DateTime.Now; fromInjectionPropertyToCode.Modification_Timestamp = DateTime.Now; fromInjectionPropertyToCode.Value_Number = gpos.FromInjection == 0 || gpos.FromInjection == null ? int.MaxValue : gpos.FromInjection; fromInjectionPropertyToCode.Save(Connection, Transaction); #endregion FROM INJECTION #region SERVICE FEE var serviceFeeProperty = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); serviceFeeProperty.Creation_Timestamp = DateTime.Now; serviceFeeProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = Guid.NewGuid(); serviceFeeProperty.IsValue_String = true; serviceFeeProperty.Modification_Timestamp = DateTime.Now; serviceFeeProperty.PropertyName = "Service Fee in EUR"; serviceFeeProperty.Tenant_RefID = securityTicket.TenantID; serviceFeeProperty.Save(Connection, Transaction); var serviceFeePropertyToCode = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); serviceFeePropertyToCode.Tenant_RefID = securityTicket.TenantID; serviceFeePropertyToCode.AssignmentID = Guid.NewGuid(); serviceFeePropertyToCode.CoveredPotentialBillCode_RefID = coveredPotentialCode.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; serviceFeePropertyToCode.CoveredPotentialBillCode_UniversalProperty_RefID = serviceFeeProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID; serviceFeePropertyToCode.Creation_Timestamp = DateTime.Now; serviceFeePropertyToCode.Modification_Timestamp = DateTime.Now; serviceFeePropertyToCode.Value_String = string.IsNullOrEmpty(gpos.ManagementFeeValue) ? "-" : gpos.ManagementFeeValue; serviceFeePropertyToCode.Save(Connection, Transaction); #endregion SERVICE FEE #region WAIVE WITH ORDER var waiveWithOrderProperty = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty(); waiveWithOrderProperty.Creation_Timestamp = DateTime.Now; waiveWithOrderProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = Guid.NewGuid(); waiveWithOrderProperty.IsValue_Boolean = true; waiveWithOrderProperty.Modification_Timestamp = DateTime.Now; waiveWithOrderProperty.PropertyName = "Waive with order"; waiveWithOrderProperty.Tenant_RefID = securityTicket.TenantID; waiveWithOrderProperty.Save(Connection, Transaction); var waiveWithOrderPropertyToCode = new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty(); waiveWithOrderPropertyToCode.Tenant_RefID = securityTicket.TenantID; waiveWithOrderPropertyToCode.AssignmentID = Guid.NewGuid(); waiveWithOrderPropertyToCode.CoveredPotentialBillCode_RefID = coveredPotentialCode.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID; waiveWithOrderPropertyToCode.CoveredPotentialBillCode_UniversalProperty_RefID = waiveWithOrderProperty.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID; waiveWithOrderPropertyToCode.Creation_Timestamp = DateTime.Now; waiveWithOrderPropertyToCode.Modification_Timestamp = DateTime.Now; waiveWithOrderPropertyToCode.Value_Boolean = gpos.WaiveServiceFeeWithOrder; waiveWithOrderPropertyToCode.Save(Connection, Transaction); #endregion WAIVE WITH ORDER #endregion POTENTIAL CODE PROPERTIES #region CONNECTED DRUGS if (gpos.DrugIDs.Length != 0) { foreach (var drugID in gpos.DrugIDs) { var potentialCodeToDrug = new ORM_HEC_BIL_PotentialCode_2_HealthcareProduct(); potentialCodeToDrug.AssignmentID = Guid.NewGuid(); potentialCodeToDrug.Creation_Timestamp = DateTime.Now; potentialCodeToDrug.HEC_BIL_PotentialCode_RefID = newPotentialCode.HEC_BIL_PotentialCodeID; potentialCodeToDrug.HEC_Product_RefID = drugID; potentialCodeToDrug.Modification_Timestamp = DateTime.Now; potentialCodeToDrug.Tenant_RefID = securityTicket.TenantID; potentialCodeToDrug.Save(Connection, Transaction); } } #endregion CONNECTED DRUGS #region CONNECTED DIAGNOSES if (gpos.DiagnoseIDs.Length != 0) { foreach (var diagnoseID in gpos.DiagnoseIDs) { var potentialCodeToDiagnose = new ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis(); potentialCodeToDiagnose.AssignmentID = Guid.NewGuid(); potentialCodeToDiagnose.Creation_Timestamp = DateTime.Now; potentialCodeToDiagnose.HEC_BIL_PotentialCode_RefID = newPotentialCode.HEC_BIL_PotentialCodeID; potentialCodeToDiagnose.HEC_DIA_PotentialDiagnosis_RefID = diagnoseID; potentialCodeToDiagnose.Modification_Timestamp = DateTime.Now; potentialCodeToDiagnose.Tenant_RefID = securityTicket.TenantID; potentialCodeToDiagnose.Save(Connection, Transaction); } } #endregion CONNECTED DIAGNOSES } #endregion NEW GPOS DATA #region EDIT else { var currentGpos = ORM_HEC_BIL_PotentialCode.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode.Query() { HEC_BIL_PotentialCodeID = gpos.GposID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (currentGpos != null) { #region BASE DATA var potentialCodeName = new Dict(ORM_HEC_BIL_PotentialCode.TableName); foreach (var lang in allLanguages) { potentialCodeName.AddEntry(lang.CMN_LanguageID, gpos.GposName); } currentGpos.CodeName = potentialCodeName; currentGpos.BillingCode = gpos.GposNumber; var catalog = ORM_HEC_BIL_PotentialCode_Catalog.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_Catalog.Query() { GlobalPropertyMatchingID = gpos.GposType, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (catalog == null) { catalog = new ORM_HEC_BIL_PotentialCode_Catalog(); var catalogNameDict = new Dict(ORM_HEC_BIL_PotentialCode_Catalog.TableName); var catalogNameString = gpos.GposType.Replace("mm.docconnect.gpos.catalog.", ""); catalogNameString = catalogNameString.Substring(0, 1).ToUpper() + catalogNameString.Substring(1); foreach (var lang in allLanguages) { catalogNameDict.AddEntry(lang.CMN_LanguageID, catalogNameString); } catalog.GlobalPropertyMatchingID = gpos.GposType; catalog.Modification_Timestamp = DateTime.Now; catalog.Tenant_RefID = securityTicket.TenantID; catalog.Save(Connection, Transaction); } currentGpos.PotentialCode_Catalog_RefID = catalog.HEC_BIL_PotentialCode_CatalogID; currentGpos.Save(Connection, Transaction); #endregion #region PRICE var currentPriceValue = ORM_CMN_Price_Value.Query.Search(Connection, Transaction, new ORM_CMN_Price_Value.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Price_RefID = currentGpos.Price_RefID }).SingleOrDefault(); if (currentPriceValue != null) { currentPriceValue.PriceValue_Amount = gpos.FeeValue; currentPriceValue.Save(Connection, Transaction); } #endregion #region CONTRACT CONNECTION var coveredPotentialCode = ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query.Search(Connection, Transaction, new ORM_HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCode.Query() { PotentialBillCode_RefID = gpos.GposID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); #endregion #region POTENTIAL CODE PROPERTIES var gposPropertyConnections = ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_2_UniversalProperty.Query() { CoveredPotentialBillCode_RefID = coveredPotentialCode.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var conn in gposPropertyConnections) { var gposProperty = ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalProperty.Query() { HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID = conn.CoveredPotentialBillCode_UniversalProperty_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (gposProperty != null) { switch (gposProperty.PropertyName) { case "From injection no.": conn.Value_Number = gpos.FromInjection; break; case "Waive with order": conn.Value_Boolean = gpos.WaiveServiceFeeWithOrder; break; case "Service Fee in EUR": conn.Value_String = gpos.ManagementFeeValue; break; } conn.Modification_Timestamp = DateTime.Now; conn.Save(Connection, Transaction); } } #endregion POTENTIAL CODE PROPERTIES #region CONNECTED DRUGS var currentGposDrugConnections = ORM_HEC_BIL_PotentialCode_2_HealthcareProduct.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_2_HealthcareProduct.Query() { HEC_BIL_PotentialCode_RefID = gpos.GposID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var drugConnection in currentGposDrugConnections) { if (gpos.DrugIDs.Length == 0 || !gpos.DrugIDs.Any(did => did == drugConnection.HEC_Product_RefID)) { drugConnection.IsDeleted = true; drugConnection.Modification_Timestamp = DateTime.Now; drugConnection.Save(Connection, Transaction); } } foreach (var drugID in gpos.DrugIDs) { if (!currentGposDrugConnections.Any(cpd => cpd.HEC_Product_RefID == drugID)) { var newDrugConnection = new ORM_HEC_BIL_PotentialCode_2_HealthcareProduct(); newDrugConnection.AssignmentID = Guid.NewGuid(); newDrugConnection.Creation_Timestamp = DateTime.Now; newDrugConnection.HEC_BIL_PotentialCode_RefID = gpos.GposID; newDrugConnection.HEC_Product_RefID = drugID; newDrugConnection.Modification_Timestamp = DateTime.Now; newDrugConnection.Tenant_RefID = securityTicket.TenantID; newDrugConnection.Save(Connection, Transaction); } } #endregion CONNECTED DRUGS #region CONNECTED DIAGNOSES var currentGposDiagnoseConnections = ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis.Query.Search(Connection, Transaction, new ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis.Query() { HEC_BIL_PotentialCode_RefID = gpos.GposID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); foreach (var diagnoseConnection in currentGposDiagnoseConnections) { if (gpos.DiagnoseIDs.Length == 0 || !gpos.DiagnoseIDs.Any(did => did == diagnoseConnection.HEC_DIA_PotentialDiagnosis_RefID)) { diagnoseConnection.IsDeleted = true; diagnoseConnection.Modification_Timestamp = DateTime.Now; diagnoseConnection.Save(Connection, Transaction); } } foreach (var diagnoseID in gpos.DiagnoseIDs) { if (!currentGposDiagnoseConnections.Any(cpd => cpd.HEC_DIA_PotentialDiagnosis_RefID == diagnoseID)) { var newDiagnoseConnection = new ORM_HEC_BIL_PotentialCode_2_PotentialDiagnosis(); newDiagnoseConnection.AssignmentID = Guid.NewGuid(); newDiagnoseConnection.Creation_Timestamp = DateTime.Now; newDiagnoseConnection.HEC_BIL_PotentialCode_RefID = gpos.GposID; newDiagnoseConnection.HEC_DIA_PotentialDiagnosis_RefID = diagnoseID; newDiagnoseConnection.Modification_Timestamp = DateTime.Now; newDiagnoseConnection.Tenant_RefID = securityTicket.TenantID; newDiagnoseConnection.Save(Connection, Transaction); } } #endregion CONNECTED DIAGNOSES } } #endregion EDIT } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CTPA_1225 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here var diagnose_details = cls_Get_Diagnose_Details_for_DiagnoseID.Invoke(Connection, Transaction, new P_CAS_GDDfDID_1608() { DiagnoseID = Parameter.diagnose_id }, securityTicket).Result; ORM_HEC_ACT_PlannedAction treatment_planned_action = null; if (Parameter.treatment_planned_action_id != Guid.Empty) { treatment_planned_action = ORM_HEC_ACT_PlannedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, HEC_ACT_PlannedActionID = Parameter.treatment_planned_action_id }).SingleOrDefault(); } if (treatment_planned_action == null) { treatment_planned_action = new ORM_HEC_ACT_PlannedAction(); treatment_planned_action.Creation_Timestamp = DateTime.Now; treatment_planned_action.HEC_ACT_PlannedActionID = Guid.NewGuid(); treatment_planned_action.IsPlannedFollowup = true; treatment_planned_action.IfPlannedFollowup_PreviousAction_RefID = Parameter.initial_performed_action_id; treatment_planned_action.IsPerformed = false; treatment_planned_action.MedicalPractice_RefID = Parameter.practice_id; treatment_planned_action.Modification_Timestamp = DateTime.Now; treatment_planned_action.Patient_RefID = Parameter.patient_id; treatment_planned_action.PlannedFor_Date = Parameter.treatment_date; treatment_planned_action.Tenant_RefID = securityTicket.TenantID; } if (Parameter.treatment_doctor_id != Guid.Empty) { var doctor_account_id = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDAIDfDID_1549() { DoctorID = Parameter.treatment_doctor_id }, securityTicket).Result.accountID; var doctor_accountQ = new ORM_USR_Account.Query(); doctor_accountQ.USR_AccountID = doctor_account_id; doctor_accountQ.Tenant_RefID = securityTicket.TenantID; doctor_accountQ.IsDeleted = false; var doctor_account = ORM_USR_Account.Query.Search(Connection, Transaction, doctor_accountQ).SingleOrDefault(); if (doctor_account != null) { treatment_planned_action.ToBePerformedBy_BusinessParticipant_RefID = doctor_account.BusinessParticipant_RefID; } } treatment_planned_action.Save(Connection, Transaction); returnValue.Result = treatment_planned_action.HEC_ACT_PlannedActionID; var treatment_planned_action_potential_procedure = ORM_HEC_ACT_PlannedAction_PotentialProcedure.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction_PotentialProcedure.Query() { PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID, PotentialProcedure_RefID = Parameter.intraocular_procedure_id, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (treatment_planned_action_potential_procedure == null) { treatment_planned_action_potential_procedure = new ORM_HEC_ACT_PlannedAction_PotentialProcedure(); treatment_planned_action_potential_procedure.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_potential_procedure.PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID; treatment_planned_action_potential_procedure.PotentialProcedure_RefID = Parameter.intraocular_procedure_id; } treatment_planned_action_potential_procedure.Modification_Timestamp = DateTime.Now; treatment_planned_action_potential_procedure.Save(Connection, Transaction); var treatment_planned_action_typeQ = new ORM_HEC_ACT_ActionType.Query(); treatment_planned_action_typeQ.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.treatment"; treatment_planned_action_typeQ.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_typeQ.IsDeleted = false; var treatment_planned_action_type = ORM_HEC_ACT_ActionType.Query.Search(Connection, Transaction, treatment_planned_action_typeQ).SingleOrDefault(); var treatment_planned_action_type_id = Guid.Empty; if (treatment_planned_action_type == null) { treatment_planned_action_type = new ORM_HEC_ACT_ActionType(); Dict action_type_name_dict = new Dict(ORM_HEC_ACT_ActionType.TableName); foreach (var lang in Parameter.all_languagesL) { var content = lang.ISO_639_1.Equals("DE") ? "behandlung" : "treatment"; action_type_name_dict.AddEntry(lang.CMN_LanguageID, content); } treatment_planned_action_type.ActionType_Name = action_type_name_dict; treatment_planned_action_type.Creation_Timestamp = DateTime.Now; treatment_planned_action_type.GlobalPropertyMatchingID = "mm.docconect.doc.app.planned.action.treatment"; treatment_planned_action_type.Modification_Timestamp = DateTime.Now; treatment_planned_action_type.HEC_ACT_ActionTypeID = Guid.NewGuid(); treatment_planned_action_type.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_type.Save(Connection, Transaction); treatment_planned_action_type_id = treatment_planned_action_type.HEC_ACT_ActionTypeID; } else { treatment_planned_action_type_id = treatment_planned_action_type.HEC_ACT_ActionTypeID; } ORM_HEC_ACT_PlannedAction_2_ActionType treatment_planned_action_2_type = new ORM_HEC_ACT_PlannedAction_2_ActionType(); treatment_planned_action_2_type.Tenant_RefID = securityTicket.TenantID; treatment_planned_action_2_type.Creation_Timestamp = DateTime.Now; treatment_planned_action_2_type.IsDeleted = false; treatment_planned_action_2_type.HEC_ACT_ActionType_RefID = treatment_planned_action_type_id; treatment_planned_action_2_type.HEC_ACT_PlannedAction_RefID = treatment_planned_action.HEC_ACT_PlannedActionID; treatment_planned_action_2_type.Modification_Timestamp = DateTime.Now; treatment_planned_action_2_type.HEC_ACT_PlannedAction_2_ActionTypeID = Guid.NewGuid(); treatment_planned_action_2_type.Save(Connection, Transaction); var treatment_planned_action_required_product = ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct.Query() { BoundTo_HealthcareProcurementOrderPosition_RefID = Parameter.procurement_order_id, PlannedAction_PotentialProcedure_RefID = treatment_planned_action_potential_procedure.HEC_ACT_PlannedAction_PotentialProcedureID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (treatment_planned_action_required_product == null) { treatment_planned_action_required_product = new ORM_HEC_ACT_PlannedAction_PotentialProcedure_RequiredProduct(); treatment_planned_action_required_product.BoundTo_HealthcareProcurementOrderPosition_RefID = Parameter.procurement_order_id; treatment_planned_action_required_product.PlannedAction_PotentialProcedure_RefID = treatment_planned_action_potential_procedure.HEC_ACT_PlannedAction_PotentialProcedureID; treatment_planned_action_required_product.Tenant_RefID = securityTicket.TenantID; } treatment_planned_action_required_product.Modification_Timestamp = DateTime.Now; treatment_planned_action_required_product.HealthcareProduct_RefID = Parameter.drug_id; treatment_planned_action_required_product.Save(Connection, Transaction); #region DIAGNOSE if (Parameter.diagnose_id != Guid.Empty) { var patient_diagnosis = new ORM_HEC_Patient_Diagnosis(); patient_diagnosis.Creation_Timestamp = DateTime.Now; patient_diagnosis.HEC_Patient_DiagnosisID = Guid.NewGuid(); patient_diagnosis.Modification_Timestamp = DateTime.Now; patient_diagnosis.Patient_RefID = Parameter.patient_id; patient_diagnosis.R_IsConfirmed = Parameter.is_confirmed; patient_diagnosis.R_PotentialDiagnosis_RefID = Parameter.diagnose_id; patient_diagnosis.Tenant_RefID = securityTicket.TenantID; patient_diagnosis.Save(Connection, Transaction); ORM_HEC_DIA_Diagnosis_Localization diagnosis_localization = new ORM_HEC_DIA_Diagnosis_Localization(); diagnosis_localization.Creation_Timestamp = DateTime.Now; diagnosis_localization.Diagnosis_RefID = Parameter.diagnose_id; diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID = Guid.NewGuid(); diagnosis_localization.Modification_Timestamp = DateTime.Now; diagnosis_localization.Tenant_RefID = securityTicket.TenantID; diagnosis_localization.LocalizationCode = Parameter.diagnose_id == Guid.Empty ? "-" : Parameter.is_left_eye ? "L" : "R"; diagnosis_localization.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate initial_performed_action_diagnose = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); initial_performed_action_diagnose.Creation_Timestamp = DateTime.Now; initial_performed_action_diagnose.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); initial_performed_action_diagnose.HEC_ACT_PerformedAction_RefID = Parameter.initial_performed_action_id; initial_performed_action_diagnose.IsDiagnosisConfirmed = Parameter.is_confirmed; initial_performed_action_diagnose.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose.PotentialDiagnosis_RefID = Parameter.diagnose_id; initial_performed_action_diagnose.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose.HEC_Patient_Diagnosis_RefID = patient_diagnosis.HEC_Patient_DiagnosisID; initial_performed_action_diagnose.IM_PotentialDiagnosis_Code = diagnose_details.diagnose_icd_10; initial_performed_action_diagnose.IM_PotentialDiagnosis_Name = diagnose_details.diagnose_name; initial_performed_action_diagnose.IM_PotentialDiagnosisCatalog_Name = diagnose_details.catalog_display_name; initial_performed_action_diagnose.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization initial_performed_action_diagnose_localization = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate_Localization(); initial_performed_action_diagnose_localization.Creation_Timestamp = DateTime.Now; initial_performed_action_diagnose_localization.HEC_ACT_PerformedAction_DiagnosisUpdate_LocalizationID = Guid.NewGuid(); initial_performed_action_diagnose_localization.HEX_EXC_Action_DiagnosisUpdate_RefID = initial_performed_action_diagnose.HEC_ACT_PerformedAction_DiagnosisUpdateID; initial_performed_action_diagnose_localization.HEC_DIA_Diagnosis_Localization_RefID = diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID; initial_performed_action_diagnose_localization.Modification_Timestamp = DateTime.Now; initial_performed_action_diagnose_localization.Tenant_RefID = securityTicket.TenantID; initial_performed_action_diagnose_localization.IM_PotentialDiagnosisLocalization_Code = Parameter.diagnose_id == Guid.Empty ? "-" : Parameter.is_left_eye ? "L" : "R"; initial_performed_action_diagnose_localization.Save(Connection, Transaction); ORM_HEC_Patient_Diagnosis_Localization patient_diagnosis_localization = new ORM_HEC_Patient_Diagnosis_Localization(); patient_diagnosis_localization.Creation_Timestamp = DateTime.Now; patient_diagnosis_localization.DIA_Diagnosis_Localization_RefID = diagnosis_localization.HEC_DIA_Diagnosis_LocalizationID; patient_diagnosis_localization.HEC_Patient_Diagnosis_LocalizationID = Guid.NewGuid(); patient_diagnosis_localization.Patient_Diagnosis_RefID = patient_diagnosis.HEC_Patient_DiagnosisID; patient_diagnosis_localization.Tenant_RefID = securityTicket.TenantID; patient_diagnosis_localization.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_MD_SNDaRNIDs_1412[] Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guids(); var allLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); returnValue.Result = Parameter.Select(diag => { var diagnose = cls_Get_DiagnoseID_for_ICD10_and_DiagnoseName.Invoke(Connection, Transaction, new P_MD_GDIDfDN_1408() { DiagnoseICD10 = diag.DiagnoseICD10, DiagnoseNameWithoutSpaces = diag.DiagnoseName.Replace(((char)32).ToString(), string.Empty).Replace(((char)160).ToString(), string.Empty) }, securityTicket).Result; if (diagnose != null) { return(diagnose.DiagnoseID); } else { Dict DiagnoseName = new Dict(ORM_HEC_DIA_PotentialDiagnosis.TableName); for (int i = 0; i < allLanguages.Count; i++) { DiagnoseName.AddEntry(allLanguages[i].CMN_LanguageID, diag.DiagnoseName); } Dict CatalogName = new Dict(ORM_HEC_DIA_PotentialDiagnosis_Catalog.TableName); for (int i = 0; i < allLanguages.Count; i++) { CatalogName.AddEntry(allLanguages[i].CMN_LanguageID, "ICD-10"); } var newDiagnose = new ORM_HEC_DIA_PotentialDiagnosis(); newDiagnose.PotentialDiagnosis_Name = DiagnoseName; newDiagnose.IsDeleted = false; newDiagnose.Tenant_RefID = securityTicket.TenantID; newDiagnose.Creation_Timestamp = DateTime.Now; newDiagnose.Modification_Timestamp = DateTime.Now; newDiagnose.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); newDiagnose.Save(Connection, Transaction); var newDiagnoseCatalog = new ORM_HEC_DIA_PotentialDiagnosis_Catalog(); newDiagnoseCatalog.IsDeleted = false; newDiagnoseCatalog.Catalog_DisplayName = "ICD-10"; newDiagnoseCatalog.Tenant_RefID = securityTicket.TenantID; newDiagnoseCatalog.Creation_Timestamp = DateTime.Now; newDiagnoseCatalog.Modification_Timestamp = DateTime.Now; newDiagnoseCatalog.HEC_DIA_PotentialDiagnosis_CatalogID = Guid.NewGuid(); newDiagnoseCatalog.Catalog_Name = CatalogName; newDiagnoseCatalog.Save(Connection, Transaction); var newDiagnose2CatalogCode = new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode(); newDiagnose2CatalogCode.IsDeleted = false; newDiagnose2CatalogCode.Tenant_RefID = securityTicket.TenantID; newDiagnose2CatalogCode.Creation_Timestamp = DateTime.Now; newDiagnose2CatalogCode.Modification_Timestamp = DateTime.Now; newDiagnose2CatalogCode.PotentialDiagnosis_RefID = newDiagnose.HEC_DIA_PotentialDiagnosisID; newDiagnose2CatalogCode.PotentialDiagnosis_Catalog_RefID = newDiagnoseCatalog.HEC_DIA_PotentialDiagnosis_CatalogID; newDiagnose2CatalogCode.Code = diag.DiagnoseICD10; newDiagnose2CatalogCode.Save(Connection, Transaction); return(newDiagnose.HEC_DIA_PotentialDiagnosisID); } }).ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SPED_1313 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); returnValue.Result = false; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; var medPro_Credentials = cls_Get_TenantMemershipData.Invoke(Connection, Transaction, securityTicket).Result; var examination = ORM_HEC_ACT_PerformedAction.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, HEC_ACT_PerformedActionID = Parameter.ExaminationID }).Single(); #region save foreach (var item in Parameter.newDiagnoses) { if (medPro_Credentials.Credantial != null) { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.Tenant_RefID = securityTicket.TenantID; potentialDiagnosisQuery.PotentialDiagnosisITL = item.DiagnoseITL; var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).SingleOrDefault(); if (potentialDiagnosis == null) { potentialDiagnosis = new ORM_HEC_DIA_PotentialDiagnosis(); potentialDiagnosis.HEC_DIA_PotentialDiagnosisID = Guid.NewGuid(); potentialDiagnosis.ICD10_Code = item.DiagnoseICD10; Dict name = new Dict("hec_dia_potentialdiagnoses"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.DiagnoseName); } potentialDiagnosis.PotentialDiagnosis_Name = name; potentialDiagnosis.PotentialDiagnosisITL = item.DiagnoseITL; potentialDiagnosis.Tenant_RefID = securityTicket.TenantID; potentialDiagnosis.Creation_Timestamp = DateTime.Now; potentialDiagnosis.Modification_Timestamp = DateTime.Now; potentialDiagnosis.Save(Connection, Transaction); } //check if exists active patient diagnoses (same one) var patientDiagQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagQuery.IsDeleted = false; patientDiagQuery.Tenant_RefID = securityTicket.TenantID; patientDiagQuery.R_IsActive = true; patientDiagQuery.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagQuery.Patient_RefID = Parameter.PatientID; var patientDiagExists = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagQuery).SingleOrDefault(); if (patientDiagExists == null) { ORM_HEC_Patient_Diagnosis patientDiagnoses = new ORM_HEC_Patient_Diagnosis(); patientDiagnoses.HEC_Patient_DiagnosisID = Guid.NewGuid(); patientDiagnoses.Creation_Timestamp = DateTime.Now; patientDiagnoses.Modification_Timestamp = DateTime.Now; patientDiagnoses.R_IsActive = true; patientDiagnoses.Patient_RefID = Parameter.PatientID; patientDiagnoses.Tenant_RefID = securityTicket.TenantID; patientDiagnoses.R_DiagnosedOnDate = examination.IfPerfomed_DateOfAction; patientDiagnoses.R_ScheduledExpiryDate = patientDiagnoses.R_DiagnosedOnDate.AddDays(item.days_valid); patientDiagnoses.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagnoses.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate diagnosisUpdate = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); diagnosisUpdate.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); diagnosisUpdate.Creation_Timestamp = DateTime.Now; diagnosisUpdate.Modification_Timestamp = DateTime.Now; diagnosisUpdate.Tenant_RefID = securityTicket.TenantID; diagnosisUpdate.ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); diagnosisUpdate.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; diagnosisUpdate.HEC_Patient_Diagnosis_RefID = patientDiagnoses.HEC_Patient_DiagnosisID; diagnosisUpdate.HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID; diagnosisUpdate.Save(Connection, Transaction); } } else { var potentialDiagnosisQuery = new ORM_HEC_DIA_PotentialDiagnosis.Query(); potentialDiagnosisQuery.IsDeleted = false; potentialDiagnosisQuery.Tenant_RefID = securityTicket.TenantID; potentialDiagnosisQuery.HEC_DIA_PotentialDiagnosisID = new Guid(item.DiagnoseITL); var potentialDiagnosis = ORM_HEC_DIA_PotentialDiagnosis.Query.Search(Connection, Transaction, potentialDiagnosisQuery).SingleOrDefault(); //check if exists active patient diagnoses (same one) var patientDiagQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagQuery.IsDeleted = false; patientDiagQuery.Tenant_RefID = securityTicket.TenantID; patientDiagQuery.R_IsActive = true; patientDiagQuery.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; var patientDiagExists = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagQuery).SingleOrDefault(); if (patientDiagExists == null) { ORM_HEC_Patient_Diagnosis patientDiagnoses = new ORM_HEC_Patient_Diagnosis(); patientDiagnoses.HEC_Patient_DiagnosisID = Guid.NewGuid(); patientDiagnoses.Creation_Timestamp = DateTime.Now; patientDiagnoses.Modification_Timestamp = DateTime.Now; patientDiagnoses.R_IsActive = true; patientDiagnoses.Patient_RefID = Parameter.PatientID; patientDiagnoses.Tenant_RefID = securityTicket.TenantID; patientDiagnoses.R_DiagnosedOnDate = DateTime.Now; patientDiagnoses.R_ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); patientDiagnoses.R_PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; patientDiagnoses.Save(Connection, Transaction); ORM_HEC_ACT_PerformedAction_DiagnosisUpdate diagnosisUpdate = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate(); diagnosisUpdate.HEC_ACT_PerformedAction_DiagnosisUpdateID = Guid.NewGuid(); diagnosisUpdate.Creation_Timestamp = DateTime.Now; diagnosisUpdate.Modification_Timestamp = DateTime.Now; diagnosisUpdate.Tenant_RefID = securityTicket.TenantID; diagnosisUpdate.ScheduledExpiryDate = DateTime.Now.AddDays(item.days_valid); diagnosisUpdate.PotentialDiagnosis_RefID = potentialDiagnosis.HEC_DIA_PotentialDiagnosisID; diagnosisUpdate.HEC_Patient_Diagnosis_RefID = patientDiagnoses.HEC_Patient_DiagnosisID; diagnosisUpdate.HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID; diagnosisUpdate.Save(Connection, Transaction); } } } #endregion #region negated foreach (var item in Parameter.deletedDiagnoses) { var patientDiagnosesQuery = new ORM_HEC_Patient_Diagnosis.Query(); patientDiagnosesQuery.IsDeleted = false; patientDiagnosesQuery.R_IsNegated = false; patientDiagnosesQuery.R_IsActive = true; patientDiagnosesQuery.Tenant_RefID = securityTicket.TenantID; patientDiagnosesQuery.HEC_Patient_DiagnosisID = item.PatientDiagnoseID; var patientDiagnoses = ORM_HEC_Patient_Diagnosis.Query.Search(Connection, Transaction, patientDiagnosesQuery).Single(); patientDiagnoses.R_IsNegated = true; patientDiagnoses.R_IsActive = false; patientDiagnoses.Save(Connection, Transaction); var diagnoseUpdateQuery = new ORM_HEC_ACT_PerformedAction_DiagnosisUpdate.Query(); diagnoseUpdateQuery.HEC_Patient_Diagnosis_RefID = item.PatientDiagnoseID; diagnoseUpdateQuery.IsDeleted = false; diagnoseUpdateQuery.IsDiagnosisNegated = false; diagnoseUpdateQuery.Tenant_RefID = securityTicket.TenantID; var patientUpdate = ORM_HEC_ACT_PerformedAction_DiagnosisUpdate.Query.Search(Connection, Transaction, diagnoseUpdateQuery).Single(); patientUpdate.IsDiagnosisNegated = true; patientUpdate.Save(Connection, Transaction); } returnValue.Result = true; #endregion 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_L5DI_SDC_1032 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //get languages for Tenant P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; #region Save if (Parameter.CatalogID == Guid.Empty || Parameter.CatalogID == null) { ORM_HEC_DIA_PotentialDiagnosis_Catalog catalog = new ORM_HEC_DIA_PotentialDiagnosis_Catalog(); catalog.HEC_DIA_PotentialDiagnosis_CatalogID = Guid.NewGuid(); catalog.Creation_Timestamp = DateTime.Now; catalog.IsPrivateCatalog = Parameter.IsPrivateCatalog; catalog.Tenant_RefID = securityTicket.TenantID; catalog.GlobalPropertyMatchingID = Parameter.Catalog_Name; catalog.Catalog_DisplayName = Parameter.Catalog_Name; Dict Catalogname = new Dict("hec_dia_potentialdiagnosis_catalogs"); for (int i = 0; i < DBLanguages.Length; i++) { Catalogname.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Catalog_Name); } catalog.Catalog_Name = Catalogname; catalog.Save(Connection, Transaction); } #endregion else { //Delete if (Parameter.isDeleted) { var catalogQuery = new ORM_HEC_DIA_PotentialDiagnosis_Catalog.Query(); catalogQuery.HEC_DIA_PotentialDiagnosis_CatalogID = Parameter.CatalogID; catalogQuery.IsDeleted = false; catalogQuery.Tenant_RefID = securityTicket.TenantID; var catalog = ORM_HEC_DIA_PotentialDiagnosis_Catalog.Query.Search(Connection, Transaction, catalogQuery).Single(); catalog.IsDeleted = true; catalog.Save(Connection, Transaction); //Delete catalog products table var catalogCodeQuery = new ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query(); catalogCodeQuery.IsDeleted = false; catalogCodeQuery.PotentialDiagnosis_Catalog_RefID = catalog.HEC_DIA_PotentialDiagnosis_CatalogID; catalogCodeQuery.Tenant_RefID = securityTicket.TenantID; ORM_HEC_DIA_PotentialDiagnosis_CatalogCode.Query.SoftDelete(Connection, Transaction, catalogCodeQuery); } //Edit else { var catalogQuery = new ORM_HEC_DIA_PotentialDiagnosis_Catalog.Query(); catalogQuery.IsDeleted = false; catalogQuery.HEC_DIA_PotentialDiagnosis_CatalogID = Parameter.CatalogID; catalogQuery.Tenant_RefID = securityTicket.TenantID; var catalog = ORM_HEC_DIA_PotentialDiagnosis_Catalog.Query.Search(Connection, Transaction, catalogQuery).Single(); catalog.GlobalPropertyMatchingID = Parameter.Catalog_Name; catalog.Catalog_DisplayName = Parameter.Catalog_Name; catalog.IsPrivateCatalog = Parameter.IsPrivateCatalog; Dict Catalogname = new Dict("hec_dia_potentialdiagnosis_catalogs"); for (int i = 0; i < DBLanguages.Length; i++) { Catalogname.AddEntry(DBLanguages[i].CMN_LanguageID, Parameter.Catalog_Name); } catalog.Catalog_Name = Catalogname; catalog.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3CA_IC_1426 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Tenant is already subscribed to this catalog var subscribedCatalogQuery = new ORM_CMN_PRO_SubscribedCatalog.Query(); subscribedCatalogQuery.Tenant_RefID = securityTicket.TenantID; subscribedCatalogQuery.CatalogCodeITL = Parameter.CatalogCodeITL; subscribedCatalogQuery.IsDeleted = false; var alreadySubscribedCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, subscribedCatalogQuery).FirstOrDefault(); if (alreadySubscribedCatalog != null) { throw new Exception("Tenant is already subscribed to this catalog!"); } #endregion #region All tenant's languages var allTenantLanguages = cls_Get_All_Languages.Invoke(Connection, Transaction, securityTicket).Result.ToList(); #endregion #region Get catalog's language or create it // 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 create it if (language == null) { language = new ORM_CMN_Language(); language.CMN_LanguageID = Guid.NewGuid(); language.ISO_639_1 = Parameter.CatalogLanguage_ISO_639_1_codes; language.Name = new Dict(ORM_CMN_Currency.TableName); foreach (var item in allTenantLanguages) { language.Name.AddEntry(item.CMN_LanguageID, "CatalogLanguage - " + Parameter.CatalogLanguage_ISO_639_1_codes); } language.Creation_Timestamp = DateTime.Now; language.Tenant_RefID = securityTicket.TenantID; language.IsDeleted = false; language.Save(Connection, Transaction); } } #endregion #region Get catalog's currency or create it // check if currency with that ISO exists for Tenant var currencyQuery = new ORM_CMN_Currency.Query(); currencyQuery.ISO4127 = Parameter.CatalogCurrency_ISO_4217.ToUpper(); currencyQuery.Tenant_RefID = securityTicket.TenantID; currencyQuery.IsDeleted = false; var currency = ORM_CMN_Currency.Query.Search(Connection, Transaction, currencyQuery).FirstOrDefault(); if (currency == null) { currencyQuery = new ORM_CMN_Currency.Query(); currencyQuery.ISO4127 = Parameter.CatalogCurrency_ISO_4217.ToLower(); currencyQuery.Tenant_RefID = securityTicket.TenantID; currencyQuery.IsDeleted = false; currency = ORM_CMN_Currency.Query.Search(Connection, Transaction, currencyQuery).FirstOrDefault(); if (currency == null) { currency = new ORM_CMN_Currency(); currency.CMN_CurrencyID = Guid.NewGuid(); currency.ISO4127 = Parameter.CatalogCurrency_ISO_4217; currency.Name = new Dict(ORM_CMN_Currency.TableName); foreach (var item in allTenantLanguages) { currency.Name.AddEntry(item.CMN_LanguageID, "CatalogCurrency - " + Parameter.CatalogCurrency_ISO_4217); } currency.Tenant_RefID = securityTicket.TenantID; currency.Creation_Timestamp = DateTime.Now; currency.Save(Connection, Transaction); } } #endregion /* * @save ORM_CMN_PRO_SubscribedCatalog * */ var 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 = Guid.Empty; // This ClassLib is not used by Lucentis 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; subscribedCatalog.SubscribedCatalog_Language_RefID = language.CMN_LanguageID; subscribedCatalog.SubscribedCatalog_Currency_RefID = currency.CMN_CurrencyID; #region Create 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.IsDeleted = false; if (Parameter.IsCatalogPublic == false) { if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.SpecialRequests)) { productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.SpecialRequests); } else if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.Houselist)) { productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); } else if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.Treatment)) { productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); } } else { productGroupQuery.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.ABDA); } 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); if (Parameter.IsCatalogPublic == false) { if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.SpecialRequests)) { productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.SpecialRequests); productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "SpecialRequests Group"); } else if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.Houselist)) { productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); productGroup.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "HauseList Group"); } else if (Parameter.CatalogType == EnumUtils.GetEnumDescription(EPrivateCatalogType.Treatment)) { productGroup.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProductGroup.Treatment); 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"); } 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_Release.Save(Connection, Transaction); /* * @create pricelist * */ ORM_CMN_SLS_Pricelist priceList = new ORM_CMN_SLS_Pricelist(); priceList.CMN_SLS_PricelistID = pricelist_Release.Pricelist_RefID; Dict nameDict = new Dict("cmn_sls_pricelist"); if (Parameter.IsCatalogPublic == false) { for (int i = 0; i < allTenantLanguages.Count; i++) { nameDict.AddEntry(allTenantLanguages[i].CMN_LanguageID, Parameter.CatalogName + "_" + Parameter.ValidFrom_Date.ToShortDateString() + "_" + Parameter.ValidTo_Date.ToShortDateString()); } } else { for (int i = 0; i < allTenantLanguages.Count; i++) { nameDict.AddEntry(allTenantLanguages[i].CMN_LanguageID, EPriceList.ABDAPriceList.ToString()); } priceList.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EPriceList.ABDAPriceList); } priceList.Pricelist_Name = nameDict; priceList.Tenant_RefID = securityTicket.TenantID; priceList.Creation_Timestamp = DateTime.Now; priceList.Save(Connection, Transaction); #endregion #region Create Supplier var CMN_BPT_SupplierID = cls_CreateOrUpdateSupplier_for_ImportedCatalog.Invoke(Connection, Transaction, Parameter.SupplierData, securityTicket).Result; #endregion subscribedCatalog.SubscribedCatalog_PricelistRelease_RefID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; subscribedCatalog.PublishingSupplier_RefID = CMN_BPT_SupplierID; subscribedCatalog.Save(Connection, Transaction); if (Parameter.IsCatalogPublic == false) { var importProductsParam = new P_L3AR_IoUPfSC_1325(); importProductsParam.SubscribedCatalogID = subscribedCatalog.CMN_PRO_SubscribedCatalogID; importProductsParam.CatalogCurrencyID = subscribedCatalog.SubscribedCatalog_Currency_RefID; importProductsParam.CatalogLanguageID = subscribedCatalog.SubscribedCatalog_Language_RefID; importProductsParam.ProductGroupID = productGroup.CMN_PRO_ProductGroupID; importProductsParam.PriceListReleaseID = pricelist_Release.CMN_SLS_Pricelist_ReleaseID; importProductsParam.Products = Parameter.Products; cls_ImportOrUpdate_Products_for_SubscribedCatalog.Invoke(Connection, Transaction, importProductsParam, securityTicket); } else { #region Create Recommended ABDA Sales PriceList var recommendedABDASalsesPrice_priceList = ORM_CMN_SLS_Pricelist.Query.Search(Connection, Transaction, new ORM_CMN_SLS_Pricelist.Query() { GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EPriceList.RecommendedABDASalesPriceList), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (recommendedABDASalsesPrice_priceList == null) { recommendedABDASalsesPrice_priceList = new ORM_CMN_SLS_Pricelist(); recommendedABDASalsesPrice_priceList.CMN_SLS_PricelistID = Guid.NewGuid(); recommendedABDASalsesPrice_priceList.Pricelist_Name = new Dict("cmn_sls_pricelist"); foreach (var lang in allTenantLanguages) { recommendedABDASalsesPrice_priceList.Pricelist_Name.AddEntry(lang.CMN_LanguageID, EPriceList.RecommendedABDASalesPriceList.ToString()); } recommendedABDASalsesPrice_priceList.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EPriceList.RecommendedABDASalesPriceList); recommendedABDASalsesPrice_priceList.Tenant_RefID = securityTicket.TenantID; recommendedABDASalsesPrice_priceList.Creation_Timestamp = DateTime.Now; recommendedABDASalsesPrice_priceList.Save(Connection, Transaction); ORM_CMN_SLS_Pricelist_Release recommendedABDASalsesPrice_pricelist_Release = new ORM_CMN_SLS_Pricelist_Release(); recommendedABDASalsesPrice_pricelist_Release.CMN_SLS_Pricelist_ReleaseID = Guid.NewGuid(); recommendedABDASalsesPrice_pricelist_Release.Release_Version = "v1"; recommendedABDASalsesPrice_pricelist_Release.IsPricelistAlwaysActive = true; recommendedABDASalsesPrice_pricelist_Release.Tenant_RefID = securityTicket.TenantID; recommendedABDASalsesPrice_pricelist_Release.Creation_Timestamp = DateTime.Now; recommendedABDASalsesPrice_pricelist_Release.Pricelist_RefID = recommendedABDASalsesPrice_priceList.CMN_SLS_PricelistID; recommendedABDASalsesPrice_pricelist_Release.Save(Connection, Transaction); } #endregion } return(returnValue); #endregion UserCode }