Esempio n. 1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_CAS_CDO_1250 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_CAS_CDO_1250 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_CAS_CDO_1250 functionReturn = new FR_CAS_CDO_1250();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Cancel_Drug_Order", ex);
            }
            return(functionReturn);
        }
Esempio n. 2
0
        protected static FR_CAS_CDO_1250 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_CDO_1250 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_CAS_CDO_1250();
            returnValue.Result = new CAS_CDO_1250();
            //Put your code here

            var treatment_planned_action_id = cls_Get_Treatment_Planned_Action_for_CaseID.Invoke(Connection, Transaction, new P_CAS_GTPAfCID_0946()
            {
                CaseID = Parameter.case_id
            }, securityTicket).Result;

            var drug_order_status_latestQ = new ORM_ORD_PRC_ProcurementOrder_Status.Query();
            drug_order_status_latestQ.ORD_PRC_ProcurementOrder_StatusID = Parameter.ord_drug_order_header.Current_ProcurementOrderStatus_RefID;
            drug_order_status_latestQ.Tenant_RefID = securityTicket.TenantID;
            drug_order_status_latestQ.IsDeleted    = false;

            var drug_order_status_latest = ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, drug_order_status_latestQ).SingleOrDefault();

            if (drug_order_status_latest.Status_Code == 6)
            {
                var previous_status = cls_Get_Previous_Order_Status_for_HeaderID.Invoke(Connection, Transaction, new P_OR_GPOSfHID_1347()
                {
                    HeaderID = Parameter.ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID
                }, securityTicket).Result;
                returnValue.Result.previous_status = previous_status != null ? "MO" + previous_status.OrderStatus : "";
            }
            else
            {
                returnValue.Result.previous_status = "MO" + drug_order_status_latest.Status_Code;
            }

            var cancellation_code   = drug_order_status_latest.Status_Code == 0 ? 9 : 6;
            var cancellation_status = String.Format("MO{0}", cancellation_code);

            var new_status = new ORM_ORD_PRC_ProcurementOrder_Status();
            new_status.Status_Code = cancellation_code;
            new_status.GlobalPropertyMatchingID = String.Format("mm.doc.connect.drug.order.status.{0}", cancellation_status.ToLower());
            new_status.Tenant_RefID             = securityTicket.TenantID;
            new_status.Modification_Timestamp   = DateTime.Now;

            Parameter.ord_drug_order_header.Current_ProcurementOrderStatus_RefID = new_status.ORD_PRC_ProcurementOrder_StatusID;
            Parameter.ord_drug_order_header.Save(Connection, Transaction);

            new_status.Status_Name = new Dict(ORM_ORD_PRC_ProcurementOrder_Status.TableName);

            foreach (var lang in Parameter.all_languagesL)
            {
                new_status.Status_Name.AddEntry(lang.CMN_LanguageID, cancellation_status);
            }

            new_status.Save(Connection, Transaction);

            var new_status_history_entry = new ORM_ORD_PRC_ProcurementOrder_StatusHistory();
            new_status_history_entry.IsStatus_Canceled                     = true;
            new_status_history_entry.Tenant_RefID                          = securityTicket.TenantID;
            new_status_history_entry.Modification_Timestamp                = DateTime.Now;
            new_status_history_entry.ProcurementOrder_Header_RefID         = Parameter.ord_drug_order_header.ORD_PRC_ProcurementOrder_HeaderID;
            new_status_history_entry.ProcurementOrder_Status_RefID         = new_status.ORD_PRC_ProcurementOrder_StatusID;
            new_status_history_entry.TriggeredAt_Date                      = DateTime.Now;
            new_status_history_entry.TriggeredBy_BusinessParticipant_RefID = Parameter.created_by_bpt;

            new_status_history_entry.Save(Connection, Transaction);

            var ord_drug_order_position_history_entry = new ORM_ORD_PRC_ProcurementOrder_Position_History();
            ord_drug_order_position_history_entry.Tenant_RefID = securityTicket.TenantID;
            ord_drug_order_position_history_entry.ProcurementOrder_Position_RefID = Parameter.procurement_order_position_id;
            ord_drug_order_position_history_entry.IsRemoved = true;
            ord_drug_order_position_history_entry.Modification_Timestamp = DateTime.Now;

            ord_drug_order_position_history_entry.Save(Connection, Transaction);

            var practice_invoice_universal_property = ORM_HEC_CAS_Case_UniversalProperty.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case_UniversalProperty.Query()
            {
                GlobalPropertyMatchingID = "mm.doc.connect.case.practice.invoice",
                Tenant_RefID             = securityTicket.TenantID,
                IsDeleted = false
            }).SingleOrDefault();

            var practice_invoice_universal_property_value = ORM_HEC_CAS_Case_UniversalPropertyValue.Query.Search(Connection, Transaction, new ORM_HEC_CAS_Case_UniversalPropertyValue.Query()
            {
                HEC_CAS_Case_UniversalProperty_RefID = practice_invoice_universal_property.HEC_CAS_Case_UniversalPropertyID,
                HEC_CAS_Case_RefID = Parameter.case_id,
                Tenant_RefID       = securityTicket.TenantID,
                IsDeleted          = false
            }).SingleOrDefault();

            if (practice_invoice_universal_property_value != null)
            {
                practice_invoice_universal_property_value.IsDeleted = true;
                practice_invoice_universal_property_value.Modification_Timestamp = DateTime.Now;

                practice_invoice_universal_property_value.Save(Connection, Transaction);
            }

            return(returnValue);

            #endregion UserCode
        }