Here are the tables I used, in their most trivial form:
Code:
Table tblNurse:
NurseID : Key
NurseName : Text Name
Table tblPatient:
PatientID : Key
PatientName : Text Name
Table tblRound:
ID : Key
NurseID : Foreign Key to tblNurse
PatientID : Foreign Key to tblPatient
RoundDate : Date/Time
Here are two queries. The first, qryNDayRound, will give the total number of rounds that a nurse performed that day. The second, qryPDayRound, will give the total number of rounds that a patient received that day.
Code:
Query qryNDayRound:
SELECT tblRound.NurseID, tblRound.RoundDate, Count(*) AS NDayRdSum
FROM tblRound
GROUP BY tblRound.NurseID, tblRound.RoundDate;
Query qryPDayRound:
SELECT tblRound.PatientID, tblRound.RoundDate, Count(*) AS PDayRdSum
FROM tblRound
GROUP BY tblRound.PatientID, tblRound.RoundDate;
The next query (qryRound1) gives the information for each Round, along with three extra anallysis fields at the end -
* RdCount is 1, for the Round itself.
* RdCountP is the number of rounds that the same patient received that day, from qryPDayRound,
* RdCountN is the number of rounds that nurse did that day, from qryNDayRound.
Code:
qryRound1:
SELECT
tblNurse.Nursename AS RdNurse,
tblNurse.NurseID AS RdNurseID,
tblPatient.PatientName AS RdPatient,
tblPatient.PatientID AS RdPatientID,
tblRound.RoundDate AS RdDate,
1 AS RdCount,
QP.PDayRdSum AS RdCountP,
QN.NDayRdSum AS RdCountN
FROM
tblPatient INNER JOIN
(tblNurse INNER JOIN
(qryNDayRound AS QN INNER JOIN
(qryPDayRound AS QP INNER JOIN tblRound
ON ((QP.RoundDate = tblRound.RoundDate)
AND (QP.PatientID = tblRound.PatientID)))
ON ((QN.RoundDate = tblRound.RoundDate)
AND (QN.NurseID = tblRound.NurseID))
ON tblNurse.NurseID = tblRound.NurseID)
ON tblPatient.PatientID = tblRound.PatientID;
Here is the final query that gives you your analysis. This particular one is coded to give you the percent of the visits that day for that one patient which were performed by a given Nurse.
Code:
qryRound1_Crosstab:
TRANSFORM Sum(QR.RdCount/QR.RdCountP) AS PctOfPDayRdCount
SELECT QR.RdNurse, QR.RdPatient, Sum(QR.RdCount) AS RdCount
FROM qryRound1 AS QR
GROUP BY QR.RdNurse, QR.RdPatient
PIVOT Format([QR.RdDate],"mm/dd");
Given this example, you should be able to work out literally any kind of reporting that you want.
Some big things to note -
(1) Crosstabs are extremely picky. The reason that qryNDayRound and qryPDayRound had to be written was because the crosstab repeatedly objected to every formulation that I tried with the subselects being in qryRound1, even though qryRound1 didn't have any problems with them.
(2) The TRANSFORM statement is overriding the detail that appears in the query matrix, so you can do anything from minor formatting in the SQl itself, for instance
Code:
TRANSFORM Format(Sum(QR.RdCount/QR.RdCountP),"00%") AS PctOfPDayRdCount
to changing the output completely to read "1 OF 3 = 33%"
Code:
TRANSFORM IIF(Sum(QR.RdCount)>0,(Sum(QR.RdCount) & " of " & Max(QR.RdCountP) & " = " &Format(Sum(QR.RdCount/QR.RdCountP),"00%")),"") AS PctOfPDayRdCount
(3) Every term in the TRANSFORM has to be an aggregate function of some sort, which explains why I'm choosing the Max of QR.RdCountP even though they will all be the same on every record for the same patient in the same day.