Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SHARING] Reportcaster job activity

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SHARING] Reportcaster job activity
 Login/Join
 
Virtuoso
posted
I am working on creating a graph of report caster job activity over a 24h time-period. The idea is that it gives information on how busy certain hours are and if there are any jobs that run into working hours and maybe need rescheduling to an earlier start.

I got quite far, as you can probably see from the fex included below.

There are however a few things I'm still struggling with:

  • Repeating jobs should ideally have repeating bar segments: Currently for such jobs the graph shows a single bar going from the first start time of the job to its last end time, spanning the times in between where the job wasn't running. We have a couple of such jobs that run every 15 minutes or so.
  • The Y1 axis and the data labels show hours. Hence, the time is in decimal notation and not in time notation; for example, the graph displays 12:30:10 as 12.301 hours.
  • The stock graph I use cannot handle date-time data-types. Using those crashes the agent. That's why I converted those values to a numeric time format within the same day.


Anyway, here's the code. Suggestions for improvements, especially pertaining the above points, are welcome.

-DEFAULT &TODAY = 0
-SET &TODAY = IF &TODAY EQ 0 THEN &YYMD ELSE &TODAY;

ENGINE SQLMSS SET CURSORS CLIENT
ENGINE SQLMSS SET DEFAULT_CONNECTION ENSSQL05
SQL SQLMSS PREPARE RCLOG FOR

WITH ts AS (
	SELECT
		CAST(START_STAMP AS BIGINT)/1000 AS START_TS,
		CAST(END_STAMP AS BIGINT)/1000 AS END_TS,
		START_STAMP, END_STAMP, JOB_DESC,
		DATEDIFF(s, '1970/01/01 00:00:00', DATEADD(dd, 0, DATEDIFF(dd, 0, GETUTCDATE()))) AS TODAY,
		DATEDIFF(s, '1970/01/01 00:00:00', DATEADD(dd, 0, DATEDIFF(dd, 0, GETUTCDATE())) +1) AS TOMORROW,
		DATEDIFF(s, GETUTCDATE(), GETDATE()) AS GMTOFFSET
	  FROM BOTLOG
)
SELECT
	DATEADD(second, START_TS + GMTOFFSET, {d '1970-01-01'}) AS START_DT,
	DATEADD(second, END_TS + GMTOFFSET, {d '1970-01-01'}) AS END_DT,
	JOB_DESC,
	SUBSTRING(JOB_DESC, 1, 20) AS JOB_NAME,
	GETDATE() AS TODAY_DT
  FROM ts
 WHERE START_TS <= TOMORROW AND END_TS >= TODAY
 ORDER BY START_STAMP DESC
;

END
-RUN

DEFINE FILE RCLOG
	START_T/HHISs	= START_DT;
	END_T/HHISs		= END_DT;
	START_T1/D10.4 = EDIT(EDIT(HCNVRT(START_T, '(HHISs)', 20, 'A20'), '99$99$99999')) / 10000;
	END_T1/D10.4 = EDIT(EDIT(HCNVRT(END_T, '(HHISs)', 20, 'A20'), '99$99$99999')) / 10000;
END
TABLE FILE RCLOG
PRINT START_T1 END_T1 TODAY_DT
BY JOB_NAME
ON TABLE HOLD AS MAI00005H_RCLOG FORMAT FOCUS INDEX JOB_NAME
END
-RUN

-*INTERNAL_PROPERTIES$fieldDisplayMode=label;OBJECTID=GLOBAL
-*INTERNAL_PROPERTIES$enablePreview=true;OBJECTID=GLOBAL
-*INTERNAL_PROPERTIES$prefixDisplayMode=;OBJECTID=GLOBAL
-*INTERNAL_PROPERTIES$GlobalRecordLimit=500;OBJECTID=GLOBAL
-*INTERNAL_PROPERTIES$SampleData=false;OBJECTID=GLOBAL
GRAPH FILE MAI00005H_RCLOG
-* Created by Advanced Graph Assistant
SUM
	MAX.END_T1 AS 'End'
	MIN.START_T1 AS 'Start'

-*	FST.TODAY_DT NOPRINT

BY JOB_NAME AS 'Job'
HEADING
"Reportcaster activity"
"Date: <FST.TODAY_DT"

ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET HAXIS 1200
ON GRAPH SET VAXIS 770
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH STOCKH
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setReportParsingErrors(false);
setFillColor(getChartBackground(),new Color(220, 220, 220));
setFillColor(getFrame(),new Color(220, 220, 220));
setFillColor(getFrameBottom(), new Color(220, 220, 220));
setFillColor(getFrameSide(), new Color(220, 220, 220));
setTransparentBorderColor(getChartBackground(),true);
setLegendDisplay(false);

setScaleMinAuto(getY1Axis(),false);
setScaleMin(getY1Axis(),-1.0);
setScaleMaxAuto(getY1Axis(),false);
setScaleMax(getY1Axis(),25.0);

setTextRotation(getO1Label(),3);
setFontSizeAbsolute(getO1Label(),true);
setFontSizeInPoints(getO1Label(),10);
setPlaceResize(getO1Label(),0);

setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),10);
setPlaceResize(getY1Label(),0);

setFontSizeAbsolute(getDataText(),true);
setFontSizeInPoints(getDataText(),8);
setPlaceResize(getDataText(),0);

setFontSizeAbsolute(getY1Title(),true);
setFontSizeInPoints(getY1Title(),10);
setPlaceResize(getY1Title(),0);
setTextString(getY1Title(),"Run time (hrs)");
setDisplay(getY1Title(),true);

setDisplay(getReferenceLineY1(0),true);
setDisplay(getReferenceLineY1(1),true);

setStock52WeekHighDisplay(true);
setStock52WeekHighValue(24.0);
setStock52WeekLowDisplay(true);
setStock52WeekLowValue(0.0);
ENDSTYLE
END

This message has been edited. Last edited by: Wep5622,


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
Updated to use an SQL query instead of relying on the master file, as time-zone conversions were needed (EPOCH is in GMT, not in local time) and WebFOCUS has no functionality for that.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
quote:
Repeating jobs should ideally have repeating bar segments:


Define an augmented jobname with unique value for each row selected from BOTLOG.

I would

count entries by JOB_NAME
print * by JOB_NAME by START_DT
HOLD

and then append a tie-breaker suffix (e.g., '(hhmm)' based on start time) to JOB_NAME wherever COUNT > 1.

I wouldn't worry about obtaining finer granularity in the suffix; If the same job starts multiple times in same minute, those would still be combined into a single bar, but that's probably fine in your context.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
If I understand you correctly, you suggest to create an extra item on the ordinal axis for every time the task runs?
The graph display tasks in a 24h time period, in our case with some tasks repeating every 15 minutes - that's 96 ordinal positions for only that task!
The O-axis isn't wide enough for that...

What I really hope for is a way to stack the graph, in such a way that the same task at a later moment ends up ABOVE the previous bar.

I think part of the problem is that WebFOCUS has no support for timeline graphs, something like this (which has the axis swapped, mind you!):

 task 1     |  +---+    +---+     +-+               ++      +--------+
 task 2     |       +---------------+              +-----------------+
 task 3     | ++        ++               ++             ++              ++
------------+------------------------------------------------------------------------
 hour   -1  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24


(No, this is not an actual example of our schedules)


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
No, I mean in the data prep steps, define an alternative identifier (the original jobname plus a tiebreaker suffix where needed to distinguish multiple starts of the same task) and use that as sort variable in the graph request. Something like this:
TABLE FILE RCLOG
WRITE CNT.JOB_NAME NOPRINT
  BY JOB_NAME AS JOB_NAME20
PRINT
 START_T1
 END_T1
 TODAY_DT
COMPUTE SUFFIX/A8=IF CNT.JOB_NAME LT 2 THEN ''
     ELSE  EDIT(HCNVRT(START_T, '(HHISs)', 20, 'A20'), ' [99$:99]');
  BY JOB_NAME AS JOB_NAME20
ON TABLE SET ASNAMES ON AND HOLDLIST PRINTONLY
ON TABLE HOLD AS MAI00005H_RCLOG
END

DEFINE FILE MAI00005H_RCLOG
  JOB_NAME/A28=JOB_NAME20 || SUFFIX
END

GRAPH FILE MAI00005H_RCLOG 
... 
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
I tried that, and it's exactly as I understood already. That creates an unreadable graph, as there are way too many items on the ordinal axis...

Using the earlier (inverted) graph as an example, with your suggestion I get something like:
 task 1     |  +---+
 task 1     |           +---+
 task 1     |                     +-+
 task 1     |                                       ++
 task 1     |                                               +--------+
 task 2     |       +---------------+
 task 2     |                                      +-----------------+
 task 3     | ++
 task 3     |           ++
 task 3     |                            ++
 task 3     |                                           ++
 task 3     |                                                           ++
------------+------------------------------------------------------------------------
 hour   -1  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24


And that's with a highly reduced number of repeating occurrences. In reality some tasks get about 100 entries on the ordinal (vertical in the above) axis if I apply your solution.

I really want only 1 entry on the ordinal axis per schedule, as there are enough schedules already to fill up most of the available axis space with just those.

But thanks for trying.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
I tried my hand at your problem. This is what I came up with. Maybe not exactly what you might want, but who knows.

I created (by hand) the following data:
  
task1    01.00 01.75
task1    01.25 02.00
task1    02.50 02.75
task1    03.00 03.75
task2    03.00 04.00
task2    03.50 04.50
task2    03.75 04.75
task2    04.00 05.00
task3    05.00 06.50
task3    06.00 07.50
task3    06.25 07.75
task4    10.00 10.50
task4    10.50 11.00
task4    10.75 11.25
task4    11.00 11.50
task4    11.25 11.70
task5    05.00 10.00
task5    10.00 15.00
task6    02.00 03.00
task7    02.75 03.75 

For each task type (task1, task2...) there is the start time and the end time. You can see that there are a few tasks with the same name, just the way you described.
For each task type, I rearranged the times in chronological order:
  
 task1     1.00  1.25  1.75  2.00  2.50  2.75  3.00  3.75
 task2     3.00  3.50  3.75  4.00  4.50  4.75  5.00
 task3     5.00  6.00  6.25  6.50  7.50  7.75
 task4    10.00 10.50 10.75 11.00 11.25 11.50 11.70
 task5     5.00 10.00 15.00
 task6     2.00  3.00
 task7     2.75  3.75

Then I graphed the result with a line of tick marks as a title for 24 hours:

A good approximation?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Master
posted Hide Post
Wep,
I have the exact same need, but for a different reason -- I'm trying to answer the question "If we have a production downtime on this date for this timeframe, what will be impacted?"

For my needs, I'll have to take consideration that I have to look at the last run time (or average of the last n runs) to guess what it will be this time. I'll also have to tie out reports to the data sources (a production downtime in the Oracle environment does not affect reports using the SQL Server environment).

To your issues, I have 2 pieces of code that may help you out (or at the least, hopefully you'll find them interesting).

What failed between this time and that time?:
Select  
Distinct Job_Desc
, 'Leith' As Server
, DATEADD(hh, (select datepart(hh,(getutcdate() - getdate())) * -1), DATEADD(ss, convert(bigint,SUBSTRING(start_stamp, PATINDEX('%[^0]%', start_stamp), LEN(start_stamp))) / 1000, '1970-01-01')) AS 'translated_start_date'
, DATEADD(hh, (select datepart(hh,(getutcdate() - getdate())) * -1), DATEADD(ss, convert(bigint,SUBSTRING(end_stamp, PATINDEX('%[^0]%', end_stamp), LEN(end_stamp))) / 1000, '1970-01-01')) AS 'translated_end_date'

From Rcaster05.Dbo.Botlog2 
inner join Rcaster05.dbo.botlog on Rcaster05.dbo.botlog.stat_bt_name = Rcaster05.dbo.botlog2.stat_bt_name 

Where 
Error <> 0 
AND (
Dateadd(Hh, (Select Datepart(Hh,(Getutcdate() - Getdate())) * -1), Dateadd(Ss, Convert(Bigint,Substring(Start_Stamp, Patindex('%[^0]%', Start_Stamp), Len(Start_Stamp))) / 1000, '1970-01-01')) >= '2012-01-24 20:00:00' And
DATEADD(hh, (select datepart(hh,(getutcdate() - getdate())) * -1), DATEADD(ss, convert(bigint,SUBSTRING(start_stamp, PATINDEX('%[^0]%', start_stamp), LEN(start_stamp))) / 1000, '1970-01-01')) <= '2012-01-25 08:00:00'
)


This code will help you organize your data in the format that you are wanting. It tells me how long a patient was in a bed. There is a pre-consumption table that loads a start time and an end time for a given patient to a given bed -- a lot like what Danny-SRL has indicated. In a nutshell, I have to go through 24 hourly iterations to see how many minutes of that hour a patient was present. Having a hard time showing the output, but it is as you describe and I can send to you as an attachment if you PM me.

How many minutes did someone occupy a bed?
-PROMPT &FROMDATE.A8.Enter Start Date (YYYYMMDD):.;
-PROMPT &TODATE.A8.Enter End Date (YYYYMMDD):.;


-* Can't Span Months
-SET &FROMMM = EDIT(&FROMDATE,'$$$$99$$');
-SET &TOMM   = EDIT(&TODATE,'$$$$99$$');
-IF &FROMMM NE &TOMM THEN GOTO ERRONEMONTH;





-SET &DEPARTMENT   = '101926400';

-SET &MYDATE       = &FROMDATE;
-SET &DAYSTOLOOP   = (&TODATE - &FROMDATE) + 1;
-SET &ILOOPNO      = 0;



-* SET THE 'LOOP' VARS ONLY TO CALC THE LOOP DAYS
-SET &FROMDATELOOP = DATECVT(&FROMDATE, 'I8YYMD', 'YYMD');
-SET &TODATELOOP   = DATECVT(&TODATE, 'I8YYMD', 'YYMD');
-SET &DAYSTOLOOP   = DATEDIF(&FROMDATELOOP,&TODATELOOP,'D');
-SET &DAYSTOLOOP   = &DAYSTOLOOP + 1;


-*-TYPE &|FROMDATE     = &FROMDATE
-*-TYPE &|TODATE       = &TODATE
-*-TYPE &|MYDATE       = &MYDATE
-*-TYPE &|DAYSTOLOOP   = &DAYSTOLOOP
-*-EXIT




-* GET # BEDS IN DEPT FOR CALCS
JOIN CLEAR *

JOIN
 INNER HSCLARITY_ROM.HSCLARITY_ROM.ROOM_ID IN HSCLARITY_ROM TO UNIQUE
 HSCLARITY_BED.HSCLARITY_BED.ROOM_ID IN HSCLARITY_BED TAG J0 AS J0
 END

TABLE FILE HSCLARITY_ROM
SUM
	CNT.HSCLARITY_BED.BED_ID AS 'BEDS_IN_UNIT'

WHERE DEPARTMENT_ID EQ '&DEPARTMENT';
ON TABLE HOLD AS BT_CNT_DEPT FORMAT ALPHA
END


-RUN
-READ BT_CNT_DEPT &BEDS_IN_UNIT.I5.
-RUN

-*-TYPE &|BEDS_IN_UNIT = &BEDS_IN_UNIT
-* GET # BEDS IN DEPT FOR CALCS



DEFINE FILE DMBEDOCCDW
	THE_DATE/YYMD                    = HDATE(DATE_OCC, 'YYMD');
	DEPARTMENT_ID/P19                = DEPARTMENT_ID;
	BED_LABEL/A256                   = BED_LABEL;
	BED_ID/A18                       = BED_ID;
	PAT_ENC_CSN_ID/P19               = PAT_ENC_CSN_ID;
	PAT_ID/A18                       = PAT_ID;
	DATES_SAME/A1                    = DATES_SAME;
	PARENT_FROM_CALC_DATETIME/HYYMDs = PARENT_FROM_CALC_DATETIME;
	PARENT_TO_CALC_DATETIME/HYYMDs   = PARENT_TO_CALC_DATETIME;
	PARENT_EFFECTIVE_TIME/HYYMDs     = PARENT_EFFECTIVE_TIME;
	CHILD_EFFECTIVE_TIME/HYYMDs      = CHILD_EFFECTIVE_TIME;
	PARENT_EVENT_ID/P19              = PARENT_EVENT_ID;
	CHILD_EVENT_ID/P19               = CHILD_EVENT_ID;
	XIN_EVENT_ID/P19                 = XIN_EVENT_ID;
	XOUT_EVENT_ID/P19                = XOUT_EVENT_ID;
	PARENT_EVENT_TYPE/I11            = PARENT_EVENT_TYPE;
	CHILD_EVENT_TYPE/I11             = CHILD_EVENT_TYPE;
	FROM_DEPT/P19                    = FROM_DEPT;
	TO_DEPT/P19                      = TO_DEPT;
	SECS_IN_BED_FOR_DATE/I11         = SECS_IN_BED_FOR_DATE;
END


TABLE FILE DMBEDOCCDW
PRINT
	PAT_ENC_CSN_ID
	PAT_ID
	DATES_SAME
	PARENT_FROM_CALC_DATETIME
	PARENT_TO_CALC_DATETIME
	PARENT_EFFECTIVE_TIME
	CHILD_EFFECTIVE_TIME
	PARENT_EVENT_ID AS 'PARENT_EVENT'
	CHILD_EVENT_ID  AS 'CHILD_EVENT'
	XIN_EVENT_ID
	XOUT_EVENT_ID
	PARENT_EVENT_TYPE AS 'EVENT_PARENT'
	CHILD_EVENT_TYPE  AS 'EVENT_CHILD'
	FROM_DEPT
	TO_DEPT
	SECS_IN_BED_FOR_DATE

	BY THE_DATE AS 'THE_DATE'
	BY DEPARTMENT_ID
	BY BED_LABEL
	BY BED_ID

WHERE DATE_OCC FROM DT('&FROMDATE') TO DT('&TODATE');
WHERE DEPARTMENT_ID EQ '&DEPARTMENT';
ON TABLE HOLD AS BT_BED_UTIL_BASE
END







-***********************************************************
-* Details By Patient
-***********************************************************

JOIN CLEAR *

JOIN
 LEFT_OUTER BT_BED_UTIL_BASE.PAT_ID IN BT_BED_UTIL_BASE TO UNIQUE
 HSPATIENT.PAT_ID IN HSPATIENT TAG J0 AS J10
 END


DEFINE FILE BT_BED_UTIL_BASE
	PAT_NAME/A1000 = IF PAT_NAME IS MISSING THEN '** UNOCCUPIED' ELSE PAT_NAME;
END

TABLE FILE BT_BED_UTIL_BASE
PRINT
	PAT_NAME
	PAT_ID
	PARENT_FROM_CALC_DATETIME
	PARENT_TO_CALC_DATETIME
	SECS_IN_BED_FOR_DATE
	PARENT_EVENT
	CHILD_EVENT
	EVENT_PARENT
	EVENT_CHILD
	XIN_EVENT_ID
	XOUT_EVENT_ID

	BY THE_DATE
	BY BED_LABEL

ON TABLE HOLD AS BT_PAT_DISP_BASE
END




-* XINs / XOUTs

JOIN CLEAR *

JOIN
 LEFT_OUTER XIN_EVENT_ID IN BT_PAT_DISP_BASE TAG BASE1
 TO UNIQUE EVENT_ID IN HSCLARITY_ADT TAG XINFROM AS J20
 END


TABLE FILE BT_PAT_DISP_BASE
PRINT
	BASE1.PAT_NAME
	BASE1.PAT_ID
	BASE1.PARENT_FROM_CALC_DATETIME
	BASE1.PARENT_TO_CALC_DATETIME
	BASE1.SECS_IN_BED_FOR_DATE
	BASE1.PARENT_EVENT
	BASE1.CHILD_EVENT
	BASE1.EVENT_PARENT
	BASE1.EVENT_CHILD
	XINFROM.DEPARTMENT_ID AS 'XIN_DISP'
	XOUT_EVENT_ID

	BY BASE1.THE_DATE
	BY BASE1.BED_LABEL

ON TABLE HOLD AS BT_PAT_XIN
END




JOIN CLEAR *

JOIN
 LEFT_OUTER XOUT_EVENT_ID IN BT_PAT_XIN TAG BASE2
 TO UNIQUE EVENT_ID IN HSCLARITY_ADT TAG XOUTTO AS J30
 END


DEFINE FILE BT_PAT_XIN
	-*DEPT_IN_DISP/A19  = PTOA(XIN_DISP, '(P19)', DEPT_IN_DISP);
	DEPT_IN_DISP/A19  = TRIM('B', PTOA(XIN_DISP, '(P19)', 'A19'), 19, ' ', 1, 'A19');

	-*DEPT_OUT_DISP/A19 = PTOA(XOUTTO.DEPARTMENT_ID,'(P19)',DEPT_IN_DISP);
	DEPT_OUT_DISP/A19  = TRIM('B', PTOA(XOUTTO.DEPARTMENT_ID, '(P19)', 'A19'), 19, ' ', 1, 'A19');

	FROM_TIME_HH/A2  = HNAME(BASE2.PARENT_FROM_CALC_DATETIME, 'HH', 'A2');
	FROM_TIME_MM/A2  = HNAME(BASE2.PARENT_FROM_CALC_DATETIME, 'MI', 'A2');
	FROM_TIME_SS/A2  = HNAME(BASE2.PARENT_FROM_CALC_DATETIME, 'SS', 'A2');

	FROM_TIME/A8     = FROM_TIME_HH | ':' | FROM_TIME_MM | ':' | FROM_TIME_SS;

	TO_TIME_HH/A2    = HNAME(BASE2.PARENT_TO_CALC_DATETIME, 'HH', 'A2');
	TO_TIME_MM/A2    = HNAME(BASE2.PARENT_TO_CALC_DATETIME, 'MI', 'A2');
	TO_TIME_SS/A2    = HNAME(BASE2.PARENT_TO_CALC_DATETIME, 'SS', 'A2');

	TO_TIME/A8       = TO_TIME_HH | ':' | TO_TIME_MM | ':' | TO_TIME_SS;

	IN_DISP/A100  = IF EVENT_PARENT EQ '1' THEN 'ADMITTED' ELSE
					IF EVENT_PARENT EQ '2' THEN 'DISCHARGED' ELSE
					IF EVENT_PARENT EQ '3' THEN 'XIN (FROM DEPT: ' | DEPT_IN_DISP || ')' ELSE
					IF EVENT_PARENT EQ '4' THEN 'XOUT (TO DEPT: ' | DEPT_OUT_DISP || ')' ELSE
					IF EVENT_PARENT EQ '5' THEN 'PT UPDATE' ELSE
					IF EVENT_PARENT EQ '6' THEN 'CENSUS' ELSE
					IF EVENT_PARENT EQ '7' THEN 'LOA OUT' ELSE
					IF EVENT_PARENT EQ '8' THEN 'LOA IN' ELSE
					IF PAT_NAME EQ '** UNOCCUPIED' THEN 'N/A' ELSE
					'UNKNOWN';

	OUT_DISP/A100  = IF EVENT_CHILD EQ '1' THEN 'ADMITTED' ELSE
					IF EVENT_CHILD EQ '2' THEN 'DISCHARGED' ELSE
					IF EVENT_CHILD EQ '3' THEN 'XIN (FROM DEPT: ' | DEPT_IN_DISP || ')' ELSE
					IF EVENT_CHILD EQ '4' THEN 'XOUT (TO DEPT: ' | DEPT_OUT_DISP || ')' ELSE
					IF EVENT_CHILD EQ '5' THEN 'PT UPDATE' ELSE
					IF EVENT_CHILD EQ '6' THEN 'CENSUS' ELSE
					IF EVENT_CHILD EQ '7' THEN 'LOA OUT' ELSE
					IF EVENT_CHILD EQ '8' THEN 'LOA IN' ELSE
					IF PAT_NAME EQ '** UNOCCUPIED' THEN 'N/A' ELSE
					'UNKNOWN';

END

TABLE FILE BT_PAT_XIN
PRINT
	BASE2.PAT_NAME
	BASE2.PAT_ID
	BASE2.PARENT_FROM_CALC_DATETIME
	FROM_TIME
	BASE2.PARENT_TO_CALC_DATETIME
	TO_TIME
	SECS_IN_BED_FOR_DATE
	IN_DISP
	OUT_DISP
	BY BASE2.THE_DATE
	BY BASE2.BED_LABEL

ON TABLE HOLD AS BT_PAT_ROLLUP_OUT
END



-***********************************************************
-* Details By Bed/Date
-***********************************************************

TABLE FILE BT_BED_UTIL_BASE
SUM
	SECS_IN_BED_FOR_DATE

	BY THE_DATE
	BY BED_LABEL

ON TABLE HOLD AS BT_BED_SECS_OCC
END


DEFINE FILE BT_BED_SECS_OCC
	SEC_IN_DAY/I10 = 86400;
	UTIL_PCT/D10.2 = (SECS_IN_BED_FOR_DATE / SEC_IN_DAY) * 100;
	SEC_UNOCC/I10  = SEC_IN_DAY - SECS_IN_BED_FOR_DATE;

END

TABLE FILE BT_BED_SECS_OCC
PRINT
	SECS_IN_BED_FOR_DATE
	SEC_UNOCC
	SEC_IN_DAY
	UTIL_PCT

	BY THE_DATE
	BY BED_LABEL

ON TABLE HOLD AS BT_BED_ROLLUP_OUT
END






-***********************************************************
-* Roll Up By Date
-***********************************************************

TABLE FILE BT_BED_UTIL_BASE
SUM
	SECS_IN_BED_FOR_DATE

	BY THE_DATE

ON TABLE HOLD AS BT_BED_SECS_OCC_ROLL
END



DEFINE FILE BT_BED_SECS_OCC_ROLL
	SEC_IN_DAY/I10 = 86400 * &BEDS_IN_UNIT;
	UTIL_PCT/D10.2 = (SECS_IN_BED_FOR_DATE / SEC_IN_DAY) * 100;
	SEC_UNOCC/I10  = SEC_IN_DAY - SECS_IN_BED_FOR_DATE;
END

TABLE FILE BT_BED_SECS_OCC_ROLL
PRINT
	SECS_IN_BED_FOR_DATE
	SEC_UNOCC
	SEC_IN_DAY
	UTIL_PCT

	BY THE_DATE

ON TABLE HOLD AS BT_DAY_ROLLUP_OUT
END







-***********************************************************
-* Aggregate Roll Up for the period
-***********************************************************

TABLE FILE BT_BED_UTIL_BASE
SUM
	SECS_IN_BED_FOR_DATE

ON TABLE HOLD AS BT_BED_SECS_AGG_ROLL
END



DEFINE FILE BT_BED_SECS_AGG_ROLL
	SEC_IN_DAY/I10 = (86400 * &BEDS_IN_UNIT) * &DAYSTOLOOP;
	UTIL_PCT/D10.2 = (SECS_IN_BED_FOR_DATE / SEC_IN_DAY) * 100;

	SEC_UNOCC/I10  = SEC_IN_DAY - SECS_IN_BED_FOR_DATE;
END

TABLE FILE BT_BED_SECS_AGG_ROLL
PRINT
	SECS_IN_BED_FOR_DATE
	SEC_UNOCC
	SEC_IN_DAY
	UTIL_PCT

ON TABLE HOLD AS BT_AGG_ROLLUP_OUT
END








-SET &MYDATE       = &FROMDATE;
-SET &DAYSTOLOOP   = (&TODATE - &FROMDATE) + 1;
-SET &ILOOPNO      = 0;


-CONTINUE
-* SET THE 'LOOP' VARS ONLY TO CALC THE LOOP DAYS
-SET &FROMDATELOOP = DATECVT(&FROMDATE, 'I8YYMD', 'YYMD');
-SET &TODATELOOP   = DATECVT(&TODATE, 'I8YYMD', 'YYMD');
-SET &DAYSTOLOOP   = DATEDIF(&FROMDATELOOP,&TODATELOOP,'D');
-SET &DAYSTOLOOP   = &DAYSTOLOOP + 1;


-*-TYPE &|FROMDATE     = &FROMDATE
-*-TYPE &|TODATE       = &TODATE
-*-TYPE &|MYDATE       = &MYDATE
-*-TYPE &|DAYSTOLOOP   = &DAYSTOLOOP
-*-EXIT



-DOLOOP3

-SET &IHMFD  = 'BTLOOP' || &ILOOPNO;



DEFINE FILE DMBEDOCCDW
	THE_DATE/YYMD      = HDATE(DATE_OCC, 'YYMD');
	MY_START_DATE/YYMD = &MYDATE;

	START_00/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 0, 8, 'HYYMDs');
	END_00/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 0, 8, 'HYYMDs');
	OCC_00/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_00 TO END_00
						OR PARENT_TO_CALC_DATETIME FROM START_00 TO END_00
						OR START_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_00/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_00/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_00/YYMD        = &MYDATE;
	MY_START_DATETIME_00/HYYMDS  = DT(&MYDATE 00:00:00);
	MY_END_DATE_00/YYMD          = &MYDATE;
	MY_END_DATETIME_00/HYYMDS    = DT(&MYDATE 00:59:59);
	FROM_00/HYYMDs MISSING ON = IF PARENT_DATETIME_00 LT START_00 THEN MY_START_DATETIME_00 ELSE PARENT_EFFECTIVE_TIME;
	TO_00/HYYMDs MISSING ON   = IF CHILD_DATETIME_00 GT END_00 THEN MY_END_DATETIME_00 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_00/I10    = IF OCC_00 EQ 1 THEN HDIFF(TO_00, FROM_00, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_00/D10.2         = IF OCC_00 EQ 1 THEN (SECS_IN_BED_FOR_00 / 3600) * 100 ELSE 0;


	START_01/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 1, 8, 'HYYMDs');
	END_01/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 1, 8, 'HYYMDs');
	OCC_01/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_01 TO END_01
						OR PARENT_TO_CALC_DATETIME FROM START_01 TO END_01
						OR START_01 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_01 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_01/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_01/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_01/YYMD        = &MYDATE;
	MY_START_DATETIME_01/HYYMDS  = DT(&MYDATE 01:00:00);
	MY_END_DATE_01/YYMD          = &MYDATE;
	MY_END_DATETIME_01/HYYMDS    = DT(&MYDATE 01:59:59);
	FROM_01/HYYMDs MISSING ON = IF PARENT_DATETIME_01 LT START_01 THEN MY_START_DATETIME_01 ELSE PARENT_EFFECTIVE_TIME;
	TO_01/HYYMDs MISSING ON   = IF CHILD_DATETIME_01 GT END_01 THEN MY_END_DATETIME_01 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_01/I10    = IF OCC_01 EQ 1 THEN HDIFF(TO_01, FROM_01, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_01/D10.2         = IF OCC_01 EQ 1 THEN (SECS_IN_BED_FOR_01 / 3600) * 100 ELSE 0;


	START_02/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 2, 8, 'HYYMDs');
	END_02/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 2, 8, 'HYYMDs');
	OCC_02/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_02 TO END_02
						OR PARENT_TO_CALC_DATETIME FROM START_02 TO END_02
						OR START_02 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_02 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_02/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_02/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_02/YYMD        = &MYDATE;
	MY_START_DATETIME_02/HYYMDS  = DT(&MYDATE 02:00:00);
	MY_END_DATE_02/YYMD          = &MYDATE;
	MY_END_DATETIME_02/HYYMDS    = DT(&MYDATE 02:59:59);
	FROM_02/HYYMDs MISSING ON = IF PARENT_DATETIME_02 LT START_02 THEN MY_START_DATETIME_02 ELSE PARENT_EFFECTIVE_TIME;
	TO_02/HYYMDs MISSING ON   = IF CHILD_DATETIME_02 GT END_02 THEN MY_END_DATETIME_02 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_02/I10    = IF OCC_02 EQ 1 THEN HDIFF(TO_02, FROM_02, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_02/D10.2         = IF OCC_02 EQ 1 THEN (SECS_IN_BED_FOR_02 / 3600) * 100 ELSE 0;


	START_03/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 3, 8, 'HYYMDs');
	END_03/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 3, 8, 'HYYMDs');
	OCC_03/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_03 TO END_03
						OR PARENT_TO_CALC_DATETIME FROM START_03 TO END_03
						OR START_03 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_03 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_03/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_03/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_03/YYMD        = &MYDATE;
	MY_START_DATETIME_03/HYYMDS  = DT(&MYDATE 03:00:00);
	MY_END_DATE_03/YYMD          = &MYDATE;
	MY_END_DATETIME_03/HYYMDS    = DT(&MYDATE 03:59:59);
	FROM_03/HYYMDs MISSING ON = IF PARENT_DATETIME_03 LT START_03 THEN MY_START_DATETIME_03 ELSE PARENT_EFFECTIVE_TIME;
	TO_03/HYYMDs MISSING ON   = IF CHILD_DATETIME_03 GT END_03 THEN MY_END_DATETIME_03 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_03/I10    = IF OCC_03 EQ 1 THEN HDIFF(TO_03, FROM_03, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_03/D10.2         = IF OCC_03 EQ 1 THEN (SECS_IN_BED_FOR_03 / 3600) * 100 ELSE 0;


	START_04/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 4, 8, 'HYYMDs');
	END_04/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 4, 8, 'HYYMDs');
	OCC_04/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_04 TO END_04
						OR PARENT_TO_CALC_DATETIME FROM START_04 TO END_04
						OR START_04 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_04 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_04/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_04/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_04/YYMD        = &MYDATE;
	MY_START_DATETIME_04/HYYMDS  = DT(&MYDATE 04:00:00);
	MY_END_DATE_04/YYMD          = &MYDATE;
	MY_END_DATETIME_04/HYYMDS    = DT(&MYDATE 04:59:59);
	FROM_04/HYYMDs MISSING ON = IF PARENT_DATETIME_04 LT START_04 THEN MY_START_DATETIME_04 ELSE PARENT_EFFECTIVE_TIME;
	TO_04/HYYMDs MISSING ON   = IF CHILD_DATETIME_04 GT END_04 THEN MY_END_DATETIME_04 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_04/I10    = IF OCC_04 EQ 1 THEN HDIFF(TO_04, FROM_04, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_04/D10.2         = IF OCC_04 EQ 1 THEN (SECS_IN_BED_FOR_04 / 3600) * 100 ELSE 0;


	START_05/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 5, 8, 'HYYMDs');
	END_05/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 5, 8, 'HYYMDs');
	OCC_05/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_05 TO END_05
						OR PARENT_TO_CALC_DATETIME FROM START_05 TO END_05
						OR START_05 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_05 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_05/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_05/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_05/YYMD        = &MYDATE;
	MY_START_DATETIME_05/HYYMDS  = DT(&MYDATE 05:00:00);
	MY_END_DATE_05/YYMD          = &MYDATE;
	MY_END_DATETIME_05/HYYMDS    = DT(&MYDATE 05:59:59);
	FROM_05/HYYMDs MISSING ON = IF PARENT_DATETIME_05 LT START_05 THEN MY_START_DATETIME_05 ELSE PARENT_EFFECTIVE_TIME;
	TO_05/HYYMDs MISSING ON   = IF CHILD_DATETIME_05 GT END_05 THEN MY_END_DATETIME_05 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_05/I10    = IF OCC_05 EQ 1 THEN HDIFF(TO_05, FROM_05, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_05/D10.2         = IF OCC_05 EQ 1 THEN (SECS_IN_BED_FOR_05 / 3600) * 100 ELSE 0;


	START_06/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 6, 8, 'HYYMDs');
	END_06/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 6, 8, 'HYYMDs');
	OCC_06/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_06 TO END_06
						OR PARENT_TO_CALC_DATETIME FROM START_06 TO END_06
						OR START_06 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_06 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_06/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_06/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_06/YYMD        = &MYDATE;
	MY_START_DATETIME_06/HYYMDS  = DT(&MYDATE 06:00:00);
	MY_END_DATE_06/YYMD          = &MYDATE;
	MY_END_DATETIME_06/HYYMDS    = DT(&MYDATE 06:59:59);
	FROM_06/HYYMDs MISSING ON = IF PARENT_DATETIME_06 LT START_06 THEN MY_START_DATETIME_06 ELSE PARENT_EFFECTIVE_TIME;
	TO_06/HYYMDs MISSING ON   = IF CHILD_DATETIME_06 GT END_06 THEN MY_END_DATETIME_06 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_06/I10    = IF OCC_06 EQ 1 THEN HDIFF(TO_06, FROM_06, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_06/D10.2         = IF OCC_06 EQ 1 THEN (SECS_IN_BED_FOR_06 / 3600) * 100 ELSE 0;


	START_07/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 7, 8, 'HYYMDs');
	END_07/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 7, 8, 'HYYMDs');
	OCC_07/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_07 TO END_07
						OR PARENT_TO_CALC_DATETIME FROM START_07 TO END_07
						OR START_07 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_07 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_07/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_07/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_07/YYMD        = &MYDATE;
	MY_START_DATETIME_07/HYYMDS  = DT(&MYDATE 07:00:00);
	MY_END_DATE_07/YYMD          = &MYDATE;
	MY_END_DATETIME_07/HYYMDS    = DT(&MYDATE 07:59:59);
	FROM_07/HYYMDs MISSING ON = IF PARENT_DATETIME_07 LT START_07 THEN MY_START_DATETIME_07 ELSE PARENT_EFFECTIVE_TIME;
	TO_07/HYYMDs MISSING ON   = IF CHILD_DATETIME_07 GT END_07 THEN MY_END_DATETIME_07 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_07/I10    = IF OCC_07 EQ 1 THEN HDIFF(TO_07, FROM_07, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_07/D10.2         = IF OCC_07 EQ 1 THEN (SECS_IN_BED_FOR_07 / 3600) * 100 ELSE 0;


	START_08/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 8, 8, 'HYYMDs');
	END_08/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 8, 8, 'HYYMDs');
	OCC_08/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_08 TO END_08
						OR PARENT_TO_CALC_DATETIME FROM START_08 TO END_08
						OR START_08 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_08 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_08/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_08/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_08/YYMD        = &MYDATE;
	MY_START_DATETIME_08/HYYMDS  = DT(&MYDATE 08:00:00);
	MY_END_DATE_08/YYMD          = &MYDATE;
	MY_END_DATETIME_08/HYYMDS    = DT(&MYDATE 08:59:59);
	FROM_08/HYYMDs MISSING ON = IF PARENT_DATETIME_08 LT START_08 THEN MY_START_DATETIME_08 ELSE PARENT_EFFECTIVE_TIME;
	TO_08/HYYMDs MISSING ON   = IF CHILD_DATETIME_08 GT END_08 THEN MY_END_DATETIME_08 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_08/I10    = IF OCC_08 EQ 1 THEN HDIFF(TO_08, FROM_08, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_08/D10.2         = IF OCC_08 EQ 1 THEN (SECS_IN_BED_FOR_08 / 3600) * 100 ELSE 0;


	START_09/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 9, 8, 'HYYMDs');
	END_09/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 9, 8, 'HYYMDs');
	OCC_09/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_09 TO END_09
						OR PARENT_TO_CALC_DATETIME FROM START_09 TO END_09
						OR START_09 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_09 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_09/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_09/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_09/YYMD        = &MYDATE;
	MY_START_DATETIME_09/HYYMDS  = DT(&MYDATE 09:00:00);
	MY_END_DATE_09/YYMD          = &MYDATE;
	MY_END_DATETIME_09/HYYMDS    = DT(&MYDATE 09:59:59);
	FROM_09/HYYMDs MISSING ON = IF PARENT_DATETIME_09 LT START_09 THEN MY_START_DATETIME_09 ELSE PARENT_EFFECTIVE_TIME;
	TO_09/HYYMDs MISSING ON   = IF CHILD_DATETIME_09 GT END_09 THEN MY_END_DATETIME_09 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_09/I10    = IF OCC_09 EQ 1 THEN HDIFF(TO_09, FROM_09, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_09/D10.2         = IF OCC_09 EQ 1 THEN (SECS_IN_BED_FOR_09 / 3600) * 100 ELSE 0;


	START_10/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 10, 8, 'HYYMDs');
	END_10/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 10, 8, 'HYYMDs');
	OCC_10/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_10 TO END_10
						OR PARENT_TO_CALC_DATETIME FROM START_10 TO END_10
						OR START_10 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_10 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_10/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_10/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_10/YYMD        = &MYDATE;
	MY_START_DATETIME_10/HYYMDS  = DT(&MYDATE 10:00:00);
	MY_END_DATE_10/YYMD          = &MYDATE;
	MY_END_DATETIME_10/HYYMDS    = DT(&MYDATE 10:59:59);
	FROM_10/HYYMDs MISSING ON = IF PARENT_DATETIME_10 LT START_10 THEN MY_START_DATETIME_10 ELSE PARENT_EFFECTIVE_TIME;
	TO_10/HYYMDs MISSING ON   = IF CHILD_DATETIME_10 GT END_10 THEN MY_END_DATETIME_10 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_10/I10    = IF OCC_10 EQ 1 THEN HDIFF(TO_10, FROM_10, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_10/D10.2         = IF OCC_10 EQ 1 THEN (SECS_IN_BED_FOR_10 / 3600) * 100 ELSE 0;


	START_11/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 11, 8, 'HYYMDs');
	END_11/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 11, 8, 'HYYMDs');
	OCC_11/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_11 TO END_11
						OR PARENT_TO_CALC_DATETIME FROM START_11 TO END_11
						OR START_11 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_11 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_11/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_11/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_11/YYMD        = &MYDATE;
	MY_START_DATETIME_11/HYYMDS  = DT(&MYDATE 11:00:00);
	MY_END_DATE_11/YYMD          = &MYDATE;
	MY_END_DATETIME_11/HYYMDS    = DT(&MYDATE 11:59:59);
	FROM_11/HYYMDs MISSING ON = IF PARENT_DATETIME_11 LT START_11 THEN MY_START_DATETIME_11 ELSE PARENT_EFFECTIVE_TIME;
	TO_11/HYYMDs MISSING ON   = IF CHILD_DATETIME_11 GT END_11 THEN MY_END_DATETIME_11 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_11/I10    = IF OCC_11 EQ 1 THEN HDIFF(TO_11, FROM_11, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_11/D10.2         = IF OCC_11 EQ 1 THEN (SECS_IN_BED_FOR_11 / 3600) * 100 ELSE 0;


	START_12/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 12, 8, 'HYYMDs');
	END_12/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 12, 8, 'HYYMDs');
	OCC_12/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_12 TO END_12
						OR PARENT_TO_CALC_DATETIME FROM START_12 TO END_12
						OR START_12 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_12 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_12/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_12/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_12/YYMD        = &MYDATE;
	MY_START_DATETIME_12/HYYMDS  = DT(&MYDATE 12:00:00);
	MY_END_DATE_12/YYMD          = &MYDATE;
	MY_END_DATETIME_12/HYYMDS    = DT(&MYDATE 12:59:59);
	FROM_12/HYYMDs MISSING ON = IF PARENT_DATETIME_12 LT START_12 THEN MY_START_DATETIME_12 ELSE PARENT_EFFECTIVE_TIME;
	TO_12/HYYMDs MISSING ON   = IF CHILD_DATETIME_12 GT END_12 THEN MY_END_DATETIME_12 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_12/I10    = IF OCC_12 EQ 1 THEN HDIFF(TO_12, FROM_12, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_12/D10.2         = IF OCC_12 EQ 1 THEN (SECS_IN_BED_FOR_12 / 3600) * 100 ELSE 0;


	START_13/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 13, 8, 'HYYMDs');
	END_13/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 13, 8, 'HYYMDs');
	OCC_13/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_13 TO END_13
						OR PARENT_TO_CALC_DATETIME FROM START_13 TO END_13
						OR START_13 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_13 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_13/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_13/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_13/YYMD        = &MYDATE;
	MY_START_DATETIME_13/HYYMDS  = DT(&MYDATE 13:00:00);
	MY_END_DATE_13/YYMD          = &MYDATE;
	MY_END_DATETIME_13/HYYMDS    = DT(&MYDATE 13:59:59);
	FROM_13/HYYMDs MISSING ON = IF PARENT_DATETIME_13 LT START_13 THEN MY_START_DATETIME_13 ELSE PARENT_EFFECTIVE_TIME;
	TO_13/HYYMDs MISSING ON   = IF CHILD_DATETIME_13 GT END_13 THEN MY_END_DATETIME_13 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_13/I10    = IF OCC_13 EQ 1 THEN HDIFF(TO_13, FROM_13, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_13/D10.2         = IF OCC_13 EQ 1 THEN (SECS_IN_BED_FOR_13 / 3600) * 100 ELSE 0;


	START_14/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 14, 8, 'HYYMDs');
	END_14/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 14, 8, 'HYYMDs');
	OCC_14/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_14 TO END_14
						OR PARENT_TO_CALC_DATETIME FROM START_14 TO END_14
						OR START_14 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_14 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_14/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_14/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_14/YYMD        = &MYDATE;
	MY_START_DATETIME_14/HYYMDS  = DT(&MYDATE 14:00:00);
	MY_END_DATE_14/YYMD          = &MYDATE;
	MY_END_DATETIME_14/HYYMDS    = DT(&MYDATE 14:59:59);
	FROM_14/HYYMDs MISSING ON = IF PARENT_DATETIME_14 LT START_14 THEN MY_START_DATETIME_14 ELSE PARENT_EFFECTIVE_TIME;
	TO_14/HYYMDs MISSING ON   = IF CHILD_DATETIME_14 GT END_14 THEN MY_END_DATETIME_14 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_14/I10    = IF OCC_14 EQ 1 THEN HDIFF(TO_14, FROM_14, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_14/D10.2         = IF OCC_14 EQ 1 THEN (SECS_IN_BED_FOR_14 / 3600) * 100 ELSE 0;


	START_15/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 15, 8, 'HYYMDs');
	END_15/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 15, 8, 'HYYMDs');
	OCC_15/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_15 TO END_15
						OR PARENT_TO_CALC_DATETIME FROM START_15 TO END_15
						OR START_15 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_15 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_15/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_15/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_15/YYMD        = &MYDATE;
	MY_START_DATETIME_15/HYYMDS  = DT(&MYDATE 15:00:00);
	MY_END_DATE_15/YYMD          = &MYDATE;
	MY_END_DATETIME_15/HYYMDS    = DT(&MYDATE 15:59:59);
	FROM_15/HYYMDs MISSING ON = IF PARENT_DATETIME_15 LT START_15 THEN MY_START_DATETIME_15 ELSE PARENT_EFFECTIVE_TIME;
	TO_15/HYYMDs MISSING ON   = IF CHILD_DATETIME_15 GT END_15 THEN MY_END_DATETIME_15 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_15/I10    = IF OCC_15 EQ 1 THEN HDIFF(TO_15, FROM_15, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_15/D10.2         = IF OCC_15 EQ 1 THEN (SECS_IN_BED_FOR_15 / 3600) * 100 ELSE 0;


	START_16/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 16, 8, 'HYYMDs');
	END_16/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 16, 8, 'HYYMDs');
	OCC_16/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_16 TO END_16
						OR PARENT_TO_CALC_DATETIME FROM START_16 TO END_16
						OR START_16 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_16 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_16/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_16/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_16/YYMD        = &MYDATE;
	MY_START_DATETIME_16/HYYMDS  = DT(&MYDATE 16:00:00);
	MY_END_DATE_16/YYMD          = &MYDATE;
	MY_END_DATETIME_16/HYYMDS    = DT(&MYDATE 16:59:59);
	FROM_16/HYYMDs MISSING ON = IF PARENT_DATETIME_16 LT START_16 THEN MY_START_DATETIME_16 ELSE PARENT_EFFECTIVE_TIME;
	TO_16/HYYMDs MISSING ON   = IF CHILD_DATETIME_16 GT END_16 THEN MY_END_DATETIME_16 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_16/I10    = IF OCC_16 EQ 1 THEN HDIFF(TO_16, FROM_16, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_16/D10.2         = IF OCC_16 EQ 1 THEN (SECS_IN_BED_FOR_16 / 3600) * 100 ELSE 0;


	START_17/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 17, 8, 'HYYMDs');
	END_17/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 17, 8, 'HYYMDs');
	OCC_17/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_17 TO END_17
						OR PARENT_TO_CALC_DATETIME FROM START_17 TO END_17
						OR START_17 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_17 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_17/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_17/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_17/YYMD        = &MYDATE;
	MY_START_DATETIME_17/HYYMDS  = DT(&MYDATE 17:00:00);
	MY_END_DATE_17/YYMD          = &MYDATE;
	MY_END_DATETIME_17/HYYMDS    = DT(&MYDATE 17:59:59);
	FROM_17/HYYMDs MISSING ON = IF PARENT_DATETIME_17 LT START_17 THEN MY_START_DATETIME_17 ELSE PARENT_EFFECTIVE_TIME;
	TO_17/HYYMDs MISSING ON   = IF CHILD_DATETIME_17 GT END_17 THEN MY_END_DATETIME_17 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_17/I10    = IF OCC_17 EQ 1 THEN HDIFF(TO_17, FROM_17, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_17/D10.2         = IF OCC_17 EQ 1 THEN (SECS_IN_BED_FOR_17 / 3600) * 100 ELSE 0;


	START_18/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 18, 8, 'HYYMDs');
	END_18/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 18, 8, 'HYYMDs');
	OCC_18/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_18 TO END_18
						OR PARENT_TO_CALC_DATETIME FROM START_18 TO END_18
						OR START_18 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_18 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_18/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_18/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_18/YYMD        = &MYDATE;
	MY_START_DATETIME_18/HYYMDS  = DT(&MYDATE 18:00:00);
	MY_END_DATE_18/YYMD          = &MYDATE;
	MY_END_DATETIME_18/HYYMDS    = DT(&MYDATE 18:59:59);
	FROM_18/HYYMDs MISSING ON = IF PARENT_DATETIME_18 LT START_18 THEN MY_START_DATETIME_18 ELSE PARENT_EFFECTIVE_TIME;
	TO_18/HYYMDs MISSING ON   = IF CHILD_DATETIME_18 GT END_18 THEN MY_END_DATETIME_18 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_18/I10    = IF OCC_18 EQ 1 THEN HDIFF(TO_18, FROM_18, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_18/D10.2         = IF OCC_18 EQ 1 THEN (SECS_IN_BED_FOR_18 / 3600) * 100 ELSE 0;


	START_19/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 19, 8, 'HYYMDs');
	END_19/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 19, 8, 'HYYMDs');
	OCC_19/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_19 TO END_19
						OR PARENT_TO_CALC_DATETIME FROM START_19 TO END_19
						OR START_19 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_19 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_19/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_19/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_19/YYMD        = &MYDATE;
	MY_START_DATETIME_19/HYYMDS  = DT(&MYDATE 19:00:00);
	MY_END_DATE_19/YYMD          = &MYDATE;
	MY_END_DATETIME_19/HYYMDS    = DT(&MYDATE 19:59:59);
	FROM_19/HYYMDs MISSING ON = IF PARENT_DATETIME_19 LT START_19 THEN MY_START_DATETIME_19 ELSE PARENT_EFFECTIVE_TIME;
	TO_19/HYYMDs MISSING ON   = IF CHILD_DATETIME_19 GT END_19 THEN MY_END_DATETIME_19 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_19/I10    = IF OCC_19 EQ 1 THEN HDIFF(TO_19, FROM_19, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_19/D10.2         = IF OCC_19 EQ 1 THEN (SECS_IN_BED_FOR_19 / 3600) * 100 ELSE 0;


	START_20/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 20, 8, 'HYYMDs');
	END_20/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 20, 8, 'HYYMDs');
	OCC_20/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_20 TO END_20
						OR PARENT_TO_CALC_DATETIME FROM START_20 TO END_20
						OR START_20 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_20 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_20/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_20/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_20/YYMD        = &MYDATE;
	MY_START_DATETIME_20/HYYMDS  = DT(&MYDATE 20:00:00);
	MY_END_DATE_20/YYMD          = &MYDATE;
	MY_END_DATETIME_20/HYYMDS    = DT(&MYDATE 20:59:59);
	FROM_20/HYYMDs MISSING ON = IF PARENT_DATETIME_20 LT START_20 THEN MY_START_DATETIME_20 ELSE PARENT_EFFECTIVE_TIME;
	TO_20/HYYMDs MISSING ON   = IF CHILD_DATETIME_20 GT END_20 THEN MY_END_DATETIME_20 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_20/I10    = IF OCC_20 EQ 1 THEN HDIFF(TO_20, FROM_20, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_20/D10.2         = IF OCC_20 EQ 1 THEN (SECS_IN_BED_FOR_20 / 3600) * 100 ELSE 0;


	START_21/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 21, 8, 'HYYMDs');
	END_21/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 21, 8, 'HYYMDs');
	OCC_21/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_21 TO END_21
						OR PARENT_TO_CALC_DATETIME FROM START_21 TO END_21
						OR START_21 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_21 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_21/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_21/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_21/YYMD        = &MYDATE;
	MY_START_DATETIME_21/HYYMDS  = DT(&MYDATE 21:00:00);
	MY_END_DATE_21/YYMD          = &MYDATE;
	MY_END_DATETIME_21/HYYMDS    = DT(&MYDATE 21:59:59);
	FROM_21/HYYMDs MISSING ON = IF PARENT_DATETIME_21 LT START_21 THEN MY_START_DATETIME_21 ELSE PARENT_EFFECTIVE_TIME;
	TO_21/HYYMDs MISSING ON   = IF CHILD_DATETIME_21 GT END_21 THEN MY_END_DATETIME_21 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_21/I10    = IF OCC_21 EQ 1 THEN HDIFF(TO_21, FROM_21, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_21/D10.2         = IF OCC_21 EQ 1 THEN (SECS_IN_BED_FOR_21 / 3600) * 100 ELSE 0;


	START_22/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 22, 8, 'HYYMDs');
	END_22/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 22, 8, 'HYYMDs');
	OCC_22/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_22 TO END_22
						OR PARENT_TO_CALC_DATETIME FROM START_22 TO END_22
						OR START_22 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_22 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_22/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_22/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_22/YYMD        = &MYDATE;
	MY_START_DATETIME_22/HYYMDS  = DT(&MYDATE 22:00:00);
	MY_END_DATE_22/YYMD          = &MYDATE;
	MY_END_DATETIME_22/HYYMDS    = DT(&MYDATE 22:59:59);
	FROM_22/HYYMDs MISSING ON = IF PARENT_DATETIME_22 LT START_22 THEN MY_START_DATETIME_22 ELSE PARENT_EFFECTIVE_TIME;
	TO_22/HYYMDs MISSING ON   = IF CHILD_DATETIME_22 GT END_22 THEN MY_END_DATETIME_22 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_22/I10    = IF OCC_22 EQ 1 THEN HDIFF(TO_22, FROM_22, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_22/D10.2         = IF OCC_22 EQ 1 THEN (SECS_IN_BED_FOR_22 / 3600) * 100 ELSE 0;


	START_23/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 23, 8, 'HYYMDs');
	END_23/HYYMDS   = HADD(DT(&MYDATE 00:59:59), 'HOUR', 23, 8, 'HYYMDs');
	OCC_23/I4       = IF (PARENT_FROM_CALC_DATETIME FROM START_23 TO END_23
						OR PARENT_TO_CALC_DATETIME FROM START_23 TO END_23
						OR START_23 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
						OR END_23 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
	PARENT_DATETIME_23/HYYMDs    = PARENT_EFFECTIVE_TIME;
	CHILD_DATETIME_23/HYYMDs     = CHILD_EFFECTIVE_TIME;
	MY_START_DATE_23/YYMD        = &MYDATE;
	MY_START_DATETIME_23/HYYMDS  = DT(&MYDATE 23:00:00);
	MY_END_DATE_23/YYMD          = &MYDATE;
	MY_END_DATETIME_23/HYYMDS    = DT(&MYDATE 23:59:59);
	FROM_23/HYYMDs MISSING ON = IF PARENT_DATETIME_23 LT START_23 THEN MY_START_DATETIME_23 ELSE PARENT_EFFECTIVE_TIME;
	TO_23/HYYMDs MISSING ON   = IF CHILD_DATETIME_23 GT END_23 THEN MY_END_DATETIME_23 ELSE CHILD_EFFECTIVE_TIME;
	SECS_IN_BED_FOR_23/I10    = IF OCC_23 EQ 1 THEN HDIFF(TO_23, FROM_23, 'SECONDS', 'I10') + 1 ELSE 0;
	UTIL_PCT_23/D10.2         = IF OCC_23 EQ 1 THEN (SECS_IN_BED_FOR_23 / 3600) * 100 ELSE 0;


END

-*TABLE FILE BT_BED_UTIL_BASE
TABLE FILE DMBEDOCCDW
PRINT
	PAT_ENC_CSN_ID
	PAT_ID
	MY_START_DATE
	PARENT_FROM_CALC_DATETIME
	PARENT_TO_CALC_DATETIME
	OCC_00
	FROM_00
	TO_00

	OCC_00
	SECS_IN_BED_FOR_00
	UTIL_PCT_00

	OCC_01
	SECS_IN_BED_FOR_01
	UTIL_PCT_01

	OCC_02
	SECS_IN_BED_FOR_02
	UTIL_PCT_02

	OCC_03
	SECS_IN_BED_FOR_03
	UTIL_PCT_03

	OCC_04
	SECS_IN_BED_FOR_04
	UTIL_PCT_04

	OCC_05
	SECS_IN_BED_FOR_05
	UTIL_PCT_05

	OCC_06
	SECS_IN_BED_FOR_06
	UTIL_PCT_06

	OCC_07
	SECS_IN_BED_FOR_07
	UTIL_PCT_07

	OCC_08
	SECS_IN_BED_FOR_08
	UTIL_PCT_08

	OCC_09
	SECS_IN_BED_FOR_09
	UTIL_PCT_09

	OCC_10
	SECS_IN_BED_FOR_10
	UTIL_PCT_10

	OCC_11
	SECS_IN_BED_FOR_11
	UTIL_PCT_11

	OCC_12
	SECS_IN_BED_FOR_12
	UTIL_PCT_12

	OCC_13
	SECS_IN_BED_FOR_13
	UTIL_PCT_13

	OCC_14
	SECS_IN_BED_FOR_14
	UTIL_PCT_14

	OCC_15
	SECS_IN_BED_FOR_15
	UTIL_PCT_15

	OCC_16
	SECS_IN_BED_FOR_16
	UTIL_PCT_16

	OCC_17
	SECS_IN_BED_FOR_17
	UTIL_PCT_17

	OCC_18
	SECS_IN_BED_FOR_18
	UTIL_PCT_18

	OCC_19
	SECS_IN_BED_FOR_19
	UTIL_PCT_19

	OCC_20
	SECS_IN_BED_FOR_20
	UTIL_PCT_20

	OCC_21
	SECS_IN_BED_FOR_21
	UTIL_PCT_21

	OCC_22
	SECS_IN_BED_FOR_22
	UTIL_PCT_22

	OCC_23
	SECS_IN_BED_FOR_23
	UTIL_PCT_23

	BY THE_DATE
	BY BED_LABEL

WHERE DATE_OCC EQ DT(&MYDATE);
ON TABLE HOLD AS &IHMFD
END

-SET &MYDATE       = &MYDATE + 1;






-SET &ILOOPNO = &ILOOPNO + 1;

-IF &ILOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP3 ELSE GOTO DOLOOP3;
-BREAKLOOP3






-SET &JLOOPNO = 1;

TABLE FILE BTLOOP0
PRINT
*

ON TABLE HOLD AS BT_BED_OCC_BASE

-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-DOLOOP4



MORE
-SET &JHMFD  = 'BTLOOP' || &JLOOPNO;
FILE &JHMFD.EVAL


-SET &JLOOPNO = &JLOOPNO + 1;
-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-BREAKLOOP4

END


-***********************************************************
-***********************************************************
-*                 D I S P L A Y
-***********************************************************
-***********************************************************




-***********************************************************
-* 1 - AGG ROLLUP (ALL DAYS)
-***********************************************************

DEFINE FILE BT_AGG_ROLLUP_OUT
	OCC_MINS/D10.2   = SECS_IN_BED_FOR_DATE / 600;
	OCC_HRS/D10.2    = SECS_IN_BED_FOR_DATE / 3600;
	UNOCC_MINS/D10.2 = SEC_UNOCC / 600;
	UNOCC_HRS/D10.2  = SEC_UNOCC / 3600;
END

TABLE FILE BT_AGG_ROLLUP_OUT
PRINT
	OCC_HRS              AS 'Time,Occupied,(in HRs)'
	OCC_MINS             AS 'Time,Occupied,(in MINs)'
	SECS_IN_BED_FOR_DATE AS 'Time,Occupied,(in SECs)'
	UNOCC_HRS            AS 'Time,Unoccupied,(in HRs)'
	UNOCC_MINS           AS 'Time,Unoccupied,(in MINs)'
	SEC_UNOCC            AS 'Time,Unoccupied,(in SECs)'
	UTIL_PCT             AS 'Bed Occ %'

HEADING
"Vidant Health"
"Decision Support Office"
"Date: &DATE"
"----------------------------------------"
"Bed Occupancy (Dept: &DEPARTMENT)"
"&FROMDATE - &TODATE"
""
"Aggregate By Department (All &BEDS_IN_UNIT Beds)"
""

ON TABLE PCHOLD FORMAT PDF OPEN NOBREAK

ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=DATA,
     COLUMN=N4,
	 JUSTIFY=RIGHT,
$
TYPE=SUBHEAD,
     BACKCOLOR=RGB(192 192 192),
     FONT='ARIAL',
     SIZE=10,
     STYLE=BOLD,
$
TYPE=TITLE,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=FOOTING,
     OBJECT=TEXT,
	 SIZE=8,
     COLOR='BLACK',
     STYLE=BOLD,
$
ENDSTYLE
END





-***********************************************************
-* 2 - DAY ROLLUP
-***********************************************************

DEFINE FILE BT_DAY_ROLLUP_OUT
	OCC_MINS/D10.2   = SECS_IN_BED_FOR_DATE / 600;
	OCC_HRS/D10.2    = SECS_IN_BED_FOR_DATE / 3600;
	UNOCC_MINS/D10.2 = SEC_UNOCC / 600;
	UNOCC_HRS/D10.2  = SEC_UNOCC / 3600;
END

TABLE FILE BT_DAY_ROLLUP_OUT
PRINT
	OCC_HRS              AS 'Time,Occupied,(in HRs)'
	OCC_MINS             AS 'Time,Occupied,(in MINs)'
	SECS_IN_BED_FOR_DATE AS 'Time,Occupied,(in SECs)'
	UNOCC_HRS            AS 'Time,Unoccupied,(in HRs)'
	UNOCC_MINS           AS 'Time,Unoccupied,(in MINs)'
	SEC_UNOCC            AS 'Time,Unoccupied,(in SECs)'
	UTIL_PCT             AS 'Bed Occ %'

	BY THE_DATE          AS 'Date'

HEADING
""
"Aggregate By Date (All &BEDS_IN_UNIT Beds)"
""

ON TABLE PCHOLD FORMAT PDF

ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=DATA,
     COLUMN=N5,
	 JUSTIFY=RIGHT,
$
TYPE=TITLE,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=FOOTING,
     OBJECT=TEXT,
	 SIZE=8,
     COLOR='BLACK',
     STYLE=BOLD,
$
ENDSTYLE
END






-***********************************************************
-* 3 - BED ROLLUP
-***********************************************************

DEFINE FILE BT_BED_ROLLUP_OUT
	OCC_MINS/D10.2   = SECS_IN_BED_FOR_DATE / 600;
	OCC_HRS/D10.2    = SECS_IN_BED_FOR_DATE / 3600;
	UNOCC_MINS/D10.2 = SEC_UNOCC / 600;
	UNOCC_HRS/D10.2  = SEC_UNOCC / 3600;
END

TABLE FILE BT_BED_ROLLUP_OUT
PRINT
	OCC_HRS              AS 'Time,Occupied,(in HRs)'
	OCC_MINS             AS 'Time,Occupied,(in MINs)'
	SECS_IN_BED_FOR_DATE AS 'Time,Occupied,(in SECs)'
	UNOCC_HRS            AS 'Time,Unoccupied,(in HRs)'
	UNOCC_MINS           AS 'Time,Unoccupied,(in MINs)'
	SEC_UNOCC            AS 'Time,Unoccupied,(in SECs)'
	UTIL_PCT             AS 'Bed Occ %'

	BY THE_DATE          AS 'Date'
	BY BED_LABEL         AS 'Bed'

HEADING
"Vidant Health"
"Decision Support Office"
"Date: &DATE"
"----------------------------------------"
"Bed Occupancy (Dept: &DEPARTMENT)"
"&FROMDATE - &TODATE"
""
"Breakdown By Date, By Bed"
""

ON TABLE PCHOLD FORMAT PDF

ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=DATA,
     COLUMN=N6,
	 JUSTIFY=RIGHT,
$
TYPE=TITLE,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=FOOTING,
     OBJECT=TEXT,
	 SIZE=8,
     COLOR='BLACK',
     STYLE=BOLD,
$
ENDSTYLE
END





-***********************************************************
-* 4 - PATIENT DETAIL
-***********************************************************

TABLE FILE BT_PAT_ROLLUP_OUT
PRINT
	PAT_NAME                    AS 'Patient Name'
	PAT_ID                      AS 'Patient ID'
-*	PARENT_FROM_CALC_DATETIME   AS 'Bed In Time (For Day)'
-*	PARENT_TO_CALC_DATETIME     AS 'Bed Out Time (For Day)'
	FROM_TIME                   AS 'Bed In Time,(For Day)'
	TO_TIME                     AS 'Bed Out Time,(For Day)'
	SECS_IN_BED_FOR_DATE        AS 'Time Spent in,Bed (Secs)'
	IN_DISP                     AS 'Dept. Disposition (In)'
	OUT_DISP                    AS 'Dept. Disposition (Out)'

	BY THE_DATE                 AS 'Date'
	BY BED_LABEL                AS 'Bed'

HEADING
"Vidant Health"
"Decision Support Office"
"Date: &DATE"
"----------------------------------------"
"Bed Occupancy (Dept: &DEPARTMENT)"
"&FROMDATE - &TODATE"
""
"Patient Breakdown"
""

ON TABLE PCHOLD FORMAT PDF

ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=TITLE,
     SIZE=9,
     STYLE=BOLD,
$
TYPE=SUBTOTAL,
	 BY=QUARTER,
	 STYLE=BOLD,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=FOOTING,
     OBJECT=TEXT,
	 SIZE=8,
     COLOR='BLACK',
     STYLE=BOLD,
$
ENDSTYLE
END





-***********************************************************
-* 5 - OCC ROLLUP %


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Master
posted Hide Post
Sorry, had to break up to 2 posts.

-***********************************************************
-* 5 - OCC ROLLUP % AGGREGATE
-***********************************************************

TABLE FILE BT_BED_OCC_BASE
SUM
	MAX.SECS_IN_BED_FOR_00
	MAX.SECS_IN_BED_FOR_01
	MAX.SECS_IN_BED_FOR_02
	MAX.SECS_IN_BED_FOR_03
	MAX.SECS_IN_BED_FOR_04
	MAX.SECS_IN_BED_FOR_05
	MAX.SECS_IN_BED_FOR_06
	MAX.SECS_IN_BED_FOR_07
	MAX.SECS_IN_BED_FOR_08
	MAX.SECS_IN_BED_FOR_09
	MAX.SECS_IN_BED_FOR_10
	MAX.SECS_IN_BED_FOR_11
	MAX.SECS_IN_BED_FOR_12
	MAX.SECS_IN_BED_FOR_13
	MAX.SECS_IN_BED_FOR_14
	MAX.SECS_IN_BED_FOR_15
	MAX.SECS_IN_BED_FOR_16
	MAX.SECS_IN_BED_FOR_17
	MAX.SECS_IN_BED_FOR_18
	MAX.SECS_IN_BED_FOR_19
	MAX.SECS_IN_BED_FOR_20
	MAX.SECS_IN_BED_FOR_21
	MAX.SECS_IN_BED_FOR_22
	MAX.SECS_IN_BED_FOR_23

	BY THE_DATE
	BY BED_LABEL

ON TABLE HOLD AS BT_BED_UTIL_HR_AGG_1
END




TABLE FILE BT_BED_UTIL_HR_AGG_1
SUM
	SECS_IN_BED_FOR_00
	SECS_IN_BED_FOR_01
	SECS_IN_BED_FOR_02
	SECS_IN_BED_FOR_03
	SECS_IN_BED_FOR_04
	SECS_IN_BED_FOR_05
	SECS_IN_BED_FOR_06
	SECS_IN_BED_FOR_07
	SECS_IN_BED_FOR_08
	SECS_IN_BED_FOR_09
	SECS_IN_BED_FOR_10
	SECS_IN_BED_FOR_11
	SECS_IN_BED_FOR_12
	SECS_IN_BED_FOR_13
	SECS_IN_BED_FOR_14
	SECS_IN_BED_FOR_15
	SECS_IN_BED_FOR_16
	SECS_IN_BED_FOR_17
	SECS_IN_BED_FOR_18
	SECS_IN_BED_FOR_19
	SECS_IN_BED_FOR_20
	SECS_IN_BED_FOR_21
	SECS_IN_BED_FOR_22
	SECS_IN_BED_FOR_23

	BY THE_DATE

ON TABLE HOLD AS BT_BED_UTIL_HR_AGG_2
END




DEFINE FILE BT_BED_UTIL_HR_AGG_2
	BED_UTIL_00/D10  = ((SECS_IN_BED_FOR_00 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_01/D10  = ((SECS_IN_BED_FOR_01 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_02/D10  = ((SECS_IN_BED_FOR_02 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_03/D10  = ((SECS_IN_BED_FOR_03 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_04/D10  = ((SECS_IN_BED_FOR_04 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_05/D10  = ((SECS_IN_BED_FOR_05 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_06/D10  = ((SECS_IN_BED_FOR_06 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_07/D10  = ((SECS_IN_BED_FOR_07 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_08/D10  = ((SECS_IN_BED_FOR_08 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_09/D10  = ((SECS_IN_BED_FOR_09 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_10/D10  = ((SECS_IN_BED_FOR_10 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_11/D10  = ((SECS_IN_BED_FOR_11 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_12/D10  = ((SECS_IN_BED_FOR_12 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_13/D10  = ((SECS_IN_BED_FOR_13 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_14/D10  = ((SECS_IN_BED_FOR_14 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_15/D10  = ((SECS_IN_BED_FOR_15 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_16/D10  = ((SECS_IN_BED_FOR_16 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_17/D10  = ((SECS_IN_BED_FOR_17 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_18/D10  = ((SECS_IN_BED_FOR_18 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_19/D10  = ((SECS_IN_BED_FOR_19 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_20/D10  = ((SECS_IN_BED_FOR_20 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_21/D10  = ((SECS_IN_BED_FOR_21 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_22/D10  = ((SECS_IN_BED_FOR_22 / 3600) / &BEDS_IN_UNIT) * 100;
	BED_UTIL_23/D10  = ((SECS_IN_BED_FOR_23 / 3600) / &BEDS_IN_UNIT) * 100;
END

TABLE FILE BT_BED_UTIL_HR_AGG_2
PRINT
	BED_UTIL_00 AS '% UTIL,00:00'
	BED_UTIL_01 AS '% UTIL,01:00'
	BED_UTIL_02 AS '% UTIL,02:00'
	BED_UTIL_03 AS '% UTIL,03:00'
	BED_UTIL_04 AS '% UTIL,04:00'
	BED_UTIL_05 AS '% UTIL,05:00'
	BED_UTIL_06 AS '% UTIL,06:00'
	BED_UTIL_07 AS '% UTIL,07:00'
	BED_UTIL_08 AS '% UTIL,08:00'
	BED_UTIL_09 AS '% UTIL,09:00'
	BED_UTIL_10 AS '% UTIL,10:00'
	BED_UTIL_11 AS '% UTIL,11:00'
	BED_UTIL_12 AS '% UTIL,12:00'
	BED_UTIL_13 AS '% UTIL,13:00'
	BED_UTIL_14 AS '% UTIL,14:00'
	BED_UTIL_15 AS '% UTIL,15:00'
	BED_UTIL_16 AS '% UTIL,16:00'
	BED_UTIL_17 AS '% UTIL,17:00'
	BED_UTIL_18 AS '% UTIL,18:00'
	BED_UTIL_19 AS '% UTIL,19:00'
	BED_UTIL_20 AS '% UTIL,20:00'
	BED_UTIL_21 AS '% UTIL,21:00'
	BED_UTIL_22 AS '% UTIL,22:00'
	BED_UTIL_23 AS '% UTIL,23:00'

	BY THE_DATE  AS 'Date'

HEADING
"Vidant Health"
"Decision Support Office"
"Date: &DATE"
"----------------------------------------"
"Bed Occupancy (Dept: &DEPARTMENT)"
"&FROMDATE - &TODATE"
""
"Percent Occupancy By Hour - Aggregate By Day"
""

ON TABLE PCHOLD FORMAT PDF
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=6,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=DATA,
     COLUMN=N2,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N2,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N2 LE 75,
$
TYPE=DATA,
     COLUMN=N2,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N2 GE 90,
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N3 LE 75,
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N3 GE 90,
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N4 LE 75,
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N4 GE 90,
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N5 LE 75,
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N5 GE 90,
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N6 LE 75,
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N6 GE 90,
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N7 LE 75,
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N7 GE 90,
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N8 LE 75,
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N8 GE 90,
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N9 LE 75,
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N9 GE 90,
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N10 LE 75,
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N10 GE 90,
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N11 LE 75,
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N11 GE 90,
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N12 LE 75,
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N12 GE 90,
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N13 LE 75,
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N13 GE 90,
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N14 LE 75,
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N14 GE 90,
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N15 LE 75,
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N15 GE 90,
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N16 LE 75,
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N16 GE 90,
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N17 LE 75,
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N17 GE 90,
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N18 LE 75,
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N18 GE 90,
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N19 LE 75,
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N19 GE 90,
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N20 LE 75,
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N20 GE 90,
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N21 LE 75,
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N21 GE 90,
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N22 LE 75,
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N22 GE 90,
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N23 LE 75,
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N23 GE 90,
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N24 LE 75,
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N24 GE 90,
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N25 LE 75,
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N25 GE 90,
$
ENDSTYLE
END


-***********************************************************
-* 5 - OCC ROLLUP % BY DAY
-***********************************************************

TABLE FILE BT_BED_OCC_BASE
SUM
	MAX.SECS_IN_BED_FOR_00
	MAX.SECS_IN_BED_FOR_01
	MAX.SECS_IN_BED_FOR_02
	MAX.SECS_IN_BED_FOR_03
	MAX.SECS_IN_BED_FOR_04
	MAX.SECS_IN_BED_FOR_05
	MAX.SECS_IN_BED_FOR_06
	MAX.SECS_IN_BED_FOR_07
	MAX.SECS_IN_BED_FOR_08
	MAX.SECS_IN_BED_FOR_09
	MAX.SECS_IN_BED_FOR_10
	MAX.SECS_IN_BED_FOR_11
	MAX.SECS_IN_BED_FOR_12
	MAX.SECS_IN_BED_FOR_13
	MAX.SECS_IN_BED_FOR_14
	MAX.SECS_IN_BED_FOR_15
	MAX.SECS_IN_BED_FOR_16
	MAX.SECS_IN_BED_FOR_17
	MAX.SECS_IN_BED_FOR_18
	MAX.SECS_IN_BED_FOR_19
	MAX.SECS_IN_BED_FOR_20
	MAX.SECS_IN_BED_FOR_21
	MAX.SECS_IN_BED_FOR_22
	MAX.SECS_IN_BED_FOR_23

	BY THE_DATE
	BY BED_LABEL

ON TABLE HOLD AS BT_BED_UTIL_HR_1
END


DEFINE FILE BT_BED_UTIL_HR_1
	BED_UTIL_00/D10  = (SECS_IN_BED_FOR_00 / 3600) * 100;
	BED_UTIL_01/D10  = (SECS_IN_BED_FOR_01 / 3600) * 100;
	BED_UTIL_02/D10  = (SECS_IN_BED_FOR_02 / 3600) * 100;
	BED_UTIL_03/D10  = (SECS_IN_BED_FOR_03 / 3600) * 100;
	BED_UTIL_04/D10  = (SECS_IN_BED_FOR_04 / 3600) * 100;
	BED_UTIL_05/D10  = (SECS_IN_BED_FOR_05 / 3600) * 100;
	BED_UTIL_06/D10  = (SECS_IN_BED_FOR_06 / 3600) * 100;
	BED_UTIL_07/D10  = (SECS_IN_BED_FOR_07 / 3600) * 100;
	BED_UTIL_08/D10  = (SECS_IN_BED_FOR_08 / 3600) * 100;
	BED_UTIL_09/D10  = (SECS_IN_BED_FOR_09 / 3600) * 100;
	BED_UTIL_10/D10  = (SECS_IN_BED_FOR_10 / 3600) * 100;
	BED_UTIL_11/D10  = (SECS_IN_BED_FOR_11 / 3600) * 100;
	BED_UTIL_12/D10  = (SECS_IN_BED_FOR_12 / 3600) * 100;
	BED_UTIL_13/D10  = (SECS_IN_BED_FOR_13 / 3600) * 100;
	BED_UTIL_14/D10  = (SECS_IN_BED_FOR_14 / 3600) * 100;
	BED_UTIL_15/D10  = (SECS_IN_BED_FOR_15 / 3600) * 100;
	BED_UTIL_16/D10  = (SECS_IN_BED_FOR_16 / 3600) * 100;
	BED_UTIL_17/D10  = (SECS_IN_BED_FOR_17 / 3600) * 100;
	BED_UTIL_18/D10  = (SECS_IN_BED_FOR_18 / 3600) * 100;
	BED_UTIL_19/D10  = (SECS_IN_BED_FOR_19 / 3600) * 100;
	BED_UTIL_20/D10  = (SECS_IN_BED_FOR_20 / 3600) * 100;
	BED_UTIL_21/D10  = (SECS_IN_BED_FOR_21 / 3600) * 100;
	BED_UTIL_22/D10  = (SECS_IN_BED_FOR_22 / 3600) * 100;
	BED_UTIL_23/D10  = (SECS_IN_BED_FOR_23 / 3600) * 100;
END

TABLE FILE BT_BED_UTIL_HR_1
PRINT
	BED_UTIL_00 AS '% UTIL,00:00'
	BED_UTIL_01 AS '% UTIL,01:00'
	BED_UTIL_02 AS '% UTIL,02:00'
	BED_UTIL_03 AS '% UTIL,03:00'
	BED_UTIL_04 AS '% UTIL,04:00'
	BED_UTIL_05 AS '% UTIL,05:00'
	BED_UTIL_06 AS '% UTIL,06:00'
	BED_UTIL_07 AS '% UTIL,07:00'
	BED_UTIL_08 AS '% UTIL,08:00'
	BED_UTIL_09 AS '% UTIL,09:00'
	BED_UTIL_10 AS '% UTIL,10:00'
	BED_UTIL_11 AS '% UTIL,11:00'
	BED_UTIL_12 AS '% UTIL,12:00'
	BED_UTIL_13 AS '% UTIL,13:00'
	BED_UTIL_14 AS '% UTIL,14:00'
	BED_UTIL_15 AS '% UTIL,15:00'
	BED_UTIL_16 AS '% UTIL,16:00'
	BED_UTIL_17 AS '% UTIL,17:00'
	BED_UTIL_18 AS '% UTIL,18:00'
	BED_UTIL_19 AS '% UTIL,19:00'
	BED_UTIL_20 AS '% UTIL,20:00'
	BED_UTIL_21 AS '% UTIL,21:00'
	BED_UTIL_22 AS '% UTIL,22:00'
	BED_UTIL_23 AS '% UTIL,23:00'

	BY THE_DATE  AS 'Date'
	BY BED_LABEL AS 'Bed'

HEADING
"Vidant Health"
"Decision Support Office"
"Date: &DATE"
"----------------------------------------"
"Bed Occupancy (Dept: &DEPARTMENT)"
"&FROMDATE - &TODATE"
""
"Percent Occupancy By Hour - Aggregate By Bed"
""

ON TABLE PCHOLD FORMAT PDF CLOSE
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON

ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.250000,
     RIGHTMARGIN=0.000000,
     TOPMARGIN=0.250000,
     BOTTOMMARGIN=0.250000,
     SQUEEZE=OFF,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=6,
     COLOR='BLACK',
     BACKCOLOR='NONE',
     LEFTGAP=0.05,
     RIGHTGAP=0.05,
	 SQUEEZE=ON,
$
TYPE=HEADING,
     OBJECT=TEXT,
	 SIZE=10,
     COLOR='BLACK',
$
TYPE=HEADING,
	 LINE = 1,
     OBJECT=TEXT,
	 SIZE=14,
     COLOR='BLACK',
     STYLE=BOLD,
$
TYPE=DATA,
	 JUSTIFY=LEFT,
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N3 LE 75,
$
TYPE=DATA,
     COLUMN=N3,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N3 GE 90,
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N4 LE 75,
$
TYPE=DATA,
     COLUMN=N4,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N4 GE 90,
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N5 LE 75,
$
TYPE=DATA,
     COLUMN=N5,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N5 GE 90,
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N6 LE 75,
$
TYPE=DATA,
     COLUMN=N6,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N6 GE 90,
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N7 LE 75,
$
TYPE=DATA,
     COLUMN=N7,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N7 GE 90,
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N8 LE 75,
$
TYPE=DATA,
     COLUMN=N8,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N8 GE 90,
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N9 LE 75,
$
TYPE=DATA,
     COLUMN=N9,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N9 GE 90,
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N10 LE 75,
$
TYPE=DATA,
     COLUMN=N10,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N10 GE 90,
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N11 LE 75,
$
TYPE=DATA,
     COLUMN=N11,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N11 GE 90,
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N12 LE 75,
$
TYPE=DATA,
     COLUMN=N12,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N12 GE 90,
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N13 LE 75,
$
TYPE=DATA,
     COLUMN=N13,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N13 GE 90,
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N14 LE 75,
$
TYPE=DATA,
     COLUMN=N14,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N14 GE 90,
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N15 LE 75,
$
TYPE=DATA,
     COLUMN=N15,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N15 GE 90,
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N16 LE 75,
$
TYPE=DATA,
     COLUMN=N16,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N16 GE 90,
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N17 LE 75,
$
TYPE=DATA,
     COLUMN=N17,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N17 GE 90,
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N18 LE 75,
$
TYPE=DATA,
     COLUMN=N18,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N18 GE 90,
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N19 LE 75,
$
TYPE=DATA,
     COLUMN=N19,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N19 GE 90,
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N20 LE 75,
$
TYPE=DATA,
     COLUMN=N20,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N20 GE 90,
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N21 LE 75,
$
TYPE=DATA,
     COLUMN=N21,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N21 GE 90,
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N22 LE 75,
$
TYPE=DATA,
     COLUMN=N22,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N22 GE 90,
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N23 LE 75,
$
TYPE=DATA,
     COLUMN=N23,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N23 GE 90,
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N24 LE 75,
$
TYPE=DATA,
     COLUMN=N24,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N24 GE 90,
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N25 LE 75,
$
TYPE=DATA,
     COLUMN=N25,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N25 GE 90,
$
TYPE=DATA,
     COLUMN=N26,
     GRID=ON,
     SIZE=8,
     COLOR='BLACK',
     BACKCOLOR='YELLOW',
$
TYPE=DATA,
     COLUMN=N26,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='RED',
     WHEN = N26 LE 75,
$
TYPE=DATA,
     COLUMN=N26,
     GRID=ON,
     SIZE=8,
     COLOR='WHITE',
     BACKCOLOR='GREEN',
     WHEN = N26 GE 90,
$
ENDSTYLE
END
-EXIT



-ERRONEMONTH
-NORPT
-TYPE *******************************************************
-TYPE ***             !!! W A R N I N G !!!               ***
-TYPE *******************************************************
-TYPE *** THE DATE RANGE YOU HAVE SPECIFIED SPANS MONTHS! ***
-TYPE ***                                                 ***
-TYPE *** PLEASE SPECIFY A DATE RANGE IN WHICH BOTH DATES ***
-TYPE *** ARE IN THE SAME MONTH.                           ***
-TYPE *******************************************************
-EXIT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Virtuoso
posted Hide Post
ABT!

Some code!
Do you have any output one could look at?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Master
posted Hide Post
send me your email and I'll send to you. Difficult to post a link to internet accessible pdf for me.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Virtuoso
posted Hide Post
@Danny
Yes, that does look pretty much like what I had in mind. I suppose there's really no way to create a bar graph that has actual gaps between the time intervals when the task is not running? In your solution those can be either red or blue, which makes it a bit difficult to see what is going on exactly at a specific time.
What type of GRAPH did you end up using? I couldn't find anything like that in the Advanced Graph editor.

@ABT
...That's a LOT of code, wow! Thanks for posting that.

It does raise a few questions/remarks though. First about that SQL query; I simplified that down to the below, and it seems to give the exact same results:[code]
Select
Distinct Job_Desc
, 'Leith' As Server
, DATEADD(
hh,
datepart(hh, getutcdate() - getdate()) * -1,
DATEADD(ss, convert(bigint, start_stamp) / 1000, '1970-01-01')
) AS translated_start_date
, DATEADD(
hh,
datepart(hh, getutcdate() - getdate()) * -1,
DATEADD(ss, convert(bigint, end_stamp) / 1000, '1970-01-01')
) AS translated_end_date
...
[code]

In detail; I don't think you need to wrap those utc-offset bits in an extra select (what is MS thinking by returning a datetime when subtracting two datetimes from each other? that's ...weird!). I also don't think there's any need to trim leading zeroes off the timestamp in START_STAMP to turn it into a valid bigint value.
Am I overlooking some potential problems there or was that just cruft left over from attempts to get the friggin' database to accept the query?

While doing that I noticed that SQLServer doesn't seem to like new-lines or tab characters in its queries (or is that a peculiarity of Squirrel SQL?) - doh! Seems like SQLServer has a bit of an attitude...


For the rest of the code; I'm not really sure where you're heading with that code, it doesn't seem very related to the problem I'm trying to solve? There are certainly some interesting parts along the way, though. The loops are interesting, I don't use those a whole lot. It seems you could use a few more too Wink


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Master
posted Hide Post
The SQL is left over from a morning's worth of trial and error several months ago working inside out. I can't remember the exact logic I was using when writing it. I do recall there being some issues I had to code around (I think the 'never repeat' date is actually an extremely large number that breaks when you don't convert ~~ I'm fuzzy).

As for the Webfocus code, the real magic is in the DMBEDOCCDW define. The point I was faced with (and it seems the same as yours) is that I had to determine the portion of an hour that something happened -- I couldn't just take a start and stop and show that. Again, fuzzy on the business logic behind it, but it seemed like the only way at the time. I'll send you the output and you tell me if it looks like something you want to pursue.

Sometimes I have to remind myself that copy/paste is not the same as code reuse.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Virtuoso
posted Hide Post
Hi all,

@ABT: my e-mail is on my public profile.

@Wep: I use the same idea as WF when creating visualization. I can send you the code if you wish: I can either post it or send it if you provide an e-mail address.
I agree that red and blue is a limitation. I suppose one could make this complete with 3 colors: red, blue for 2 subsequent tasks, purple for overlapping and white for time when nothing is running.
Good luck...


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SHARING] Reportcaster job activity

Copyright © 1996-2020 Information Builders