Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDECXML3

SDECXML3.m

Go to the documentation of this file.
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