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

SDCED.m

Go to the documentation of this file.
  1. SDCED ;ALB/JCH - VSE GUI RESOURCE MANAGEMENT REPORT DATA COMPILER ;19 Oct 14 04:11PM
  1. ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
  1. ;;
  1. ; Reference to NOTES^TIUSRVLV is supported by ICR #2812
  1. ; Reference to V PROVIDER file is supported by ICR #2316
  1. Q
  1. QUEUE ; Task to background
  1. N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
  1. S ZTIO=""
  1. ;
  1. I $$ISLOCKED() Q
  1. ;
  1. S ZTRTN="EN^SDCED"
  1. S ZTSAVE("SDECMAIL")=""
  1. S ZTDTH=$$NOW^XLFDT
  1. S ZTDESC="SD Resource Management Report Data Compiler"
  1. D ^%ZTLOAD
  1. Q
  1. ;
  1. EN ; This utility will create a temporary storage global in ^XTMP("SDVSE") that contains
  1. ; data used by the VSE GUI Resource Management Reports.
  1. ;
  1. N SDFAC,DATE,SDWEEKS,SDSTPAR,SDSTART,SDECTOT,OLOC,SDRPT,SDRPTAR,SDBEGRNG,SDENDRNG,DTRANGE,PROV
  1. N SDSTRT,SDSTP,SDCMP,DAYS,STCNT,STGL
  1. ;
  1. S STGL="^XTMP(""SDVSE"",""RPTSTATS"")" K @STGL
  1. ; If last process completed successfully, only check for data for the last 90 days
  1. ; from the last completed process.
  1. S DAYS=$S($P($G(^XTMP("SDVSE",0)),U,5)'="":90,1:365)
  1. S SDATE=$$NOW^XLFDT
  1. S SDSTART=$$FMADD^XLFDT(SDATE,-DAYS),SDEND=$$NOW^XLFDT
  1. S SDFAC=$P($$SITE^VASITE(),"^",2)
  1. ;
  1. I '$$LOCK() D Q
  1. .I '$G(ZTSK) W !!?5,"SD Resource Management Report Data compile cannot be started at this time.",!! D PAUSE
  1. ;
  1. D BLDSTAT("")
  1. D BLDSTAT("SDEC REPORT DATA option runtime statistics")
  1. D BLDSTAT("------------------------------------------"),BLDSTAT("")
  1. D BLDSTAT("Collecting data from "_$$FMTE^XLFDT(SDSTART)_" to "_$$FMTE^XLFDT(SDEND)),BLDSTAT("")
  1. D GETCLNS^SDECSTP(.SDSTPAR)
  1. ; Get Clinic Appointment data
  1. S SDSTRT=$$NOW^XLFDT D RPT^SDECRPT(DAYS,.SDSTPAR) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("Collect Clinic Appointment Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. ; Get Clinic Supply data
  1. N SDSTRT,SDSTP,SDCMP S SDSTRT=$$NOW^XLFDT D SUPPLY S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Collect Clinic Supply Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. ; Get Provider Outpatient Appointment data
  1. N SDSTRT,SDSTP,SDCMP S SDSTRT=$$NOW^XLFDT D PROVIDER S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Collect Provider Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. ; Merge all compiled data
  1. D MERGE(SDATE)
  1. F SDRPT="M","P","S" S SDRPTAR(SDRPT)=""
  1. N SDSTRT,SDSTP,SDCMP S SDSTRT=$$NOW^XLFDT D EN^SDCED1(.SDRPTAR) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Cross Reference and Aggregate All Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. ; Build the Report Filter data
  1. N SDSTRT,SDSTP,SDCMP,XMLNODE
  1. S SDSTRT=$$NOW^XLFDT,XMLNODE="FLTXML" D START^SDECXML("MPS","YQMWD",,,1,"","",XMLNODE) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Build Filter Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. ; Build the Full Year Report data
  1. N SDLAST,SDSTRT,SDBEGDT,SDSTP,SDCMP,XMLNODE
  1. S SDSTRT=$$NOW^XLFDT,SDLAST=$O(^XTMP("SDVSE","DT",""),-1),SDBEGDT=$$FMADD^XLFDT(SDLAST,-365),XMLNODE="YRPTXML-S"
  1. D START^SDECXML("S","D",SDBEGDT,SDSTRT,,"Year","",XMLNODE) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Build Specialty Care Year XML Report Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. N SDLAST,SDSTRT,SDBEGDT,SDSTP,SDCMP,XMLNODE
  1. S SDSTRT=$$NOW^XLFDT,SDLAST=$O(^XTMP("SDVSE","DT",""),-1),SDBEGDT=$$FMADD^XLFDT(SDLAST,-365),XMLNODE="YRPTXML-P"
  1. D START^SDECXML("P","D",SDBEGDT,SDSTRT,,"Year","",XMLNODE) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Build Primary Care Year XML Report Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. N SDLAST,SDSTRT,SDBEGDT,SDSTP,SDCMP,XMLNODE
  1. S SDSTRT=$$NOW^XLFDT,SDLAST=$O(^XTMP("SDVSE","DT",""),-1),SDBEGDT=$$FMADD^XLFDT(SDLAST,-365),XMLNODE="YRPTXML-M"
  1. D START^SDECXML("M","D",SDBEGDT,SDSTRT,,"Year","",XMLNODE) S SDSTP=$$NOW^XLFDT,SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3) D
  1. . D BLDSTAT("")
  1. . D BLDSTAT("Build Mental Health Year XML Report Data:")
  1. . D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. . D BLDSTAT(" Total Run Time: "_$S(SDCMP]"":SDCMP,1:"0:00:01")_" (DD HH:MM:SS)")
  1. D CLEAN,RPTSTAT
  1. Q
  1. ;
  1. PROVIDER ; Get encounters by provider
  1. N ENCDCNT,SDDT,SDPR,SDCL,SDCEX,TMPDAY,NXTDAY,SVCAT,SDEC,SDIV
  1. N CLSTOP,SDEST,DFN,ENC,BDATE,CDATE,LOC,CATEGORY,SDNEW,SDIV
  1. D BLDPRDT("PR",$P(SDSTART,"."),.SDSTPAR,SDEND)
  1. S SDIV="" F S SDIV=$O(^TMP("SDECX",$J,"CL",SDIV)) Q:'SDIV D
  1. .S SDEC="" F S SDEC=$O(^TMP("SDECX",$J,"CL",SDIV,SDEC)) Q:SDEC="" D
  1. ..S SDCL=0 F S SDCL=$O(^TMP("SDECX",$J,"CL",SDIV,SDEC,SDCL)) Q:'SDCL D CNTPROV(SDIV,SDEC,SDCL)
  1. Q
  1. ;
  1. CNTPROV(SDIV,SDEC,SDCL) ; aggregate daily encounters by provider
  1. N SDEST,SDNEW,TELCATD,DIVEX,CLINEX,PROVEX S SDEST=0,SDNEW=0
  1. S SDPR=0 F S SDPR=$O(^TMP("SDECX",$J,"CL",SDIV,SDEC,SDCL,"PR",SDPR)) Q:'SDPR D
  1. .S ENCDCNT=0,TELCATD=0
  1. .S SDDT=0 F S SDDT=$O(^TMP("SDECX",$J,"CL",SDIV,SDEC,SDCL,"PR",SDPR,SDDT)) Q:'SDDT S TMPDAY=$P(SDDT,".") D
  1. ..N ENC,SDDFN
  1. ..S ENC=0 F S ENC=$O(^TMP("SDECX",$J,"CL",SDIV,SDEC,SDCL,"PR",SDPR,SDDT,ENC)) Q:'ENC D
  1. ...N SDENCND,SVCAT,SDSGNM,SDTMPND,AGGDATA
  1. ...S SDENCND=$G(^TMP("SDECX",$J,"CL",SDIV,SDEC,SDCL,"PR",SDPR,SDDT,ENC))
  1. ...S SDSGNM="" D GETSCAT(SDCL,.SDSGNM,.SDSTPAR) ; Get Stop Code Group Name
  1. ...Q:SDSGNM="UNKNOWN"
  1. ...S SVCAT=$P(SDENCND,"^"),TELCATD=$S(SVCAT="T":1,1:0)
  1. ...S SDEST=+$P(SDENCND,"^",2),SDNEW=$S($G(SDEST):0,1:1)
  1. ...S SDTMPND=$G(^TMP("SDCEX",$J,$E(SDSGNM),+SDCL,SDDT,+SDPR,"ENC"))
  1. ...S AGGDATA=($P(SDTMPND,"^")+1)_"^"_(SDNEW+$P(SDTMPND,"^",2))_"^"_(SDEST+$P(SDTMPND,"^",3))_"^"_(TELCATD+$P(SDTMPND,"^",4))
  1. ...S ^TMP("SDCEX",$J,$E(SDSGNM),+SDCL,SDDT,+SDPR,"ENC")=AGGDATA
  1. Q
  1. ;
  1. CLEAN ; Clean up
  1. K ^TMP("SDECX",$J),^TMP("SDCEX",$J)
  1. S $P(^XTMP("SDVSE",0),U,5)=$$NOW^XLFDT()
  1. N SDSTRT,SDSTP,SDCMP
  1. S SDSTRT=$P(^XTMP("SDVSE",0),U,2),SDSTP=$P(^XTMP("SDVSE",0),U,5)
  1. S SDCMP=$$FMDIFF^XLFDT(SDSTP,SDSTRT,3)
  1. D BLDSTAT("")
  1. D BLDSTAT("SDEC REPORT DATA Option:")
  1. D BLDSTAT(" Started at "_$$FMTE^XLFDT(SDSTRT)_" Finished at "_$$FMTE^XLFDT(SDSTP))
  1. D BLDSTAT(" Total Run Time: "_SDCMP_" (DD HH:MM:SS)")
  1. D BLDSTAT(""),BLDSTAT("")
  1. D BLDSTAT("*****************************************************************")
  1. D BLDSTAT("This message can be disabled by setting the SDECMAIL value in the")
  1. D BLDSTAT("Entry Action field of the SDEC REPORT DATA Option to zero.")
  1. D BLDSTAT("ENTRY ACTION: S SDECMAIL=0"),BLDSTAT("")
  1. D BLDSTAT("To re-enable the statistics, set the value back to one.")
  1. D BLDSTAT("ENTRY ACTION: S SDECMAIL=1")
  1. D BLDSTAT("*****************************************************************")
  1. Q
  1. ;
  1. BLDPRDT(ENCTYP,SDSTARTD,SDSTPAR,SDEND) ; Collect Provider Encounter data from ENCOUNTER (#409.68) file "D" xref
  1. N II,IC,SDENC,SDENCDT,SDENCPR,SDENCL,DGENDTST,SDDIVI,SDDIVIE,SDGRPA,SDEST,SDNEW,SDENCND,VISIT,SDCHILD,SDCKODT
  1. S DGENDTST=$$FMADD^XLFDT(SDSTARTD,,,-1)
  1. S SDEND=$P(SDEND,".")_".24"
  1. F S DGENDTST=$O(^SCE("D",DGENDTST)) Q:'DGENDTST!(DGENDTST>SDEND) D
  1. .S SDCKODT=0 F II=1:1 S SDCKODT=$O(^SCE("D",DGENDTST,SDCKODT)) Q:'SDCKODT D
  1. ..S SDENC=0 F IC=1:1 S SDENC=$O(^SCE("D",DGENDTST,SDCKODT,SDENC)) Q:'SDENC D
  1. ...N SDDFN,CDATE,SDEST,SDNEW,SDAPDATA,ENCARAY,SDENC0,SDVISIT
  1. ...N SDVPRV,SDENCAR,SDVAR
  1. ...; Delete invalid cross references
  1. ...I '$D(^SCE(SDENC,0)) K ^SCE("D",DGENDTST,SDCKODT,SDENC) Q
  1. ...S SDENC0=^SCE(SDENC,0)
  1. ...S SDVISIT=$P(SDENC0,U,5) Q:$G(SDVISIT)=""
  1. ...S SDENCPR=$$VPRV(SDVISIT) Q:$G(SDENCPR)=""
  1. ...S SDENCL=$P(SDENC0,U,4) Q:'$G(SDENCL)
  1. ...S SDENCDT=$P(SDENC0,U) Q:'$G(SDENCDT)
  1. ...S SDDIVI=$P(SDENC0,U,11) Q:$G(SDDIVI)=""
  1. ...S SDDFN=$P($G(^SCE(+SDENC,0)),"^",2) Q:'$G(SDDFN)
  1. ...S CDATE=DGENDTST
  1. ...N SDTMPLOC,SDTMPSTP S SDTMPSTP=$P($G(^SCE(+SDENC,0)),"^",3) Q:'SDTMPSTP
  1. ...S SDTMPLOC=$$CHKEST(SDDFN,CDATE,SDENC,.SDTMPSTP) S SDEST=$S(+$G(SDTMPLOC):1,1:""),SDNEW=$S($G(SDEST):0,1:1)
  1. ...S SVCAT="" S SVCAT=$S($$TELE(SDVISIT):"T",1:$P($G(^AUPNVSIT(+SDVISIT,0)),"^",7))
  1. ...N SDSGNM S SDSGNM="" D GETSCAT(SDENCL,.SDSGNM,.SDSTPAR) ; Get Stop Code Group Name
  1. ...S ^TMP("SDECX",$J,"CL",+$G(SDDIVI),SDSGNM,SDENCL,"PR",SDENCPR,SDENCDT,SDENC)=SVCAT_"^"_$G(SDEST)
  1. Q
  1. ;
  1. MERGE(SDATE) ; copy data to ^TMP
  1. M ^XTMP("SDVSE","DT",$P(SDATE,"."))=^TMP("SDCEX",$J)
  1. K ^TMP("SDCEX",$J)
  1. Q
  1. ;
  1. GETSCAT(SDLOC,SDSGNM,SDSTPAR) ; Get Stop Code Group Name
  1. N CSTOP S CSTOP="",SDSGNM="UNKNOWN"
  1. D CLSTOP(SDLOC,.CSTOP)
  1. I $G(CSTOP) D STOPCAT(CSTOP,.SDSGNM,.SDSTPAR)
  1. Q
  1. ;
  1. STOPCAT(CLSTOP,CAT,SDSTPAR) ; Get stop code category (Mental Health, Specialty, Primary)
  1. N CLINEX,STPCNT,OK,TMPCAT,FOUND S FOUND=0
  1. Q:'$G(CLSTOP) K CAT S TMPCAT="UNKNOWN"
  1. S STPCNT="" F S STPCNT=$O(SDSTPAR(STPCNT)) Q:(STPCNT="")!$G(FOUND) D
  1. .S CLINEX="" F S CLINEX=$O(SDSTPAR(STPCNT,CLINEX)) Q:CLINEX=""!$G(FOUND) D
  1. ..I +$P($G(SDSTPAR(STPCNT,CLINEX)),"^",2)=+CLSTOP S FOUND=CLSTOP
  1. ..S TMPCAT=STPCNT
  1. S CAT=$S(TMPCAT="S":"SPECIALTY CARE",TMPCAT="M":"MENTAL HEALTH",TMPCAT="P":"PRIMARY CARE",1:"UNKNOWN")
  1. Q
  1. ;
  1. CLSTOP(SDLOC,CSTOP) ; Get Clinic Stop
  1. N X,Y,DIQ,DIC,DA,DR,SDCS K CSTOP S CSTOP=""
  1. S DIC="44",DA=SDLOC,DR="8"
  1. D GETS^DIQ(DIC,DA,DR,"I","SDCS")
  1. S CSTOP=$G(SDCS(DIC,DA_",",8,"I"))
  1. Q:'CSTOP K SDCS
  1. N X,Y,DIQ,DIC,DA,DR
  1. S DIC=40.7,DA=CSTOP,DR="1"
  1. D GETS^DIQ(DIC,DA,DR,"I","SDCS")
  1. S CSTOP=$G(SDCS(DIC,DA_",",1,"I"))
  1. Q
  1. ;
  1. CHKEST(DFN,BDATE,ENC,CLSTOP) ; Was Patient DFN's encounter on date DATE considered Established or New?
  1. N SDLOC,OENCND,SDCHIT,PRVDATE,PRVENC,OCLSTOP S PRVDATE=BDATE,PRVENC=ENC
  1. Q:'$G(DFN) "" Q:'$G(BDATE) "" Q:'$G(ENC) "" Q:'$D(^SCE(ENC,0)) ""
  1. S SDLOC=$P($G(^SCE(ENC,0)),"^",4),CLSTOP=""
  1. D CLSTOP(SDLOC,.CLSTOP) I 'CLSTOP S CLSTOP=$P($G(^SCE(ENC,0)),"^",3) Q:'CLSTOP ""
  1. S SDCHIT=0
  1. F Q:$G(SDCHIT) S PRVDATE=$O(^SCE("ADFN",DFN,PRVDATE),-1) Q:'PRVDATE!($$FMDIFF^XLFDT(BDATE,PRVDATE)>730) S PRVENC=0 F S PRVENC=$O(^SCE("ADFN",DFN,PRVDATE,PRVENC)) Q:'PRVENC!$G(SDCHIT) D
  1. .S OENCND=$G(^SCE(PRVENC,0)) S OCLSTOP="",OLOC=$P(OENCND,"^",4)
  1. .D CLSTOP(OLOC,.OCLSTOP) S:'$G(OCLSTOP) OCLSTOP=$P(OENCND,"^",3)
  1. .I OCLSTOP=CLSTOP S SDCHIT=$P(^SCE(ENC,0),"^",4)
  1. Q $S($G(SDCHIT):$G(SDCHIT),1:0)
  1. ;
  1. TELE(VISIT) ; If the Visit has at least one telephone note, return true
  1. N TMPNM,SDPHN,GLB S TMPNM=""
  1. D NOTES^TIUSRVLV(.TMPNM,VISIT)
  1. Q:TMPNM="" "" S SDPHN=0
  1. S GLB=TMPNM F Q:$G(SDPHN) S GLB=$Q(@GLB) Q:GLB'["TIU"!(GLB'[$J) I @GLB["TELEPHON" S SDPHN=1
  1. Q $S($G(SDPHN):1,1:0)
  1. ;
  1. VPRV(VISIT) ; Find encounter provider
  1. Q:'$G(VISIT)
  1. N VPRV,ENCARAY,VARAY,DIC,DA,DR,DIQ
  1. S VPRV=$O(^AUPNVPRV("AD",+VISIT,0))
  1. Q:'VPRV ""
  1. Q +$P(^AUPNVPRV(VPRV,0),U)
  1. ;
  1. SUPPLY ; Supply by clinic
  1. N RDT S RDT=DT
  1. D SUPPLY^SDECXUTL(.SDSTPAR)
  1. Q
  1. ;
  1. NONCNT(SDCL) ; Non-Count Clinic?
  1. Q $S($P($G(^SC(+SDCL,0)),"^",17)="Y":1,1:0)
  1. ;
  1. ISLOCKED() ; -- Returns 1 if the locked, otherwise 0 if unlocked
  1. ; Format of zero node:
  1. ; ^XTMP("SDVSE",0)="Save Through Date/Time^Last Start Date/Time^Description^Task #^Complete Date/Time
  1. ; Check if top level node does not exist then let it run
  1. I '$D(^XTMP("SDVSE",0)) Q 0
  1. ; Check the task status. If task defined and is still running then it's locked
  1. I +$P($G(^XTMP("SDVSE",0)),U,4),$$TSKSTAT($P(^XTMP("SDVSE",0),U,4)) Q "1^Resource Management Report data is compiling. Please try again later."
  1. ; Not Locked
  1. Q 0
  1. ;
  1. LOCK() ; -- lock "SDCEX,0" node
  1. I +$$ISLOCKED() Q 0
  1. S ^XTMP("SDVSE",0)=$$FMADD^XLFDT($$NOW^XLFDT,7,0,0,)_U_$$NOW^XLFDT_U_"SD Resource Management Report Data compile started by "_$P(^VA(200,DUZ,0),U)_U_$G(ZTSK)_U_""
  1. Q 1
  1. ;
  1. TSKSTAT(ZTSK) ; Check the status of a task
  1. ; Returns 0 if task is undefined or 1 if task is still running
  1. D STAT^%ZTLOAD
  1. I 'ZTSK(0) Q 0
  1. ; Task status is still Active if ZTSK(1)=1 or 2
  1. I ZTSK(1)=1!(ZTSK(1)=2) Q 1
  1. ; Any other task status means the task is inactive
  1. Q 0
  1. ;
  1. BLDSTAT(TEXT) ; Build the report data collection stats email text
  1. I $G(STCNT)="" S STCNT=0
  1. I $G(STGL)="" S STGL="^XTMP(""SDVSE"",""RPTSTATS"")"
  1. S STCNT=STCNT+1
  1. S @STGL@(0)="",@STGL@(STCNT)=TEXT
  1. Q
  1. ;
  1. RPTSTAT ; Report the status of the job
  1. N XMSUB,XMTEXT,XMDUZ,XMY,XMMG,XMSTRIP,XMROU,DIFROM,XMYBLOB,XMZ,XMMG,TMPDUZ
  1. S $P(^XTMP("SDECMAIL",0),U)=$$FMADD^XLFDT($$NOW^XLFDT,7,0,0,)
  1. Q:$G(SDECMAIL)'=1
  1. S TMPDUZ=$P($G(^XTMP("SDECMAIL",0)),U,2)
  1. Q:'TMPDUZ
  1. S XMY(TMPDUZ)="",XMSUB="SDEC REPORT DATA Stats for "_$$FMTE^XLFDT($$NOW^XLFDT)
  1. S XMTEXT=$P(STGL,")")_","
  1. D ^XMD
  1. ; Reset Purge date for MailMan Status Report user id.
  1. S $P(^XTMP("SDECMAIL",0),U)=$$FMADD^XLFDT($$NOW^XLFDT,7,0,0,)
  1. Q
  1. ;
  1. EXITOPT ; SD VSE REPORT DATA option exit action
  1. I '$D(IO("Q")) D Q
  1. .I '$G(ZTSK),+$P($G(^XTMP("SDVSE",0)),U,4),$$TSKSTAT($P(^XTMP("SDVSE",0),U,4)) W !!?5,"SD Resource Management Report Data compile has been queued.",!! D PAUSE Q
  1. .I '$G(ZTSK),+$P($G(^XTMP("SDVSE",0)),U,2),$P($G(^XTMP("SDVSE",0)),U,5)="" W !!?5,"SD Resource Management Report Data compile is running",!! D PAUSE
  1. .I '$G(ZTSK),+$P($G(^XTMP("SDVSE",0)),U,2),+$P($G(^XTMP("SDVSE",0)),U,5) W !!?5,"SD Resource Management Report has completed",!! D PAUSE
  1. Q
  1. ;
  1. SETDXREF(DA) ; This function is the set condition for the "D" index on the Outpatient Encounter file #409.68
  1. ; This cross reference is only used by the VistA Scheduling GUI Resource Management Reports.
  1. ; The cross reference is used to collect the total Outpatient Encounters for a Provider over a year time period.
  1. ; Verify that all required fields exist before setting cross reference
  1. ; Input: DA = IEN of file 409.68
  1. N SDOK,SDEDT,SDLOC,SDVST S SDOK=0
  1. ; Don't set index if Date of encounter greater than one year and a day in the past.
  1. S SDEDT=$P(^SCE(DA,0),U) I $$FMDIFF^XLFDT(DT,SDEDT,1)>366 Q SDOK
  1. ; Don't set index if this is a Child Encounter
  1. Q:+$P(^SCE(DA,0),U,6) SDOK
  1. ; Don't set if Visit is not defined
  1. S SDVST=$P(^SCE(DA,0),U,5) Q:SDVST="" SDOK
  1. ; Don't set index if Encounter Provider is not defined in the V PROVIDER file
  1. Q:'$O(^AUPNVPRV("AD",+SDVST,0)) SDOK
  1. ; Don't set index if Location not defined
  1. S SDLOC=$P(^SCE(DA,0),U,4) Q:'$D(^SC(+SDLOC)) SDOK
  1. ; Don't set index if Location is a non-count clinic
  1. Q:$P($G(^SC(+SDLOC,0)),"^",17)="Y" SDOK
  1. Q 1
  1. ;
  1. KILDXREF(DA) ; This function is the kill condition for the "D" index ont he Outpatient Encounter file #409.68
  1. N SDOK,SDEDT,SDVST S SDOK=1
  1. ; Kill index if date of encounter is greater than one year and a day in the past
  1. S SDEDT=$P(^SCE(DA,0),U) I $$FMDIFF^XLFDT(DT,SDEDT,1)>366 Q SDOK
  1. ; Kill index if this is a Child Encounter
  1. Q:+$P(^SCE(DA,0),U,6) SDOK
  1. ; Kill index if Visit is not defined
  1. S SDVST=$P(^SCE(DA,0),U,5) Q:SDVST="" SDOK
  1. ; Kill index if Encounter Provider is not defined
  1. Q:'$O(^AUPNVPRV("AD",+SDVST,0)) SDOK
  1. ; Kill index if Location not defined
  1. S SDLOC=$P(^SCE(DA,0),U,4) Q:'$D(^SC(+SDLOC)) SDOK
  1. ; Kill index if Location is a non-count clinic
  1. Q:$P($G(^SC(+SDLOC,0)),"^",17)="Y" SDOK
  1. Q 0
  1. ;
  1. PAUSE ;
  1. Q:$E(IOST)'="C"!(IO'=IO(0))
  1. N DIRUT,DUOUT
  1. S DIR(0)="EO",DIR("A")="Press return to continue...." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. Q