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

PRSPSAPU.m

Go to the documentation of this file.
  1. PRSPSAPU ;WOIFO/JAH - PT Physician, supervisor approval utils ;01/22/05
  1. ;;4.0;PAID;**93,125**;Sep 21, 1995;Build 6
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. Q
  1. ONEPTP(TLE) ; get one or all ptp's from a TLE
  1. ; if the selection hasn't a memo or hasn't an ESR to be approved
  1. ; then inform and re-ask
  1. ;
  1. ; return PRSIEN for successful PTP selection
  1. ; return 0 for all PTP's in T&L
  1. ; return -1 for abort/timeout
  1. ;
  1. N ALL,PTP,OUT
  1. S (PTP,ALL,OUT)=0
  1. F D Q:(OUT!(PTP>0)!(ALL))
  1. . S PTP=$$ALL1PTP(TLE)
  1. . I PTP=0 S ALL=1 Q ; all ptp's were selected
  1. . I PTP<0 S OUT=1 Q ; user uparrow or timeout
  1. . I PTP>0,'$D(^PRST(458.7,"B",PTP)) W !!,"There are no Service Level Memoranda on file for ",$P(^PRSPC(PTP,0),U) S PTP=0
  1. . I PTP>0,'$D(^PRST(458,"ASA",PTP)) W !!,"There are no daily ESR's pending approval for ",$P(^PRSPC(PTP,0),U) S PTP=0
  1. I ALL S PTP=0
  1. I OUT S PTP=-1
  1. Q PTP
  1. ;
  1. ALL1PTP(TLE) ; ask for one part time physician from a TLE or ALL
  1. I TLE'?1A.E,TLE'>0 Q PRSIEN
  1. N DIC,PRSIEN,D,Y,DUOUT,DTOUT
  1. S PRSIEN=""
  1. S DIC("A")="Select an EMPLOYEE or press RETURN for ALL: "
  1. S DIC(0)="AEQM"
  1. S DIC="^PRSPC("
  1. S DIC("S")="I $P(^(0),""^"",8)=TLE"
  1. ; start look up with ATL xref
  1. S D="ATL"_TLE
  1. W !
  1. D IX^DIC
  1. ;
  1. ; user hit return for all (return 0)
  1. I Y=-1,'($D(DUOUT)!$D(DTOUT)) D
  1. . S PRSIEN=0
  1. E D
  1. . S PRSIEN=+Y
  1. Q PRSIEN
  1. ;
  1. UPESRST(PPI,PRSIEN,PRSD) ;update ESR DAILY STATUS
  1. N DIE,DR,DA
  1. S DA(2)=$G(PPI),DA(1)=$G(PRSIEN),DA=$G(PRSD)
  1. S DR="146///SIGNED;149///MANUAL POST"
  1. S DIE="^PRST(458,"_DA(2)_",""E"","_DA(1)_",""D"","
  1. D ^DIE
  1. Q
  1. ESRDTS(ESRDTS,PRSIEN,PPI) ; Return signed dates from PTP's ESR
  1. ; return array ESRDTS subscripted sequentially from 1
  1. ; ESRDTS(1) = Tue 2-NOV-04
  1. ; ESRDTS(2) = Fri 5-NOV-04
  1. N PRSD,ITEMS,PRSDTS
  1. S PRSDTS=$G(^PRST(458,PPI,2))
  1. S (PRSD,ITEMS)=0
  1. F S PRSD=$O(^TMP($J,"PRSPSAP",PRSIEN,PPI,PRSD)) Q:PRSD'>0 D
  1. . S ITEMS=ITEMS+1
  1. . S ESRDTS(ITEMS)=PRSD_U_$P(PRSDTS,U,PRSD)
  1. Q
  1. DISPLAY(PRSIEN,PPI,CNT) ;display PPI signed esr days for super review/action
  1. ; RETURN array CNT
  1. ; CNT = count of days
  1. ; CNT(1)= days w/status from supervisor during this option
  1. ; PGLNS = lines on current page
  1. ; DYLNS = lines in a day
  1. ;
  1. N I,PRSD,ESRDTS,ESEG,ESR,PGLNS,DAYLNS,OUT
  1. D HDRESR^PRSPSAP1(PRSIEN,PPI,.PGLNS)
  1. ;
  1. D ESRDTS^PRSPSAPU(.ESRDTS,PRSIEN,PPI)
  1. S (PRSD,CNT,CNT(1),OUT)=0
  1. F S PRSD=$O(^TMP($J,"PRSPSAP",PRSIEN,PPI,PRSD)) Q:PRSD'>0!(OUT) D
  1. . I $Y>(IOSL-6) S OUT=$$ASK^PRSLIB00() D HDRESR^PRSPSAP1(PRSIEN,PPI,.PGLNS)
  1. . Q:OUT
  1. . D GETESR^PRSPSAP1(.ESR,PPI,PRSIEN,PRSD)
  1. . S CNT=CNT+1
  1. . W !,CNT
  1. . D DAY(.DAYLNS,ESRDTS(CNT),.ESR,PRSIEN,PPI)
  1. . S PGLNS=PGLNS+DAYLNS
  1. Q
  1. ;
  1. DAY(LN,EXTDAY,ESR,PRSIEN,PPI) ; write a day, return # of lines.
  1. N STE,ESEG,REMARKS,START,STOP,MEAL,HOURS,STATUSI,LCNT
  1. S LN=0
  1. S HOURS=""
  1. W ?3,$P(EXTDAY,U,2)
  1. W ?17,ESR("TODEXT")
  1. ; if tour is too wide for column move down a line
  1. I $L(ESR("TODEXT"))>16 W ! S LN=LN+1
  1. ;
  1. F ESEG=1:5:31 Q:($P(ESR("WORK"),U,ESEG)="") D
  1. . I ESEG>1 W !
  1. .; start
  1. . S START=$P(ESR("WORK"),U,ESEG)
  1. . S STOP=$P(ESR("WORK"),U,ESEG+1)
  1. . S MEAL=$P(ESR("WORK"),U,ESEG+4)
  1. . W ?33,START
  1. . I START'["No work:" D
  1. .. W "-"
  1. .. S HOURS=$$ELAPSE^PRSPESR2(MEAL,START,STOP)
  1. .; stop
  1. . W STOP
  1. .; type of time
  1. . W ?49,$$TTE($P(ESR("WORK"),U,ESEG+2))
  1. .; remarks - use 458.02 to convert to external
  1. . S REMARKS=$P(ESR("WORK"),U,ESEG+3)
  1. . I REMARKS>0 D
  1. .. S LN=LN+1
  1. .. W !,?34,"Remarks: ",$$EXTERNAL^DILFD(458.02,44,"",REMARKS)
  1. .; hours and meal
  1. . W ?61,HOURS,?68,MEAL
  1. ; display PTP remarks (if any)
  1. I ESR("RMK")]"" D
  1. . W !,?2,"Physician Remarks: "
  1. . D WRAP(.LCNT,ESR("RMK"),21,66)
  1. . S LN=LN+LCNT
  1. S STATUSI=$G(^TMP($J,"PRSPSAP",PRSIEN,PPI,+EXTDAY,1))
  1. W ?72,$$STATUSE(STATUSI)
  1. Q
  1. GETDAY(ESRDY,ESRDTS,ESR,CNT,PRSIEN,PPI) ; RETURN write a day IN ESRDY ARRAY
  1. N BLANKS,LN,ESEG,START
  1. S LN=1
  1. S BLANKS=" "
  1. S ESRDY(LN)=" "_$P(ESRDTS(CNT),U,2)
  1. S ESRDY(LN)=$E(ESRDY(LN)_BLANKS,1,18)_ESR("TODEXT")
  1. ; if tour is too wide for the column move down a line for the work
  1. I $L(ESR("TODEXT"))>16 S LN=LN+1,ESRDY(LN)=""
  1. ;
  1. F ESEG=1:5:31 Q:($P(ESR("WORK"),U,ESEG)="") D
  1. . I ESEG>1 W !
  1. .; start
  1. . S START=$P(ESR("WORK"),U,ESEG)
  1. . S ESRDY(LN)=$E(ESRDY(LN)_BLANKS,1,35)_START
  1. . I START'["No work-signed by" S ESRDY(LN)=ESRDY(LN)_"-"
  1. .; stop
  1. . S ESRDY(LN)=ESRDY(LN)_$P(ESR("WORK"),U,ESEG+1)
  1. .; type of time
  1. . S ESRDY(LN)=$E(ESRDY(LN)_BLANKS,1,51)_$$TTE($P(ESR("WORK"),U,ESEG+2))
  1. .; remarks
  1. . S ESRDY(LN)=$E(ESRDY(LN)_BLANKS,1,54)_$P(ESR("WORK"),U,ESEG+3)
  1. .; meal
  1. . S ESRDY(LN)=$E(ESRDY(LN)_BLANKS,1,68)_$P(ESR("WORK"),U,ESEG+4)
  1. . S ST=$$STATUSE($G(^TMP($J,"PRSPSAP",PRSIEN,PPI,+ESRDTS(CNT),1)))
  1. . S ESRDY(LN)=$E(ESRDY(LN),1,71)_ST
  1. . S LN=LN+1,ESRDY(LN)=""
  1. Q
  1. ;
  1. TTE(CODE) ; return external type of time
  1. N K
  1. Q:$G(CODE)="" CODE
  1. S K=$O(^PRST(457.3,"B",CODE,0))
  1. Q $P($G(^PRST(457.3,+K,0)),"^",2)
  1. ;
  1. STATUSE(ST) ; return external form of supervisor action status
  1. S ST=$G(ST)
  1. Q $S(ST="B":"Bypass",ST="R":"Resubmit",ST="A":"Approved",1:"")
  1. ;
  1. CLRTCDY(PPI,PRSIEN,PRSD,EST) ;function true (1) for success otherwise 0
  1. ; clear a timecard day (2,3,10 nodes) if status is (T) timekeeper
  1. ; clear work, posting status and remove approved status from ESR day.
  1. ; INPUT: PPI,PRSIEN,PRSD: package standard
  1. ; EST : optional, valid ESR DAILY STATUS internal value
  1. ;
  1. Q:($G(PPI)'>0)!($G(PRSIEN)'>0)!($G(PRSD)'>0) 0
  1. Q:'$D(^PRST(458,PPI,"E",PRSIEN,"D",PRSD,0)) 0
  1. N TCSTAT
  1. S TCSTAT=$$TCSTAT^PRSPSAP2(PPI,PRSIEN)
  1. Q:$G(TCSTAT)'="T" 0
  1. ;
  1. ; kill the timecard work nodes
  1. K ^PRST(458,PPI,"E",PRSIEN,"D",PRSD,2),^(3),^(10)
  1. ;
  1. ; ONLY if a valid ESR daily status is passed then set it
  1. N VALID
  1. D CHK^DIE(458.02,146,"",$G(EST),.VALID)
  1. Q:VALID["^" 1
  1. ;
  1. N IENS,PRSFDA
  1. S IENS=PRSD_","_PRSIEN_","_PPI_","
  1. S PRSFDA(458.02,IENS,146)=EST
  1. D FILE^DIE("","PRSFDA")
  1. D MSG^DIALOG()
  1. Q 1
  1. ;
  1. WRAP(LNS,STR,TAB,WID) ; format a long message string to break lines at words
  1. ; TAB is left margin
  1. ; WID is right margin
  1. ; return LNS number of lines it took to write
  1. N WORD,I,WC,COLW,W1,W2
  1. S WC=0,WORD=""
  1. S COLW=WID-TAB+1
  1. W ?$G(TAB)
  1. S LNS=1
  1. F I=1:1:$L(STR," ") D
  1. . S WORD=$P(STR," ",I)
  1. . Q:WORD=""
  1. .; break words longer than the width of the column
  1. . F Q:($L(WORD)<(COLW+1)) D
  1. .. S W1=$E(WORD,1,COLW-1)_"-"
  1. .. S W2=$E(WORD,COLW,$L(WORD))
  1. .. S WORD=W1 D WW
  1. .. S WORD=W2
  1. . D WW
  1. Q
  1. WW ; Write Word
  1. I ($X+$L(WORD))>WID D
  1. . I WC>0 W !,?$G(TAB) S LNS=LNS+1,WC=0
  1. W WORD," " S WC=WC+1
  1. Q
  1. ;
  1. ;
  1. ;===============================================================
  1. ;
  1. AMT(START,STOP,MEAL) ; return decimal hours between times
  1. ; times are in PAID timecard work node format. (e.g. 04:30P )
  1. N AMT,X
  1. S AMT=$$ELAPSE^PRSPESR2(MEAL,START,STOP)
  1. S X=$P(AMT,":",2) S X=$S(X=30:5,X=15:25,X=45:75,1:0)
  1. S AMT=+$P(AMT,":",1)_"."_X
  1. Q AMT