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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving from one building to another with Crystal Reports 1

Status
Not open for further replies.

BigDaddyE

MIS
Apr 29, 2010
27
US
I am writing a report for Hospital patients. Each patient has a start date and a discharge date for the buildings that they recieve treatment in. I am working on a report that displays the patients that moved from one building to another withen 7 days. I want to count each patient who has met this criteria once. So if given the data below I would like the report to display "John Doe 1" because John Doe met the criteria.

@Patient epsd.building epsd.Start_date epsd.Dschg_date
John Doe A 06/20/2010 07/05/2010
John Doe C 07/06/2010 07/23/2010
Bob Smith A 06/20/2010 06/25/2010
 
Group by patient. Do summary totals for the maximum and minimum of building. When they are not the same, they must have changed building at least once. I think a running total could use this as a formula to selectively count: failing that you could use a variable.

If you're not already familiar with Crystal's automated totals, see FAQ767-6524.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options. In this case, it probably makes no difference.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Insert a group on {@Patient} and then create a formula for the detail section:

whileprintingrecords;
numbervar cnt;
if {table.patient} = previous({table.patient}) and
{espd.building} <> previous({espd.building}) and
{espd.startdate}-previous({espd.dischg_date}) <= 7 then
cnt := cnt + 1;

In the group header, add a reset formula:

whileprintingrecords;
numbervar cnt;
if not inrepeatedgroupheader then
cnt := 0;

In the section expert, suppress the group header and the detail section. Select the group footer->suppress->x+2 and enter:

whileprintingrecords;
numbervar cnt;
cnt = 0 //note no colon

Drag the groupname into the group footer.

-LB
 
Allright. lbass this worked almost perfectly. The only problem is that the very first record and the very last record in the results has nothing to do with the filter. I am guessing this is because of the
{table.patient} = previous({table.patient})

Any suggestions on how to modify the code so that the 1st and last record is not displayed?
 
Try:

whileprintingrecords;
numbervar cnt;
if not onfirstrecord and
{table.patient} = previous({table.patient}) and
{espd.building} <> previous({espd.building}) and
{espd.startdate}-previous({espd.dischg_date}) <= 7 then
cnt := cnt + 1;

I'm not following what the issue is with the last record. Can you show some sample data and explain what is still not working?

-LB
 
If
((
(not onlastrecord) and //just added
({patient.med_rec_num} = next ({patient.med_rec_num})) and
({ep_discipline.dc_reason_code} = ["37", "20"]) and
({episode.team_code} = ["28", "29"]) and
({episode.dschg_date} in {?Discharged Date}) and
(["84", "85", "87", "88"]= next({substation.sub_code}))
)
or
(
(not onfirstrecord) and // just added
({patient.med_rec_num} = previous({patient.med_rec_num})) and
({substation.sub_code} = ["84", "85", "87", "88"]) and
(["37", "20"] = previous ({ep_discipline.dc_reason_code})) and
(previous({episode.dschg_date}) in {?Discharged Date}) and
(IsNull ({episode.ntuc_date}))
))

Then TRUE
 
What? This bears no relation to my suggestions.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top