FSCNOTS ;SLC/STAFF-NOIS Notification Send ;1/13/98 13:58
;;1.1;NOIS;;Sep 06, 1998
;
NOTIFY(CALL) ; from FSCTASKU
N ADDRESS,ARRAY,DA,DIK,EVENT,MAILMSG,METHOD,MSG,NOTIFY,NUM,OK,USER K ARRAY
S NUM=0 F S NUM=$O(^FSCD("NOTIFY","B",CALL,NUM)) Q:NUM<1 D
.S NOTIFY=^FSCD("NOTIFY",NUM,0)
.D GET(NOTIFY,.USER,.METHOD,.EVENT,.ADDRESS)
.D SEND(NOTIFY,CALL,EVENT,USER,.OK,.MSG) I OK D
..I METHOD="MAIL" D Q
...S MAILMSG=$S('$D(MAILMSG):MSG,1:$S(MSG["Status":MSG,1:MAILMSG))
...I $L(ADDRESS) S ARRAY(ADDRESS)="",ARRAY(ADDRESS,1)="I" Q
...S ARRAY(USER)="",ARRAY(USER,1)="I"
..I METHOD="ALERT" D ALERT(CALL,USER,MSG) Q
.I EVENT="ADDED" S DA=NUM,DIK="^FSCD(""NOTIFY""," D ^DIK
.I EVENT="CLOSED" S DA=NUM,DIK="^FSCD(""NOTIFY""," D ^DIK
I $L($O(ARRAY(0))) D MAIL(CALL,.ARRAY,MAILMSG)
Q
;
GET(NOTIFY,USER,METHOD,EVENT,ADDRESS) ; from FSCTASKN
N CALL,LIST,LOC S ADDRESS=""
S CALL=$P(NOTIFY,U),LIST=$P(NOTIFY,U,2),LOC=$P(NOTIFY,U,3),USER=$P(NOTIFY,U,4),METHOD=$P(NOTIFY,U,5),EVENT=$P(NOTIFY,U,6)
I USER S ADDRESS=$P($G(^FSC("SPEC",USER,0)),U,6) S:'$L(ADDRESS) ADDRESS=USER Q
I LIST S USER=$P(^FSC("LIST",LIST,0),U,2),METHOD=$P(^(0),U,6),EVENT=$P(^(0),U,7),ADDRESS=$P($G(^FSC("SPEC",USER,0)),U,6) S:'$L(ADDRESS) ADDRESS=USER Q
I LOC S USER=$P(^FSC("SITE",LOC,0),U,6),METHOD=$P(^(0),U,4),EVENT=$P(^(0),U,5),ADDRESS=$P(^(0),U,10) S:'$L(ADDRESS) ADDRESS=USER
Q
;
SEND(NOTIFY,CALL,EVENT,USER,OK,MSG) ; (notify zero node,call,event,user for notification,ok,msg) returns ok to send notification and msg
N EDITTIME,EDITUSER,FROM,LOG,STATTIME,TO,USERFLAG S OK=0,MSG=""
S EDITTIME=$P(^FSCD("CALL",CALL,120),U,4),EDITUSER=$P(^(120),U,5),STATTIME=$P(^(120),U,2),FROM=$P(^(120),U,8),TO=$P(^(0),U,24)
I EDITUSER=USER Q
I 'USER Q
S USERFLAG=$S($$ACCESS^FSCU(EDITUSER,"SPEC"):"",1:"<non Specialist> ")
I EVENT="EDITED" D Q
.S OK=1,MSG="Edited by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$P($$FMTE^XLFDT(EDITTIME),":",1,2)_"."
I EVENT="STATUS CHANGED",EDITTIME=STATTIME D Q
.S FROM=$$VALUE^FSCGET(FROM,7100,4.6),TO=$$VALUE^FSCGET(TO,7100,4.5)
.S OK=1,MSG="Status changed "_$S($L(FROM):"from "_FROM_" ",1:"")_"to "_TO_" by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$P($$FMTE^XLFDT(EDITTIME),":",1,2)_"."
I EVENT="ADDED" D Q
.S OK=1,MSG="Call added to "_$P($G(^FSC("LIST",+$P(NOTIFY,U,2),0)),U)_" "_$$FMTE^XLFDT(DT)_"."
I EVENT="CLOSED" D Q
.S OK=1,MSG="Call Closed by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$$FMTE^XLFDT(DT)_"."
Q
;
MAIL(CALL,XMY,MAILMSG) ; from FSCTASKN
N XMDUZ,XMSUB,XMTEXT K ^TMP("FSC MAIL DETAIL",$J)
S XMDUZ="NOIS Notification",XMSUB=$$SHORT^FSCGETS(CALL,"NOIS:")
I XMSUB[U S XMSUB=$$REPLACE^FSCRU(XMSUB,U,"~U~")
D
.I $D(^XTMP("FSC CALL DETAIL",CALL)) S XMTEXT="^XTMP(""FSC CALL DETAIL"","_CALL_"," Q
.S ^TMP("FSC MAIL DETAIL",$J,0,1,0)=MAILMSG
.S ^TMP("FSC MAIL DETAIL",$J,0,2,0)=" "
.D BUILD^FSCFORM(0,CALL,"DETAIL",2,"FSC MAIL ") S XMTEXT="^TMP(""FSC MAIL DETAIL"",$J,0,"
D ^XMD
K ^TMP("FSC MAIL DETAIL",$J)
Q
;
ALERT(CALL,USER,MSG) ; from FSCTASKN
I '$L(USER) Q
N NUM,ON,XQA,XQADATA,XQAID,XQAMSG,XAQROU K XQA S ON=1
I '$G(^FSCD("ALERT","ALERT",USER)) S ON=0
S NUM=$G(^FSCD("ALERT","AUC",USER,CALL))
D
.I NUM S $P(^FSCD("ALERT",NUM,0),U,3)=MSG Q
.D NEWALERT(USER,CALL,MSG)
I ON Q
S XQA(USER)="",XQADATA="",XQAMSG="NOIS Calls",XQAROU="USER^FSCNAR",XQAID="FSC-A"
D SETUP^XQALERT
Q
;
NEWALERT(USER,CALL,MSG,NUM,DELIVERY) ; from FSCNAS, FSCRPCN
N DA,DIK
S CALL=$G(CALL),MSG=$G(MSG),DELIVERY=$G(DELIVERY)
S NUM=1+$P(^FSCD("ALERT",0),U,3)
L +^FSCD("ALERT",0):30 I '$T Q ; *** needs ok
F Q:'$D(^FSCD("ALERT",NUM,0)) S NUM=NUM+1
I DELIVERY S ^FSCD("ALERT",NUM,0)=USER_U_CALL_U_MSG_"^^"_DELIVERY
E S ^FSCD("ALERT",NUM,0)=USER_U_CALL_U_MSG_U_$$NOW^XLFDT
S $P(^FSCD("ALERT",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
L -^FSCD("ALERT",0)
S DIK="^FSCD(""ALERT"",",DA=NUM D IX1^DIK
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFSCNOTS 3954 printed Dec 13, 2024@02:18:48 Page 2
FSCNOTS ;SLC/STAFF-NOIS Notification Send ;1/13/98 13:58
+1 ;;1.1;NOIS;;Sep 06, 1998
+2 ;
NOTIFY(CALL) ; from FSCTASKU
+1 NEW ADDRESS,ARRAY,DA,DIK,EVENT,MAILMSG,METHOD,MSG,NOTIFY,NUM,OK,USER
KILL ARRAY
+2 SET NUM=0
FOR
SET NUM=$ORDER(^FSCD("NOTIFY","B",CALL,NUM))
if NUM<1
QUIT
Begin DoDot:1
+3 SET NOTIFY=^FSCD("NOTIFY",NUM,0)
+4 DO GET(NOTIFY,.USER,.METHOD,.EVENT,.ADDRESS)
+5 DO SEND(NOTIFY,CALL,EVENT,USER,.OK,.MSG)
IF OK
Begin DoDot:2
+6 IF METHOD="MAIL"
Begin DoDot:3
+7 SET MAILMSG=$SELECT('$DATA(MAILMSG):MSG,1:$SELECT(MSG["Status":MSG,1:MAILMSG))
+8 IF $LENGTH(ADDRESS)
SET ARRAY(ADDRESS)=""
SET ARRAY(ADDRESS,1)="I"
QUIT
+9 SET ARRAY(USER)=""
SET ARRAY(USER,1)="I"
End DoDot:3
QUIT
+10 IF METHOD="ALERT"
DO ALERT(CALL,USER,MSG)
QUIT
End DoDot:2
+11 IF EVENT="ADDED"
SET DA=NUM
SET DIK="^FSCD(""NOTIFY"","
DO ^DIK
+12 IF EVENT="CLOSED"
SET DA=NUM
SET DIK="^FSCD(""NOTIFY"","
DO ^DIK
End DoDot:1
+13 IF $LENGTH($ORDER(ARRAY(0)))
DO MAIL(CALL,.ARRAY,MAILMSG)
+14 QUIT
+15 ;
GET(NOTIFY,USER,METHOD,EVENT,ADDRESS) ; from FSCTASKN
+1 NEW CALL,LIST,LOC
SET ADDRESS=""
+2 SET CALL=$PIECE(NOTIFY,U)
SET LIST=$PIECE(NOTIFY,U,2)
SET LOC=$PIECE(NOTIFY,U,3)
SET USER=$PIECE(NOTIFY,U,4)
SET METHOD=$PIECE(NOTIFY,U,5)
SET EVENT=$PIECE(NOTIFY,U,6)
+3 IF USER
SET ADDRESS=$PIECE($GET(^FSC("SPEC",USER,0)),U,6)
if '$LENGTH(ADDRESS)
SET ADDRESS=USER
QUIT
+4 IF LIST
SET USER=$PIECE(^FSC("LIST",LIST,0),U,2)
SET METHOD=$PIECE(^(0),U,6)
SET EVENT=$PIECE(^(0),U,7)
SET ADDRESS=$PIECE($GET(^FSC("SPEC",USER,0)),U,6)
if '$LENGTH(ADDRESS)
SET ADDRESS=USER
QUIT
+5 IF LOC
SET USER=$PIECE(^FSC("SITE",LOC,0),U,6)
SET METHOD=$PIECE(^(0),U,4)
SET EVENT=$PIECE(^(0),U,5)
SET ADDRESS=$PIECE(^(0),U,10)
if '$LENGTH(ADDRESS)
SET ADDRESS=USER
+6 QUIT
+7 ;
SEND(NOTIFY,CALL,EVENT,USER,OK,MSG) ; (notify zero node,call,event,user for notification,ok,msg) returns ok to send notification and msg
+1 NEW EDITTIME,EDITUSER,FROM,LOG,STATTIME,TO,USERFLAG
SET OK=0
SET MSG=""
+2 SET EDITTIME=$PIECE(^FSCD("CALL",CALL,120),U,4)
SET EDITUSER=$PIECE(^(120),U,5)
SET STATTIME=$PIECE(^(120),U,2)
SET FROM=$PIECE(^(120),U,8)
SET TO=$PIECE(^(0),U,24)
+3 IF EDITUSER=USER
QUIT
+4 IF 'USER
QUIT
+5 SET USERFLAG=$SELECT($$ACCESS^FSCU(EDITUSER,"SPEC"):"",1:"<non Specialist> ")
+6 IF EVENT="EDITED"
Begin DoDot:1
+7 SET OK=1
SET MSG="Edited by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$PIECE($$FMTE^XLFDT(EDITTIME),":",1,2)_"."
End DoDot:1
QUIT
+8 IF EVENT="STATUS CHANGED"
IF EDITTIME=STATTIME
Begin DoDot:1
+9 SET FROM=$$VALUE^FSCGET(FROM,7100,4.6)
SET TO=$$VALUE^FSCGET(TO,7100,4.5)
+10 SET OK=1
SET MSG="Status changed "_$SELECT($LENGTH(FROM):"from "_FROM_" ",1:"")_"to "_TO_" by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$PIECE($$FMTE^XLFDT(EDITTIME),":",1,2)_"."
End DoDot:1
QUIT
+11 IF EVENT="ADDED"
Begin DoDot:1
+12 SET OK=1
SET MSG="Call added to "_$PIECE($GET(^FSC("LIST",+$PIECE(NOTIFY,U,2),0)),U)_" "_$$FMTE^XLFDT(DT)_"."
End DoDot:1
QUIT
+13 IF EVENT="CLOSED"
Begin DoDot:1
+14 SET OK=1
SET MSG="Call Closed by "_USERFLAG_$$VALUE^FSCGET(EDITUSER,7100,124)_" on "_$$FMTE^XLFDT(DT)_"."
End DoDot:1
QUIT
+15 QUIT
+16 ;
MAIL(CALL,XMY,MAILMSG) ; from FSCTASKN
+1 NEW XMDUZ,XMSUB,XMTEXT
KILL ^TMP("FSC MAIL DETAIL",$JOB)
+2 SET XMDUZ="NOIS Notification"
SET XMSUB=$$SHORT^FSCGETS(CALL,"NOIS:")
+3 IF XMSUB[U
SET XMSUB=$$REPLACE^FSCRU(XMSUB,U,"~U~")
+4 Begin DoDot:1
+5 IF $DATA(^XTMP("FSC CALL DETAIL",CALL))
SET XMTEXT="^XTMP(""FSC CALL DETAIL"","_CALL_","
QUIT
+6 SET ^TMP("FSC MAIL DETAIL",$JOB,0,1,0)=MAILMSG
+7 SET ^TMP("FSC MAIL DETAIL",$JOB,0,2,0)=" "
+8 DO BUILD^FSCFORM(0,CALL,"DETAIL",2,"FSC MAIL ")
SET XMTEXT="^TMP(""FSC MAIL DETAIL"",$J,0,"
End DoDot:1
+9 DO ^XMD
+10 KILL ^TMP("FSC MAIL DETAIL",$JOB)
+11 QUIT
+12 ;
ALERT(CALL,USER,MSG) ; from FSCTASKN
+1 IF '$LENGTH(USER)
QUIT
+2 NEW NUM,ON,XQA,XQADATA,XQAID,XQAMSG,XAQROU
KILL XQA
SET ON=1
+3 IF '$GET(^FSCD("ALERT","ALERT",USER))
SET ON=0
+4 SET NUM=$GET(^FSCD("ALERT","AUC",USER,CALL))
+5 Begin DoDot:1
+6 IF NUM
SET $PIECE(^FSCD("ALERT",NUM,0),U,3)=MSG
QUIT
+7 DO NEWALERT(USER,CALL,MSG)
End DoDot:1
+8 IF ON
QUIT
+9 SET XQA(USER)=""
SET XQADATA=""
SET XQAMSG="NOIS Calls"
SET XQAROU="USER^FSCNAR"
SET XQAID="FSC-A"
+10 DO SETUP^XQALERT
+11 QUIT
+12 ;
NEWALERT(USER,CALL,MSG,NUM,DELIVERY) ; from FSCNAS, FSCRPCN
+1 NEW DA,DIK
+2 SET CALL=$GET(CALL)
SET MSG=$GET(MSG)
SET DELIVERY=$GET(DELIVERY)
+3 SET NUM=1+$PIECE(^FSCD("ALERT",0),U,3)
+4 ; *** needs ok
LOCK +^FSCD("ALERT",0):30
IF '$TEST
QUIT
+5 FOR
if '$DATA(^FSCD("ALERT",NUM,0))
QUIT
SET NUM=NUM+1
+6 IF DELIVERY
SET ^FSCD("ALERT",NUM,0)=USER_U_CALL_U_MSG_"^^"_DELIVERY
+7 IF '$TEST
SET ^FSCD("ALERT",NUM,0)=USER_U_CALL_U_MSG_U_$$NOW^XLFDT
+8 SET $PIECE(^FSCD("ALERT",0),U,3)=NUM
SET $PIECE(^(0),U,4)=$PIECE(^(0),U,4)+1
+9 LOCK -^FSCD("ALERT",0)
+10 SET DIK="^FSCD(""ALERT"","
SET DA=NUM
DO IX1^DIK
+11 QUIT