- SDECXML ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 ;11/03/14 10:59am
- ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
- ;
- GETFLT(RESULT,ALL,SDEBUG) ; RPC - Filter Data only
- N SDRPTYP,SDDT,I,SDPC,DTAGAB,SDFLTFLG,DTRANGE,SDLCNT,NODATA,SDSTAT
- S SDEBUG=$G(SDEBUG),NODATA=0
- S SDSTAT=$$ISLOCKED^SDCED()
- ; If the background job is running then return NODATA with error text
- I +SDSTAT D NODATA^SDECXUTL(.RESULT,$P(SDSTAT,U,2)) Q
- I '$D(^XTMP("SDVSE","FLTXML")) D Q:NODATA
- .I $D(^XTMP("SDVSE","DT")),SDSTAT=0 D START("MPS","YQMWD","","",1,"","","FLTXML") Q
- .D NODATA^SDECXUTL(.RESULT) S NODATA=1
- S RESULT=$NAME(^TMP($J,"FLTXML"))
- M ^TMP($J,"FLTXML")=^XTMP("SDVSE","FLTXML")
- Q
- ;
- REPORT(RESULT,SDRPTLST,SDBEGRNG,SDENDRNG,SDEBUG) ; RPC - Report Data
- N SDRPTYP,SDDT,I,SDPC,DTAGAB,SDUR,SDACTDT1,SDWEEKS,SDLCNT,DATE,SDINTDT,XMLNODE
- K ^TMP($J,"SDECXML")
- S RESULT=$NAME(^TMP($J,"SDECXML"))
- S SDEBUG=$G(SDEBUG),XMLNODE="SDECXML"
- S SDACTDT1=$O(^XTMP("SDVSE","DT","")) S:'SDACTDT1 SDACTDT1=$P($$NOW^XLFDT,".")
- I $G(SDRPTLST)="" S SDRPTLST="MPS"
- S SDBEGRNG=$G(SDBEGRNG),SDENDRNG=$G(SDENDRNG)
- I SDBEGRNG,(SDBEGRNG'?7N.E) S SDBEGRNG=$$SDETFM(SDBEGRNG)
- I SDENDRNG,(SDENDRNG'?7N.E) S SDENDRNG=$$SDETFM(SDENDRNG)
- I ",Y,Q,M,W,D,"[(","_SDBEGRNG_",") D
- .S SDUR=$S(SDBEGRNG="Y":"Year",SDBEGRNG="Q":"Quarter",SDBEGRNG="M":"Month",SDBEGRNG="W":"Week",1:"Date")
- .I SDUR="Year" D Q
- ..S SDBEGRNG=$$FMADD^XLFDT(SDACTDT1,-365),SDENDRNG=SDACTDT1
- .I SDUR'="Year" D Q
- ..N SDDATE,ACTDT1,ACTDT2
- ..S SDBEGRNG=SDENDRNG
- ..I SDUR="Week" D
- ...D WEEKS^SDCED1(SDENDRNG,.SDWEEKS)
- ...S SDBEGRNG=$$GETWEEK^SDCED1(SDBEGRNG,.SDWEEKS)
- ..S SDDATE=SDBEGRNG
- ..D BEGEND^SDECXUTL(SDDATE,.ACTDT1,.ACTDT2,$E(SDUR),SDDATE)
- ..I '($G(ACTDT1)?7N.E) S SDBEGRNG=$$SDETFM(ACTDT1)
- ..I '($G(ACTDT2)?7N.E) S SDENDRNG=$$SDETFM(ACTDT2)
- I $G(SDUR)="" S SDUR=$$FMDIFF^XLFDT(SDENDRNG,SDBEGRNG) D
- .S SDUR=$S(SDUR>93:"Year",SDUR>31:"Quarter",SDUR>7:"Month",SDUR>1:"Week",1:"Date")
- ; If this is a Year report request and if Yearly report already exists then return without recompiling XML report data
- I SDUR="Year",$D(^XTMP("SDVSE","YRPTXML-"_SDRPTLST)) M ^TMP($J,"SDECXML")=^XTMP("SDVSE","YRPTXML-"_SDRPTLST) Q
- S SDDTINC="D"
- D START(SDRPTLST,.SDDTINC,SDBEGRNG,SDENDRNG,,SDUR,SDEBUG,XMLNODE)
- M ^TMP($J,"SDECXML")=^XTMP("SDVSE",XMLNODE)
- K ^XTMP("SDVSE",XMLNODE)
- Q
- ;
- START(SDRPTLST,SDDTINC,SDBEGRNG,SDENDRNG,SDFLTFLG,SDUR,SDEBUG,XMLNODE) ; Begin building report data from ^XTMP("SDVSE","DT"
- N DT,SDDT,SDBEGDT,SDENDDT,SDFACNUM,SDFACNAM,SDFILT,SDFAC,DTNAMAR,SDDTCNT,SDRPTCNT,DTRANGE,SDNODE,SDRPTAR
- N CLNTAG,DIVTAG,GRPFLG,SDACTDT,DTNAM,SDRPT
- I $G(XMLNODE)="" S XMLNODE=$S($G(SDFLTFLG)=1:"FLTXML",1:"SDECXML")
- K ^XTMP("SDVSE",XMLNODE)
- F SDRPT="M","P","S" S SDRPTAR(SDRPT)=""
- S (SDACTDT,DT)=$O(^XTMP("SDVSE","DT","")) Q:'SDACTDT
- S SDBEGDT=$S($G(SDBEGRNG):$$SDETFM(SDBEGRNG),1:"")
- S SDENDDT=$S($G(SDENDRNG)&$G(SDBEGDT):$$SDETFM(SDENDRNG),1:"")
- I '$G(SDFLTFLG),$G(SDBEGDT)&$G(SDENDDT) S DTRANGE=SDBEGDT_"-"_SDENDDT
- S SDNODE=$S($G(DTRANGE):$J_",SDCEX",1:"SDCEX")
- I $G(DTRANGE) D
- .D EN^SDCED1(.SDRPTAR,SDBEGRNG,SDENDRNG,SDNODE)
- ;
- S SDLCNT=0,SDFACNAM=$$SITE^VASITE,SDFACNUM=+SDFACNAM,SDFACNAM=$P(SDFACNAM,"^",2)
- F DTNAM="Year","Quarter","Month","Week","Date" S DTNAMAR($E(DTNAM))=DTNAM
- S SDFAC=$$SITE^VASITE
- D OUTPUT^SDECXUTL("<?xml version=""1.0"" encoding=""UTF-8""?>",0,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE) ; Generic Set/Output
- S SDFILT=$$FAC(SDFAC) D SETFILT(.SDLCNT,SDFILT,2)
- F SDRPTCNT=1:1:$L(SDRPTLST) S SDRPT=$E(SDRPTLST,SDRPTCNT) D
- .S SDFILT=$$RPT(SDRPT) D SETFILT(.SDLCNT,SDFILT,4)
- .F SDDTCNT=1:1:$L(SDDTINC) S SDTINC=$E(SDDTINC,SDDTCNT) D
- ..Q:'$D(DTNAMAR(SDTINC)) S SDTINC=$G(DTNAMAR(SDTINC))
- ..Q:SDTINC=""
- ..D DATINC(.SDLCNT,SDBEGDT,SDENDDT,SDRPT,SDTINC,$G(DTRANGE),SDNODE,SDEBUG,XMLNODE)
- .D OUTPUT^SDECXUTL("</ReportType>",4,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- I '$G(SDFLTFLG) D SETSDREC^SDECXUTL(.SDLCNT,$E(SDRPTLST),,XMLNODE)
- D OUTPUT^SDECXUTL("</VAFacility>",2,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- I $G(SDNODE)["," K ^XTMP(SDNODE)
- Q
- ;
- DATINC(SDLCNT,SDBEGDT,SDENDDT,SDRPTYP,DATINC,DTRANGE,SDNODE,SDEBUG,XMLNODE) ; Get Year, Quarter, Month, Week, and Date data for Division, Group, Clinic, Provider
- N SDPRV,SDCLN,SDDGRP,SDIV,SDFAC,SDII,SDDATE,SDRPT,SDTINC,IC,SDALL,SDDIV
- N CLNTAG,GRPFLG,DIVTAG,STRING
- I '$G(SDBEGDT) S SDBEGDT=$$FMADD^XLFDT($$NOW^XLFDT,-365)
- I '$G(SDENDDT) S SDENDDT=$P($$FMADD^XLFDT($$NOW^XLFDT,1),".")
- S SDDATE=$S($G(DTRANGE):"",1:$$FMADD^XLFDT(SDBEGDT,,-1))
- I DATINC="Year",'$G(DTRANGE) S SDDATE=$O(^XTMP(SDNODE,DATINC,SDRPTYP,""))
- S SDDATE="",SDCALL="",SDGALL=""
- I $G(SDFLTFLG),DATINC="Date" S SDDATE=$$FMADD^XLFDT(SDACTDT,,,1)
- I $G(SDFLTFLG),DATINC="Week" I $O(^XTMP(SDNODE,DATINC,SDRPTYP,""),-1)>$$FMADD^XLFDT(SDACTDT,6) S SDDATE=$$FMADD^XLFDT(SDACTDT,6)
- F SDII=0:1 S SDDATE=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE),-1) Q:SDDATE=""!($G(DTRANGE)&(SDDATE<SDBEGDT)) D
- .I SDII=0 D OUTPUT^SDECXUTL("<DateAggregate DateAgg="""_$S(($G(SDUR)]""):SDUR,1:DATINC)_""">",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- .D OUTPUT^SDECXUTL($$DATE(SDDATE,$E(DATINC),SDACTDT,$G(DTRANGE)),8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- .S SDFAC="" F S SDFAC=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC)) Q:SDFAC=""!(SDFAC="APP") D
- ..Q:$G(SDFLTFLG)
- ..Q:$G(XMLNODE)="FLTXML"
- ..N SDALLALL,SDVGRCL,SDGALL,SDCALL
- ..S SDVGRCL="",SDALL=0,SDGALL=0,SDCALL=0
- ..S SDDIV="" F DIVCOUNT=0:1 S SDDIV=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV)) Q:'SDDIV D
- ...;Q:(SDDIV="APP")
- ...D DIVISION(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,$E(DATINC),DIVCOUNT,XMLNODE)
- ...N SDSINGRP S SDSINGRP=0
- ...S SDGALL=0
- ...S SDDGRP=0 F IG=1:1 S SDDGRP=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP)) Q:SDDGRP="" D
- ....Q:(SDDGRP="APP")
- ....D GROUP(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,$E(DATINC),IG)
- ....Q:((SDDGRP=0)&$G(SDSINGRP))
- ....S SDGALL=$G(SDGALL)+1
- ....S SDCALL=0
- ....S SDCLN="" F IC=1:1 S SDCLN=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN)) Q:SDCLN="" D
- .....Q:(SDCLN="APP")!(SDCLN="STAT")
- .....D CLINIC^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,$E(DATINC),SDNODE,.CLNTAG,SDCALL,.GRPFLG,SDEBUG,XMLNODE)
- .....S SDCALL=$G(SDCALL)+1
- .....S SDPRV="" F S SDPRV=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV)) Q:SDPRV="" D
- ......Q:'(SDPRV["^")
- ......D PROVIDER^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV,DATINC,.CLNTAG,.GRPFLG,SDCALL,DTNAM,SDGALL,SDNODE)
- .....I $G(CLNTAG) D OUTPUT^SDECXUTL("</Rs>",13,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- ....I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- ...I $G(DIVTAG) D OUTPUT^SDECXUTL("</Division>",10,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- .D OUTPUT^SDECXUTL("</Date>",8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- Q:'SDII
- D OUTPUT^SDECXUTL("</DateAggregate>",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- Q
- ;
- DIVISION(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,DIVCOUNT,XMLNODE) ; Division
- N SDFILT,DTNAM
- S DTNAM=$G(DTNAMAR(DTINC))
- I '$G(DIVCOUNT) D DIVALL^SDECXML3(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE) ; All divisions -
- ;
- S SDFILT=$$DIV(SDIV) D SETTMPF(.SDLCNT,SDFILT,11)
- Q
- ;
- GROUP(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,DTINC,IG) ; Group
- N SDFILT,SDDATA,DTNAM,SDFILT,SDGRPRV
- Q:$G(SDIV)=""
- S DTNAM=$G(DTNAMAR(DTINC))
- I '$G(SDGALL) D GRPALL^SDECXML3(SDRPTYP,SDAT,SDFAC,SDIV,"",SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- ;
- I SDGRP D
- .I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
- .S SDFILT=$$GRP(SDGRP) D SETTMPF(.SDLCNT,SDFILT,15) S GRPFLG=1
- Q
- ;
- RPT(RPT) ; Report Type
- S RPT=$S(RPT="S":"Specialty Care",RPT="M":"Mental Health",RPT="P":"Primary Care",1:"")
- S STRING="ReportType ReportType="""_RPT_""""
- Q STRING
- FAC(SDFAC,XTYP) ; Return formatted Facility
- N SDFACDAT S SDFACDAT=$$SITE^VASITE()
- S STRING="VAFacility Name="""_$$SYMENC^MXMLUTL($P(SDFACDAT,"^",2))_""" ID="""_+SDFACDAT_"""" Q STRING
- DIV(DIV,XTYP) ; Return formatted Division
- S DIVTAG=1
- S STRING="Division Name="""_$$DIVNAME^SDECXUTL(DIV)_"""" Q STRING
- GRP(GRP,XTYP) ; Return Clinic Group
- N GRPNAM
- S GRPNAM=$$GRPNAM(GRP)
- I $G(XTYP)="M" S STRING="Rg="""_$S(GRPNAM]"":GRPNAM,1:"")_"""" Q STRING
- S STRING="Rg Rg="""_$S(GRPNAM]"":GRPNAM,1:"")_"""" Q STRING
- GRPNAM(GRP) ; Get Group Name
- N DIC,DR,DA,DIQ S GRPNAM=""
- I GRP="All" S GRPNAM=GRP
- I ($G(GRPNAM)'="All") D
- .S GRPNAM=$P(GRP,"^",2)
- .I GRPNAM="" S GRPNAM="UNKNOWN" Q
- .S GRPNAM="("_+GRP_") "_GRPNAM
- Q $$SYMENC^MXMLUTL(GRPNAM)
- CLIN(CLIN,FILT) ; Return formatted Clinic
- N CLNAM I CLIN["^" S CLIN=$P(CLIN,"^",2)
- S CLNAM=$S($G(CLIN):$P($G(^SC(+CLIN,0)),"^"),1:CLIN),CLNTAG=1
- S STRING="" I $G(FILT) S STRING="Rs "
- S STRING=STRING_"Rn="""_$$SYMENC^MXMLUTL(CLNAM)_"""" Q STRING
- PROV(PROV) ; Return formatted Provider
- N PRVNAM S PRVNAM=""
- I $P(PROV,"^",2) S PRVNAM=$P(PROV,"^")
- I PRVNAM="" S PRVNAM=$S($G(PROV):$P($G(^VA(200,PROV,0)),"^"),1:PROV)
- I PRVNAM["^" S PRVNAM=$P(PRVNAM,"^") D
- .I PRVNAM=" None" S PRVNAM="N/A"
- S STRING="Pr="""_$$SYMENC^MXMLUTL(PRVNAM)_"""" Q STRING
- DATE(DATE,DTFMT,SDACTDT,DTRANGE) ; Return formatted Date
- N BEGDT,ENDDT,RANGE,RANGEX,DTNAMEX
- S STRING="",RANGEX=""
- I $G(DTRANGE) S RANGE=$$XDATE^SDECXUTL($P(DTRANGE,"-"))_"-"_$$XDATE^SDECXUTL($P(DTRANGE,"-",2)) D
- .;S RANGEX=" DateRange="""_DTRANGE_""""
- .S DTNAMEX=" DateName="""_$P(RANGE,"^")_""""
- I '$G(DTRANGE) D BEGEND^SDECXUTL(DATE,.BEGDT,.ENDDT,DTFMT,SDACTDT) D
- .S RANGEX=" DateRange="""_BEGDT_"-"_ENDDT_""""
- .S DTNAMEX=" DateName="""_BEGDT_""""
- I DTFMT="Y"!(DTFMT="W") S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- I DTFMT="Q" D
- .S DTNAMEX=" DateName="""_$P(DATE,"-",2)_"-"_$P(DATE,"-")_""""
- .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- I DTFMT="M" D
- .N X,Y,DTNAMEX,%DT S %DT="I" S DTNAMEX=" DateName="""_$$FMTE^XLFDT(DATE)_""""
- .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- I DTFMT="D" D
- .I '$G(DTRANGE) S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">" Q
- .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_$P(RANGE,"-")_""" EndDate="""_$P(RANGE,"-",2)_""""_DTNAMEX_">"
- Q STRING
- ENC(ENC,TEL,NEW,EST) ; Return formatted number of encounters
- S STRING="Mn=""Encounters"" Vt=""Actual"" Vl="""_ENC_""""
- Q STRING
- TEL(TEL) ; Return formatted telephone encounters
- S STRING="Mn=""Encounters"" Vt=""Telephone Encounters"" Vl="""_TEL_"""" Q STRING
- NEW(NEW) ; Return new patients
- S STRING="Mn=""Encounters"" Vt=""New Patients"" Vl="""_NEW_"""" Q STRING
- EST(EST) ; Return established patients
- S STRING="Mn=""Encounters"" Vt=""Established Patients"" Vl="""_EST_"""" Q STRING
- RCAOVR(OVR) ; Appointment
- S STRING="Mn=""Appointments"" Vt=""Overbooks"" Vl="""_OVR_""""
- Q STRING
- RCADEM(DEM) ; Demand
- S DEM=DEM/60
- S STRING="Mn=""Total Demand"" Vt=""Actual"" Vl="""_$FN(DEM,",",2)_""""
- Q STRING
- RCADEMA(DEM) ; Demand
- S DEM=DEM/60
- S STRING="Mn=""Adjusted Demand"" Vt=""Actual"" Vl="""_$FN(DEM,",",2)_""""
- Q STRING
- RCASUP(SUP) ; Supply
- S STRING="Mn=""Total Supply"" Vt=""Actual"" Vl="""_$FN(SUP,",",2)_""""
- Q STRING
- SETTMPF(SDLCNT,SDFILT,INDENTF,SDMEAS) ; Set/Write filter
- D SETFILT(.SDLCNT,SDFILT,$G(INDENTF))
- Q
- ;
- SETFILT(SDLCNT,SDFILT,INDENT) ; Set ^XTMP or Write
- Q:SDFILT="" S SDLCNT=SDLCNT+1
- I $G(XMLNODE)="" S XMLNODE=$S($G(SDFLTFLG):"FLTXML",1:"SDECXML")
- I $G(INDENT) N PAD S $P(PAD," ",INDENT)=""
- I $G(SDEBUG) U IO W !,$G(PAD)_"<"_SDFILT_">"
- S ^XTMP("SDVSE",XMLNODE,SDLCNT)="<"_SDFILT_">"
- I $E(SDFILT,1,5)="Rg Rg" S GRPFLG=1
- I $E(SDFILT,1,8)="Division" S DIVTAG=1
- I $E(SDFILT,1,5)="Rs Rn" S CLNTAG=1
- Q
- ;
- SETREC(SDLCNT,SDDATA,INDENT) ; Set/Write Record
- ;I SDDATA["Pr=""N/A""" Q
- N TMPREC,NEWDATA,TMPDATA
- I SDDATA["'" S SDDATA=$$PARSE(SDDATA,"'","'")
- S SDLCNT=$G(SDLCNT)+1
- S TMPREC="<Rc "_SDDATA_"/>"
- I $G(SDEBUG) U IO W !,?($G(INDENT)+1),TMPREC
- S ^XTMP("SDVSE",XMLNODE,SDLCNT)=TMPREC
- Q
- ;
- ; Pull out data and aggregate it
- PARSE(STRING,CHAR,SUBS) ; Aggregate pieces of node
- N NEWDATA,TMPDATA S NEWDATA="",TMPDATA=""
- I STRING[CHAR F I=1:1:$L(STRING,"'") D
- .S TMPDATA=$P(STRING,"'",I) S NEWDATA=NEWDATA_TMPDATA_$S(I=$L(STRING,CHAR):"",1:SUBS)
- Q NEWDATA
- ;
- SDETFM(DATE) ; Convert external date to FM
- N X,Y,DATNAM
- S SDINTDT=""
- I ($G(DATE)?7N)!($G(DATE)?7N1"."1.N) Q DATE
- S X=DATE D ^%DT I Y>0 S SDINTDT=+Y
- Q $S($G(SDINTDT):SDINTDT,1:DATE)
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDECXML 13019 printed Jan 18, 2025@03:54:11 Page 2
- SDECXML ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 ;11/03/14 10:59am
- +1 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
- +2 ;
- GETFLT(RESULT,ALL,SDEBUG) ; RPC - Filter Data only
- +1 NEW SDRPTYP,SDDT,I,SDPC,DTAGAB,SDFLTFLG,DTRANGE,SDLCNT,NODATA,SDSTAT
- +2 SET SDEBUG=$GET(SDEBUG)
- SET NODATA=0
- +3 SET SDSTAT=$$ISLOCKED^SDCED()
- +4 ; If the background job is running then return NODATA with error text
- +5 IF +SDSTAT
- DO NODATA^SDECXUTL(.RESULT,$PIECE(SDSTAT,U,2))
- QUIT
- +6 IF '$DATA(^XTMP("SDVSE","FLTXML"))
- Begin DoDot:1
- +7 IF $DATA(^XTMP("SDVSE","DT"))
- IF SDSTAT=0
- DO START("MPS","YQMWD","","",1,"","","FLTXML")
- QUIT
- +8 DO NODATA^SDECXUTL(.RESULT)
- SET NODATA=1
- End DoDot:1
- if NODATA
- QUIT
- +9 SET RESULT=$NAME(^TMP($JOB,"FLTXML"))
- +10 MERGE ^TMP($JOB,"FLTXML")=^XTMP("SDVSE","FLTXML")
- +11 QUIT
- +12 ;
- REPORT(RESULT,SDRPTLST,SDBEGRNG,SDENDRNG,SDEBUG) ; RPC - Report Data
- +1 NEW SDRPTYP,SDDT,I,SDPC,DTAGAB,SDUR,SDACTDT1,SDWEEKS,SDLCNT,DATE,SDINTDT,XMLNODE
- +2 KILL ^TMP($JOB,"SDECXML")
- +3 SET RESULT=$NAME(^TMP($JOB,"SDECXML"))
- +4 SET SDEBUG=$GET(SDEBUG)
- SET XMLNODE="SDECXML"
- +5 SET SDACTDT1=$ORDER(^XTMP("SDVSE","DT",""))
- if 'SDACTDT1
- SET SDACTDT1=$PIECE($$NOW^XLFDT,".")
- +6 IF $GET(SDRPTLST)=""
- SET SDRPTLST="MPS"
- +7 SET SDBEGRNG=$GET(SDBEGRNG)
- SET SDENDRNG=$GET(SDENDRNG)
- +8 IF SDBEGRNG
- IF (SDBEGRNG'?7N.E)
- SET SDBEGRNG=$$SDETFM(SDBEGRNG)
- +9 IF SDENDRNG
- IF (SDENDRNG'?7N.E)
- SET SDENDRNG=$$SDETFM(SDENDRNG)
- +10 IF ",Y,Q,M,W,D,"[(","_SDBEGRNG_",")
- Begin DoDot:1
- +11 SET SDUR=$SELECT(SDBEGRNG="Y":"Year",SDBEGRNG="Q":"Quarter",SDBEGRNG="M":"Month",SDBEGRNG="W":"Week",1:"Date")
- +12 IF SDUR="Year"
- Begin DoDot:2
- +13 SET SDBEGRNG=$$FMADD^XLFDT(SDACTDT1,-365)
- SET SDENDRNG=SDACTDT1
- End DoDot:2
- QUIT
- +14 IF SDUR'="Year"
- Begin DoDot:2
- +15 NEW SDDATE,ACTDT1,ACTDT2
- +16 SET SDBEGRNG=SDENDRNG
- +17 IF SDUR="Week"
- Begin DoDot:3
- +18 DO WEEKS^SDCED1(SDENDRNG,.SDWEEKS)
- +19 SET SDBEGRNG=$$GETWEEK^SDCED1(SDBEGRNG,.SDWEEKS)
- End DoDot:3
- +20 SET SDDATE=SDBEGRNG
- +21 DO BEGEND^SDECXUTL(SDDATE,.ACTDT1,.ACTDT2,$EXTRACT(SDUR),SDDATE)
- +22 IF '($GET(ACTDT1)?7N.E)
- SET SDBEGRNG=$$SDETFM(ACTDT1)
- +23 IF '($GET(ACTDT2)?7N.E)
- SET SDENDRNG=$$SDETFM(ACTDT2)
- End DoDot:2
- QUIT
- End DoDot:1
- +24 IF $GET(SDUR)=""
- SET SDUR=$$FMDIFF^XLFDT(SDENDRNG,SDBEGRNG)
- Begin DoDot:1
- +25 SET SDUR=$SELECT(SDUR>93:"Year",SDUR>31:"Quarter",SDUR>7:"Month",SDUR>1:"Week",1:"Date")
- End DoDot:1
- +26 ; If this is a Year report request and if Yearly report already exists then return without recompiling XML report data
- +27 IF SDUR="Year"
- IF $DATA(^XTMP("SDVSE","YRPTXML-"_SDRPTLST))
- MERGE ^TMP($JOB,"SDECXML")=^XTMP("SDVSE","YRPTXML-"_SDRPTLST)
- QUIT
- +28 SET SDDTINC="D"
- +29 DO START(SDRPTLST,.SDDTINC,SDBEGRNG,SDENDRNG,,SDUR,SDEBUG,XMLNODE)
- +30 MERGE ^TMP($JOB,"SDECXML")=^XTMP("SDVSE",XMLNODE)
- +31 KILL ^XTMP("SDVSE",XMLNODE)
- +32 QUIT
- +33 ;
- START(SDRPTLST,SDDTINC,SDBEGRNG,SDENDRNG,SDFLTFLG,SDUR,SDEBUG,XMLNODE) ; Begin building report data from ^XTMP("SDVSE","DT"
- +1 NEW DT,SDDT,SDBEGDT,SDENDDT,SDFACNUM,SDFACNAM,SDFILT,SDFAC,DTNAMAR,SDDTCNT,SDRPTCNT,DTRANGE,SDNODE,SDRPTAR
- +2 NEW CLNTAG,DIVTAG,GRPFLG,SDACTDT,DTNAM,SDRPT
- +3 IF $GET(XMLNODE)=""
- SET XMLNODE=$SELECT($GET(SDFLTFLG)=1:"FLTXML",1:"SDECXML")
- +4 KILL ^XTMP("SDVSE",XMLNODE)
- +5 FOR SDRPT="M","P","S"
- SET SDRPTAR(SDRPT)=""
- +6 SET (SDACTDT,DT)=$ORDER(^XTMP("SDVSE","DT",""))
- if 'SDACTDT
- QUIT
- +7 SET SDBEGDT=$SELECT($GET(SDBEGRNG):$$SDETFM(SDBEGRNG),1:"")
- +8 SET SDENDDT=$SELECT($GET(SDENDRNG)&$GET(SDBEGDT):$$SDETFM(SDENDRNG),1:"")
- +9 IF '$GET(SDFLTFLG)
- IF $GET(SDBEGDT)&$GET(SDENDDT)
- SET DTRANGE=SDBEGDT_"-"_SDENDDT
- +10 SET SDNODE=$SELECT($GET(DTRANGE):$JOB_",SDCEX",1:"SDCEX")
- +11 IF $GET(DTRANGE)
- Begin DoDot:1
- +12 DO EN^SDCED1(.SDRPTAR,SDBEGRNG,SDENDRNG,SDNODE)
- End DoDot:1
- +13 ;
- +14 SET SDLCNT=0
- SET SDFACNAM=$$SITE^VASITE
- SET SDFACNUM=+SDFACNAM
- SET SDFACNAM=$PIECE(SDFACNAM,"^",2)
- +15 FOR DTNAM="Year","Quarter","Month","Week","Date"
- SET DTNAMAR($EXTRACT(DTNAM))=DTNAM
- +16 SET SDFAC=$$SITE^VASITE
- +17 ; Generic Set/Output
- DO OUTPUT^SDECXUTL("<?xml version=""1.0"" encoding=""UTF-8""?>",0,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- +18 SET SDFILT=$$FAC(SDFAC)
- DO SETFILT(.SDLCNT,SDFILT,2)
- +19 FOR SDRPTCNT=1:1:$LENGTH(SDRPTLST)
- SET SDRPT=$EXTRACT(SDRPTLST,SDRPTCNT)
- Begin DoDot:1
- +20 SET SDFILT=$$RPT(SDRPT)
- DO SETFILT(.SDLCNT,SDFILT,4)
- +21 FOR SDDTCNT=1:1:$LENGTH(SDDTINC)
- SET SDTINC=$EXTRACT(SDDTINC,SDDTCNT)
- Begin DoDot:2
- +22 if '$DATA(DTNAMAR(SDTINC))
- QUIT
- SET SDTINC=$GET(DTNAMAR(SDTINC))
- +23 if SDTINC=""
- QUIT
- +24 DO DATINC(.SDLCNT,SDBEGDT,SDENDDT,SDRPT,SDTINC,$GET(DTRANGE),SDNODE,SDEBUG,XMLNODE)
- End DoDot:2
- +25 DO OUTPUT^SDECXUTL("</ReportType>",4,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- End DoDot:1
- +26 IF '$GET(SDFLTFLG)
- DO SETSDREC^SDECXUTL(.SDLCNT,$EXTRACT(SDRPTLST),,XMLNODE)
- +27 DO OUTPUT^SDECXUTL("</VAFacility>",2,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- +28 IF $GET(SDNODE)[","
- KILL ^XTMP(SDNODE)
- +29 QUIT
- +30 ;
- DATINC(SDLCNT,SDBEGDT,SDENDDT,SDRPTYP,DATINC,DTRANGE,SDNODE,SDEBUG,XMLNODE) ; Get Year, Quarter, Month, Week, and Date data for Division, Group, Clinic, Provider
- +1 NEW SDPRV,SDCLN,SDDGRP,SDIV,SDFAC,SDII,SDDATE,SDRPT,SDTINC,IC,SDALL,SDDIV
- +2 NEW CLNTAG,GRPFLG,DIVTAG,STRING
- +3 IF '$GET(SDBEGDT)
- SET SDBEGDT=$$FMADD^XLFDT($$NOW^XLFDT,-365)
- +4 IF '$GET(SDENDDT)
- SET SDENDDT=$PIECE($$FMADD^XLFDT($$NOW^XLFDT,1),".")
- +5 SET SDDATE=$SELECT($GET(DTRANGE):"",1:$$FMADD^XLFDT(SDBEGDT,,-1))
- +6 IF DATINC="Year"
- IF '$GET(DTRANGE)
- SET SDDATE=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,""))
- +7 SET SDDATE=""
- SET SDCALL=""
- SET SDGALL=""
- +8 IF $GET(SDFLTFLG)
- IF DATINC="Date"
- SET SDDATE=$$FMADD^XLFDT(SDACTDT,,,1)
- +9 IF $GET(SDFLTFLG)
- IF DATINC="Week"
- IF $ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,""),-1)>$$FMADD^XLFDT(SDACTDT,6)
- SET SDDATE=$$FMADD^XLFDT(SDACTDT,6)
- +10 FOR SDII=0:1
- SET SDDATE=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE),-1)
- if SDDATE=""!($GET(DTRANGE)&(SDDATE<SDBEGDT))
- QUIT
- Begin DoDot:1
- +11 IF SDII=0
- DO OUTPUT^SDECXUTL("<DateAggregate DateAgg="""_$SELECT(($GET(SDUR)]""):SDUR,1:DATINC)_""">",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- +12 DO OUTPUT^SDECXUTL($$DATE(SDDATE,$EXTRACT(DATINC),SDACTDT,$GET(DTRANGE)),8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- +13 SET SDFAC=""
- FOR
- SET SDFAC=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC))
- if SDFAC=""!(SDFAC="APP")
- QUIT
- Begin DoDot:2
- +14 if $GET(SDFLTFLG)
- QUIT
- +15 if $GET(XMLNODE)="FLTXML"
- QUIT
- +16 NEW SDALLALL,SDVGRCL,SDGALL,SDCALL
- +17 SET SDVGRCL=""
- SET SDALL=0
- SET SDGALL=0
- SET SDCALL=0
- +18 SET SDDIV=""
- FOR DIVCOUNT=0:1
- SET SDDIV=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV))
- if 'SDDIV
- QUIT
- Begin DoDot:3
- +19 ;Q:(SDDIV="APP")
- +20 DO DIVISION(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,$EXTRACT(DATINC),DIVCOUNT,XMLNODE)
- +21 NEW SDSINGRP
- SET SDSINGRP=0
- +22 SET SDGALL=0
- +23 SET SDDGRP=0
- FOR IG=1:1
- SET SDDGRP=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP))
- if SDDGRP=""
- QUIT
- Begin DoDot:4
- +24 if (SDDGRP="APP")
- QUIT
- +25 DO GROUP(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,$EXTRACT(DATINC),IG)
- +26 if ((SDDGRP=0)&$GET(SDSINGRP))
- QUIT
- +27 SET SDGALL=$GET(SDGALL)+1
- +28 SET SDCALL=0
- +29 SET SDCLN=""
- FOR IC=1:1
- SET SDCLN=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN))
- if SDCLN=""
- QUIT
- Begin DoDot:5
- +30 if (SDCLN="APP")!(SDCLN="STAT")
- QUIT
- +31 DO CLINIC^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,$EXTRACT(DATINC),SDNODE,.CLNTAG,SDCALL,.GRPFLG,SDEBUG,XMLNODE)
- +32 SET SDCALL=$GET(SDCALL)+1
- +33 SET SDPRV=""
- FOR
- SET SDPRV=$ORDER(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV))
- if SDPRV=""
- QUIT
- Begin DoDot:6
- +34 if '(SDPRV["^")
- QUIT
- +35 DO PROVIDER^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV,DATINC,.CLNTAG,.GRPFLG,SDCALL,DTNAM,SDGALL,SDNODE)
- End DoDot:6
- +36 IF $GET(CLNTAG)
- DO OUTPUT^SDECXUTL("</Rs>",13,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- End DoDot:5
- +37 IF $GET(GRPFLG)
- DO OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- End DoDot:4
- +38 IF $GET(DIVTAG)
- DO OUTPUT^SDECXUTL("</Division>",10,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- End DoDot:3
- End DoDot:2
- +39 DO OUTPUT^SDECXUTL("</Date>",8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- End DoDot:1
- +40 if 'SDII
- QUIT
- +41 DO OUTPUT^SDECXUTL("</DateAggregate>",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- +42 QUIT
- +43 ;
- DIVISION(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,DIVCOUNT,XMLNODE) ; Division
- +1 NEW SDFILT,DTNAM
- +2 SET DTNAM=$GET(DTNAMAR(DTINC))
- +3 ; All divisions -
- IF '$GET(DIVCOUNT)
- DO DIVALL^SDECXML3(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- +4 ;
- +5 SET SDFILT=$$DIV(SDIV)
- DO SETTMPF(.SDLCNT,SDFILT,11)
- +6 QUIT
- +7 ;
- GROUP(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,DTINC,IG) ; Group
- +1 NEW SDFILT,SDDATA,DTNAM,SDFILT,SDGRPRV
- +2 if $GET(SDIV)=""
- QUIT
- +3 SET DTNAM=$GET(DTNAMAR(DTINC))
- +4 IF '$GET(SDGALL)
- DO GRPALL^SDECXML3(SDRPTYP,SDAT,SDFAC,SDIV,"",SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
- +5 ;
- +6 IF SDGRP
- Begin DoDot:1
- +7 IF $GET(GRPFLG)
- DO OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$GET(XMLNODE))
- +8 SET SDFILT=$$GRP(SDGRP)
- DO SETTMPF(.SDLCNT,SDFILT,15)
- SET GRPFLG=1
- End DoDot:1
- +9 QUIT
- +10 ;
- RPT(RPT) ; Report Type
- +1 SET RPT=$SELECT(RPT="S":"Specialty Care",RPT="M":"Mental Health",RPT="P":"Primary Care",1:"")
- +2 SET STRING="ReportType ReportType="""_RPT_""""
- +3 QUIT STRING
- FAC(SDFAC,XTYP) ; Return formatted Facility
- +1 NEW SDFACDAT
- SET SDFACDAT=$$SITE^VASITE()
- +2 SET STRING="VAFacility Name="""_$$SYMENC^MXMLUTL($PIECE(SDFACDAT,"^",2))_""" ID="""_+SDFACDAT_""""
- QUIT STRING
- DIV(DIV,XTYP) ; Return formatted Division
- +1 SET DIVTAG=1
- +2 SET STRING="Division Name="""_$$DIVNAME^SDECXUTL(DIV)_""""
- QUIT STRING
- GRP(GRP,XTYP) ; Return Clinic Group
- +1 NEW GRPNAM
- +2 SET GRPNAM=$$GRPNAM(GRP)
- +3 IF $GET(XTYP)="M"
- SET STRING="Rg="""_$SELECT(GRPNAM]"":GRPNAM,1:"")_""""
- QUIT STRING
- +4 SET STRING="Rg Rg="""_$SELECT(GRPNAM]"":GRPNAM,1:"")_""""
- QUIT STRING
- GRPNAM(GRP) ; Get Group Name
- +1 NEW DIC,DR,DA,DIQ
- SET GRPNAM=""
- +2 IF GRP="All"
- SET GRPNAM=GRP
- +3 IF ($GET(GRPNAM)'="All")
- Begin DoDot:1
- +4 SET GRPNAM=$PIECE(GRP,"^",2)
- +5 IF GRPNAM=""
- SET GRPNAM="UNKNOWN"
- QUIT
- +6 SET GRPNAM="("_+GRP_") "_GRPNAM
- End DoDot:1
- +7 QUIT $$SYMENC^MXMLUTL(GRPNAM)
- CLIN(CLIN,FILT) ; Return formatted Clinic
- +1 NEW CLNAM
- IF CLIN["^"
- SET CLIN=$PIECE(CLIN,"^",2)
- +2 SET CLNAM=$SELECT($GET(CLIN):$PIECE($GET(^SC(+CLIN,0)),"^"),1:CLIN)
- SET CLNTAG=1
- +3 SET STRING=""
- IF $GET(FILT)
- SET STRING="Rs "
- +4 SET STRING=STRING_"Rn="""_$$SYMENC^MXMLUTL(CLNAM)_""""
- QUIT STRING
- PROV(PROV) ; Return formatted Provider
- +1 NEW PRVNAM
- SET PRVNAM=""
- +2 IF $PIECE(PROV,"^",2)
- SET PRVNAM=$PIECE(PROV,"^")
- +3 IF PRVNAM=""
- SET PRVNAM=$SELECT($GET(PROV):$PIECE($GET(^VA(200,PROV,0)),"^"),1:PROV)
- +4 IF PRVNAM["^"
- SET PRVNAM=$PIECE(PRVNAM,"^")
- Begin DoDot:1
- +5 IF PRVNAM=" None"
- SET PRVNAM="N/A"
- End DoDot:1
- +6 SET STRING="Pr="""_$$SYMENC^MXMLUTL(PRVNAM)_""""
- QUIT STRING
- DATE(DATE,DTFMT,SDACTDT,DTRANGE) ; Return formatted Date
- +1 NEW BEGDT,ENDDT,RANGE,RANGEX,DTNAMEX
- +2 SET STRING=""
- SET RANGEX=""
- +3 IF $GET(DTRANGE)
- SET RANGE=$$XDATE^SDECXUTL($PIECE(DTRANGE,"-"))_"-"_$$XDATE^SDECXUTL($PIECE(DTRANGE,"-",2))
- Begin DoDot:1
- +4 ;S RANGEX=" DateRange="""_DTRANGE_""""
- +5 SET DTNAMEX=" DateName="""_$PIECE(RANGE,"^")_""""
- End DoDot:1
- +6 IF '$GET(DTRANGE)
- DO BEGEND^SDECXUTL(DATE,.BEGDT,.ENDDT,DTFMT,SDACTDT)
- Begin DoDot:1
- +7 SET RANGEX=" DateRange="""_BEGDT_"-"_ENDDT_""""
- +8 SET DTNAMEX=" DateName="""_BEGDT_""""
- End DoDot:1
- +9 IF DTFMT="Y"!(DTFMT="W")
- SET STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- +10 IF DTFMT="Q"
- Begin DoDot:1
- +11 SET DTNAMEX=" DateName="""_$PIECE(DATE,"-",2)_"-"_$PIECE(DATE,"-")_""""
- +12 SET STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- End DoDot:1
- +13 IF DTFMT="M"
- Begin DoDot:1
- +14 NEW X,Y,DTNAMEX,%DT
- SET %DT="I"
- SET DTNAMEX=" DateName="""_$$FMTE^XLFDT(DATE)_""""
- +15 SET STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- End DoDot:1
- +16 IF DTFMT="D"
- Begin DoDot:1
- +17 IF '$GET(DTRANGE)
- SET STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
- QUIT
- +18 SET STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_$PIECE(RANGE,"-")_""" EndDate="""_$PIECE(RANGE,"-",2)_""""_DTNAMEX_">"
- End DoDot:1
- +19 QUIT STRING
- ENC(ENC,TEL,NEW,EST) ; Return formatted number of encounters
- +1 SET STRING="Mn=""Encounters"" Vt=""Actual"" Vl="""_ENC_""""
- +2 QUIT STRING
- TEL(TEL) ; Return formatted telephone encounters
- +1 SET STRING="Mn=""Encounters"" Vt=""Telephone Encounters"" Vl="""_TEL_""""
- QUIT STRING
- NEW(NEW) ; Return new patients
- +1 SET STRING="Mn=""Encounters"" Vt=""New Patients"" Vl="""_NEW_""""
- QUIT STRING
- EST(EST) ; Return established patients
- +1 SET STRING="Mn=""Encounters"" Vt=""Established Patients"" Vl="""_EST_""""
- QUIT STRING
- RCAOVR(OVR) ; Appointment
- +1 SET STRING="Mn=""Appointments"" Vt=""Overbooks"" Vl="""_OVR_""""
- +2 QUIT STRING
- RCADEM(DEM) ; Demand
- +1 SET DEM=DEM/60
- +2 SET STRING="Mn=""Total Demand"" Vt=""Actual"" Vl="""_$FNUMBER(DEM,",",2)_""""
- +3 QUIT STRING
- RCADEMA(DEM) ; Demand
- +1 SET DEM=DEM/60
- +2 SET STRING="Mn=""Adjusted Demand"" Vt=""Actual"" Vl="""_$FNUMBER(DEM,",",2)_""""
- +3 QUIT STRING
- RCASUP(SUP) ; Supply
- +1 SET STRING="Mn=""Total Supply"" Vt=""Actual"" Vl="""_$FNUMBER(SUP,",",2)_""""
- +2 QUIT STRING
- SETTMPF(SDLCNT,SDFILT,INDENTF,SDMEAS) ; Set/Write filter
- +1 DO SETFILT(.SDLCNT,SDFILT,$GET(INDENTF))
- +2 QUIT
- +3 ;
- SETFILT(SDLCNT,SDFILT,INDENT) ; Set ^XTMP or Write
- +1 if SDFILT=""
- QUIT
- SET SDLCNT=SDLCNT+1
- +2 IF $GET(XMLNODE)=""
- SET XMLNODE=$SELECT($GET(SDFLTFLG):"FLTXML",1:"SDECXML")
- +3 IF $GET(INDENT)
- NEW PAD
- SET $PIECE(PAD," ",INDENT)=""
- +4 IF $GET(SDEBUG)
- USE IO
- WRITE !,$GET(PAD)_"<"_SDFILT_">"
- +5 SET ^XTMP("SDVSE",XMLNODE,SDLCNT)="<"_SDFILT_">"
- +6 IF $EXTRACT(SDFILT,1,5)="Rg Rg"
- SET GRPFLG=1
- +7 IF $EXTRACT(SDFILT,1,8)="Division"
- SET DIVTAG=1
- +8 IF $EXTRACT(SDFILT,1,5)="Rs Rn"
- SET CLNTAG=1
- +9 QUIT
- +10 ;
- SETREC(SDLCNT,SDDATA,INDENT) ; Set/Write Record
- +1 ;I SDDATA["Pr=""N/A""" Q
- +2 NEW TMPREC,NEWDATA,TMPDATA
- +3 IF SDDATA["'"
- SET SDDATA=$$PARSE(SDDATA,"'","'")
- +4 SET SDLCNT=$GET(SDLCNT)+1
- +5 SET TMPREC="<Rc "_SDDATA_"/>"
- +6 IF $GET(SDEBUG)
- USE IO
- WRITE !,?($GET(INDENT)+1),TMPREC
- +7 SET ^XTMP("SDVSE",XMLNODE,SDLCNT)=TMPREC
- +8 QUIT
- +9 ;
- +10 ; Pull out data and aggregate it
- PARSE(STRING,CHAR,SUBS) ; Aggregate pieces of node
- +1 NEW NEWDATA,TMPDATA
- SET NEWDATA=""
- SET TMPDATA=""
- +2 IF STRING[CHAR
- FOR I=1:1:$LENGTH(STRING,"'")
- Begin DoDot:1
- +3 SET TMPDATA=$PIECE(STRING,"'",I)
- SET NEWDATA=NEWDATA_TMPDATA_$SELECT(I=$LENGTH(STRING,CHAR):"",1:SUBS)
- End DoDot:1
- +4 QUIT NEWDATA
- +5 ;
- SDETFM(DATE) ; Convert external date to FM
- +1 NEW X,Y,DATNAM
- +2 SET SDINTDT=""
- +3 IF ($GET(DATE)?7N)!($GET(DATE)?7N1"."1.N)
- QUIT DATE
- +4 SET X=DATE
- DO ^%DT
- IF Y>0
- SET SDINTDT=+Y
- +5 QUIT $SELECT($GET(SDINTDT):SDINTDT,1:DATE)