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

            FR_CAS_GTYOctCIfL_1939 functionReturn = new FR_CAS_GTYOctCIfL_1939();

            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_Get_TreatmentYearOctCount_IndependentForLocalization", ex);
            }
            return(functionReturn);
        }
Beispiel #2
0
        protected static FR_CAS_GTYOctCIfL_1939 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_GTYOctCIfL_1939 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_CAS_GTYOctCIfL_1939();
            //Put your code here
            var relevant_oct_actions = cls_Get_RelevantActionIDs_for_PatientID.Invoke(Connection, Transaction, new P_CAS_GRAIDsfPID_1352()
            {
                PatientID              = Parameter.PatientID,
                ActionTypeID           = Parameter.OctPlannedActionTypeID,
                TreatmentYearEndDate   = Parameter.TreatmentYearEndDate,
                TreatmentYearStartDate = Parameter.TreatmentYearStartDate
            }, securityTicket).Result.Where(t => t.action_id != Parameter.OctActionIdToOmit).ToList();

            var relevant_oct_actions_grouped_by_case = relevant_oct_actions.GroupBy(t => t.case_id).ToDictionary(t => t.Key, t => t.ToList());

            var oct_count = 0;
            if (relevant_oct_actions.Any())
            {
                var case_ids = relevant_oct_actions.Select(t => t.case_id).ToArray();

                var oct_fs_statuses = cls_Get_OctFsStatuses_for_PatientID_in_TimeSpan_LocalizationIndependent.Invoke(Connection, Transaction, new P_CAS_GOctFSSfPIDiTSLI_1117()
                {
                    DateFrom  = Parameter.TreatmentYearStartDate,
                    DateTo    = Parameter.TreatmentYearEndDate,
                    PatientID = Parameter.PatientID
                }, securityTicket).Result.GroupBy(r => r.case_id).ToDictionary(r => r.Key, r => r.ToList());

                foreach (var case_oct_actions in relevant_oct_actions_grouped_by_case)
                {
                    if (oct_fs_statuses.ContainsKey(case_oct_actions.Key))
                    {
                        var fs_statuses = oct_fs_statuses[case_oct_actions.Key];
                        for (var i = 0; i < case_oct_actions.Value.Count; i++)
                        {
                            var fs_status_code = fs_statuses[i].fs_status;
                            if (fs_status_code != 8 && fs_status_code != 11 && fs_status_code != 17)
                            {
                                oct_count++;
                            }
                        }
                    }
                }
            }

            returnValue.Result = new CAS_GTYOctCIfL_1939();
            returnValue.Result.fs_status_count = oct_count;

            return(returnValue);

            #endregion UserCode
        }