I am trying to do this in the data environment (vb 6 sp 5) using parent and child commands. Each command is a sql statement.
I have four tables (simplified here for clarity):
Injections
injID
mdID
patID
hhcaID
Doctors
mdID
mdFName
mdLName
HHCA
hhcaID
hhcaName
Patients
patID
patFName
patLName
There are a bunch of other fields to boot but these are the ones I am after I think. The Injections table is the only place where all info is tied together through the ID's.
Anyway, I am after a report that will show me:
Each Doctor and under Doctor I need each HHCA (home health care agency) associated to the doctor and under HHCA each patient associated to the hhca.
kinda like this:
Doctor1
HHCA1
Patient1
Patient2
HHCA2
Patient3
Doctor2
HHCA2
Patient4
HHCA3
Patient5
Patient6
I can get close but the HHCA's will repeat themselves over and over. My command objects don't have the right relationships defined in the relationship tab.
I have three commands:
Parent = Doctor Info (Doctors Name and injID)
Child1 = HHCA Info (HHCA Name, hhcaID, injID)
relation to Parent = injID
Child2 = Patient Info (Patient Name and hhcaID)
relation to Child1 = hhcaID
What should the sql code be (roughly) and the relationships.
I have been stuck on this since summer and think maybe data shaping is beyond my ability to comprehend.
Anyone willing to try and point me to the promised land???
Thanks In Advance,
PS. If it helps, here is the entire horrid ado hierarchy and the shape command as shown under Hierarchy Info for the parent command:
rsDocHHCAPat
Doc2hhca
HHCA2Child
SHAPE {SELECT DISTINCT [Doctors].[mdID],
[Doctors].[mdFName], [Doctors].[mdLName], [InjectSchedule].[isDoctor], [InjectSchedule].[isChartNo] AS ChartNo1, [InjectSchedule].[isHHCA] AS DocToHick
FROM Doctors INNER JOIN InjectSchedule ON [Doctors].[mdID] =[InjectSchedule].[isDoctor] ORDER BY [Doctors].[mdLName]} AS DocPatHHCA APPEND (( SHAPE {SELECT DISTINCT [HHCA].[hName], [InjectSchedule].[isDoctor], [InjectSchedule].[isHHCA], [InjectSchedule].[isChartNo] AS ChartNo2
FROM HHCA INNER JOIN InjectSchedule ON [HHCA].[hID] =[InjectSchedule].[isHHCA] ORDER BY [HHCA].[hName]} AS Doc2hhca APPEND ({SELECT DISTINCT [InjectSchedule].[isChartNo] AS ChartNo3, [InjectSchedule].[isPatID], [InjectSchedule].[isHHCA] AS Child2Hick, [InjectSchedule].[isDoctor] AS Doc, [Patients].[pFName], [Patients].[pLName]
FROM Patients INNER JOIN InjectSchedule ON [Patients].[pID] =[InjectSchedule].[isPatID] ORDER BY [Patients].[pLName]} AS HHCA2Child RELATE 'isHHCA' TO 'Child2Hick') AS HHCA2Child) AS Doc2hhca RELATE 'ChartNo1' TO 'ChartNo2') AS Doc2hhca
I have four tables (simplified here for clarity):
Injections
injID
mdID
patID
hhcaID
Doctors
mdID
mdFName
mdLName
HHCA
hhcaID
hhcaName
Patients
patID
patFName
patLName
There are a bunch of other fields to boot but these are the ones I am after I think. The Injections table is the only place where all info is tied together through the ID's.
Anyway, I am after a report that will show me:
Each Doctor and under Doctor I need each HHCA (home health care agency) associated to the doctor and under HHCA each patient associated to the hhca.
kinda like this:
Doctor1
HHCA1
Patient1
Patient2
HHCA2
Patient3
Doctor2
HHCA2
Patient4
HHCA3
Patient5
Patient6
I can get close but the HHCA's will repeat themselves over and over. My command objects don't have the right relationships defined in the relationship tab.
I have three commands:
Parent = Doctor Info (Doctors Name and injID)
Child1 = HHCA Info (HHCA Name, hhcaID, injID)
relation to Parent = injID
Child2 = Patient Info (Patient Name and hhcaID)
relation to Child1 = hhcaID
What should the sql code be (roughly) and the relationships.
I have been stuck on this since summer and think maybe data shaping is beyond my ability to comprehend.
Anyone willing to try and point me to the promised land???
Thanks In Advance,
PS. If it helps, here is the entire horrid ado hierarchy and the shape command as shown under Hierarchy Info for the parent command:
rsDocHHCAPat
Doc2hhca
HHCA2Child
SHAPE {SELECT DISTINCT [Doctors].[mdID],
[Doctors].[mdFName], [Doctors].[mdLName], [InjectSchedule].[isDoctor], [InjectSchedule].[isChartNo] AS ChartNo1, [InjectSchedule].[isHHCA] AS DocToHick
FROM Doctors INNER JOIN InjectSchedule ON [Doctors].[mdID] =[InjectSchedule].[isDoctor] ORDER BY [Doctors].[mdLName]} AS DocPatHHCA APPEND (( SHAPE {SELECT DISTINCT [HHCA].[hName], [InjectSchedule].[isDoctor], [InjectSchedule].[isHHCA], [InjectSchedule].[isChartNo] AS ChartNo2
FROM HHCA INNER JOIN InjectSchedule ON [HHCA].[hID] =[InjectSchedule].[isHHCA] ORDER BY [HHCA].[hName]} AS Doc2hhca APPEND ({SELECT DISTINCT [InjectSchedule].[isChartNo] AS ChartNo3, [InjectSchedule].[isPatID], [InjectSchedule].[isHHCA] AS Child2Hick, [InjectSchedule].[isDoctor] AS Doc, [Patients].[pFName], [Patients].[pLName]
FROM Patients INNER JOIN InjectSchedule ON [Patients].[pID] =[InjectSchedule].[isPatID] ORDER BY [Patients].[pLName]} AS HHCA2Child RELATE 'isHHCA' TO 'Child2Hick') AS HHCA2Child) AS Doc2hhca RELATE 'ChartNo1' TO 'ChartNo2') AS Doc2hhca