Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Special selection criteria - need help Post Reply Post New Topic
Author Message
hjorrdis
Newbie
Newbie
Avatar

Joined: 13 Sep 2013
Location: United States
Online Status: Offline
Posts: 8
Quote hjorrdis Replybullet Topic: Special selection criteria - need help
     Posted: 02 Sep 2014 at 10:00am
Okay. I work at a medical practice where all visits are logged in the database and will have CPT codes attached. Sometimes a visit will only have one code, sometimes it will have multiple codes.

For visits that have one specific visit code, I want to select only those visits that also have other codes as well.

For instance if
visit number 8133 has codes 99211 and 98036
visit number 8136 only has code 99211
visit number 8140 only has code 99212

I do not want to select visit number 8136 because it only has code 99211, but I want the other two visits to be selected.

I hope that makes sense. Please feel free to ask me for more clarification. I so appreciate your help as I've been struggling with this one for weeks.

Thanks,
Melissa
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 02 Sep 2014 at 11:08am
If I understand you correctly, if a patient has code 99211, you only want to show them if they also have another code. If a patient doesn't have code 99211, you always want to show them. Is that correct?

-Dell
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 02 Sep 2014 at 12:24pm
group on CPT code

in group select expert try
(if CPT ="99211" then count(CPT,CPT)>1 else
1=1)
IP IP Logged
hjorrdis
Newbie
Newbie
Avatar

Joined: 13 Sep 2013
Location: United States
Online Status: Offline
Posts: 8
Quote hjorrdis Replybullet Posted: 03 Sep 2014 at 1:51am
Hi Hilfy - you've got it perfectly.

Kostya1122 - That would only work if both CPT codes are 99211 - in this case any additional CPT codes would be different. You did make me think that maybe I can group by visit number and then use a count to try to figure out if there is another code on the visit or not...

Will be playing with that idea.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 Sep 2014 at 3:25am
How are your SQL skills? I think the only way you're going to be able to do this is to write a Command, which is just a SQL select statement. Since I don't know your table structures, I can just give you some general logic for this:
[code]
Select distinct <all the fields you need for the report>
from <joined tables>
where <selection criteria>
and (CPT_CODE <> '99211' or
    exists (
      Select 1
      From <table with CPT codes>
      where <link to patient>
        and CPT_CODE != '99211')

Your best bet may be to start with the SQL that Crystal has already generated.

Also, DO NOT use the Select Expert to filter your data - put your filters in the Where clause of the Command. Otherwise Crystal will pull ALL of the data into memory and filter it there. If you have any parameters in your selection criteria, delete them from the main report and recreate them in the Command Editor - the Command Editor can't "see" parameters from the report.

-Dell
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Sep 2014 at 4:14am
Dell's approach is much more elegant and moves the processing onto the server but if you cannot get it to work you should be able to do this through group selectin criteria.
Keep in mind that group selction criteria happens after summarizations so if you are doing any counts or summary of the data you need to do that with runningtotals or shared variables that also exclude the groups.
group on visit number
create a 'flag' formula
//is_99211
If table.CPT ="99211" then 1
 
insert a count of the cpt code field at the vistinumber group
do a sum of of the formula field at the visitnumber group
now you can use the two values for your condition
Count(cpt,vistinumber)<>sum(is_99211,visitnumber)
IP IP Logged
hjorrdis
Newbie
Newbie
Avatar

Joined: 13 Sep 2013
Location: United States
Online Status: Offline
Posts: 8
Quote hjorrdis Replybullet Posted: 03 Sep 2014 at 4:39am
Thanks everyone.

I think I have a great starting point now so I will play around with it a bit and see if I can get it to work.

Thank you for mentioning that the group selection expert happens after summarizations. This is actually a report I need to use summaries for, so I will have to modify the way I am doing it.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum