SCMCTPM ;ALB/REW - Patient Position Changes MailMessages ; 26 Mar 1996
;;5.3;Scheduling;**41,45,48,87,100,130**;AUG 13, 1993
;1
MAIL ;Do Patient Team Changes MailMan Message
; - called by SCMC PT TEAM CHANGES MAIL MESSAGE protocol
G:$G(SCNOMAIL) END ;- flag can be set to stop message generation
N XMDUZ,XMY,XMSUB,XMTEXT,VA,VAERR,XMZ,Y,ZTQUEUED
N SCTMAR,SCSTAT,DFN,SCNODE,SCY,SCSPACE,SCPAD,SCTPXM,SCLNCNT,SCTPDT,SCPTNM
S ZTQUEUED=1
S $P(SCSPACE," ",80)=""
; SCTMAR - ARRAY OF TEAMS (before & after)
S:SCTMAF SCTMAR(SCTMAF)=""
S:SCTMB4 SCTMAR(SCTMB4)=""
S:'SCTPAF SCSTAT="DELETED"
S:'SCTPB4 SCSTAT="NEW"
S:SCTPB4&SCTPAF SCSTAT="CHANGED"
S DFN=$S(SCSTAT="DELETED":+$G(^SCPT(404.42,+SCPTTPB4,0)),1:+$G(^SCPT(404.42,+SCPTTPAF,0)))
;set xmy array for practitioners in positions receiving TMchg notices
G:'$$PCMMXMY^SCAPMC25(3,DFN,"SCTMAR","SCTPDT",0) END
;D:'$G(DGQUIET) EN^DDIOL("Sending "_SCSTAT_" Patient-Position Assignment Message")
D PID^VADPT6
S SCPTNM=$P(^DPT(DFN,0),U,1)
S XMSUB=SCSTAT_" PATIENT-POSITION ASSIGNMENT for Patient ("_$E(SCPTNM,1)_$G(VA("BID"))_")",XMTEXT="^TMP($J,""SCTPXM"",",SCLNCNT=0
IF SCSTAT="NEW" D
.D SETLN("Current Patient Team Data:")
.D SETLN("==========================")
.F SCX=1:1:9 D
..D SETLN($$TEXT(404.43,SCPTTPAF,SCX,SCSPACE,1))
IF SCSTAT="DELETED" D
.D SETLN("Previous Patient Team Data:")
.D SETLN("===========================")
.F SCX=1:1:9 S SCFLD=SCX*.01 D
..D SETLN($$TEXT(404.43,SCPTTPB4,SCX,SCSPACE,1))
IF SCSTAT="CHANGED" D
.D SETLN("Fields: "_$E(SCSPACE,1,19)_"Previous Data: Current Patient Data:")
.D SETLN("=======================================================================")
.F SCX=1:1:9 S SCFLD=SCX*.01 D
..N SCLAB2,SCY,SCZ
..S SCY=$$TEXT(404.43,SCPTTPB4,SCX,SCSPACE,1)
..S:'$L(SCY) SCLAB2=2
..S SCZ=$$TEXT(404.43,SCPTTPAF,SCX,SCSPACE,+$G(SCLAB2))
..D:$L(SCY)!($L(SCZ)) SETLN(SCY_$E(SCSPACE,1,(52-$L(SCY)))_SCZ)
S SCLNCNT=$$PCMAIL^SCMCMM(DFN,"^TMP($J,""SCTPXM"")",DT)
S XMDUZ=$G(DUZ,.5)
D ^XMD
END K ^TMP($J,"SCTPXM")
Q
;
SETLN(TEXT) ;
Q:$G(TEXT)=""
; increments SCLNCNT, adds text to scTPxm(sclncnt)
S SCLNCNT=SCLNCNT+1
S ^TMP($J,"SCTPXM",SCLNCNT)=TEXT
Q
;
TEXT(SCFILE,SCNODE,SCPC,SCSPACE,SCLAB) ;returns fldname & external value
;returns fldname & external value
; Note- Only works for non wp fields of standard numbering conventions
; SCFLILE =FILENUM
; SCNODE = 0 NODE
; SCPC = piece of node
; SCSPACE = 80 SPACES
; SCLAB = 1 if print field name
N SCX,SCINT,SCFLD
S SCX=""
S SCINT=$P(SCNODE,U,SCPC)
G:SCINT="" QTTXT
S SCFLD=SCPC*.01
;;;
IF $G(SCLAB) D
.S SCX=$$DDNAME^SCMCRU(SCFILE,SCFLD)_":"
.S:$G(SCLAB)=1 SCX=SCX_$E(SCSPACE,1,(27-$L(SCX)))
.S:$G(SCLAB)=2 SCX=SCX_$E(SCSPACE,1,(52-$L(SCX)))
S:SCINT]"" SCX=SCX_$$EXTERNAL^DILFD(SCFILE,SCFLD,"",SCINT)
QTTXT Q SCX
DDNAME(FILE,FIELD) ;return the fieldname
N SCX
D FIELD^DID(FILE,FIELD,"","LABEL","SCX")
Q $G(SCX("LABEL"))
;
MAILLST(SCTP,SCFIELDA,SCDATE,SCNEWTP,SCOLDTP,SCBADTP) ;
; Input:
; SCTP - Pointer to Team Position File (#404.57)
; SCFIELDA - Field array with internal values
; SCDATE - Effective Date
; SCNEWTP - DFN array of newly assigned to position
; SCOLDTP - DFN array of previously assigned to position
; SCBADTP - DFN array of patients unassignable to position
;
G:$G(SCNOMAIL) QTMULT ;- flag can be set to stop message generation
G:'$D(SCNEWTP) QTMULT
G:'$O(@SCNEWTP@(0)) QTMULT ;if no new assignments
N XMDUZ,XMY,XMSUB,XMTEXT,VA,VAERR,XMZ,Y,SCTPDT,ZTQUEUED
N SCTPNM,DFN,SCOK,SCPTNM,SCFLD,SCNODE,SCNDX,SCSPACE,SCE,SCB,SCTMNM,SCDELTEM,SCDETAIL
S ZTQUEUED=1
S SCDELTEM=1 ;ok to delete tmp global
IF $D(SCFIELDA) D
.IF $D(SCFIELDA(.03)) S SCB=SCFIELDA(.03)
.IF $D(SCFIELDA(.04)) S SCE=SCFIELDA(.04)
S SCB=$G(SCB,DT)
S SCE=$G(SCE,DT)
S $P(SCSPACE," ",80)=""
S SCTPDT("BEGIN")=$S(SCB<SCDATE:SCB,1:SCDATE)
S SCTPDT("END")=$S(SCE>SCDATE:SCE,1:SCDATE)
S SCTPDT("INCL")=0
S SCTPNM=$P($G(^SCTM(404.57,+SCTP,0)),U,1)
S XMSUB="Multiple PATIENT-POSITION ASSIGNMENT for "_SCTPNM,XMTEXT="^TMP($J,""SCTPXM"",",SCLNCNT=0
D:'$G(DGQUIET) EN^DDIOL("Sending Multiple Patient-Position Assignment Message")
S SCOK=1
S SCTPNM=$P($G(^SCTM(404.57,+SCTP,0)),U,1)
S SCTMNM=$P($G(^SCTM(404.51,+$P($G(^SCTM(404.57,+SCTP,0)),U,2),0)),U,1)
D SETLN("Team: "_SCTMNM)
D SETLN("Position: "_SCTPNM)
S Y=SCDATE X ^DD("DD")
D SETLN("Effective Date: "_Y)
D SETLN(" ")
IF $D(SCFIELDA) D
.F SCNDX=1:1:14 S SCFLD=SCNDX*.01 IF $D(SCFIELDA(SCFLD)) D
..S $P(SCNODE,U,SCNDX)=SCFIELDA(SCFLD)
..D SETLN($$TEXT(404.43,SCNODE,SCNDX,SCSPACE,1))
D SETLN(" ")
D SETLN("There has been a new position assignment for the following patients:")
S DFN=0
NEW F S DFN=$O(@SCNEWTP@(DFN)) Q:'DFN D
.S:$$PCMMXMY^SCAPMC25(3,DFN,,"SCTPDT",0) SCOK=0
.D PID^VADPT6
.S SCPTNM=$P(^DPT(DFN,0),U,1)
.S ^TMP("SCTP MAIL LST",$J,SCTP,1,DFN)=(" "_SCPTNM_" ("_$G(VA("PID"))_")")
.S ^TMP("SCTP MAIL LST",$J,SCTP,1,"B",SCPTNM,DFN)=""
S SCPTNM=""
F S SCPTNM=$O(^TMP("SCTP MAIL LST",$J,SCTP,1,"B",SCPTNM)) Q:SCPTNM']"" D
.S DFN=0
.F S DFN=$O(^TMP("SCTP MAIL LST",$J,SCTP,1,"B",SCPTNM,DFN)) Q:'DFN D
..S SCDETAIL=$G(^TMP("SCTP MAIL LST",$J,SCTP,1,DFN)) Q:SCDETAIL']"" D SETLN(SCDETAIL)
BAD IF $O(@SCBADTP@(0)) D
.D SETLN(" ")
.D SETLN("There has been NO new position assignment for the following patients:")
.S DFN=0
.F S DFN=$O(@SCBADTP@(DFN)) Q:'DFN D
..S:$$PCMMXMY^SCAPMC25(3,DFN,,"SCTPDT",0) SCOK=0
..S SCPTNM=$P(^DPT(DFN,0),U,1)
..D PID^VADPT6
..S ^TMP("SCTP MAIL LST",$J,SCTP,2,DFN)=(" "_SCPTNM_" ("_$G(VA("PID"))_")")
..S ^TMP("SCTP MAIL LST",$J,SCTP,2,"B",SCPTNM,DFN)=""
.S SCPTNM=""
.F S SCPTNM=$O(^TMP("SCTP MAIL LST",$J,SCTP,2,"B",SCPTNM)) Q:SCPTNM']"" D
..S DFN=0
..F S DFN=$O(^TMP("SCTP MAIL LST",$J,SCTP,2,"B",SCPTNM,DFN)) Q:'DFN D
...S SCDETAIL=$G(^TMP("SCTP MAIL LST",$J,SCTP,2,DFN)) Q:SCDETAIL']"" D SETLN(SCDETAIL)
S XMDUZ=$G(DUZ,.5)
D ^XMD
QTMULT K:$G(SCDELTEM) ^TMP("SCTP MAIL LST",$J,SCTP)
K ^TMP($J,"SCTPXM")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCMCTPM 6189 printed Oct 16, 2024@18:42:02 Page 2
SCMCTPM ;ALB/REW - Patient Position Changes MailMessages ; 26 Mar 1996
+1 ;;5.3;Scheduling;**41,45,48,87,100,130**;AUG 13, 1993
+2 ;1
MAIL ;Do Patient Team Changes MailMan Message
+1 ; - called by SCMC PT TEAM CHANGES MAIL MESSAGE protocol
+2 ;- flag can be set to stop message generation
if $GET(SCNOMAIL)
GOTO END
+3 NEW XMDUZ,XMY,XMSUB,XMTEXT,VA,VAERR,XMZ,Y,ZTQUEUED
+4 NEW SCTMAR,SCSTAT,DFN,SCNODE,SCY,SCSPACE,SCPAD,SCTPXM,SCLNCNT,SCTPDT,SCPTNM
+5 SET ZTQUEUED=1
+6 SET $PIECE(SCSPACE," ",80)=""
+7 ; SCTMAR - ARRAY OF TEAMS (before & after)
+8 if SCTMAF
SET SCTMAR(SCTMAF)=""
+9 if SCTMB4
SET SCTMAR(SCTMB4)=""
+10 if 'SCTPAF
SET SCSTAT="DELETED"
+11 if 'SCTPB4
SET SCSTAT="NEW"
+12 if SCTPB4&SCTPAF
SET SCSTAT="CHANGED"
+13 SET DFN=$SELECT(SCSTAT="DELETED":+$GET(^SCPT(404.42,+SCPTTPB4,0)),1:+$GET(^SCPT(404.42,+SCPTTPAF,0)))
+14 ;set xmy array for practitioners in positions receiving TMchg notices
+15 if '$$PCMMXMY^SCAPMC25(3,DFN,"SCTMAR","SCTPDT",0)
GOTO END
+16 ;D:'$G(DGQUIET) EN^DDIOL("Sending "_SCSTAT_" Patient-Position Assignment Message")
+17 DO PID^VADPT6
+18 SET SCPTNM=$PIECE(^DPT(DFN,0),U,1)
+19 SET XMSUB=SCSTAT_" PATIENT-POSITION ASSIGNMENT for Patient ("_$EXTRACT(SCPTNM,1)_$GET(VA("BID"))_")"
SET XMTEXT="^TMP($J,""SCTPXM"","
SET SCLNCNT=0
+20 IF SCSTAT="NEW"
Begin DoDot:1
+21 DO SETLN("Current Patient Team Data:")
+22 DO SETLN("==========================")
+23 FOR SCX=1:1:9
Begin DoDot:2
+24 DO SETLN($$TEXT(404.43,SCPTTPAF,SCX,SCSPACE,1))
End DoDot:2
End DoDot:1
+25 IF SCSTAT="DELETED"
Begin DoDot:1
+26 DO SETLN("Previous Patient Team Data:")
+27 DO SETLN("===========================")
+28 FOR SCX=1:1:9
SET SCFLD=SCX*.01
Begin DoDot:2
+29 DO SETLN($$TEXT(404.43,SCPTTPB4,SCX,SCSPACE,1))
End DoDot:2
End DoDot:1
+30 IF SCSTAT="CHANGED"
Begin DoDot:1
+31 DO SETLN("Fields: "_$EXTRACT(SCSPACE,1,19)_"Previous Data: Current Patient Data:")
+32 DO SETLN("=======================================================================")
+33 FOR SCX=1:1:9
SET SCFLD=SCX*.01
Begin DoDot:2
+34 NEW SCLAB2,SCY,SCZ
+35 SET SCY=$$TEXT(404.43,SCPTTPB4,SCX,SCSPACE,1)
+36 if '$LENGTH(SCY)
SET SCLAB2=2
+37 SET SCZ=$$TEXT(404.43,SCPTTPAF,SCX,SCSPACE,+$GET(SCLAB2))
+38 if $LENGTH(SCY)!($LENGTH(SCZ))
DO SETLN(SCY_$EXTRACT(SCSPACE,1,(52-$LENGTH(SCY)))_SCZ)
End DoDot:2
End DoDot:1
+39 SET SCLNCNT=$$PCMAIL^SCMCMM(DFN,"^TMP($J,""SCTPXM"")",DT)
+40 SET XMDUZ=$GET(DUZ,.5)
+41 DO ^XMD
END KILL ^TMP($JOB,"SCTPXM")
+1 QUIT
+2 ;
SETLN(TEXT) ;
+1 if $GET(TEXT)=""
QUIT
+2 ; increments SCLNCNT, adds text to scTPxm(sclncnt)
+3 SET SCLNCNT=SCLNCNT+1
+4 SET ^TMP($JOB,"SCTPXM",SCLNCNT)=TEXT
+5 QUIT
+6 ;
TEXT(SCFILE,SCNODE,SCPC,SCSPACE,SCLAB) ;returns fldname & external value
+1 ;returns fldname & external value
+2 ; Note- Only works for non wp fields of standard numbering conventions
+3 ; SCFLILE =FILENUM
+4 ; SCNODE = 0 NODE
+5 ; SCPC = piece of node
+6 ; SCSPACE = 80 SPACES
+7 ; SCLAB = 1 if print field name
+8 NEW SCX,SCINT,SCFLD
+9 SET SCX=""
+10 SET SCINT=$PIECE(SCNODE,U,SCPC)
+11 if SCINT=""
GOTO QTTXT
+12 SET SCFLD=SCPC*.01
+13 ;;;
+14 IF $GET(SCLAB)
Begin DoDot:1
+15 SET SCX=$$DDNAME^SCMCRU(SCFILE,SCFLD)_":"
+16 if $GET(SCLAB)=1
SET SCX=SCX_$EXTRACT(SCSPACE,1,(27-$LENGTH(SCX)))
+17 if $GET(SCLAB)=2
SET SCX=SCX_$EXTRACT(SCSPACE,1,(52-$LENGTH(SCX)))
End DoDot:1
+18 if SCINT]""
SET SCX=SCX_$$EXTERNAL^DILFD(SCFILE,SCFLD,"",SCINT)
QTTXT QUIT SCX
DDNAME(FILE,FIELD) ;return the fieldname
+1 NEW SCX
+2 DO FIELD^DID(FILE,FIELD,"","LABEL","SCX")
+3 QUIT $GET(SCX("LABEL"))
+4 ;
MAILLST(SCTP,SCFIELDA,SCDATE,SCNEWTP,SCOLDTP,SCBADTP) ;
+1 ; Input:
+2 ; SCTP - Pointer to Team Position File (#404.57)
+3 ; SCFIELDA - Field array with internal values
+4 ; SCDATE - Effective Date
+5 ; SCNEWTP - DFN array of newly assigned to position
+6 ; SCOLDTP - DFN array of previously assigned to position
+7 ; SCBADTP - DFN array of patients unassignable to position
+8 ;
+9 ;- flag can be set to stop message generation
if $GET(SCNOMAIL)
GOTO QTMULT
+10 if '$DATA(SCNEWTP)
GOTO QTMULT
+11 ;if no new assignments
if '$ORDER(@SCNEWTP@(0))
GOTO QTMULT
+12 NEW XMDUZ,XMY,XMSUB,XMTEXT,VA,VAERR,XMZ,Y,SCTPDT,ZTQUEUED
+13 NEW SCTPNM,DFN,SCOK,SCPTNM,SCFLD,SCNODE,SCNDX,SCSPACE,SCE,SCB,SCTMNM,SCDELTEM,SCDETAIL
+14 SET ZTQUEUED=1
+15 ;ok to delete tmp global
SET SCDELTEM=1
+16 IF $DATA(SCFIELDA)
Begin DoDot:1
+17 IF $DATA(SCFIELDA(.03))
SET SCB=SCFIELDA(.03)
+18 IF $DATA(SCFIELDA(.04))
SET SCE=SCFIELDA(.04)
End DoDot:1
+19 SET SCB=$GET(SCB,DT)
+20 SET SCE=$GET(SCE,DT)
+21 SET $PIECE(SCSPACE," ",80)=""
+22 SET SCTPDT("BEGIN")=$SELECT(SCB<SCDATE:SCB,1:SCDATE)
+23 SET SCTPDT("END")=$SELECT(SCE>SCDATE:SCE,1:SCDATE)
+24 SET SCTPDT("INCL")=0
+25 SET SCTPNM=$PIECE($GET(^SCTM(404.57,+SCTP,0)),U,1)
+26 SET XMSUB="Multiple PATIENT-POSITION ASSIGNMENT for "_SCTPNM
SET XMTEXT="^TMP($J,""SCTPXM"","
SET SCLNCNT=0
+27 if '$GET(DGQUIET)
DO EN^DDIOL("Sending Multiple Patient-Position Assignment Message")
+28 SET SCOK=1
+29 SET SCTPNM=$PIECE($GET(^SCTM(404.57,+SCTP,0)),U,1)
+30 SET SCTMNM=$PIECE($GET(^SCTM(404.51,+$PIECE($GET(^SCTM(404.57,+SCTP,0)),U,2),0)),U,1)
+31 DO SETLN("Team: "_SCTMNM)
+32 DO SETLN("Position: "_SCTPNM)
+33 SET Y=SCDATE
XECUTE ^DD("DD")
+34 DO SETLN("Effective Date: "_Y)
+35 DO SETLN(" ")
+36 IF $DATA(SCFIELDA)
Begin DoDot:1
+37 FOR SCNDX=1:1:14
SET SCFLD=SCNDX*.01
IF $DATA(SCFIELDA(SCFLD))
Begin DoDot:2
+38 SET $PIECE(SCNODE,U,SCNDX)=SCFIELDA(SCFLD)
+39 DO SETLN($$TEXT(404.43,SCNODE,SCNDX,SCSPACE,1))
End DoDot:2
End DoDot:1
+40 DO SETLN(" ")
+41 DO SETLN("There has been a new position assignment for the following patients:")
+42 SET DFN=0
NEW FOR
SET DFN=$ORDER(@SCNEWTP@(DFN))
if 'DFN
QUIT
Begin DoDot:1
+1 if $$PCMMXMY^SCAPMC25(3,DFN,,"SCTPDT",0)
SET SCOK=0
+2 DO PID^VADPT6
+3 SET SCPTNM=$PIECE(^DPT(DFN,0),U,1)
+4 SET ^TMP("SCTP MAIL LST",$JOB,SCTP,1,DFN)=(" "_SCPTNM_" ("_$GET(VA("PID"))_")")
+5 SET ^TMP("SCTP MAIL LST",$JOB,SCTP,1,"B",SCPTNM,DFN)=""
End DoDot:1
+6 SET SCPTNM=""
+7 FOR
SET SCPTNM=$ORDER(^TMP("SCTP MAIL LST",$JOB,SCTP,1,"B",SCPTNM))
if SCPTNM']""
QUIT
Begin DoDot:1
+8 SET DFN=0
+9 FOR
SET DFN=$ORDER(^TMP("SCTP MAIL LST",$JOB,SCTP,1,"B",SCPTNM,DFN))
if 'DFN
QUIT
Begin DoDot:2
+10 SET SCDETAIL=$GET(^TMP("SCTP MAIL LST",$JOB,SCTP,1,DFN))
if SCDETAIL']""
QUIT
DO SETLN(SCDETAIL)
End DoDot:2
End DoDot:1
BAD IF $ORDER(@SCBADTP@(0))
Begin DoDot:1
+1 DO SETLN(" ")
+2 DO SETLN("There has been NO new position assignment for the following patients:")
+3 SET DFN=0
+4 FOR
SET DFN=$ORDER(@SCBADTP@(DFN))
if 'DFN
QUIT
Begin DoDot:2
+5 if $$PCMMXMY^SCAPMC25(3,DFN,,"SCTPDT",0)
SET SCOK=0
+6 SET SCPTNM=$PIECE(^DPT(DFN,0),U,1)
+7 DO PID^VADPT6
+8 SET ^TMP("SCTP MAIL LST",$JOB,SCTP,2,DFN)=(" "_SCPTNM_" ("_$GET(VA("PID"))_")")
+9 SET ^TMP("SCTP MAIL LST",$JOB,SCTP,2,"B",SCPTNM,DFN)=""
End DoDot:2
+10 SET SCPTNM=""
+11 FOR
SET SCPTNM=$ORDER(^TMP("SCTP MAIL LST",$JOB,SCTP,2,"B",SCPTNM))
if SCPTNM']""
QUIT
Begin DoDot:2
+12 SET DFN=0
+13 FOR
SET DFN=$ORDER(^TMP("SCTP MAIL LST",$JOB,SCTP,2,"B",SCPTNM,DFN))
if 'DFN
QUIT
Begin DoDot:3
+14 SET SCDETAIL=$GET(^TMP("SCTP MAIL LST",$JOB,SCTP,2,DFN))
if SCDETAIL']""
QUIT
DO SETLN(SCDETAIL)
End DoDot:3
End DoDot:2
End DoDot:1
+15 SET XMDUZ=$GET(DUZ,.5)
+16 DO ^XMD
QTMULT if $GET(SCDELTEM)
KILL ^TMP("SCTP MAIL LST",$JOB,SCTP)
+1 KILL ^TMP($JOB,"SCTPXM")
+2 QUIT