T
terry
I need to create a query to determine whether or not the proper number of
home health visits occurred based on the doctor's orders...
I have set up three new tables in my database for this purpose... they are
as follows
tblCertificationPeriod
fields are
[CERT-PK Cert Period ID] 'primary key for this table
[CERT-FK Client ID] 'foreign key to identify the client
[CERT Certification Start] 'start date for doctor's order
[CERT Certification End] 'end date for doctor's order
[CERT-FK AorR] 'admit or recertification
[CERT-FK Billing Source] 'Foreign key to identify the Doctor who place
the order
tblDoctorsOrders
[DO-FK Cert Period id] 'Foreign key into tblCertificationPeriod
[DO-FK Visit Code] 'Foreign key into visit code list... this would
be x for times, xw for times per week etc
[DO Occurances] 'Occurances for the above time code if visit code
is xw and this number is 2 then the meaning is 2 times per week during the
certification period. if visit code is x and this number is 5 it means 5
times during the certification period
[DO-FK Type of Visit] ' Foreign key into a type of discipline visit
i.e. skilled nursing, occupational therapy, physical therapy etc.
[DO Number Of Weeks] 'this is for number of weeks if the order is for
times per week sometimes the order is 2 times per week for the first two
weeks then 1 time per week for the remaining time period
[DO Date Start Week] 'this is for the date this order starts... this
helps if the order changes in the middle of the cert period
[DO-PKp 'this is the primary key for this table
tblActualVisits
[LCMV-FK Cert Period] 'foreign key into the cert period table
[LCMV-FK Emp ID] 'foreign key into the employee table
[LCMV DOS] 'actual date of home health visit
[LCMV-FK Type of Visit] 'type of visit ie skilled nursing, occupational
therapy, physical therapy etc.
[LCMV-PK] 'primary key into this table
from this I need to compare the doctor's orders to the actual visits to make
sure they match and to create a report identifies those that don't (and those
that do)
basically I need to take the starting date from the doctors orders table for
a specific client/certperiod/discipline and compare the order to the actual
visit for the same client/certperiod/discipline.
the problems I'm having trouble overcoming is designing a query that will
match the correct dates
examples are for doctors orders starting
for same client, same cert period I may have the following doctors orders
[DO-FK Visit Code] XM = times per week
[DO Occurances] 2
[DO-FK Type of Visit] SN = "Skilled Nursing"
[DO Number Of Weeks] 2
[DO Date Start Week] 01/02/05
[DO-PK] 1
[DO-FK Visit Code] XM = times per week
[DO Occurances] 1
[DO-FK Type of Visit] SN = "Skilled Nursing"
[DO Number Of Weeks] 6
[DO Date Start Week] 01/16/05
[DO-PK] 2
[DO-FK Visit Code] XM = times per week
[DO Occurances] 2
[DO-FK Type of Visit] OT = "Occupational therapy"
[DO Number Of Weeks] 3
[DO Date Start Week] 01/02/05
[DO-PK] 3
[DO-FK Visit Code] X = times total
[DO Occurances] 5
[DO-FK Type of Visit] OT = "Occupational therapy"
[DO Number Of Weeks] 0 (meaning not a per week time frame)
[DO Date Start Week] 01/23/05
[DO-PK] 4
and the following actual visits
[LCMV DOS] 01/03/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 1
[LCMV DOS] 01/05/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 2
[LCMV DOS] 01/10/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 3
[LCMV DOS] 01/12/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 4
[LCMV DOS] 01/18/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 5
[LCMV DOS] 01/25/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 6
[LCMV DOS] 01/26/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 7
[LCMV DOS] 01/05/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 8
[LCMV DOS] 01/10/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 9
[LCMV DOS] 01/12/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 10
[LCMV DOS] 01/19/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 11
[LCMV DOS] 01/24/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 12
The report I need would be something like this
For Client/Cert period run on 01/30/05 would show
Week of 01/02/05 SN OK
Week of 01/09/05 SN OK
Week of 01/16/05 SN OK
Week of 01/23/05 SN Not OK
Week of 01/02/05 OT Not OK
Week of 01/09/05 OT OK
Week of 01/16/05 OT Not OK
Week of 01/23/05 OT OK 4 visits remain
or a weekly report in a specific week would go through all the clients and
give report
For the week of 01/02/05 (with other specific information but basically I
need to know which client/certperiod the visits don't match.
SN
Client 1 ok
client 2 not ok
Client 3 ok
Client 4 ok
OT
etc
PT
etc
etc
etc
home health visits occurred based on the doctor's orders...
I have set up three new tables in my database for this purpose... they are
as follows
tblCertificationPeriod
fields are
[CERT-PK Cert Period ID] 'primary key for this table
[CERT-FK Client ID] 'foreign key to identify the client
[CERT Certification Start] 'start date for doctor's order
[CERT Certification End] 'end date for doctor's order
[CERT-FK AorR] 'admit or recertification
[CERT-FK Billing Source] 'Foreign key to identify the Doctor who place
the order
tblDoctorsOrders
[DO-FK Cert Period id] 'Foreign key into tblCertificationPeriod
[DO-FK Visit Code] 'Foreign key into visit code list... this would
be x for times, xw for times per week etc
[DO Occurances] 'Occurances for the above time code if visit code
is xw and this number is 2 then the meaning is 2 times per week during the
certification period. if visit code is x and this number is 5 it means 5
times during the certification period
[DO-FK Type of Visit] ' Foreign key into a type of discipline visit
i.e. skilled nursing, occupational therapy, physical therapy etc.
[DO Number Of Weeks] 'this is for number of weeks if the order is for
times per week sometimes the order is 2 times per week for the first two
weeks then 1 time per week for the remaining time period
[DO Date Start Week] 'this is for the date this order starts... this
helps if the order changes in the middle of the cert period
[DO-PKp 'this is the primary key for this table
tblActualVisits
[LCMV-FK Cert Period] 'foreign key into the cert period table
[LCMV-FK Emp ID] 'foreign key into the employee table
[LCMV DOS] 'actual date of home health visit
[LCMV-FK Type of Visit] 'type of visit ie skilled nursing, occupational
therapy, physical therapy etc.
[LCMV-PK] 'primary key into this table
from this I need to compare the doctor's orders to the actual visits to make
sure they match and to create a report identifies those that don't (and those
that do)
basically I need to take the starting date from the doctors orders table for
a specific client/certperiod/discipline and compare the order to the actual
visit for the same client/certperiod/discipline.
the problems I'm having trouble overcoming is designing a query that will
match the correct dates
examples are for doctors orders starting
for same client, same cert period I may have the following doctors orders
[DO-FK Visit Code] XM = times per week
[DO Occurances] 2
[DO-FK Type of Visit] SN = "Skilled Nursing"
[DO Number Of Weeks] 2
[DO Date Start Week] 01/02/05
[DO-PK] 1
[DO-FK Visit Code] XM = times per week
[DO Occurances] 1
[DO-FK Type of Visit] SN = "Skilled Nursing"
[DO Number Of Weeks] 6
[DO Date Start Week] 01/16/05
[DO-PK] 2
[DO-FK Visit Code] XM = times per week
[DO Occurances] 2
[DO-FK Type of Visit] OT = "Occupational therapy"
[DO Number Of Weeks] 3
[DO Date Start Week] 01/02/05
[DO-PK] 3
[DO-FK Visit Code] X = times total
[DO Occurances] 5
[DO-FK Type of Visit] OT = "Occupational therapy"
[DO Number Of Weeks] 0 (meaning not a per week time frame)
[DO Date Start Week] 01/23/05
[DO-PK] 4
and the following actual visits
[LCMV DOS] 01/03/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 1
[LCMV DOS] 01/05/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 2
[LCMV DOS] 01/10/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 3
[LCMV DOS] 01/12/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 4
[LCMV DOS] 01/18/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 5
[LCMV DOS] 01/25/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 6
[LCMV DOS] 01/26/05
[LCMV-FK Type of Visit] SN
[LCMV-PK] 7
[LCMV DOS] 01/05/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 8
[LCMV DOS] 01/10/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 9
[LCMV DOS] 01/12/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 10
[LCMV DOS] 01/19/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 11
[LCMV DOS] 01/24/05
[LCMV-FK Type of Visit] OT
[LCMV-PK] 12
The report I need would be something like this
For Client/Cert period run on 01/30/05 would show
Week of 01/02/05 SN OK
Week of 01/09/05 SN OK
Week of 01/16/05 SN OK
Week of 01/23/05 SN Not OK
Week of 01/02/05 OT Not OK
Week of 01/09/05 OT OK
Week of 01/16/05 OT Not OK
Week of 01/23/05 OT OK 4 visits remain
or a weekly report in a specific week would go through all the clients and
give report
For the week of 01/02/05 (with other specific information but basically I
need to know which client/certperiod the visits don't match.
SN
Client 1 ok
client 2 not ok
Client 3 ok
Client 4 ok
OT
etc
PT
etc
etc
etc