public void Generate()
        {
            HQLHeader cHQLHeader = new HQLHeader();

            // Pass some configuration items to the Header
            cHQLHeader.SetID = homeForm.sSetID;
            cHQLHeader.SetDescription = homeForm.sSetDescription;

            cHQLHeader.ScheduledQuery = homeForm.ifCbScheduled.Checked;
            cHQLHeader.ScheduledStart = homeForm.ifDtScheduledStart.Value;
            cHQLHeader.ScheduledEnd = homeForm.ifDtScheduledEnd.Value;
            cHQLHeader.ScheduledPeriod = Convert.ToInt16(homeForm.ifTbScheduledPeriod.Text);
            cHQLHeader.ScheduledWeekMonth = homeForm.ifCbScheduledWeekMonth.Text;

            cHQLHeader.RemoteItems = homeForm.ifCbRemote.Checked;
            cHQLHeader.PracticeCode = homeForm.ifTbPracticeCode.Text;
            cHQLHeader.Media = homeForm.ifCbMedia.Text;

            cHQLHeader.SetCodeSet(homeForm.ifCbSystemType.Text);

            homeForm.fLogFile.WriteLine("Creating HQL Files");

            GenerateCohort(ref cHQLHeader);

            GenerateJournal(ref cHQLHeader, homeForm.cCohorts.GlobalCohort);

            if (homeForm.ifCbEncounterGen.Checked)
            {
                GenerateEncounters(ref cHQLHeader, homeForm.cCohorts.GlobalCohort);
            }

            if (homeForm.ifCbReferralGen.Checked)
            {
                GenerateReferrals(ref cHQLHeader, homeForm.cCohorts.GlobalCohort);
            }
            //homeForm.fLogFile.WriteLine("Querynames: " + cHQLHeader.ListQueries());
            cHQLHeader.Clear();
        }