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!

Event Time Differences 1

Status
Not open for further replies.

AvgMoJoe

Technical User
Nov 7, 2007
26
US
Given the following results:

Patient #1
Event_Type Event_DTTM
------------------- -----------------
Arrived 10/16/2012 8:00AM
Roomed 10/16/2012 8:15AM
Physician Assigned 10/16/2012 8:20AM
Physician Assigned 10/16/2012 8:25AM
Disposition Assigned 10/16/2012 8:30AM
Discharged 10/16/2012 9:00AM

I would like to output the following:

Arrived to 1st Physician Assigned Arrived to Disposition 1st Physician Assigned to Disposition Disposition to Discharge
--------------------------------- ---------------------- ------------------------------------- ------------------------
20 Min 30 Min 10 Min 30 Min

How do I accomplish this?
 
This formula goes in the detail section:

Code:
//@AssignVariables
whileprintingrecords;
datetimevar v_arrived;
datetimevar v_assigned;
datetimevar v_disp;
datetimevar v_discharge;

if {Sheet1_.EventType} = "Arrived" then v_arrived := {Sheet1_.EventTime}
else
if {Sheet1_.EventType} = "Physician Assigned" and v_assigned = date(1900,1,1) then v_assigned := {Sheet1_.EventTime}
else
if {Sheet1_.EventType} = "Disposition Assigned" then v_disp := {Sheet1_.EventTime}
else
if {Sheet1_.EventType} = "Discharged" then v_discharge := {Sheet1_.EventTime};

This one goes in the group header (assuming you have groups, if not then the report header):

Code:
//@Reset
whileprintingrecords;
datetimevar v_arrived := datetime(1900,1,1);
datetimevar v_assigned := datetime(1900,1,1);
datetimevar v_disp := datetime(1900,1,1);
datetimevar v_discharge := datetime(1900,1,1);

Then create formulas for each of the values you want to display - here's the first one:

Code:
//@ArrivedToFirstPhysician
whileprintingrecords;
datetimevar v_arrived;
datetimevar v_assigned;
datetimevar v_disp;
datetimevar v_discharge;


totext(datediff("n",v_arrived,v_assigned),0) + " Min"




 
Excellent, Thank you! If there are multiple events of the same type and they do not necessarily load chronologically, I assume you would toss in a Min() somehow?
 

It would probably be easier to sort the report by event datetime. Otherwise you'd have to test the value, something like:

if {Sheet1_.EventType} = "Physician Assigned"
and
(v_assigned = date(1900,1,1) or {Sheet1_.EventTime} < @v_assigned) then v_assigned := {Sheet1_.EventTime}

Which says if the event type has not been seen yet for this group, or if the new value is less than the current value, update the variable.

Since the variable is being overwritten, there's only one value at any time - so a min wouldn't work in this case, but you have the right idea.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top