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

Formula for first record

Status
Not open for further replies.

mbumstead

Technical User
Apr 30, 2009
13
0
0
US
I have Crystal XI and I write reports for a surgery department with 11 operating rooms. I need a formula that will select just the first case record of the day for each room no matter what time it started.
 
Do you need to use this value anywhere else or is it just to display?

You can group by Date and then Theatre and then do a minimum summary based on the OR time.
 
I am not sure I am following you. Some times the first surgery in a room could be at 10:00 and some at 7:30. I am trying to find just the first case of the day for each room so I can report on the on time starts.
 
Assuming you already filter down to a date by parameter or some other means.

I would group by room (Ascending) and then by time (Descending), hide the detail record but show the detail data in the time group footer.

The first of the day would be that last one available so it would show in the footer --for each room.

Scotto the Unwise
 
I went back to a similar report I had built (calculate average time for first case of the day over a given period).

I needed to have more fields than just the time displayed so. So if this is the case for you, here is a simplification:

GH1 - DATE
GH2 - Theatre

<Formula INIT>
//insert this formula in the GH2
//Set to highest possible time in the day
//Create shared variables for each field you would like to display (I put PatientName and MRN as an example)

Shared Timevar tInit := Time (23,59 ,59 );
Shared Stringvar strPatientName = "";
Shared Stringvar strMRN = "";


<Formula FIRSTCASE>
//insert this formula in the details section
//include all the variables that you put in the Init formula

Shared Timevar tInit;
shared Timevar tFirstCase;
Shared Stringvar strPatientName;
Shared Stringvar strMRN;
//include all the variables that you put in the Init formula


If {ORtime.field} < than tInit then
(
tFirstCase := {ORtime.field};
strPatientName := {PatientName.field}
strMRN := {MRN.field}
(repeat for whatever fields you included)
);

Now depending on how you want to display this information you would create formulas that call the shared variable in
GH2.

hopefully this is clear, I haven't had my morning cofee yet ; )
 
If you have a group on room and then date or date and then room, you should be able to insert a minimum on the datetime field at the appropriate group level.

-LB
 
I tried the formula and it is getting hung up on the than in the IF statement

Here is a copy of what I have so far.

//<Formula FIRSTCASE>
//insert this formula in the details section
//include all the variables that you put in the Init formula

Shared Timevar tInit;
shared Timevar tFirstCase;
Shared StringVar strcrn;
//include all the variables that you put in the Init formula


If {v_basic_booking_data_ODBC.book_setup_start_time} <= than tInit then
(
tFirstCase := {v_basic_booking_data_ODBC.book_setup_start_time};
strcrn := {v_basic_case_rec_data_ODBC_new.cr_urn};
// (repeat for whatever fields you included)
//);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top