Beispiel #1
0
        protected static FR_CAS_GTYOctC_1939 Execute(DbConnection Connection, DbTransaction Transaction, P_CAS_GTYOctC_1939 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_CAS_GTYOctC_1939();
            //Put your code here
            var relevant_oct_actions = cls_Get_RelevantActionIDs_for_PatientID_and_LocalizationCode.Invoke(Connection, Transaction, new P_CAS_GRAIDsfPIDaLC_1011()
            {
                LocalizationCode       = Parameter.LocalizationCode,
                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).Distinct().ToArray();
                var oct_fs_statuses = cls_Get_OctFsStatuses_for_PatientID_in_TimeSpan.Invoke(Connection, Transaction, new P_CAS_GOctFSSfPIDiTS_1103s()
                {
                    DateFrom         = Parameter.TreatmentYearStartDate,
                    DateTo           = Parameter.TreatmentYearEndDate,
                    LocalizationCode = Parameter.LocalizationCode,
                    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_GTYOctC_1939();
            returnValue.Result.fs_status_count = oct_count;

            return(returnValue);

            #endregion UserCode
        }
Beispiel #2
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_CAS_GTYOctC_1939 Invoke(DbConnection Connection, P_CAS_GTYOctC_1939 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
Beispiel #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_CAS_GTYOctC_1939 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_CAS_GTYOctC_1939 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_CAS_GTYOctC_1939 functionReturn = new FR_CAS_GTYOctC_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", ex);
            }
            return(functionReturn);
        }