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