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);
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);