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

FSCAFFIL.m

Go to the documentation of this file.
FSCAFFIL ;SLC/STAFF-NOIS Affiliation ;1/17/98  16:50
 ;;1.1;NOIS;;Sep 06, 1998
 ;
AFFIL(CALL) ; from FSCTASKA
 N ADD,REMOVE K ADD,REMOVE
 D CLEAN(CALL,.REMOVE,.ADD)
 I $O(REMOVE(0)) D DEL(.REMOVE)
 I $O(ADD(0)) D NEW(CALL,.ADD)
 K ADD,REMOVE
 Q
 ;
CLEAN(CALL,REMOVE,ADD) ;
 N EVENT,METHOD,MISC,NEVENT,NMETHOD,NOTNUM,PACK,PACKGP,RTD,SPEC,USER
 D CINFO(CALL,.PACK,.PACKGP,.MISC,.RTD,.SPEC)
 S USER=0 F  S USER=$O(^FSCD("NOTIFY","ACUSER",CALL,USER)) Q:USER'>0  S NOTNUM=+^(USER) I NOTNUM D
 .I $P($G(^FSCD("NOTIFY",NOTNUM,0)),U,7) Q
 .I '$D(^FSC("SPEC",USER,0)) Q  ; ** should not be processing non spec
 .D SINFO(USER,.METHOD,.EVENT)
 .I '$L(METHOD) S REMOVE(USER)=NOTNUM Q
 .I '$L(EVENT) S REMOVE(USER)=NOTNUM Q
 .I USER'=SPEC D
 ..I '$$CHECK(USER,PACK,PACKGP) S REMOVE(USER)=NOTNUM Q
 ..I MISC,$D(^FSC("SPEC","AF",1,USER)) S REMOVE(USER)=NOTNUM
 .I $D(REMOVE(USER)) Q
 .D NINFO(NOTNUM,.NMETHOD,.NEVENT)
 .I NMETHOD'=METHOD S $P(^FSCD("NOTIFY",NOTNUM,0),U,5)=METHOD
 .I NEVENT'=EVENT S $P(^FSCD("NOTIFY",NOTNUM,0),U,6)=EVENT
 I SPEC,'$D(^FSCD("NOTIFY","ACUSER",CALL,SPEC)) D CHKADD(SPEC,.ADD)
 I PACK S USER=0 F  S USER=$O(^FSC("SPEC","AP",PACK,USER)) Q:USER'>0  D
 .I $D(REMOVE(USER)) Q
 .I $D(ADD(USER)) Q
 .I $D(^FSCD("NOTIFY","ACUSER",CALL,USER)) Q
 .I RTD,$D(^FSC("SPEC","AF",2,USER)) D CHKADD(USER,.ADD)
 .I 'MISC,$D(^FSC("SPEC","AF",1,USER)) D CHKADD(USER,.ADD)
 I PACKGP S USER=0 F  S USER=$O(^FSC("SPEC","AG",PACKGP,USER)) Q:USER'>0  D
 .I $D(REMOVE(USER)) Q
 .I $D(ADD(USER)) Q
 .I $D(^FSCD("NOTIFY","ACUSER",CALL,USER)) Q
 .I '$P($G(^FSC("SPEC",USER,20,+$O(^FSC("SPEC","AG",PACKGP,USER,0)),0)),U,3) Q
 .I RTD,$D(^FSC("SPEC","AF",2,USER)) D CHKADD(USER,.ADD)
 .I 'MISC,$D(^FSC("SPEC","AF",1,USER)) D CHKADD(USER,.ADD)
 Q
 ;
CHECK(USER,PACK,PACKGP) ; $$(user,package,package group) -> 0 or 1 if ok to tag for notify
 I '$P($G(^FSC("SPEC",USER,0)),U,22) Q 0
 I PACKGP,$P($G(^FSC("SPEC",USER,20,+$O(^FSC("SPEC","AG",PACKGP,USER,0)),0)),U,3) Q 1
 I PACK,$O(^FSC("SPEC","AP",PACK,USER,0)) Q 1
 Q 0
 ;
CHKADD(USER,ADD) ;
 N EVENT,METHOD
 D SINFO(USER,.METHOD,.EVENT)
 I '$L(METHOD) Q
 I '$L(EVENT) Q
 S ADD(USER)=METHOD_U_EVENT
 Q
 ;
CINFO(CALL,PACK,PACKGP,MISC,RTD,SPEC) ;
 N ZERO,ONETW
 S ZERO=$G(^FSCD("CALL",+CALL,0)),ONETW=$G(^(120))
 S PACK=$P(ONETW,U,9)
 S PACKGP=$P(ONETW,U,13)
 S MISC=$S($P(ZERO,U,10)=5:1,1:"")
 S RTD=$S($P(ZERO,U,17):1,1:"")
 S SPEC=$P(ZERO,U,9)
 Q
 ;
SINFO(SPEC,METHOD,EVENT) ;
 S METHOD=$P($G(^FSC("SPEC",+SPEC,0)),U,14),EVENT=$P($G(^(0)),U,15)
 Q
 ;
NINFO(NUM,METHOD,EVENT) ;
 S METHOD=$P($G(^FSCD("NOTIFY",+NUM,0)),U,5),EVENT=$P($G(^(0)),U,6)
 Q
 ;
DEL(REMOVE) ;
 N USER
 S USER=0 F  S USER=$O(REMOVE(USER)) Q:USER'>0  D
 .I REMOVE(USER) D DEL^FSCUCD("^FSCD(""NOTIFY"",",REMOVE(USER))
 Q
 ;
NEW(CALL,ADD) ;
 N USER
 S USER=0 F  S USER=$O(ADD(USER)) Q:USER'>0  D
 .D SETUP^FSCNOT(CALL,,,USER,$P(ADD(USER),U),$P(ADD(USER),U,2))
 Q
 ;
TEST ; run in debug
 N CALL
 S CALL=999 F  S CALL=$O(^FSCD("CALL",CALL)) Q:CALL<1  Q:CALL>10000  W !,CALL D AFFIL(CALL)
 Q