VistA-WorldVistAEHR/r/NOIS-FSC/FSCNOT.m

52 lines
2.0 KiB
Mathematica

FSCNOT ;SLC/STAFF NOIS Notification ;1/11/98 18:43
;;1.1;NOIS;;Sep 06, 1998
;
SETUP(CALL,LIST,LOC,USER,METHOD,EVENT) ; from FSCAFFIL, FSCEL, FSCLMPNB, FSCLP, FSCRPCN, FSCTASKU
N DA,DIE,DR,NUM
L +^FSCD("NOTIFY",0):30 I '$T Q ; *** needs ok
S NUM=1+$P(^FSCD("NOTIFY",0),U,3)
F Q:'$D(^FSCD("NOTIFY",NUM,0)) S NUM=NUM+1
S $P(^FSCD("NOTIFY",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
S ^FSCD("NOTIFY",NUM,0)=CALL,^FSCD("NOTIFY","B",CALL,NUM)=""
L -^FSCD("NOTIFY",0)
S DA=NUM,DIE=7100.2,DR=""
D
.I $G(LIST) S DR=DR_"1///`"_LIST Q
.I $G(LOC) S DR=DR_"2///`"_LOC Q
.I $G(USER) D Q
..S DR=DR_"3///`"_+USER
..I $P(USER,U,2) S DR=DR_";6///1"
I '$L(DR) Q
I $L($G(METHOD)),$L($G(EVENT)) S DR=DR_";4///"_METHOD_";5///"_EVENT
L +^FSCD("NOTIFY",NUM):30 I '$T Q ; *** needs ok
D ^DIE
L -^FSCD("NOTIFY",NUM)
Q
;
NOTINFO(CALL,USER) ; from FSCLMPNR, FSCLMPON, FSCRPCN, FSCRPCON
; returns ^TMP("FSC NOTIFY",$J,notification #) = msg
; ^TMP("FSC NOTIFY",$J,"B",msg,notification #) = ""
N MSG,NUM
S NUM=0 F S NUM=$O(^FSCD("NOTIFY","B",CALL,NUM)) Q:NUM<1 D
.D MSG(NUM,$G(USER),.MSG)
.I $L(MSG) S ^TMP("FSC NOTIFY",$J,NUM)=MSG,^TMP("FSC NOTIFY",$J,"B",$E(MSG,1,60),NUM)=""
Q
;
MSG(NUM,USER,MSG) ;
N EMAIL,EVENT,LIST,LOC,METHOD,PERSON S OK=1,MSG=""
S LIST=$P(^FSCD("NOTIFY",NUM,0),U,2),LOC=$P(^(0),U,3),PERSON=$P(^(0),U,4),METHOD=$P(^(0),U,5),EVENT=$P(^(0),U,6)
I PERSON D Q
.I USER,USER'=PERSON Q
.S MSG=METHOD_" "_$$VALUE^FSCGET(PERSON,7100.2,3)_" when "_EVENT
I LIST D Q
.S PERSON=$P(^FSC("LIST",LIST,0),U,2),METHOD=$P(^(0),U,6),EVENT=$P(^(0),U,7)
.I 'PERSON Q
.I USER,USER'=PERSON Q
.S MSG=METHOD_" "_$$VALUE^FSCGET(PERSON,7100.2,3)_" (from list: "_$$VALUE^FSCGET(LIST,7100.2,1)_") when "_EVENT
I LOC D Q
.S PERSON=$P(^FSC("SITE",LOC,0),U,6),EMAIL=$P(^(0),U,10),METHOD=$P(^(0),U,4),EVENT=$P(^(0),U,5)
.I USER,USER'=PERSON Q
.I METHOD="MAIL" S PERSON=$S($L(EMAIL):EMAIL,PERSON:$$VALUE^FSCGET(PERSON,7100.2,3),1:"") I '$L(PERSON) Q
.S MSG=METHOD_" "_PERSON_" ("_$$VALUE^FSCGET(LOC,7100.2,2)_") when "_EVENT
Q