SDCED2 ;ALB/JCH - VSE ENCOUNTER XREF ; 19 Oct 14 04:11PM
;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
;;
Q
;
APPT(SDNODE,SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,DTRANGE,TMPMON,TMPQRT,TMPYR,SDWEEKS) ; Aggregate Appointment information by Year/Quarter/Month/Week/Date
N SDAPPND,SDLEN,SDTOT,TMPND,DTNAM,SDGLR,SDGLF,SDTOT,SDLEN,SDSTAT,SDSTATOT,SUFFIX
N APPLEN,DIC,DR
S SDAPPND=$G(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP"))
;
S TMPDT=SDDT
Q:'$G(SDGRP)
;
; Appointment Lengths and Statuses - Get smallest (Date) increment at full (unique) path, add to all increments and subtotals (Group/Provider totals)
N SDLG,SDLG2
D SDGRP^SDECXUTL(+SDCL,.SDLG)
S SDLEN="" F S SDLEN=$O(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN)) Q:'SDLEN D
.S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2)) Q:SDLG2="" D
..S SDTOT=$G(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2))
..Q:SDTOT=""
..;
..; New Overbook^New^Estab
..; --------------------------------------------------------------------------------------------------
..; 1. Aggregate appointments' overbooks, new, and established values
..S SDAPPND=$G(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2))
..S SDGLR="^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC"
..; Aggregate Annual, Quarterly, Monthly, Weekly Group, Division, Clinic, Provider
..F DTNAM="Year","Month","Week","Quarter","Date" D
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""DEM"")",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""FAC"",SDGRP,SDCL,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...I DTNAM'="Date" D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
..;
..; Don't add each group to facility and division totals - already done with group 0 (all)
..;
..; Provider Specific - Aggregate overbooks, new, and established for Provider Specific Annual, Quarterly, Monthly, Weekly, Daily totals
..S SDGLR="^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT"
..F DTNAM="Year","Quarter","Month","Week","Date" D
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,""CLIN"",SDCL,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
...D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,SDIV,""GRP"",SDGRP,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
..;
..; Group Specific by Facility - Appointment Lengths - Aggregate Resource Group Specific, Facility totals Annually, Quarterly, Monthly, Weekly, Daily
..S SDGLR="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC" D
...F DTNAM="Year","Quarter","Month","Week","Date" D
....S SDGLF=SDGLR_",SDGRP,""APP"",""LEN"",SDLEN,SDLG2)" D AGGSET(SDGLF,DTNAM,SDTOT)
..;
..; Appointment Statuses, by appt length
..S SDSTAT="" F S SDSTAT=$O(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,"STAT",SDSTAT)) Q:SDSTAT="" D
...S SDSTATOT=$P($G(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,"STAT",SDSTAT)),"^")
...;
...; 1. Full Path - Appointment Statuses by Appt Length- Aggregate Annual, Quarterly, Monthly, Weekly by Group, Division, Clinic, Provider
...S SDGLR="^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC"
...F DTNAM="Year","Month","Week","Quarter","Date" D
....I $G(DTRANGE) Q:'(DTNAM="Date")
....N SUFFIX S SUFFIX=",""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)"
....D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""FAC"",SDGRP,SDCL,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....I DTNAM'="Date" D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
...;
...; 2. Group Specific by Facility - Appointment Statuses - Aggregate Resource Group Specific, Facility totals Annually, Quarterly, Monthly, Weekly, Daily
...S SDGLR="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC" D
....F DTNAM="Year","Quarter","Month","Week","Date" D
.....S SDGLF="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC,SDGRP,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)" D AGGSET(SDGLF,DTNAM,SDSTATOT)
...;
...; 3. Provider Specific - Appointment Statuses - Provider Specific Annual, Quarterly, Monthly, Weekly, Daily totals
...F DTNAM="Year","Quarter","Month","Week","Date" D
....I $G(DTRANGE) Q:DTNAM'="Date"
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,""CLIN"",SDCL,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
....D AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,SDIV,""GRP"",SDGRP,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
Q
;
SUP ; Appointment supply
N SDSUP,CLNAM,SDAPPND,TMPDT,DTNAM
;
Q:$P($G(SDPRV),"^",2) ; Providers do not have supply/slots, only clinics
N CLNAM S CLNAM=$S($G(SDCL):$P($G(^SC(+SDCL,0)),"^"),1:$P(SDCL,"^"))
S SDAPPND=$G(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,"APP","SUP"))
Q:SDAPPND=""
Q:'$G(SDGRP)
S TMPDT=SDDT
;
; 1. Full Path - Aggregate supply
F DTNAM="Year","Month","Week","Quarter","Date" D
.I $G(DTRANGE) Q:DTNAM'="Date"
.; Don't add each group to facility and division totals - already done with group 0 (all)
.D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""SUP"")",DTNAM,SDAPPND)
.D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""SUP"")",DTNAM,SDAPPND)
.D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""SUP"")",DTNAM,SDAPPND)
.D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""GRP"",SDGRP,""APP"",""SUP"")",DTNAM,SDAPPND)
.D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""CLIN"",SDGRP,SDCL,""APP"",""SUP"")",DTNAM,SDAPPND)
.I DTNAM'="Date" D AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""SUP"")",DTNAM,SDAPPND)
.;I SDRPTYP="M" W !,"SDGRP:",SDGRP,!?5,"-SDIV:",SDIV,!?5,"-SDCL:",SDCL,!?5,"-SDAPPND:",SDAPPND
;
; Supply
F DTNAM="Year","Quarter","Month","Week","Date" D
.S SDGLF="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC,SDGRP,""APP"",""SUP"")" D AGGSET(SDGLF,DTNAM,SDAPPND)
;
Q
;
AGGLEN(SDGLOB,DTNAM,PRVND) ; Perform generic aggregation of Pn values into SDGLOB
N I,TMPDT,TOT,AGGDATA
S TMPDT=$S(DTNAM="Year":TMPYR,DTNAM="Quarter":TMPQRT,DTNAM="Month":TMPMON,DTNAM="Week":TMPWK,1:SDDT)
S TOT=$P($G(@(SDGLOB)),"^")
S AGGDATA=TOT+PRVND
S $P(@(SDGLOB),"^")=AGGDATA
Q
;
AGGSET(SDGLOB,DTNAM,PRVND) ; Perform generic aggregation of Pn values into SDGLOB
N I,TMPDT,TOT,AGGDATA,TMPWK
S TMPWK=$$GETWEEK^SDCED1(SDDT,.SDWEEKS)
S TMPDT=$S(DTNAM="Year":TMPYR,DTNAM="Quarter":TMPQRT,DTNAM="Month":TMPMON,DTNAM="Week":TMPWK,1:SDDT)
S TOT=$G(@(SDGLOB))
F I=1:1:$L(PRVND,"^") S $P(AGGDATA,"^",I)=($P(TOT,"^",I)+$P(PRVND,"^",I))
S @(SDGLOB)=AGGDATA
Q
;
GETSUP2(CLIN,SUPDT) ; Get supply for date SUPDT
N SLOTS,LEN,SDSUP,MAX
S SDSUP=""
K ^TMP("SD",$J),^TMP("SDS",$J),^TMP("SDTMP",$J),^TMP("SDTOT",$J)
Q:'CLIN SDSUP
;S X1=SUPDT,X2=SUPDT D ^%DTC S MAX=X+1
D INIT^SCRPW71 S SLOTS=+$$CLINIC^SCRPW71(CLIN,"S",SUPDT,SUPDT,1,1)
Q:'SLOTS SDSUP
S LEN=+$P($G(^SC(CLIN,"SL")),U)
I LEN S SDSUP=(LEN*SLOTS)/60
Q SDSUP
;
APPLEN(CLIN) ; Get appt length
N DIE,DIQ,DIR,DA,X,Y
S DIQ(0)="I",DIC=44,DA=+$G(CLIN),DR="1912"
D GETS^DIQ(DIC,DA,DR,"I","APPLEN")
S APPLEN=$G(APPLEN(DIC,DA_",",1912,"I"))
Q APPLEN
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDCED2 9820 printed Oct 16, 2024@18:49:33 Page 2
SDCED2 ;ALB/JCH - VSE ENCOUNTER XREF ; 19 Oct 14 04:11PM
+1 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
+2 ;;
+3 QUIT
+4 ;
APPT(SDNODE,SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,DTRANGE,TMPMON,TMPQRT,TMPYR,SDWEEKS) ; Aggregate Appointment information by Year/Quarter/Month/Week/Date
+1 NEW SDAPPND,SDLEN,SDTOT,TMPND,DTNAM,SDGLR,SDGLF,SDTOT,SDLEN,SDSTAT,SDSTATOT,SUFFIX
+2 NEW APPLEN,DIC,DR
+3 SET SDAPPND=$GET(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP"))
+4 ;
+5 SET TMPDT=SDDT
+6 if '$GET(SDGRP)
QUIT
+7 ;
+8 ; Appointment Lengths and Statuses - Get smallest (Date) increment at full (unique) path, add to all increments and subtotals (Group/Provider totals)
+9 NEW SDLG,SDLG2
+10 DO SDGRP^SDECXUTL(+SDCL,.SDLG)
+11 SET SDLEN=""
FOR
SET SDLEN=$ORDER(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN))
if 'SDLEN
QUIT
Begin DoDot:1
+12 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:2
+13 SET SDTOT=$GET(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2))
+14 if SDTOT=""
QUIT
+15 ;
+16 ; New Overbook^New^Estab
+17 ; --------------------------------------------------------------------------------------------------
+18 ; 1. Aggregate appointments' overbooks, new, and established values
+19 SET SDAPPND=$GET(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,SDLG2))
+20 SET SDGLR="^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC"
+21 ; Aggregate Annual, Quarterly, Monthly, Weekly Group, Division, Clinic, Provider
+22 FOR DTNAM="Year","Month","Week","Quarter","Date"
Begin DoDot:3
+23 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""DEM"")",DTNAM,SDAPPND)
+24 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+25 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+26 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+27 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+28 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""FAC"",SDGRP,SDCL,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+29 IF DTNAM'="Date"
DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
End DoDot:3
+30 ;
+31 ; Don't add each group to facility and division totals - already done with group 0 (all)
+32 ;
+33 ; Provider Specific - Aggregate overbooks, new, and established for Provider Specific Annual, Quarterly, Monthly, Weekly, Daily totals
+34 SET SDGLR="^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT"
+35 FOR DTNAM="Year","Quarter","Month","Week","Date"
Begin DoDot:3
+36 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+37 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,""CLIN"",SDCL,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+38 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+39 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+40 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+41 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
+42 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,SDIV,""GRP"",SDGRP,SDPRV,""APP"",""LEN"",SDLEN,SDLG2)",DTNAM,SDAPPND)
End DoDot:3
+43 ;
+44 ; Group Specific by Facility - Appointment Lengths - Aggregate Resource Group Specific, Facility totals Annually, Quarterly, Monthly, Weekly, Daily
+45 SET SDGLR="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC"
Begin DoDot:3
+46 FOR DTNAM="Year","Quarter","Month","Week","Date"
Begin DoDot:4
+47 SET SDGLF=SDGLR_",SDGRP,""APP"",""LEN"",SDLEN,SDLG2)"
DO AGGSET(SDGLF,DTNAM,SDTOT)
End DoDot:4
End DoDot:3
+48 ;
+49 ; Appointment Statuses, by appt length
+50 SET SDSTAT=""
FOR
SET SDSTAT=$ORDER(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,"STAT",SDSTAT))
if SDSTAT=""
QUIT
Begin DoDot:3
+51 SET SDSTATOT=$PIECE($GET(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,"APP","LEN",SDLEN,"STAT",SDSTAT)),"^")
+52 ;
+53 ; 1. Full Path - Appointment Statuses by Appt Length- Aggregate Annual, Quarterly, Monthly, Weekly by Group, Division, Clinic, Provider
+54 SET SDGLR="^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC"
+55 FOR DTNAM="Year","Month","Week","Quarter","Date"
Begin DoDot:4
+56 IF $GET(DTRANGE)
if '(DTNAM="Date")
QUIT
+57 NEW SUFFIX
SET SUFFIX=",""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)"
+58 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+59 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+60 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+61 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+62 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""FAC"",SDGRP,SDCL,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+63 IF DTNAM'="Date"
DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
End DoDot:4
+64 ;
+65 ; 2. Group Specific by Facility - Appointment Statuses - Aggregate Resource Group Specific, Facility totals Annually, Quarterly, Monthly, Weekly, Daily
+66 SET SDGLR="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC"
Begin DoDot:4
+67 FOR DTNAM="Year","Quarter","Month","Week","Date"
Begin DoDot:5
+68 SET SDGLF="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC,SDGRP,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)"
DO AGGSET(SDGLF,DTNAM,SDSTATOT)
End DoDot:5
End DoDot:4
+69 ;
+70 ; 3. Provider Specific - Appointment Statuses - Provider Specific Annual, Quarterly, Monthly, Weekly, Daily totals
+71 FOR DTNAM="Year","Quarter","Month","Week","Date"
Begin DoDot:4
+72 IF $GET(DTRANGE)
if DTNAM'="Date"
QUIT
+73 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+74 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""FAC"",SDFAC,""CLIN"",SDCL,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+75 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+76 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""DIV"",SDIV,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+77 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""PROV"",SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+78 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,""GRP"",SDGRP,""CLIN"",SDCL,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
+79 DO AGGSET("^XTMP(SDNODE,""PROVIDER"",DTNAM,SDRPTYP,TMPDT,SDIV,""GRP"",SDGRP,SDPRV,""APP"",""LEN"",SDLEN,""STAT"",SDSTAT)",DTNAM,SDSTATOT)
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+80 QUIT
+81 ;
SUP ; Appointment supply
+1 NEW SDSUP,CLNAM,SDAPPND,TMPDT,DTNAM
+2 ;
+3 ; Providers do not have supply/slots, only clinics
if $PIECE($GET(SDPRV),"^",2)
QUIT
+4 NEW CLNAM
SET CLNAM=$SELECT($GET(SDCL):$PIECE($GET(^SC(+SDCL,0)),"^"),1:$PIECE(SDCL,"^"))
+5 SET SDAPPND=$GET(^XTMP(SDNODE,"Date",SDRPTYP,SDDT,SDFAC,SDIV,SDGRP,SDCL,"APP","SUP"))
+6 if SDAPPND=""
QUIT
+7 if '$GET(SDGRP)
QUIT
+8 SET TMPDT=SDDT
+9 ;
+10 ; 1. Full Path - Aggregate supply
+11 FOR DTNAM="Year","Month","Week","Quarter","Date"
Begin DoDot:1
+12 IF $GET(DTRANGE)
if DTNAM'="Date"
QUIT
+13 ; Don't add each group to facility and division totals - already done with group 0 (all)
+14 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""APP"",""SUP"")",DTNAM,SDAPPND)
+15 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,""APP"",""SUP"")",DTNAM,SDAPPND)
+16 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,""APP"",""SUP"")",DTNAM,SDAPPND)
+17 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""GRP"",SDGRP,""APP"",""SUP"")",DTNAM,SDAPPND)
+18 DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,""CLIN"",SDGRP,SDCL,""APP"",""SUP"")",DTNAM,SDAPPND)
+19 IF DTNAM'="Date"
DO AGGSET("^XTMP(SDNODE,DTNAM,SDRPTYP,TMPDT,SDFAC,SDIV,SDGRP,SDCL,""APP"",""SUP"")",DTNAM,SDAPPND)
+20 ;I SDRPTYP="M" W !,"SDGRP:",SDGRP,!?5,"-SDIV:",SDIV,!?5,"-SDCL:",SDCL,!?5,"-SDAPPND:",SDAPPND
End DoDot:1
+21 ;
+22 ; Supply
+23 FOR DTNAM="Year","Quarter","Month","Week","Date"
Begin DoDot:1
+24 SET SDGLF="^XTMP(SDNODE,""GROUP"",DTNAM,SDRPTYP,TMPDT,SDFAC,SDGRP,""APP"",""SUP"")"
DO AGGSET(SDGLF,DTNAM,SDAPPND)
End DoDot:1
+25 ;
+26 QUIT
+27 ;
AGGLEN(SDGLOB,DTNAM,PRVND) ; Perform generic aggregation of Pn values into SDGLOB
+1 NEW I,TMPDT,TOT,AGGDATA
+2 SET TMPDT=$SELECT(DTNAM="Year":TMPYR,DTNAM="Quarter":TMPQRT,DTNAM="Month":TMPMON,DTNAM="Week":TMPWK,1:SDDT)
+3 SET TOT=$PIECE($GET(@(SDGLOB)),"^")
+4 SET AGGDATA=TOT+PRVND
+5 SET $PIECE(@(SDGLOB),"^")=AGGDATA
+6 QUIT
+7 ;
AGGSET(SDGLOB,DTNAM,PRVND) ; Perform generic aggregation of Pn values into SDGLOB
+1 NEW I,TMPDT,TOT,AGGDATA,TMPWK
+2 SET TMPWK=$$GETWEEK^SDCED1(SDDT,.SDWEEKS)
+3 SET TMPDT=$SELECT(DTNAM="Year":TMPYR,DTNAM="Quarter":TMPQRT,DTNAM="Month":TMPMON,DTNAM="Week":TMPWK,1:SDDT)
+4 SET TOT=$GET(@(SDGLOB))
+5 FOR I=1:1:$LENGTH(PRVND,"^")
SET $PIECE(AGGDATA,"^",I)=($PIECE(TOT,"^",I)+$PIECE(PRVND,"^",I))
+6 SET @(SDGLOB)=AGGDATA
+7 QUIT
+8 ;
GETSUP2(CLIN,SUPDT) ; Get supply for date SUPDT
+1 NEW SLOTS,LEN,SDSUP,MAX
+2 SET SDSUP=""
+3 KILL ^TMP("SD",$JOB),^TMP("SDS",$JOB),^TMP("SDTMP",$JOB),^TMP("SDTOT",$JOB)
+4 if 'CLIN
QUIT SDSUP
+5 ;S X1=SUPDT,X2=SUPDT D ^%DTC S MAX=X+1
+6 DO INIT^SCRPW71
SET SLOTS=+$$CLINIC^SCRPW71(CLIN,"S",SUPDT,SUPDT,1,1)
+7 if 'SLOTS
QUIT SDSUP
+8 SET LEN=+$PIECE($GET(^SC(CLIN,"SL")),U)
+9 IF LEN
SET SDSUP=(LEN*SLOTS)/60
+10 QUIT SDSUP
+11 ;
APPLEN(CLIN) ; Get appt length
+1 NEW DIE,DIQ,DIR,DA,X,Y
+2 SET DIQ(0)="I"
SET DIC=44
SET DA=+$GET(CLIN)
SET DR="1912"
+3 DO GETS^DIQ(DIC,DA,DR,"I","APPLEN")
+4 SET APPLEN=$GET(APPLEN(DIC,DA_",",1912,"I"))
+5 QUIT APPLEN
+6 ;