Here's the SQL code!! Don't laugh....the query may be long & complex, but
we
do get all the data we ask for in the query result. The issue is that the
Radiotherapy and Antineoplastic items don't appear in the MailMerge
document,
but the Surgery items do:
SELECT DISTINCTROW qryAllPatientAndDiseaseRecords.Surname,
qryAllPatientAndDiseaseRecords.[Given Name],
qryAllPatientAndDiseaseRecords.Title, qryAllPatientAndDiseaseRecords.Sex,
qryAllPatientAndDiseaseRecords.[Date Of Birth],
qryAllPatientAndDiseaseRecords.[Country of Birth],
qryAllPatientAndDiseaseRecords.[Indigenous Status Code],
qryAllPatientAndDiseaseRecords.[Street/Address],
qryAllPatientAndDiseaseRecords.Suburb,
qryAllPatientAndDiseaseRecords.Postcode,
qryAllPatientAndDiseaseRecords.[Date
of Death], qryAllPatientAndDiseaseRecords.[Disease Record Id],
qryAllPatientAndDiseaseRecords.[Date of Primary Cancer Diagnosis],
qryAllPatientAndDiseaseRecords.[Definitive Site of Cancer (ICD Code],
xtblPrimarySiteLookup.Site, qryAllPatientAndDiseaseRecords.[Cancer Site
Group], qryAllPatientAndDiseaseRecords.[Best Basis for Diagnosis],
qryAllPatientAndDiseaseRecords.Laterality,
qryAllPatientAndDiseaseRecords.[Histopathological Grade],
qryAllPatientAndDiseaseRecords.[Morphology of Cancer (ICD Code)],
qryAllPatientAndDiseaseRecords.[Morphology of Cancer],
qryAllPatientAndDiseaseRecords.[T Stage],
qryAllPatientAndDiseaseRecords.[N
Stage], qryAllPatientAndDiseaseRecords.[M Stage],
qryAllPatientAndDiseaseRecords.[Other Staging Basis],
qryAllPatientAndDiseaseRecords.[Other Staging Scheme],
qryAllPatientAndDiseaseRecords.[Scheme Group],
qryAllPatientAndDiseaseRecords.[Disease Entry Status],
qryProcedureCodesTabularWithSurgeon.[Facility Code],
qryProcedureCodesTabularWithSurgeon.MRN,
qryProcedureCodesTabularWithSurgeon.[AMO Registration Number],
qryProcedureCodesTabularWithSurgeon.internet_display_name,
qryProcedureCodesTabularWithSurgeon.[Admission Date],
qryProcedureCodesTabularWithSurgeon.Procedure1,
qryProcedureCodesTabularWithSurgeon.[Surgical Procedure Descriptor 1],
qryProcedureCodesTabularWithSurgeon.[Procedure 2],
qryProcedureCodesTabularWithSurgeon.[Surgical Procedure Descriptor 2],
qryProcedureCodesTabularWithSurgeon.[Procedure 3],
qryProcedureCodesTabularWithSurgeon.[Surgical Procedure Descriptor 3],
qryProcedureCodesTabularWithSurgeon.[Discharge Date],
qryRadioFilteredByDiseaseCodeRange.[Facility Code],
qryRadioFilteredByDiseaseCodeRange.MRN,
qryRadioFilteredByDiseaseCodeRange.[AMO Registration Number],
qryRadioFilteredByDiseaseCodeRange.internet_display_name,
qryRadioFilteredByDiseaseCodeRange.[Radiotherapy Start Date],
qryRadioFilteredByDiseaseCodeRange.[Radiotherapy Type],
qryRadioFilteredByDiseaseCodeRange.[Radiation Dose],
qryRadioFilteredByDiseaseCodeRange.[Number of Radiation Fractions],
qryRadioFilteredByDiseaseCodeRange.[Radiotherapy End Date],
qryRadioFilteredByDiseaseCodeRange.[Date of Referral to Specialist],
qryRadioFilteredByDiseaseCodeRange.[Date of Consultation with Specialist],
qryChemoFilteredByDiseaseCodeRange.[Facility Code],
qryChemoFilteredByDiseaseCodeRange.MRN,
qryChemoFilteredByDiseaseCodeRange.[AMO Registration Number],
qryChemoFilteredByDiseaseCodeRange.internet_display_name,
qryChemoFilteredByDiseaseCodeRange.[Anti-Neoplastic Start Date],
qryChemoFilteredByDiseaseCodeRange.[Protocol Unique Identifier],
qryChemoFilteredByDiseaseCodeRange.[Protocol Acronym],
qryChemoFilteredByDiseaseCodeRange.[Number of Cycles],
qryChemoFilteredByDiseaseCodeRange.[Anti-Neoplastic End Date],
qryChemoFilteredByDiseaseCodeRange.[Date of Referral to Specialist],
qryChemoFilteredByDiseaseCodeRange.[Date of Consultation with Specialist],
dtblAllClinCRQOCRecords.[Date First Clinical Trial Enrolment],
dtblAllClinCRQOCRecords.[Date First MTeam Consultation],
dtblAllClinCRQOCRecords.[Palliative Care Status],
dtblAllClinCRQOCRecords.[Date of Referral to Palliative Care],
dtblAllClinCRQOCRecords.[Performance Status Code at Diag],
dtblAllClinCRQOCRecords.[Psycho Social Referral],
dtblAllClinCRQOCRecords.[Distress Thermometer Score]
FROM ((((qryAllPatientAndDiseaseRecords INNER JOIN xtblPrimarySiteLookup
ON
qryAllPatientAndDiseaseRecords.[Definitive Site of Cancer (ICD Code] =
xtblPrimarySiteLookup.ICD10Code) LEFT JOIN
qryProcedureCodesTabularWithSurgeon ON
qryAllPatientAndDiseaseRecords.[Disease Record Id] =
qryProcedureCodesTabularWithSurgeon.[Disease Record ID]) LEFT JOIN
qryRadioFilteredByDiseaseCodeRange ON
qryAllPatientAndDiseaseRecords.[Disease
Record Id] = qryRadioFilteredByDiseaseCodeRange.[Disease Record Id]) LEFT
JOIN qryChemoFilteredByDiseaseCodeRange ON
qryAllPatientAndDiseaseRecords.[Disease Record Id] =
qryChemoFilteredByDiseaseCodeRange.[Disease Record ID]) LEFT JOIN
dtblAllClinCRQOCRecords ON qryAllPatientAndDiseaseRecords.[Disease Record
Id]
= dtblAllClinCRQOCRecords.[Disease Record Id]
WHERE (((qryAllPatientAndDiseaseRecords.[Definitive Site of Cancer (ICD
Code]) Between "C51" And "C59.9" Or
(qryAllPatientAndDiseaseRecords.[Definitive Site of Cancer (ICD Code])
Like
"C48*" Or (qryAllPatientAndDiseaseRecords.[Definitive Site of Cancer (ICD
Code])="C45.1"))
ORDER BY qryAllPatientAndDiseaseRecords.Surname;
Thanks,
Sally.--
Sally Smith
Peter Jamieson said:
Do you have the SQL code for the query?