SELECT fldNESector AS Sector, fldPCTCode As PCT, "Discharges" AS Source, fldHRGCode AS HRG,ConvOPCS4(fldOPCS4code) AS OPCS4, FinYear([fldDischargeDate]) AS [Financial Year], FinMonth([fldDischargeDate]) As Period, Year([fldDischargeDate]) AS [Year], Month([fldDischargeDate]) AS [Month], Format(Format([fldDischargeDate],"ww"),"00") AS Wk, 1 AS [Count],[fldGPCodeNetcare] AS GMC,
[fldPracticeCodeNetcare] as Practice
FROM TbdDischarges
WHERE (((fldTreated)=-1));
UNION ALL SELECT TbdDischarges.fldNESector AS Sector, QryAllAuthorsations.fldPCT AS PCT, "Additionals" AS Source, QryAllAuthorsations.fldHRGCode AS HRG, QryAllAuthorsations.OPCS4, FinYear([fldDischargeDate]) AS [Financial Year], FinMonth([fldDischargeDate]) AS Period, Year([fldDischargeDate]) AS [Year], Month([fldDischargeDate]) AS [Month], Format(Format([fldDischargeDate],"ww"),"00") AS Wk, 1 AS [Count], TbdDischarges.fldGPCodeNetcare AS GMC, TbdDischarges.fldPracticeCodeNetcare AS Practice
FROM QryAllAuthorsations INNER JOIN TbdDischarges ON QryAllAuthorsations.WorkFlowId = TbdDischarges.fldWorkflowID
WHERE (((QryAllAuthorsations.fldChargeable)=-1));
UNION ALL SELECT tbdPreOpData.fldNESector AS Sector, tbdPreOpData.fldPCTCode AS PCT, "Pre-Ops" AS Source, tbdPreOpData.fldHRGCode AS HRG, ConvOPCS4(fldOPCS4Code) AS OPCS4, FinYear([fldClinicAppointmentDate]) AS [Financial Year], FinMonth([fldClinicAppointmentDate]) AS Period, Year([fldClinicAppointmentDate]) AS [Year], Month([fldClinicAppointmentDate]) AS [Month], Format(Format([fldClinicAppointmentDate],"ww"),"00") AS Wk, 1 AS [Count], tbdPreOpData.fldGPCodeNetcare AS GMC, tbdPreOpData.fldPracticeCodeNetcare AS Practice
FROM tbdPreOpData
WHERE (((tbdPreOpData.fldPatientAttended)=True));