SDECXML3 ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 (cont) ;11/03/14 10:59am
;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
;
DIVALL(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,SDEBUG,SDGALL,SDCALL,SDNODE,CLNTAG,GRPFLG,DIVTAG,XMLNODE) ; All divisions - when there are > 1 divisions?
N SDFILT,SDMEAS,DTNAM,SDFILT,APPTOT,SDVGRCL,SDDIVALL,DTNAM
D DTNAM^SDECXUTL(DTINC,.DTNAM)
S $P(SDVGRCL,"^")=1,SDDIVALL=1
S SDIV="ALL"
S SDFILT=$$DIV^SDECXML("All") D SETTMPF^SDECXML(.SDLCNT,SDFILT,12)
;
N MULTGRP,TMPGRP,TMPGRPA,TMPDIV S MULTGRP="",TMPGRP="",TMPGRPA=""
D GRPALLF^SDECXML1(SDRPTYP,SDAT,SDFAC,"All",,.CLNTAG,DTINC,DTNAM,.GRPFLG,.SDLCNT,SDEBUG,SDGALL,SDCALL,SDNODE,XMLNODE) ; If multiple groups, do "All" groups
;
I $G(DIVTAG) D OUTPUT^SDECXUTL("</Division>",10,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
Q
;
GRPALL(SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDEBUG,SDGALL,SDCALL,SDNODE,CLNTAG,GRPFLG,DIVTAG,XMLNODE) ; all groups
; If ResourceGroup=All, get all clins and provs in all groups
;
N TMPGRP,SDGRPALL,SDGRCL
N SDGRP,SDCLN,SDGRPAR,SDDVTAG,TOT,TOTA,TOTS,SDPRV,IP,ADJDIFF,ADJDEM,APPDEM
S (TMPGRP,SDGRP)="All"
;
;; Do All Groups
I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
S SDFILT=$$GRP^SDECXML("All") D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
S (TOT,TOTA,TOTS)=""
S TOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV))
S TOTA=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",""))
S TOTS=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","SUP"))
;I (TOT'="")!(TOTA)!(TOTS'="") D
I $G(CLNTAG) D OUTPUT^SDECXUTL("</Rs>",15,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
S SDFILT=$$CLIN^SDECXML("All",1) D SETTMPF^SDECXML(.SDLCNT,SDFILT,15)
;
; Appointments - Supply
S APPTOT=TOTS
D PARSE^SDECXML2(APPTOT,"All","All","SUP")
;
; Appointments - Single Division Demand, Lengths
I $G(SDIV) D
.N APPLEN,SDLG2,APPDEM,APPNEW,APPEST,APPOVR,ACTOT,ADJDEM,ADJDIFF
.S APPTOT="",SDLG2="",APPDEM="",APPNEW="",APPEST="",APPOVR="",ACTOT="",ADJDEM="",ADJDIFF=""
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2=""!(SDLG2="STAT") D
...Q:SDLG2="STAT"
...Q:$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))="" S ACTOT=""
...S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
...S APPDEM=APPDEM+$P(APPTOT,"^")
..S SDRESCH="" F S SDRESCH=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH="" D
...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
.I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
.S ADJDEM=$S($G(ADJDEM):ADJDEM,1:APPDEM)
.I '(APPDEM="") D PARSE^SDECXML2(APPDEM,"All","All","DEM",APPLEN,SDLG2,ADJDEM)
.N APPLEN,SDLG2,APPDEM,APPNEW,APPEST,APPOVR,ACTOT
.S APPTOT="",SDLG2="",APPDEM="",APPNEW="",APPEST="",APPOVR="",ACTOT=""
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2="" D
...Q:SDLG2="STAT" S ACTOT=""
...S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
...S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
...I ACTOT D PARSE^SDECXML2(ACTOT,"All","All","APPACT",APPLEN,SDLG2)
...I '(APPOVR="") D PARSE^SDECXML2(APPOVR,"All","All","APPOVR",APPLEN,SDLG2)
...I '(APPNEW="") D PARSE^SDECXML2(APPNEW,"All","All","APPNEW",APPLEN,SDLG2)
...I '(APPEST="") D PARSE^SDECXML2(APPEST,"All","All","APPEST",APPLEN,SDLG2)
;
; Encounters
I $G(SDIV) D
.S TOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV))
I TOT'="" D PARSE^SDECXML2(TOT,"All","All")
;
; Appointments - Provider specific
S SDPRV="" F IP=0:1 S SDPRV=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV)) Q:SDPRV="" D
.Q:'(SDPRV["^")
.D GPALCONT
;
; Do all clinics in all groups
D ALLCLGRP(SDNODE,DTNAM,SDAT,SDIV)
;
I $G(CLNTAG) D OUTPUT^SDECXUTL("</Rs>",15,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
I ($G(SDGRP)'=0) I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",13,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
;
Q
;
GPALCONT ; Continue GRPALL
N APPLEN,SDLG,SDLG2,APPDEM,APPTOT,SDLG2,ACTOT,ADJDEM,ADJDIFF,SDRESCH,APPDEM,DIVTOT
;
; Appointments - Single division Demand, Lengths
S APPLEN="",APPDEM="",APPTOT="",SDLG2="",ACTOT="",ADJDEM="",ADJDIFF="",SDRESCH=""
I $G(SDIV) D
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2="" D
...Q:SDLG2="STAT" S ACTOT=""
...S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
...Q:APPTOT="" S ACTOT=""
...S APPDEM=APPDEM+$P(APPTOT,"^")
..S SDRESCH="" F S SDRESCH=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH="" D
...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
.I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
.S ADJDEM=$S($G(ADJDEM):ADJDEM,1:APPDEM)
.D PARSE^SDECXML2(APPDEM,"All",SDPRV,"DEM",APPLEN,SDLG2,ADJDEM)
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2="" D
...Q:SDLG2="STAT"
...S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
...Q:APPTOT="" S ACTOT=""
...S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
...D PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDLG2)
...I '(APPOVR="") D PARSE^SDECXML2(APPOVR,"All",SDPRV,"APPOVR",APPLEN,SDLG2)
...I '(APPNEW="") D PARSE^SDECXML2(APPNEW,"All",SDPRV,"APPNEW",APPLEN,SDLG2)
...I '(APPEST="") D PARSE^SDECXML2(APPEST,"All",SDPRV,"APPEST",APPLEN,SDLG2)
;
; Appointments - All divisions Demand, Lengths
S APPLEN="",APPDEM="",APPTOT="",SDLG2="",ACTOT="",ADJDEM="",ADJDIFF=""
I '$G(SDIV) D
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2="" D
...Q:SDLG2="STAT" S ACTOT=""
...S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
...Q:APPTOT=""
...S APPDEM=APPDEM+$P(APPTOT,"^")
..S SDRESCH="" F S SDRESCH=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH="" D
...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
.I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
.S ADJDEM=$S($G(ADJDEM):ADJDEM,1:APPDEM)
.D PARSE^SDECXML2(APPDEM,"All",SDPRV,"DEM",APPLEN,SDLG2,ADJDEM)
.S APPLEN=0 F S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN D
..S SDLG2="" F S SDLG2=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2)) Q:SDLG2="" D
...S SDLG2="" S ACTOT=""
...S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
...Q:APPTOT=""
...S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
...D PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDLG2)
...I '(APPOVR="") D PARSE^SDECXML2(APPOVR,"All",SDPRV,"APPOVR",APPLEN,SDLG2)
...I '(APPNEW="") D PARSE^SDECXML2(APPNEW,"All",SDPRV,"APPNEW",APPLEN,SDLG2)
...I '(APPEST="") D PARSE^SDECXML2(APPEST,"All",SDPRV,"APPEST",APPLEN,SDLG2)
;
S DIVTOT=""
I $G(SDIV) S DIVTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV))
I '(DIVTOT="") D PARSE^SDECXML2(DIVTOT,"All",SDPRV)
Q
;
ALLCLGRP(SDNODE,DTNAM,SDAT,SDIV) ; All clinics in this group
; Get all clinic totals for specific group, for ONE division
N DIVCLNAR,SDAGTYP,CLN,IC,PRV,DIV,GRP,CLGRPCNT S IC=0,DIV="",CLGRPCNT=0
K DIVCLNAR
D GETDIVCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,SDIV,.DIVCLNAR)
S CLN="" F S CLN=$O(DIVCLNAR(SDIV,CLN)) Q:CLN="" D
.Q:CLN="APP"
.D ONECLIN^SDECXML4(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,CLN,DTINC,"",SDEBUG,.CLNTAG,.GRPFLG,SDNODE,XMLNODE) ; Single Clinic
.S PRV="" F S PRV=$O(^XTMP(SDNODE,"PROVIDER",DATINC,SDRPTYP,SDAT,"DIV",SDIV,"CLIN",CLN,PRV)) Q:PRV="" D
..Q:'(PRV["^")
..D PROVIDER^SDECXML2(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,"All",CLN,PRV,$E(DATINC),.CLNTAG,.GRPFLG,SDCALL,$G(DTNAM),SDGALL,SDNODE)
Q
;
GETDIVCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,DIVCLNAR) ; Get clinics in one division
N TMPGRP,TMPCLN
S TMPGRP=0 F S TMPGRP=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,TMPGRP)) Q:TMPGRP="" D
.Q:TMPGRP="APP"
.S TMPCLN="" F S TMPCLN=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,TMPGRP,TMPCLN)) Q:TMPCLN="" D
..Q:TMPCLN="APP"
..S DIVCLNAR(DIV,TMPCLN)=""
Q
;
GETGRPCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,GRPCLNAR) ; Get clinics in each group
N DIV,CLN
S DIV="" F S DIV=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV)) Q:DIV="" D
.Q:DIV="APP"!(DIV="FAC") S GRP="" F S GRP=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,GRP)) Q:GRP="" D
..Q:GRP="APP"!(GRP=0) S CLN="" F S CLN=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,GRP,CLN)) Q:CLN="" D
...Q:CLN="APP" S GRPCLNAR(GRP,CLN)=""
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDECXML3 10149 printed Dec 13, 2024@02:53:06 Page 2
SDECXML3 ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 (cont) ;11/03/14 10:59am
+1 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
+2 ;
DIVALL(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,SDEBUG,SDGALL,SDCALL,SDNODE,CLNTAG,GRPFLG,DIVTAG,XMLNODE) ; All divisions - when there are > 1 divisions?
+1 NEW SDFILT,SDMEAS,DTNAM,SDFILT,APPTOT,SDVGRCL,SDDIVALL,DTNAM
+2 DO DTNAM^SDECXUTL(DTINC,.DTNAM)
+3 SET $PIECE(SDVGRCL,"^")=1
SET SDDIVALL=1
+4 SET SDIV="ALL"
+5 SET SDFILT=$$DIV^SDECXML("All")
DO SETTMPF^SDECXML(.SDLCNT,SDFILT,12)
+6 ;
+7 NEW MULTGRP,TMPGRP,TMPGRPA,TMPDIV
SET MULTGRP=""
SET TMPGRP=""
SET TMPGRPA=""
+8 ; If multiple groups, do "All" groups
DO GRPALLF^SDECXML1(SDRPTYP,SDAT,SDFAC,"All",,.CLNTAG,DTINC,DTNAM,.GRPFLG,.SDLCNT,SDEBUG,SDGALL,SDCALL,SDNODE,XMLNODE)
+9 ;
+10 IF $GET(DIVTAG)
DO OUTPUT^SDECXUTL("</Division>",10,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
+11 QUIT
+12 ;
GRPALL(SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDEBUG,SDGALL,SDCALL,SDNODE,CLNTAG,GRPFLG,DIVTAG,XMLNODE) ; all groups
+1 ; If ResourceGroup=All, get all clins and provs in all groups
+2 ;
+3 NEW TMPGRP,SDGRPALL,SDGRCL
+4 NEW SDGRP,SDCLN,SDGRPAR,SDDVTAG,TOT,TOTA,TOTS,SDPRV,IP,ADJDIFF,ADJDEM,APPDEM
+5 SET (TMPGRP,SDGRP)="All"
+6 ;
+7 ;; Do All Groups
+8 IF $GET(GRPFLG)
DO OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
+9 SET SDFILT=$$GRP^SDECXML("All")
DO SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
+10 SET (TOT,TOTA,TOTS)=""
+11 SET TOT=$GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV))
+12 SET TOTA=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",""))
+13 SET TOTS=$GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","SUP"))
+14 ;I (TOT'="")!(TOTA)!(TOTS'="") D
+15 IF $GET(CLNTAG)
DO OUTPUT^SDECXUTL("</Rs>",15,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
+16 SET SDFILT=$$CLIN^SDECXML("All",1)
DO SETTMPF^SDECXML(.SDLCNT,SDFILT,15)
+17 ;
+18 ; Appointments - Supply
+19 SET APPTOT=TOTS
+20 DO PARSE^SDECXML2(APPTOT,"All","All","SUP")
+21 ;
+22 ; Appointments - Single Division Demand, Lengths
+23 IF $GET(SDIV)
Begin DoDot:1
+24 NEW APPLEN,SDLG2,APPDEM,APPNEW,APPEST,APPOVR,ACTOT,ADJDEM,ADJDIFF
+25 SET APPTOT=""
SET SDLG2=""
SET APPDEM=""
SET APPNEW=""
SET APPEST=""
SET APPOVR=""
SET ACTOT=""
SET ADJDEM=""
SET ADJDIFF=""
+26 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+27 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""!(SDLG2="STAT")
QUIT
Begin DoDot:3
+28 if SDLG2="STAT"
QUIT
+29 if $GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))=""
QUIT
SET ACTOT=""
+30 SET APPTOT=$GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
+31 SET APPDEM=APPDEM+$PIECE(APPTOT,"^")
End DoDot:3
+32 SET SDRESCH=""
FOR
SET SDRESCH=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,"STAT",SDRESCH))
if SDRESCH=""
QUIT
Begin DoDot:3
+33 if '($PIECE(SDRESCH,";")="NSR"!($PIECE(SDRESCH,";")="CPR")!($PIECE(SDRESCH,";")="CCR"))
QUIT
+34 SET ADJDIFF=ADJDIFF+(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
End DoDot:3
End DoDot:2
+35 IF ADJDIFF&APPDEM
SET ADJDEM=APPDEM-ADJDIFF
+36 SET ADJDEM=$SELECT($GET(ADJDEM):ADJDEM,1:APPDEM)
+37 IF '(APPDEM="")
DO PARSE^SDECXML2(APPDEM,"All","All","DEM",APPLEN,SDLG2,ADJDEM)
+38 NEW APPLEN,SDLG2,APPDEM,APPNEW,APPEST,APPOVR,ACTOT
+39 SET APPTOT=""
SET SDLG2=""
SET APPDEM=""
SET APPNEW=""
SET APPEST=""
SET APPOVR=""
SET ACTOT=""
+40 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+41 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:3
+42 if SDLG2="STAT"
QUIT
SET ACTOT=""
+43 SET APPTOT=$GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,"APP","LEN",APPLEN,SDLG2))
+44 SET APPOVR=$PIECE(APPTOT,"^",2)
SET APPNEW=$PIECE(APPTOT,"^",3)
SET APPEST=$PIECE(APPTOT,"^",4)
SET ACTOT=APPNEW+APPEST
+45 IF ACTOT
DO PARSE^SDECXML2(ACTOT,"All","All","APPACT",APPLEN,SDLG2)
+46 IF '(APPOVR="")
DO PARSE^SDECXML2(APPOVR,"All","All","APPOVR",APPLEN,SDLG2)
+47 IF '(APPNEW="")
DO PARSE^SDECXML2(APPNEW,"All","All","APPNEW",APPLEN,SDLG2)
+48 IF '(APPEST="")
DO PARSE^SDECXML2(APPEST,"All","All","APPEST",APPLEN,SDLG2)
End DoDot:3
End DoDot:2
End DoDot:1
+49 ;
+50 ; Encounters
+51 IF $GET(SDIV)
Begin DoDot:1
+52 SET TOT=$GET(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV))
End DoDot:1
+53 IF TOT'=""
DO PARSE^SDECXML2(TOT,"All","All")
+54 ;
+55 ; Appointments - Provider specific
+56 SET SDPRV=""
FOR IP=0:1
SET SDPRV=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV))
if SDPRV=""
QUIT
Begin DoDot:1
+57 if '(SDPRV["^")
QUIT
+58 DO GPALCONT
End DoDot:1
+59 ;
+60 ; Do all clinics in all groups
+61 DO ALLCLGRP(SDNODE,DTNAM,SDAT,SDIV)
+62 ;
+63 IF $GET(CLNTAG)
DO OUTPUT^SDECXUTL("</Rs>",15,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
+64 IF ($GET(SDGRP)'=0)
IF $GET(GRPFLG)
DO OUTPUT^SDECXUTL("</Rg>",13,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
+65 ;
+66 QUIT
+67 ;
GPALCONT ; Continue GRPALL
+1 NEW APPLEN,SDLG,SDLG2,APPDEM,APPTOT,SDLG2,ACTOT,ADJDEM,ADJDIFF,SDRESCH,APPDEM,DIVTOT
+2 ;
+3 ; Appointments - Single division Demand, Lengths
+4 SET APPLEN=""
SET APPDEM=""
SET APPTOT=""
SET SDLG2=""
SET ACTOT=""
SET ADJDEM=""
SET ADJDIFF=""
SET SDRESCH=""
+5 IF $GET(SDIV)
Begin DoDot:1
+6 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+7 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:3
+8 if SDLG2="STAT"
QUIT
SET ACTOT=""
+9 SET APPTOT=$GET(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
+10 if APPTOT=""
QUIT
SET ACTOT=""
+11 SET APPDEM=APPDEM+$PIECE(APPTOT,"^")
End DoDot:3
+12 SET SDRESCH=""
FOR
SET SDRESCH=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH))
if SDRESCH=""
QUIT
Begin DoDot:3
+13 if '($PIECE(SDRESCH,";")="NSR"!($PIECE(SDRESCH,";")="CPR")!($PIECE(SDRESCH,";")="CCR"))
QUIT
+14 SET ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
End DoDot:3
End DoDot:2
+15 IF ADJDIFF&APPDEM
SET ADJDEM=APPDEM-ADJDIFF
+16 SET ADJDEM=$SELECT($GET(ADJDEM):ADJDEM,1:APPDEM)
+17 DO PARSE^SDECXML2(APPDEM,"All",SDPRV,"DEM",APPLEN,SDLG2,ADJDEM)
+18 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+19 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:3
+20 if SDLG2="STAT"
QUIT
+21 SET APPTOT=$GET(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV,"APP","LEN",APPLEN,SDLG2))
+22 if APPTOT=""
QUIT
SET ACTOT=""
+23 SET APPOVR=$PIECE(APPTOT,"^",2)
SET APPNEW=$PIECE(APPTOT,"^",3)
SET APPEST=$PIECE(APPTOT,"^",4)
SET ACTOT=APPNEW+APPEST
+24 DO PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDLG2)
+25 IF '(APPOVR="")
DO PARSE^SDECXML2(APPOVR,"All",SDPRV,"APPOVR",APPLEN,SDLG2)
+26 IF '(APPNEW="")
DO PARSE^SDECXML2(APPNEW,"All",SDPRV,"APPNEW",APPLEN,SDLG2)
+27 IF '(APPEST="")
DO PARSE^SDECXML2(APPEST,"All",SDPRV,"APPEST",APPLEN,SDLG2)
End DoDot:3
End DoDot:2
End DoDot:1
+28 ;
+29 ; Appointments - All divisions Demand, Lengths
+30 SET APPLEN=""
SET APPDEM=""
SET APPTOT=""
SET SDLG2=""
SET ACTOT=""
SET ADJDEM=""
SET ADJDIFF=""
+31 IF '$GET(SDIV)
Begin DoDot:1
+32 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+33 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:3
+34 if SDLG2="STAT"
QUIT
SET ACTOT=""
+35 SET APPTOT=$GET(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
+36 if APPTOT=""
QUIT
+37 SET APPDEM=APPDEM+$PIECE(APPTOT,"^")
End DoDot:3
+38 SET SDRESCH=""
FOR
SET SDRESCH=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH))
if SDRESCH=""
QUIT
Begin DoDot:3
+39 if '($PIECE(SDRESCH,";")="NSR"!($PIECE(SDRESCH,";")="CPR")!($PIECE(SDRESCH,";")="CCR"))
QUIT
+40 SET ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
End DoDot:3
End DoDot:2
+41 IF ADJDIFF&APPDEM
SET ADJDEM=APPDEM-ADJDIFF
+42 SET ADJDEM=$SELECT($GET(ADJDEM):ADJDEM,1:APPDEM)
+43 DO PARSE^SDECXML2(APPDEM,"All",SDPRV,"DEM",APPLEN,SDLG2,ADJDEM)
+44 SET APPLEN=0
FOR
SET APPLEN=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN))
if 'APPLEN
QUIT
Begin DoDot:2
+45 SET SDLG2=""
FOR
SET SDLG2=$ORDER(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
if SDLG2=""
QUIT
Begin DoDot:3
+46 SET SDLG2=""
SET ACTOT=""
+47 SET APPTOT=$GET(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"FAC",SDFAC,SDPRV,"APP","LEN",APPLEN,SDLG2))
+48 if APPTOT=""
QUIT
+49 SET APPOVR=$PIECE(APPTOT,"^",2)
SET APPNEW=$PIECE(APPTOT,"^",3)
SET APPEST=$PIECE(APPTOT,"^",4)
SET ACTOT=APPNEW+APPEST
+50 DO PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDLG2)
+51 IF '(APPOVR="")
DO PARSE^SDECXML2(APPOVR,"All",SDPRV,"APPOVR",APPLEN,SDLG2)
+52 IF '(APPNEW="")
DO PARSE^SDECXML2(APPNEW,"All",SDPRV,"APPNEW",APPLEN,SDLG2)
+53 IF '(APPEST="")
DO PARSE^SDECXML2(APPEST,"All",SDPRV,"APPEST",APPLEN,SDLG2)
End DoDot:3
End DoDot:2
End DoDot:1
+54 ;
+55 SET DIVTOT=""
+56 IF $GET(SDIV)
SET DIVTOT=$GET(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"DIV",SDIV,SDPRV))
+57 IF '(DIVTOT="")
DO PARSE^SDECXML2(DIVTOT,"All",SDPRV)
+58 QUIT
+59 ;
ALLCLGRP(SDNODE,DTNAM,SDAT,SDIV) ; All clinics in this group
+1 ; Get all clinic totals for specific group, for ONE division
+2 NEW DIVCLNAR,SDAGTYP,CLN,IC,PRV,DIV,GRP,CLGRPCNT
SET IC=0
SET DIV=""
SET CLGRPCNT=0
+3 KILL DIVCLNAR
+4 DO GETDIVCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,SDIV,.DIVCLNAR)
+5 SET CLN=""
FOR
SET CLN=$ORDER(DIVCLNAR(SDIV,CLN))
if CLN=""
QUIT
Begin DoDot:1
+6 if CLN="APP"
QUIT
+7 ; Single Clinic
DO ONECLIN^SDECXML4(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,CLN,DTINC,"",SDEBUG,.CLNTAG,.GRPFLG,SDNODE,XMLNODE)
+8 SET PRV=""
FOR
SET PRV=$ORDER(^XTMP(SDNODE,"PROVIDER",DATINC,SDRPTYP,SDAT,"DIV",SDIV,"CLIN",CLN,PRV))
if PRV=""
QUIT
Begin DoDot:2
+9 if '(PRV["^")
QUIT
+10 DO PROVIDER^SDECXML2(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,"All",CLN,PRV,$EXTRACT(DATINC),.CLNTAG,.GRPFLG,SDCALL,$GET(DTNAM),SDGALL,SDNODE)
End DoDot:2
End DoDot:1
+11 QUIT
+12 ;
GETDIVCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,DIVCLNAR) ; Get clinics in one division
+1 NEW TMPGRP,TMPCLN
+2 SET TMPGRP=0
FOR
SET TMPGRP=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,TMPGRP))
if TMPGRP=""
QUIT
Begin DoDot:1
+3 if TMPGRP="APP"
QUIT
+4 SET TMPCLN=""
FOR
SET TMPCLN=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,TMPGRP,TMPCLN))
if TMPCLN=""
QUIT
Begin DoDot:2
+5 if TMPCLN="APP"
QUIT
+6 SET DIVCLNAR(DIV,TMPCLN)=""
End DoDot:2
End DoDot:1
+7 QUIT
+8 ;
GETGRPCL(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,GRPCLNAR) ; Get clinics in each group
+1 NEW DIV,CLN
+2 SET DIV=""
FOR
SET DIV=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV))
if DIV=""
QUIT
Begin DoDot:1
+3 if DIV="APP"!(DIV="FAC")
QUIT
SET GRP=""
FOR
SET GRP=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,GRP))
if GRP=""
QUIT
Begin DoDot:2
+4 if GRP="APP"!(GRP=0)
QUIT
SET CLN=""
FOR
SET CLN=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDAT,SDFAC,DIV,GRP,CLN))
if CLN=""
QUIT
Begin DoDot:3
+5 if CLN="APP"
QUIT
SET GRPCLNAR(GRP,CLN)=""
End DoDot:3
End DoDot:2
End DoDot:1
+6 QUIT