Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude results

Status
Not open for further replies.

gk17

Technical User
Sep 6, 2013
86
US
Hi, I can't figure out where to start on this report. We have an exams view where we want the Patient Name, medical record number, exam code, date of exam returned. The criteria is that we don't want any results returned for patients who have exams in more than one dept done on the same day. So if the patient has an exam in Dept A and then another exam on the same day for Dept B, we want them excluded from the report.

The user will input the dept in the report parameter. So if they enter "Dept A", they should only get data returned for those patients who didn't have any other exams in the other departments.

Part 2: As an added twist, how to exclude those patients where the exams are done within the same department also on the same day? So basically no exceptions regardless of which department the exam was performed in.

I was thinking of comparing the date and dept but for the life of me can't figure out how to do this in Crystal Reports.

Using Crystal Reports 11.

Thanks.
 
Assuming I understand the challenge, in broad terms:

1. List all of the data for the day and group by Patient'
2. Do a Distinct Count of Exam Codes for each patient. If that result is > 1 then you want to exclude them as they have more than 1 Exam on that day.(which can be done using Group Selection formula);

Hope this helps
Cheers
Pete
 
Hi Pete,

You hit it right on the nail. That makes sense. I grouped it by Day first and then by Patient. How do I do the second part with the group selection formula? I tried using DistinctCount ({ExamCode}) < 2 so it should only include those that have 1 count but I think by doing this it's doing an account on the entire report and not just by the Patient group. I also did a distinct count on the Patient group itself but don't know how to store or pass this value to do the exclusion.

Thanks.
 
In the Group Selection Formula, enter the following:

Code:
DistinctCount({Table.ExamCode, Table.Patient}) < 2

Cheers
Pete
 
Thank Pete. I was missing the second parameter for the DistinctCount. Added in the Patient table and that got the results needed :)

Just one more item. I will have one report parameter called "Dept". The user will enter the dept and this will be used to exclude all depts except for the one the user entered. For example, if the user enters MRI for the dept they want it to show other MRI exams for the same day but exclude everything else.

Basically this report will have two options for the end user. If they leave that dept parameter blank, it will be for ALL dept. Otherwise, if a value is entered, it will exclude all except that value they entered.
 
I think I got it working. Seems to be working so far:

Code:
DistinctCount({Table.ExamCode, Table.Patient}) < 2  and
{Table.Department} = {?Dept}
 
Looks like I spoke too soon. I have the following:

Code:
DistinctCount({Table.ExamCode, Table.Patient}) < 2  and
(({?Dept} = {Table.Department}) or ({?Dept} = ''))

Made a slight change to accomodate blank/no values. I think the distinct count will cause problems for the second scenario I mentioned above where the user enters the dept to exclude. I was thinking of using a formula and inserting that formula into the group selection but received a message saying that the formula couldn't be used because it must be evaluated later. I was thinking of using something like the following formula:

Code:
if {?Dept} = '' then
    DistinctCount ({Table.ExamCode, Table.Patient}) < 2
else
    (({?Dept} = {Table.Department}) ) or ({?Dept} = ''))
    DistinctCount ({Table.ExamCode, Table.Patient}) > 1

The goal for this is to make sure they're are no exams done on the same day but if they are done in the same dept (assuming the user entered a value for "dept" parametere), they will be counted and shown in the report.

Am I going in the right direction with this? Just not sure how to get this to work with the group selection.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top