Hi everybody,
[Access 2003]
I've got a large database that I'm using to track timeliness for a particular set of forms (that aren't static and will indeed change in the future) in a patient's chart. The forms I'm looking at are a selection indicated be yes/no field on the forms table (identified as 'CCC').
I've got multiple queries set up that show me the data that I need, but I noticed that for small date ranges in the parameters it will exclude forms that don't have timeliness issues (no timeliness issues for a form is a good thing, but not having them show up on the report isn't).
I would like to add these forms, but I'm having a lot of trouble. I know it involves LEFT JOINS, but I've currently got the query with all the row values left joined to the query with the data.
I'm attaching the SQL for each of the 4 queries:
qryTimeliness - shows all records for the 'CCC' forms
qryTimelinessFormCount - shows a total for the timely/not timely forms for each patient
qryTimelinessFormByPatient - shows the 'Not Timely' forms for each patient along with the unit they reside on
qryTimelinessSummary - and last, but not least, the crosstab (I have parameters in the query so that I can show the date range selected on the final report)
I'm sorry for the clutter, but I appreciate any help that anyone can throw my way. I'm completely stumped and I have a deadline to submit this by the end of today.
I can send a picture of the relationships between my tables if that would help.
Thanks...
[Access 2003]
I've got a large database that I'm using to track timeliness for a particular set of forms (that aren't static and will indeed change in the future) in a patient's chart. The forms I'm looking at are a selection indicated be yes/no field on the forms table (identified as 'CCC').
I've got multiple queries set up that show me the data that I need, but I noticed that for small date ranges in the parameters it will exclude forms that don't have timeliness issues (no timeliness issues for a form is a good thing, but not having them show up on the report isn't).
I would like to add these forms, but I'm having a lot of trouble. I know it involves LEFT JOINS, but I've currently got the query with all the row values left joined to the query with the data.
I'm attaching the SQL for each of the 4 queries:
qryTimeliness - shows all records for the 'CCC' forms
SQL:
SELECT DISTINCT
qryPatientDetail.PatientDetailID, qryPatientDetail.Episode,
qryPatientDetail.DischargeDate, NZ([FormName]) AS Form,
qryForms.FormName, qryPrograms.ProgramInitials,
IIf(([ComplianceCalculationConsideration]=True),True,False) AS CCC,
qryEpisodeDetail.CorrectedDate, 1 AS TotalCharts,
qryDeficiencyType.DeficiencyType,
IIf([deficiencytype]="Not Done in Timeframe *UNC",1,0) AS Timeframe
FROM
(qryForms RIGHT JOIN ((qryPatientDetail LEFT JOIN qryEpisodeDetail
ON qryPatientDetail.PatientDetailID = qryEpisodeDetail.PatientDetailIDFK)
LEFT JOIN qryDeficiencyType ON
qryEpisodeDetail.DeficiencyIDFK = qryDeficiencyType.DeficiencyTypeID)
ON qryForms.FormID = qryEpisodeDetail.FormIDFK)
LEFT JOIN qryPrograms ON qryPatientDetail.ProgramIDFK = qryPrograms.ProgramID
WHERE
(((IIf(([ComplianceCalculationConsideration]=True),True,False))=True))
ORDER BY
qryPatientDetail.PatientDetailID, qryPatientDetail.DischargeDate;
qryTimelinessFormCount - shows a total for the timely/not timely forms for each patient
SQL:
SELECT DISTINCT
qryForms.FormName, qryTimeliness.PatientDetailID,
Sum(qryTimeliness.Timeframe) AS [Count]
FROM
qryForms RIGHT JOIN qryTimeliness
ON qryForms.FormName = qryTimeliness.FormName
GROUP BY
qryForms.FormName, qryTimeliness.PatientDetailID;
qryTimelinessFormByPatient - shows the 'Not Timely' forms for each patient along with the unit they reside on
SQL:
SELECT DISTINCT
qryPatientDetail.PatientDetailID, IIf([count]>0,'Not Timely','Timely') AS Result,
qryPrograms.ProgramInitials, qryPatientDetail.DischargeDate,
qryTimelinessFormCount.FormName
FROM
(qryPrograms INNER JOIN qryPatientDetail
ON qryPrograms.ProgramID = qryPatientDetail.ProgramIDFK)
LEFT JOIN qryTimelinessFormCount
ON qryPatientDetail.PatientDetailID = qryTimelinessFormCount.PatientDetailID
GROUP BY
qryPatientDetail.PatientDetailID, IIf([count]>0,'Not Timely','Timely'),
qryPrograms.ProgramInitials, qryPatientDetail.DischargeDate, qryTimelinessFormCount.FormName
HAVING
(((IIf([count]>0,'Not Timely','Timely'))="Not Timely"))
ORDER BY
qryPatientDetail.PatientDetailID;
qryTimelinessSummary - and last, but not least, the crosstab (I have parameters in the query so that I can show the date range selected on the final report)
SQL:
PARAMETERS
[Forms]![frmReportCompliance]![BeginningDate] DateTime,
[Forms]![frmReportCompliance]![EndingDate] DateTime;
TRANSFORM
Count(qryTimelinessFormByPatient.Result) AS CountOfResult
SELECT
qryFormsCCC.FormName,
Forms!frmReportCompliance!BeginningDate AS BeginningDate,
Forms!frmReportCompliance!EndingDate AS EndingDate,
Count(qryTimelinessFormByPatient.Result) AS [Total by Form]
FROM
qryFormsCCC LEFT JOIN qryTimelinessFormByPatient
ON qryFormsCCC.FormName = qryTimelinessFormByPatient.FormName
WHERE
(((qryTimelinessFormByPatient.DischargeDate)
Between [Forms]![frmReportCompliance]![BeginningDate]
And [Forms]![frmReportCompliance]![EndingDate]))
GROUP BY
qryFormsCCC.FormName,
Forms!frmReportCompliance!BeginningDate,
Forms!frmReportCompliance!EndingDate,
Forms!frmReportCompliance!BeginningDate,
Forms!frmReportCompliance!EndingDate
PIVOT
qryTimelinessFormByPatient.ProgramInitials In
("AFP","BMTP","CAP","Competency","EEP","GPP","MDP","RIDR","SBP","SLRP");
I'm sorry for the clutter, but I appreciate any help that anyone can throw my way. I'm completely stumped and I have a deadline to submit this by the end of today.
I can send a picture of the relationships between my tables if that would help.
Thanks...