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

SDEC54.m

Go to the documentation of this file.
SDEC54 ;ALB/SAT - VISTA SCHEDULING RPCS ;JUN 21, 2017
 ;;5.3;Scheduling;**627,642,658,665**;Aug 13, 1993;Build 14
 ;
 ;Reference is made to ICR #6185
 Q
 ;
 ;DATE RANGE FOR INPUT
SUMMGET(SDECRET,SDBEG,SDEND,USER,LSUB,MAXREC)  ;GET Audit Summary for given date range
 N CLOSED,COUNT,DFN,DISPDT,DISPU,FNUM,NAMEPART,PROVNAME,RET,WLDATA,WLIEN,X,Y,%DT
 N APPO,ARIEN,SDDATA,SDEC54,SDECI,SDECY,SDNUM,SDTMP,SDTOT,SDDEMO,SDSUB,SDT,SDU,USER1   ;alb/sat 642 added APPO
 S SDECRET="^TMP(""SDEC54"","_$J_",""SUMMGET"")"
 K @SDECRET
 S SDSUB=""
 S SDEC54=0
 ;              1                 2         3          4          5             6
 S SDTMP="T00030REQUESTTYPE^T00030DFN^T00030NAME^T00030DATE^T00030USERIEN^T00030USERNAME"
 ;                     7           8             9              10             11
 S SDTMP=SDTMP_"^T00030DATE1^T00030PROVIEN^T00030PROVNAME^T00030PCONTACT^T00030APPT_SCHED_DATE"
 ;                     12          13            14             15
 S SDTMP=SDTMP_"^T00030DATE2^T00030CLINIEN^T00030CLINNAME^T00030ACTIVITY^T00030IEN"
 S SDTMP=SDTMP_"^T00030LASTSUB^T00030NUMBER^T00030TOTAL^T00030MRTC"
 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 ;check begin date (optional)
 I $G(SDBEG)'="" S %DT="" S X=$P($G(SDBEG),"@",1) D ^%DT S SDBEG=Y I Y=-1 S SDBEG=1410102   ;alb/sat 658 use valid FM range instead of 1000101
 I $G(SDBEG)="" S SDBEG=1410102   ;alb/sat 658 use valid FM range instead of 1000101
 ;check end date (optional)
 I $G(SDEND)'="" S %DT="" S X=$P($G(SDEND),"@",1) D ^%DT S SDEND=Y I Y=-1 S SDEND=4141015   ;alb/sat 658 use valid FM range instead of 9991231
 I $G(SDEND)="" S SDEND=4141015   ;alb/sat 658 use valid FM range instead of 9991231
 ;check user
 S USER=$G(USER)
 I '$D(^VA(200,+USER,0)) S USER=""
 ;check LSUB   <COUNT> | <TYPE> | <SUBSCRIPT [ <SUBSCRIPT> ...
 S LSUB=$G(LSUB)
 S SDTOT=+$P(LSUB,"|",1)
 ;check MAXREC
 S MAXREC=$G(MAXREC) S:'+MAXREC MAXREC=9999999   ;alb/sat 665 - remove limits
 ;get SDEC APPOINTMENT entries with DATE APPT MADE in date range   ;alb/sat 642
 D APPO^SDEC54A(.APPO,SDBEG,SDEND,USER)  ;artf19425
 ;get SDEC APPT REQUEST data
 I (LSUB="")!($P(LSUB,"|",2)="APPT") D APPT
 G:SDEC54'<MAXREC XIT
 I (LSUB="")!($P(LSUB,"|",2)="APPTAP") D APPTAPPS  ;artf19425
 G:SDEC54'<MAXREC XIT
 ;get patient contacts from APPT
 I (LSUB="")!($P(LSUB,"|",2)="APPTPC") D APPTPC^SDEC54A(.SDEC54,SDECRET,SDTOT,SDBEG,SDEND,USER,MAXREC,LSUB,.SDSUB)  ;artf19425
 G:SDEC54'<MAXREC XIT  ;artf19425
 ;get SD WAIT LIST data
 I (LSUB="")!($P(LSUB,"|",2)="EWL") D EWL
 G:SDEC54'<MAXREC XIT
 I (LSUB="")!($P(LSUB,"|",2)="WLAP") D WLAPPS  ;artf19425
 G:SDEC54'<MAXREC XIT
 ;get patient contacts from wait list
 I (LSUB="")!($P(LSUB,"|",2)="EWLPC") D EWLPC^SDEC54A(.SDEC54,SDECRET,SDTOT,SDBEG,SDEND,USER,MAXREC,LSUB,.SDSUB)  ;artf19425
 G:SDEC54'<MAXREC XIT  ;artf19425
 ;get RECALL and RECALL REMOVED data
 I (LSUB="")!($P(LSUB,"|",2)="REC") D RECALL
 G:SDEC54'<MAXREC XIT
 ;get recall appointments made
 I (LSUB="")!($P(LSUB,"|",2)="REC") D RECAPPS  ;artf19425
 G:SDEC54'<MAXREC XIT
 ;get REQUEST/CONSULTATION data
 I (LSUB="")!($P(LSUB,"|",2)="REQ") D REQGET
 G:SDEC54'<MAXREC XIT
 ;get consult appointments made
 I (LSUB="")!($P(LSUB,"|",2)="REQAP") D REQAPPS  ;artf19425
 G:SDEC54'<MAXREC XIT
XIT ;
 K APPO    ;alb/sat 642
 I SDEC54>0 S SDTMP=$P(@SDECRET@(SDEC54),$C(30),1) S $P(SDTMP,U,19)=(SDTOT+SDEC54) S:SDSUB'="" $P(SDTMP,U,17)=SDSUB S @SDECRET@(SDEC54)=SDTMP_$C(30)
 S @SDECRET@(SDEC54)=@SDECRET@(SDEC54)_$C(31)
 Q
 ;
EWL ; get SD WAIT LIST data
 ;get WAIT LIST data
 D WLINIT
 S RET="^TMP(""SDEC"","_$J_")"
 S NAMEPART=""
 K @RET
 S CLOSED=1
 S FNUM=$$FNUM^SDECWL
 ;S WLIEN=0 F  S WLIEN=$O(^SDWL(409.3,"C",DUZ(2),WLIEN)) Q:'WLIEN  D
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3)-.0001,1:$P(SDBEG,".",1))
 F  S SDT=$O(^SDWL(409.3,"AC",SDT)) Q:SDT'>0  Q:$P(SDT,".",1)>SDEND  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|EWL|"_SDT_"|"_SDU_"|"_WLIEN Q
 .I USER'="" S SDU=USER D EWL1
 .I USER="" S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4)-1,1:0) F  S SDU=$O(^SDWL(409.3,"AC",SDT,SDU)) Q:SDU'>0  D EWL1  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|EWL|"_SDT_"|"_SDU_"|"_WLIEN Q
 K @RET
 Q
EWL1 ;
 S WLIEN=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:0) S LSUB="" F  S WLIEN=$O(^SDWL(409.3,"AC",SDT,SDU,WLIEN)) Q:WLIEN'>0  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|EWL|"_SDT_"|"_SDU_"|"_WLIEN Q
 .S COUNT=0
 .D ONEPAT^SDECWL1
 .K WLDATA
 .S WLDATA=$G(@RET@(COUNT))
 .S WLDATA=$P(WLDATA,$C(30),1)
 .S WLDATA=$P(WLDATA,$C(31),1)
 .Q:WLDATA=""
 .;get disposition data, if any
 .;S DISPDT=$P($G(^SDWL(409.3,WLIEN,"DIS")),U,1)
 .;S DISPU=$P($G(^SDWL(409.3,WLIEN,"DIS")),U,2)
 .;        1       2               3                4                5                 6
 .S SDTMP="EWL"_U_$P(WLDATA,U,1)_U_$P(WLDATA,U,2)_U_$P(WLDATA,U,53)_U_$P(WLDATA,U,18)_U_$P(WLDATA,U,19)
 .;               7                 8                 9                   11
 .S SDTMP=SDTMP_U_$P(WLDATA,U,41)_U_$P(WLDATA,U,42)_U_$P(WLDATA,U,43)_U_U_$P(WLDATA,U,29)
 .S SDTMP=SDTMP_U_U_U_U_U_WLIEN_U_U_(SDTOT+SDEC54+1)
 .S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 Q
WLAPPS  ;get EWL appointments made   ;alb/sat 642
 N APPT,SDU,WLIEN,SDCNT,SDATA,SDECY,SDT,SDTMP
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3),1:"")
 F  S SDT=$O(APPO("E",SDT)) Q:SDT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|WLAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 .S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4),1:"")
 .F  S SDU=$O(APPO("E",SDT,SDU)) Q:SDU=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|WLAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ..S SDCNT=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:"")
 ..F  S SDCNT=$O(APPO("E",SDT,SDU,SDCNT)) Q:SDCNT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|WLAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ...S WLIEN=APPO("E",SDT,SDU,SDCNT)
 ...;D ONEPAT^SDECWL1
 ...D WLGET^SDEC(.SDECY,WLIEN)
 ...Q:$G(@SDECY@(1))=""
 ...S APPT=SDT_"||"_SDU_"|"_$$GET1^DIQ(200,SDU_",",.01)
 ...S SDATA=@SDECY@(1)
 ...S SDATA=$P(SDATA,$C(30),1)
 ...S SDTMP="EWL"_U_$P(SDATA,U,1)_U_$P(SDATA,U,2)_U_U_$P(SDATA,U,18)_U_$P(SDATA,U,19)    ;6
 ...S SDTMP=SDTMP_U_$P(SDATA,U,41)_U_$P(SDATA,U,42)_U_$P(SDATA,U,43)_U_U_$P(SDATA,U,29)  ;11
 ...S SDTMP=SDTMP_U_APPT_U_U_U_U_WLIEN_U_U_(SDTOT+SDEC54+1)  ;18
 ...S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 ...K @SDECY
 Q
 ;
APPT ; get SDEC APPT REQUEST data
 ;get WAIT LIST data
 D WLINIT
 S RET="^TMP(""SDEC"","_$J_")"
 S NAMEPART=""
 K @RET
 S CLOSED=1
 S FNUM=409.85
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3)-.0001,1:$P(SDBEG,".",1))
 F  S SDT=$O(^SDEC(409.85,"AC",SDT)) Q:SDT'>0  Q:$P(SDT,".",1)>SDEND  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPT|"_SDT_"|"_SDU_"|"_ARIEN Q
 .I USER'="" S SDU=USER D APPT1
 .I USER="" S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4)-1,1:0) F  S SDU=$O(^SDEC(409.85,"AC",SDT,SDU)) Q:SDU'>0  D APPT1  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPT|"_SDT_"|"_SDU_"|"_ARIEN Q
 K @RET
 Q
APPT1 ;
 N PARENT
 S ARIEN=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:0) S LSUB="" F  S ARIEN=$O(^SDEC(409.85,"AC",SDT,SDU,ARIEN)) Q:ARIEN'>0  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPT|"_SDT_"|"_SDU_"|"_ARIEN Q
 .S COUNT=0
 .D ONEPAT^SDECAR1
 .K WLDATA
 .S WLDATA=$G(@RET@(COUNT))
 .S WLDATA=$P(WLDATA,$C(30),1)
 .S WLDATA=$P(WLDATA,$C(31),1)
 .Q:WLDATA=""
 .;get disposition data, if any
 .;S DISPDT=$P($G(^SDEC(409.85,ARIEN,"DIS")),U,1)
 .;S DISPU=$P($G(^SDEC(409.85,ARIEN,"DIS")),U,2)
 .S PARENT=$S($P(WLDATA,U,66)'="":1,$P(WLDATA,U,67)=$P(WLDATA,U,7):1,1:0)
 .;        1        2               3                4                5                 6
 .S SDTMP="APPT"_U_$P(WLDATA,U,1)_U_$P(WLDATA,U,2)_U_$P(WLDATA,U,46)_U_$P(WLDATA,U,14)_U_""
 .;               7                 8                 9                 10   11
 .S SDTMP=SDTMP_U_$P(WLDATA,U,34)_U_$P(WLDATA,U,35)_U_$P(WLDATA,U,36)_U_""_U_$P(WLDATA,U,59)
 .S SDTMP=SDTMP_U_U_U_U_U_ARIEN_U_U_(SDTOT+SDEC54+1)_U_U_PARENT
 .S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 Q
APPTAPPS  ;get APPT appointments made   ;alb/sat 642
 N SDU,APPT,ARIEN,COUNTQ,SDCNT,SDATA,PARENT,RET,SDT,SDTMP
 ;S RET="^TMP(""SDEC"","_$J_")"
 ;K @RET
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3),1:"")
 F  S SDT=$O(APPO("A",SDT)) Q:SDT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPTAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 .S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4),1:"")
 .F  S SDU=$O(APPO("A",SDT,SDU)) Q:SDU=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPTAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ..S SDCNT=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:"")
 ..F  S SDCNT=$O(APPO("A",SDT,SDU,SDCNT)) Q:SDCNT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|APPTAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ...S ARIEN=APPO("A",SDT,SDU,SDCNT)
 ...S COUNT=0
 ...;D ONEPAT^SDECAR1
 ...D ARGET^SDEC(.RET,ARIEN)
 ...I $G(@RET@(1))="" K @RET Q
 ...S APPT=SDT_"||"_SDU_"|"_$$GET1^DIQ(200,SDU_",",.01)
 ...S SDATA=@RET@(1)
 ...S SDATA=$P(SDATA,$C(30),1)
 ...S PARENT=$S($P(SDATA,U,66)'="":1,$P(SDATA,U,67)=$P(SDATA,U,7):1,1:0)
 ...S SDTMP="APPT"_U_$P(SDATA,U,1)_U_$P(SDATA,U,2)_U_U_$P(SDATA,U,14)_U    ;6
 ...S SDTMP=SDTMP_U_$P(SDATA,U,34)_U_$P(SDATA,U,35)_U_$P(SDATA,U,36)_U_U_$P(SDATA,U,59)  ;11
 ...S SDTMP=SDTMP_U_APPT_U_U_U_U_ARIEN_U_U_(SDTOT+SDEC54+1)_U_U_+PARENT  ;18
 ...S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 ...K @RET
 Q
 ;
REQGET ;get REQUEST/CONSULTATION data for SCHEDULED and CANCELED activities (from SDEC51)
 N LSUB1,SDCAN,SDCANL,SDGMR,SDGMR0,SDI,SDJ,SDK,SDNOD,SDRPA,SDRPA0,SDSCHED,SDSCHEDF,STSTATF
 N RQCNT,SDGMR,SDT,SDU
 S RQCNT=SDEC54
 S SDECY="^TMP(""SDEC"","_$J_")"
 K @SDECY
 S SDECI=0
 S SDSCHEDF=0
 S SDCAN=$$GETIEN^SDEC51("CANCELLED")
 I SDCAN="" Q  ;D ERR1^SDECERR(-1,"REQUEST ACTION TYPES file does not have an entry of RECEIVED.",.SDECI,SDECY) Q
 S SDSCHED=$$GETIEN^SDEC51("SCHEDULED")
 I SDSCHED="" Q  ;D ERR1^SDECERR(-1,"REQUEST ACTION TYPES file does not have an entry of SCHEDULED.",.SDECI,SDECY) Q
 ;alb/sat 658 - new rules use AE instead of AG
 N DRQ,OSACT,OSPEND,SVC,SDGMR,STAT
 S OSACT=$O(^ORD(100.01,"B","ACTIVE",0))
 S OSPEND=$O(^ORD(100.01,"B","PENDING",0))
 S SDEC54=$G(SDEC54,0)
 S SVC=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3)-1,1:0)
 F  S SVC=$O(^GMR(123,"AE",SVC)) Q:SVC=""  D  Q:SDECI>(MAXREC-1)
 .F STAT=OSACT,OSPEND D  Q:SDECI>(MAXREC-1)
 ..Q:STAT=""
 ..Q:($P(LSUB,"|",4)'="")&($P(LSUB,"|",4)'=STAT)
 ..S DRQ=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5)-.0001,1:SDBEG-1)
 ..F  S DRQ=$O(^GMR(123,"AE",SVC,STAT,DRQ)) Q:DRQ=""  Q:$P(DRQ,".",1)>SDEND  D REQGET1 Q:SDECI>(MAXREC-1)
 Q
REQGET1 ;
 N SDSTATF
 S SDGMR=$S($P(LSUB,"|",6)'="":$P(LSUB,"|",6),1:0)
 S LSUB=""
 F  S SDGMR=$O(^GMR(123,"AE",SVC,STAT,DRQ,SDGMR)) Q:SDGMR=""  D  I SDEC54'<MAXREC S SDSUB=(SDTOT+SDEC54)_"|REQ|"_SVC_"|"_STAT_"|"_DRQ_"|"_SDGMR Q
 .S SDCANL=""
 .S (SDSCHEDF,SDSTATF)=0
 .S SDRPA=0 F  S SDRPA=$O(^GMR(123,SDGMR,40,SDRPA)) Q:SDRPA'>0  D
 ..S SDRPA0=$G(^GMR(123,SDGMR,40,SDRPA,0))  ;ICR 6185
 ..I USER="",$P(SDRPA0,U,4)'=USER Q
 ..I ($P(SDRPA0,U,2)=SDCAN)!($P(SDRPA0,U,2)=SDSCHED) D
 ...S SDCANL=$S(SDCANL'="":SDCANL_"|",1:"")_SDGMR_";;"_SDRPA_";;"_$$FMTE^XLFDT($P(SDRPA0,U,1))
 ...S SDCANL=SDCANL_";;"_$$GET1^DIQ(123.02,SDRPA_","_SDGMR_",",1)_";;"_$P(SDRPA0,U,5)_";;"_$P($G(^VA(200,+$P(SDRPA0,U,5),0)),U,1)
 .I SDCANL'="" D
 ..S DFN=$$GET1^DIQ(123,SDGMR_",",.02,"I")
 ..;collect demographics
 ..S NAME=$$GET1^DIQ(2,DFN_",",.01)   ;SDDEMO("NAME")
 ..K SDDATA,SDMSG
 ..;SDCANL=<REQUEST PROCESSING ACTIVITY pointer> ;; <DATE/TIME OF ACTION ENTRY> ;; <ACTIVITY> ;; <WHO ENTERED ACTIVITY ien> ;; <WHO ENTERED ACTIVITY name>
 ..S SDTMP="CONSULT"_U_DFN_U_NAME_U_$$GET1^DIQ(123,SDGMR_",",3,"I")_U_U                 ;6
 ..S SDTMP=SDTMP_U_U_U_U_U                              ;11
 ..S SDTMP=SDTMP_U_U_U_U_SDCANL_U_SDGMR_U_U_(SDTOT+SDEC54+1)   ;18
 ..S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 Q
REQAPPS  ;get recall appointments made   ;alb/sat 642
 N APPT,SDU,SDID,SDCNT,SDATA,SDECY,SDT,SDTMP
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3),1:"")
 F  S SDT=$O(APPO("C",SDT)) Q:SDT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REQAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 .S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4),1:"")
 .F  S SDU=$O(APPO("C",SDT,SDU)) Q:SDU=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REQAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ..S SDCNT=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:"")
 ..F  S SDCNT=$O(APPO("C",SDT,SDU,SDCNT)) Q:SDCNT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REQAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ...S SDID=APPO("C",SDT,SDU,SDCNT)
 ...D REQGET^SDEC(.SDECY,,,,,SDID)
 ...Q:$G(@SDECY@(1))=""
 ...S SDATA=@SDECY@(1)
 ...S SDATA=$P(SDATA,$C(30),1)
 ...S APPT=SDT_"||"_SDU_"|"_$$GET1^DIQ(200,SDU_",",.01)
 ...S SDTMP="CONSULT"_U_$P(SDATA,U,3)_U_$P(SDATA,U,4)_U_U_U         ;6
 ...S SDTMP=SDTMP_U_U_U_U_U                                                                          ;11
 ...S SDTMP=SDTMP_U_APPT_U_$P(SDATA,U,6)_U_$P(SDATA,U,7)_U_U_$P(SDATA,U,1)_U_U_(SDTOT+SDEC54+1)  ;18
 ...S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 ...K @SDECY
 Q
 ;
RECALL ;get RECALL REMINDERS data
 N SDECY,SDR,SDT,SDU
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3)-.0001,1:$P(SDBEG,".",1))
 F  S SDT=$O(^SD(403.5,"AC",SDT)) Q:SDT'>0  Q:$P(SDT,".",1)>SDEND  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REC|"_SDT_"|"_SDU_"|"_SDR Q
 .I USER'="" S SDU=USER D RECALL1
 .I USER="" S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4)-1,1:0) F  S SDU=$O(^SD(403.5,"AC",SDT,SDU)) Q:SDU'>0  Q:(USER'="")&(SDU'=USER)  D RECALL1  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REC|"_SDT_"|"_SDU_"|"_SDR Q
 Q
RECALL1 ;
 S SDR=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:0)  F  S SDR=$O(^SD(403.5,"AC",SDT,SDU,SDR)) Q:SDR'>0  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|REC|"_SDT_"|"_SDU_"|"_SDR Q
 .S SDECY=""
 .D RECIEN^SDEC(.SDECY,SDR)
 .Q:$G(@SDECY@(1))=""
 .S WLDATA=@SDECY@(1)
 .S WLDATA=$P(WLDATA,$C(30),1)
 .S SDTMP="RECALL"_U_$P(WLDATA,U,2)_U_$P(WLDATA,U,3)_U_$P(WLDATA,U,32)_U_$P(WLDATA,U,22)_U_$P(WLDATA,U,23)     ;6
 .S SDTMP=SDTMP_U_U_U_U_U                                                                                      ;11
 .S SDTMP=SDTMP_U_U_$P(WLDATA,U,16)_U_$P(WLDATA,U,17)_U_U_$P(WLDATA,U,1)_U_U_(SDTOT+SDEC54+1)  ;18  ;alb/sat 642 null for DATE2
 .S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 .K @SDECY
 Q
 ;
RECAPPS  ;get recall appointments made   ;alb/sat 642
 N APPT,SDU,SDID,SDCNT,SDATA,SDECY,SDT,SDTMP
 S SDT=$S($P(LSUB,"|",3)'="":$P(LSUB,"|",3),1:"")
 F  S SDT=$O(APPO("R",SDT)) Q:SDT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|RECAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 .S SDU=$S($P(LSUB,"|",4)'="":$P(LSUB,"|",4),1:"")
 .F  S SDU=$O(APPO("R",SDT,SDU)) Q:SDU=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|RECAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ..S SDCNT=$S($P(LSUB,"|",5)'="":$P(LSUB,"|",5),1:"")
 ..F  S SDCNT=$O(APPO("R",SDT,SDU,SDCNT)) Q:SDCNT=""  D  I SDEC54'<MAXREC S:SDSUB="" SDSUB=(SDTOT+SDEC54)_"|RECAP|"_SDT_"|"_SDU_"|"_SDCNT Q
 ...S SDID=APPO("R",SDT,SDU,SDCNT)
 ...D RECIEN^SDEC(.SDECY,SDID)
 ...Q:$G(@SDECY@(1))=""
 ...S SDATA=@SDECY@(1)
 ...S SDATA=$P(SDATA,$C(30),1)
 ...S APPT=SDT_"||"_SDU_"|"_$$GET1^DIQ(200,SDU_",",.01)
 ...S SDTMP="RECALL"_U_$P(SDATA,U,2)_U_$P(SDATA,U,3)_U_U_$P(SDATA,U,22)_U_$P(SDATA,U,23)         ;6
 ...S SDTMP=SDTMP_U_U_U_U_U                                                                          ;11
 ...S SDTMP=SDTMP_U_APPT_U_$P(SDATA,U,16)_U_$P(SDATA,U,17)_U_U_$P(SDATA,U,1)_U_U_(SDTOT+SDEC54+1)  ;18
 ...S SDEC54=SDEC54+1 S @SDECRET@(SDEC54)=SDTMP_$C(30)
 ...K @SDECY
 Q
 ;
DEMO ;get patient demographics
 N SDDEMO
 D PDEMO^SDECU3(.SDDEMO,DFN)   ;alb/sat 658 PDEMO moved to SDECU3
 S NAME=SDDEMO("NAME")
 Q
 ;
WLINIT ;
 N NAME,NAMEPART,DOB,GENDER,HRN,SSN,INSTIEN,INSTNAME
 N PRIGRP,ELIGIEN,ELIGNAME,SVCCONN,SVCCONNP,TYPEIEN
 N TYPENAME,PTPHONE,WLORIGDT,WLINST,WLINSTNM,WLTYPE
 N WLTEAM,WLPOS,WLSSIEN,WLSSNAME,WLCLIEN,WLCLNAME
 N WLUSER,WLUSRNM,WLPRIO,WLENPRI,WLREQBY,WLPROV
 N WLPROVNM,WLDAPTDT,WLCOMM,WLEESTAT,WLASD,WLMAR
 N WLMAI,WLMAN,WLPC
 Q