alexfromuno
Programmer
- Nov 6, 2002
- 20
I'm running Crystal 8.5, Oracle 8.1.7 and can't seem to get the Selection Formula for a Group working correctly.
Here are the details:
Working at a hospital, trying to produce a list of all patients in a programs (Kidney, liver, heart, etc), that have no Primary Care Physician attached to that patient. There is more than 1 table involved in the query to get the program name (like Kidney, Liver, Heart, etc.), patient name and other items of interest, but basically, what I'm attempting to do is that, for a given patient and for all referring physicians for that patient, if there is 1 Primary care physician in that patients group, than do not print it.
Here's an example of SQL code:
SELECT prc.REFERRING_TYPE, pp.PROGRAM_ID, pp.PAT_ID,
rt.DESCRIPTION, pd.FIRST_NAME, pd.LAST_NAME, p.PROGRAM_NAME
FROM PAT_PROGRAM pp,
PATIENT_DEMO pd,
PROGRAMS p,
PAT_REF_CARE prc,
REFERRING_TYPES rt
WHERE (pp.PAT_ID = pd.PAT_ID)
AND (pp.PROGRAM_ID = p.PROGRAM_ID)
AND (pd.PAT_ID = prc.PAT_ID)
AND (prc.REFERRING_TYPE = rt.REFERRING_TYPE)
AND pp.PROGRAM_ID = 4
ORDER BY p.PROGRAM_NAME, pp.PAT_ID, pp.PROGRAM_ID
where program_id refers to the program (Liver, kidney, Heart) and the referring_type is the type of doctor
(1 = Primary, 2=referring, 3= attending, etc)
to repeat, what I'd like to do is be able to say that, when a patient has a primary care, then do not print that group (patient ID, anme and all reffering doctors associated with that patient) but only print groups with NO primary care doctor. Sorry if I'm a little long winded here, I've been fighting with this for days.
Thanks in advance.
alex
Here are the details:
Working at a hospital, trying to produce a list of all patients in a programs (Kidney, liver, heart, etc), that have no Primary Care Physician attached to that patient. There is more than 1 table involved in the query to get the program name (like Kidney, Liver, Heart, etc.), patient name and other items of interest, but basically, what I'm attempting to do is that, for a given patient and for all referring physicians for that patient, if there is 1 Primary care physician in that patients group, than do not print it.
Here's an example of SQL code:
SELECT prc.REFERRING_TYPE, pp.PROGRAM_ID, pp.PAT_ID,
rt.DESCRIPTION, pd.FIRST_NAME, pd.LAST_NAME, p.PROGRAM_NAME
FROM PAT_PROGRAM pp,
PATIENT_DEMO pd,
PROGRAMS p,
PAT_REF_CARE prc,
REFERRING_TYPES rt
WHERE (pp.PAT_ID = pd.PAT_ID)
AND (pp.PROGRAM_ID = p.PROGRAM_ID)
AND (pd.PAT_ID = prc.PAT_ID)
AND (prc.REFERRING_TYPE = rt.REFERRING_TYPE)
AND pp.PROGRAM_ID = 4
ORDER BY p.PROGRAM_NAME, pp.PAT_ID, pp.PROGRAM_ID
where program_id refers to the program (Liver, kidney, Heart) and the referring_type is the type of doctor
(1 = Primary, 2=referring, 3= attending, etc)
to repeat, what I'd like to do is be able to say that, when a patient has a primary care, then do not print that group (patient ID, anme and all reffering doctors associated with that patient) but only print groups with NO primary care doctor. Sorry if I'm a little long winded here, I've been fighting with this for days.
Thanks in advance.
alex