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

SDECXML5.m

Go to the documentation of this file.
SDECXML5 ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 (cont) ;11/03/14 10:59am
 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
 ;
 ; ALL CLINICS
 Q
ALLCLIN(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,DTINC,CLNTAG,ALLCLDIV,SDCALL,SDNODE,GRPFLG,SDEBUG,XMLNODE) ; All Clinic
 N SDCLDIV,APPDEM,ADJDIFF,ADJDEM,APPTOT,SDDATA,APPDEM,ADJDEM,APPLEN,ADJDIFF,SDSTP
 N APPOVR,APPNEW,APPEST,ACTOT,DTNAM,GRPTOT,PRGDTOT,SDACTAP,SDFILT,SDCLIN,SDPRV,SDRESCH
 D DTNAM^SDECXUTL(DTINC,.DTNAM)
 ;
 ; If the first clinic in this group, and more than one clinic, create an "All" clinic grouping
 I $G(SDGRP),($G(SDCALL)<1),'($G(ALLCLDIV)=1) D
 .I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 .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)
 ;
 ; Supply
 N APPTOT
 I ($G(ALLCLDIV)=1) S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,"APP","SUP"))
 I ($G(ALLCLDIV)=2) S APPTOT=$G(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","SUP"))
 I '$G(ALLCLDIV) S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","SUP"))
 S SDDATA=$$PROV^SDECXML("All")_" "_$$RCASUP^SDECXML($P(APPTOT,"^"))
 D SETREC^SDECXML(.SDLCNT,SDDATA,16)
 ;
 ; Totals at the group level - sum of all clinics in the group
 ;  Appointments - Group at Facility level, Demand, Lengths
 S APPTOT="",APPLEN="",SDACTAP="",APPDEM="",ACTOT="",ADJDEM="",ADJDIFF="",SDSTP=""
 ; Appointments - Group Level totals Demand, Length
 I $G(SDIV) D
 .S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...Q:SDSTP="STAT"
 ...S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN,SDSTP))
 ...Q:(APPTOT="")
 ...S APPDEM=APPDEM+$P(APPTOT,"^")
 ..S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"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,SDGRP,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
 .I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
 .S ADJDEM=$S($G(ADJDEM):ADJDEM,1:APPDEM) S:ADJDEM<0 ADJDEM=0
 .D PARSE^SDECXML2(APPDEM,"All","All","DEM",+$G(APPLEN),+$G(SDSTP),$G(ADJDEM))
 .S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN)) Q:APPLEN=""  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...S ACTOT=""
 ...S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,"APP","LEN",APPLEN,SDSTP))
 ...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,SDSTP)
 ...I APPOVR S SDDATA=$$PROV^SDECXML("All")_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ...I APPNEW S SDDATA=$$PROV^SDECXML("All")_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ...I APPEST S SDDATA=$$PROV^SDECXML("All")_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 .;
 .; Appointments - Group Level totals Demand, Length
 S APPTOT="",APPDEM="",ADJDIFF="",ADJDEM=""
 I '$G(SDIV) D
 .S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...Q:SDSTP="STAT"
 ...S APPTOT=$G(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,SDSTP))
 ...Q:(APPTOT="")
 ...S APPDEM=APPDEM+$P(APPTOT,"^")
 ..S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH=""  D
 ...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
 ...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
 ...I ADJDIFF>APPDEM
 .I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
 .S ADJDEM=$S($G(ADJDEM):ADJDEM,1:APPDEM) S:ADJDEM<0 ADJDEM=0
 .D PARSE^SDECXML2(APPDEM,"All","All","DEM",APPLEN,SDSTP,ADJDEM)
 .S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN)) Q:APPLEN=""  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...S ACTOT=""
 ...S APPTOT=$G(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP,"APP","LEN",APPLEN,SDSTP))
 ...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,SDSTP)
 ...I APPOVR S SDDATA=$$PROV^SDECXML("All")_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ...I APPNEW S SDDATA=$$PROV^SDECXML("All")_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ...I APPEST S SDDATA=$$PROV^SDECXML("All")_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 ; Encounters 
 I $G(SDIV) S GRPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP))
 I '$G(SDIV) S GRPTOT=$G(^XTMP(SDNODE,"GROUP",DTNAM,SDRPTYP,SDAT,SDFAC,SDGRP))
 I '(GRPTOT="") N SDI F SDI=1:1:4 D
 .S SDDATA=$$PROV^SDECXML("All")_" "_$S(SDI=1:$$ENC^SDECXML($P(GRPTOT,"^",SDI)),SDI=2:$$NEW^SDECXML($P(GRPTOT,"^",SDI)),SDI=3:$$EST^SDECXML($P(GRPTOT,"^",SDI)),SDI=4:$$TEL^SDECXML($P(GRPTOT,"^",SDI)),1:"")
 .Q:($TR(SDDATA,"^","")="")
 .I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 ; Get the total for the provider at the Group level, is the sum of All clinics
 ;  Provider's cross-division resourcegroup totals
 N SDCLIN
 I $G(SDIV) D
 .S SDPRV="" F  S SDPRV=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV)) Q:SDPRV=""  D
 ..Q:(SDPRV'["^")  S APPDEM="",APPTOT="",ADJDIFF="",ADJDEM=""
 ..S APPLEN=0 F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ...S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ....Q:SDSTP=""  S ACTOT=""
 ....S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ....Q:(APPTOT="")
 ....;I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ....S APPDEM=APPDEM+$P(APPTOT,"^")
 ...S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,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,SDIV,"GRP",SDGRP,SDPRV,"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",SDPRV,"DEM",APPLEN,SDSTP,ADJDEM)
 ..S APPOVR="",APPNEW="",APPEST="",APPTOT=""
 ..S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ...S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ....S ACTOT=""
 ....S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ....Q:(APPTOT="")
 ....I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ....S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
 ....D PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDSTP)
 ....I APPOVR S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ....I APPNEW S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ....I APPEST S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..;
 ..; Encounters
 ..I SDIV="All" S PRGDTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV))
 ..I $G(SDIV) S PRGDTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,SDIV,"GRP",SDGRP,SDPRV))
 ..I '(PRGDTOT="") D
 ...N SDI F SDI=1:1:4 D
 ....S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$S(SDI=1:$$ENC^SDECXML($P(PRGDTOT,"^",SDI)),SDI=2:$$NEW^SDECXML($P(PRGDTOT,"^",SDI)),SDI=3:$$EST^SDECXML($P(PRGDTOT,"^",SDI)),SDI=4:$$TEL^SDECXML($P(PRGDTOT,"^",SDI)),1:"")
 ....Q:($TR(SDDATA,"^","")="")
 ....D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 N SDCLIN
 I '$G(SDIV) D
 .S SDPRV="" F  S SDPRV=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV)) Q:SDPRV=""  D
 ..Q:(SDPRV'["^")  S APPDEM="",APPTOT="",ADJDIFF="",ADJDEM=""
 ..S APPLEN=0 F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ...S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ....Q:SDSTP=""  S ACTOT=""
 ....S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN,SDSTP))
 ....Q:(APPTOT="")
 ....;I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ....S APPDEM=APPDEM+$P(APPTOT,"^")
 ...S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",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,"GRP",SDGRP,"PROV",SDPRV,"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",SDPRV,"DEM",APPLEN,SDSTP,ADJDEM)
 ..S APPOVR="",APPNEW="",APPEST="",APPTOT=""
 ..S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ...S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ....S ACTOT=""
 ....S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV,"APP","LEN",APPLEN,SDSTP))
 ....Q:(APPTOT="")
 ....I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ....S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
 ....D PARSE^SDECXML2(ACTOT,"All",SDPRV,"APPACT",APPLEN,SDSTP)
 ....I APPOVR S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ....I APPNEW S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ....I APPEST S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..;
 ..; Encounters
 ..I '$G(SDIV) S PRGDTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV))
 ..I $G(SDIV) S PRGDTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"PROV",SDPRV))
 ..I '(PRGDTOT="") D
 ...N SDI F SDI=1:1:4 D
 ....S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$S(SDI=1:$$ENC^SDECXML($P(PRGDTOT,"^",SDI)),SDI=2:$$NEW^SDECXML($P(PRGDTOT,"^",SDI)),SDI=3:$$EST^SDECXML($P(PRGDTOT,"^",SDI)),SDI=4:$$TEL^SDECXML($P(PRGDTOT,"^",SDI)),1:"")
 ....Q:($TR(SDDATA,"^","")="")
 ....D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $G(CLNTAG) D OUTPUT^SDECXUTL("</Rs>",15,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
 Q