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!

First and Last Record

Status
Not open for further replies.

budoyboy

MIS
Dec 28, 2007
19
US
Hello,

I get lab records listed below. What I want to do in Crystal is compare the first record to the last i.e.result 1.9 to 3 and to see if the results are greater than 1(which in this case is true). Does anyome know how to look at records for one patient can compare the first and the last?



name mrn date result
DOE,JOHN 1234576 8/21/2008 1.9
DOE,JOHN 1234576 8/22/2008 1.7
DOE,JOHN 1234576 8/23/2008 2.2
DOE,JOHN 1234576 8/24/2008 1.4
DOE,JOHN 1234576 8/25/2008 1.8
DOE,JOHN 1234576 8/26/2008 3

 
Can the later value be greater or less than the first value?

If so then assuming that you are grouping by name then try the following:

Also please let us know what you would like to do when the value is greater or lower by this amount, for the time being I will just display a different text string based on output which you can obviously adjust to suit your needs.

//{@Compare}
if maximum({db.result},{db.name}) <> (minimum({db.result},{db.name}) -1) to (minimum({db.result},{db.name}) +1) then 'Greater than 1 - (' + totext(abs(
maximum({db.result},{db.name}) - minimum({db.result},{db.name}))1) + ')' else 'Less than 1'

'J
 
I just found what they want is if any lab result is greater than the first lab result by 1 than flag it
 
Makes it a little easier to be honest.

//{@Greaterthan}
if {db.result} >= (minimum({db.result},{db.name}) + 1) then
'Plus ' + totext(abs({db.result}-minimum({db.result,{db.name})),1) else ''

Not at my desk atm so can't test - please give it a test run and let me know.

'J
 
It is sort of working. It taking the lowest test compared to the highest when it should be first compared to the highest.
 
Which formula are you trying at the moment?

Can you copy paste it in for reference please?

I am a little unclear on the grounds for flagging these accounts:


budoyboy (MIS) 9 Sep 08 7:39
I just found what they want is if any lab result is greater than the first lab result by 1 than flag it

budoyboy (MIS) 9 Sep 08 11:07
It is sort of working. It taking the lowest test compared to the highest when it should be first compared to the highest.


Perhaps if you provide some sample data and preffered output it might help.
 
name mrn date result
DOE,JOHN 1234576 8/21/2008 1.9 first test
DOE,JOHN 1234576 8/22/2008 1.7
DOE,JOHN 1234576 8/23/2008 2.2
DOE,JOHN 1234576 8/24/2008 1.4
DOE,JOHN 1234576 8/25/2008 1.8
DOE,JOHN 1234576 8/26/2008 3 flag this result because it is more 1.0 over than the first test.


Here is your formula that I used:
//{@Greaterthan}
if {db.result} >= (minimum({db.result},{db.name}) + 1) then
'Plus ' + totext(abs({db.result}-minimum({db.result,{db.name})),1) else ''
 
Try this in the detail section:

whileprintingrecords;
numbervar mintest;
if {table.date} = minimum({table.date},{table.group}) then
mintest := {table.results};
if {table.results} > mintest + 1 then
"Flag"

-LB
 
Lance Bass is a winner!

He can sing, dance and write Crystal code.

Thanks this works really well.
Budoyboy
 
Call me a sexist pig then.

Sorry for the incorrect assumption.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top