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

Concatenate with Array - Crystal Report 1

Status
Not open for further replies.

MochaLatte

Technical User
Jan 11, 2011
39
US
Hello,
I have a report for patients each patient has different diagnosis.
For example: (Detail Section)
Patient A Chest Pain
Patient B Cough
Patient A Chest Pain
Patient B Nausea
Patient B Nausea
Patient A Headache

I need to concatenate diagnosis in the footer into a single field, it should look like this: (no repetitions)
Patient A: Chest Pain, Headache
Patient B: Cough, Nausea

I have the following array

@Initialize
whileprintingrecords;

stringvar diagnosis:="";
stringvar Admit_dept:="";

@Diagnosis
whileprintingrecords;
stringvar array summary;
numbervar array_size:=ubound(summary);

numbervar found_sw:=0;
numbervar i;

if not(isnull({PAT_ENC_RSN_VISIT.ENC_REASON_NAME}))

then

for i:= 1 to array_size do
if summary={PAT_ENC_RSN_VISIT.ENC_REASON_NAME} then
found_sw:=1;
if found_sw = 0 then
(array_size := ubound (summary) +1;
redim preserve summary[array_size];
summary[array_size]:={PAT_ENC_RSN_VISIT.ENC_REASON_NAME});
found_sw:=0
;

@Display Diagnosis
whileprintingrecords;
stringvar array summary;
numbervar array_size:=ubound(summary);
stringvar display_summary:="";
numbervar i;


for i:=2 to array_size do
(
if summary <> summary[i-1] then
display_summary:= display_summary & summary & chr(13)
);
display_summary;


Thanks for any help!!!!!
 
here is a solution without using arrays if you are interested:

I assume you will have a grouping on Patient
@initialize
WhilePrintingRecords;
stringvar conditions2:="";
(placed in group header)

@showDiagnosis
WhilePrintingRecords;

stringvar conditions2 ;
if instr(conditions2,{PAT_ENC_RSN_VISIT.ENC_REASON_NAME})= 0 then
if instr(",",conditions2) = 0 then
conditions2 := conditions2 + ", " + {PAT_ENC_RSN_VISIT.ENC_REASON_NAME}
else conditions2 := {PAT_ENC_RSN_VISIT.ENC_REASON_NAME};
conditions2
(placed in BOTH details and the group footer)
place group name in footer
hide details
hide header (optional if you need it for something else)

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Thank you CoSpringsGuy, your solution works really well, and it is easier to understand than arrays. Thanks again!!!!! You made my day!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top