protected static FR_L5EX_GED_1024 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EX_GED_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5EX_GED_1024();
            returnValue.Result = new L5EX_GED_1024();

            //observations
            var madeObservationsForPerformedActionID = ORM_HEC_ACT_PerformedAction_MadeObservation.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction_MadeObservation.Query()
            {
                IsDeleted    = false,
                Tenant_RefID = securityTicket.TenantID,
                HEC_ACT_PerformedAction_RefID = Parameter.ExaminationID
            }).ToArray();

            List <L5EX_GED_1024_patient_observations> observaionList = new List <L5EX_GED_1024_patient_observations>();

            foreach (var item in madeObservationsForPerformedActionID)
            {
                L5EX_GED_1024_patient_observations observation = new L5EX_GED_1024_patient_observations();
                observation.id = item.HEC_ACT_PerformedAction_ObservationID.ToString();
                if (item.Comment == null)
                {
                    var potentialObservationQuery = new ORM_HEC_PotentialObservation.Query();
                    potentialObservationQuery.HEC_PotentialObservationID = item.PotentialObservation_RefID;
                    potentialObservationQuery.IsDeleted    = false;
                    potentialObservationQuery.Tenant_RefID = securityTicket.TenantID;
                    var potentialObdervation = ORM_HEC_PotentialObservation.Query.Search(Connection, Transaction, potentialObservationQuery).First();
                    observation.name = potentialObdervation.Observation_Text.Contents[0].Content;
                }
                else
                {
                    observation.name = item.Comment;
                }
                observaionList.Add(observation);
            }
            returnValue.Result.observations = observaionList.ToArray();

            //diagnoses
            var patient_diagnoses_list = cls_Get_Examination_Diagnoses.Invoke(Connection, Transaction, new P_L5EX_GED_1640
            {
                ExaminationID = Parameter.ExaminationID,
                PatientID     = Parameter.PatientID
            }, securityTicket).Result.ToList();

            List <L5EX_GED_1024_patient_diagnoses> diagnoseList = new List <L5EX_GED_1024_patient_diagnoses>();
            foreach (var item in patient_diagnoses_list)
            {
                L5EX_GED_1024_patient_diagnoses diagnose = new L5EX_GED_1024_patient_diagnoses();
                diagnose.id   = item.HEC_Patient_DiagnosisID.ToString();
                diagnose.name = item.ICD10_Code + " " + item.PotentialDiagnosis_Name.Contents[0].Content;
                diagnoseList.Add(diagnose);
            }

            returnValue.Result.patient_diagnoses = diagnoseList.ToArray();

            //medications

            var productList = cls_Get_MedicationProduct_for_PerformedActionID.Invoke(Connection, Transaction, new P_L5ME_GMPfPAID_1133
            {
                PerformedActionID = Parameter.ExaminationID
            }, securityTicket).Result.ToList();

            List <L5EX_GED_1024_patient_medications> medication_list = new List <L5EX_GED_1024_patient_medications>();

            foreach (var item in productList)
            {
                L5EX_GED_1024_patient_medications medication = new L5EX_GED_1024_patient_medications();
                medication.id    = item.HEC_ACT_PerformedAction_MedicationUpdateID.ToString();
                medication.name  = item.Product_Name.Contents[0].Content + " " + item.DosageForm_Name.Contents[0].Content + " " + item.DosageText;
                medication.image = item.IsMedicationDeactivated == false ? "../Images/icons/added.png" : "../Images/icons/removed.png";
                medication_list.Add(medication);
            }

            P_L5EMR_GSfEID_1210 substancesParameter = new P_L5EMR_GSfEID_1210();
            substancesParameter.PerformedActionID = Parameter.ExaminationID;
            var substanceList = cls_Get_Substances_for_ExaminationID.Invoke(Connection, Transaction, substancesParameter, securityTicket).Result;

            foreach (var item in substanceList)
            {
                L5EX_GED_1024_patient_medications medication = new L5EX_GED_1024_patient_medications();
                medication.id    = item.HEC_ACT_PerformedAction_MedicationUpdateID.ToString();
                medication.name  = item.GlobalPropertyMatchingID + " " + item.IfSubstance_Strength + " " + item.ISOCode;
                medication.image = item.IsMedicationDeactivated == false ? "../Images/icons/added.png" : "../Images/icons/removed.png";
                medication_list.Add(medication);
            }

            returnValue.Result.medications = medication_list.ToArray();

            //aftercares

            var aftercareList = cls_Get_Followups_for_PatientID_and_ExaminationID.Invoke(Connection, Transaction, new P_L5EX_GFPIDEID_1805 {
                ExaminationID = Parameter.ExaminationID,
                PatientID     = Parameter.PatientID
            }, securityTicket).Result;


            List <L5EX_GED_1024_patient_aftercares> aftercare_list = new List <L5EX_GED_1024_patient_aftercares>();
            foreach (var item in aftercareList)
            {
                L5EX_GED_1024_patient_aftercares aftercare = new L5EX_GED_1024_patient_aftercares();
                aftercare.id     = item.HEC_ACT_PlannedActionID.ToString();
                aftercare.date   = item.date.ToShortDateString();
                aftercare.reason = item.FollowupReason;
                aftercare_list.Add(aftercare);
            }

            returnValue.Result.aftercares = aftercare_list.ToArray();

            //Referral
            var referralList = cls_Get_Examination_Referrals.Invoke(Connection, Transaction, new P_L5EX_GER_1744 {
                ExaminationID = Parameter.ExaminationID
            }, securityTicket).Result;
            List <L5EX_GED_1024_patient_referrals> referral_list = new List <L5EX_GED_1024_patient_referrals>();
            foreach (var item in referralList)
            {
                L5EX_GED_1024_patient_referrals referral = new L5EX_GED_1024_patient_referrals();
                referral.id = item.id.ToString();
                if (item.OrganizationalUnit_Name_DictID.Contents.Count != 0)
                {
                    referral.medical_practice = item.OrganizationalUnit_Name_DictID.Contents[0].Content;
                }
                if (item.MedicalPracticeType_Name.Contents.Count != 0)
                {
                    referral.medical_practice_type = item.MedicalPracticeType_Name.Contents[0].Content;
                }
                referral_list.Add(referral);
            }

            returnValue.Result.referrals = referral_list.ToArray();


            return(returnValue);

            #endregion UserCode
        }
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L5EX_GED_1024 Invoke(DbConnection Connection, DbTransaction Transaction, P_L5EX_GED_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5EX_GED_1024 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5EX_GED_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5EX_GED_1024 functionReturn = new FR_L5EX_GED_1024();

            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 ex;
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L5EX_GED_1024 Invoke(string ConnectionString, P_L5EX_GED_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }