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

Collect minutes by hour of Day

Status
Not open for further replies.

jemsmom

IS-IT--Management
May 31, 2005
43
US
I am using the formula below for each hour of the day summarizing the total minutes used by hour.

This worked great until the end user says there are two possible sets of timing elements. Despite my efforts to modify the formula I cannot get it to work. Any help is appreciated.

Every record can have 2 sets of possible timing events:

PACU Level 1

{OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN}
{OR_LOG_CASE_TIMES_pacu_out_1.TRACKING_TIME_IN}

PACU Level 2
{OR_LOG_CASE_TIMES_pacu_in_2.TRACKING_TIME_IN}
{OR_LOG_CASE_TIMES_pacu_out_2.TRACKING_TIME_IN}

A log can have both sets of pacu_1 and Pacu_2 times or they can have only a pacu_1 or a pacu_2.

If the record has both sets of events pacu_in_1 and pacu_in_2 times I want the date diff to be pacu_in_1 to pacu_out_2

I would like the output to look like this:

ID pacu_in_1 pacu_out_1 pacu_in_2 pacu_out_2 16 17 18

1 17:40 18:55 20 55
2 16:28 17:05 17:05 17:56 32 56
3 16:15 16:45 30

total for range: 62 76 55
One formula for every hour:

WhileReadingRecords;
local numberVar nTrimBef;
local numberVar nTrimAft;
local dateTimeVar beginRange;
local dateTimeVar endRange;
stringVar CaseCount := "Case Minutes";

numberVar ThresholdMins =0 ;
//The time range can be configured by changing the Time fields below.
beginRange:=DateTime(Date({OR_LOG.SURGERY_DATE}),Time(16,00,00)); //Set time to beginning of desired range. Ex. Time(16,00,00)=4:00 PM
endRange:=DateTime(Date({OR_LOG.SURGERY_DATE}),Time(17,00,00)); //Set time to end of desired range. Ex. Time(17,00,00)=5:00 PM

if {OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN} > endRange then 0 //Start of case occurs after end of range. No minutes in range.
else if {OR_LOG_CASE_TIMES_pacu_out_1.TRACKING_TIME_IN}<beginRange then 0 //End of case occurs before begin of range. No minutes in range.
else
( //Find the minutes not in range (trim amount) and subtract from total time.
nTrimBef:=DateDiff("n",{OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN},beginRange); //Time between start of case and begin of range.
nTrimBef:=IIF (nTrimBef>0,nTrimBef,0); //If start of case occurs after begin of range, set trim amount to 0.
nTrimAft:=DateDiff("n",endRange,{OR_LOG_CASE_TIMES_pacu_out_1.TRACKING_TIME_IN}); //Time between end of range and end of case.
nTrimAft:=IIF (nTrimAft>0,nTrimAft,0); //If end of case occurs before end of range, set trim amount to 0.
DateDiff("n",{OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN},{OR_LOG_CASE_TIMES_pacu_out_1.TRACKING_TIME_IN})-(nTrimBef+nTrimAft);
 
jemssmom,

Assuming the patient trasfers directly from PACU 1 to PACU 2, I would set a varialble to find the start of the total PACU stay and one for the end of the total PACU stay. Perhaps something like:

Local datetimevar StartTime;
Local datetimevar EndTime;

StartTime: = if IsNull({OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN}) Then {OR_LOG_CASE_TIMES_pacu_in_2.TRACKING_TIME_IN} else {OR_LOG_CASE_TIMES_pacu_in_1.TRACKING_TIME_IN};
// Assumes that the PACU 1 In Time is the 1st that would occur

End Time:= if IsNull({OR_LOG_CASE_TIMES_pacu_out_2.TRACKING_TIME_IN}) Then {OR_LOG_CASE_TIMES_pacu_out_1.TRACKING_TIME_IN} else {OR_LOG_CASE_TIMES_pacu_out_2.TRACKING_TIME_IN};
// Assumes that the PACU 2 Out Time is the last that would occur with no significant break between PACU 1 and 2

Set the variable declarations with the others and the formulas setting them before you start setting nTrimBef
Then use these variables, StartTime and EndTime, in place of the Tracking Time In fields in the rest of the formulas.

Hope that helps
 
This works perfect. Thank you for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top