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

XMVGROUP.m

Go to the documentation of this file.
  1. XMVGROUP ;ISC-SF/GMB-Group creation/enrollment ;04/15/2003 12:50
  1. ;;8.0;MailMan;**18**;Jun 28, 2002
  1. ; Replaces JOIN, ENT^XMA7G & ^XMA7G1 (ISC-WASH/RJ/THM/CAP/JA)
  1. ; Entry points used by MailMan options (not covered by DBIA):
  1. ; EDITMG XMEDITMG - Mail Group Edit
  1. ; ENROLL XMENROLL - Enroll in / Disenroll from a group
  1. ; LCOORD XMMGR-MAIL-GRP-COORDINATOR
  1. ; RCOORD XMMGR-MAIL-GRP-COORD-W/REMOTES
  1. ; PERSONAL XMEDITPERSGROUP - Edit user's personal group.
  1. ;
  1. ; DBIAs:
  1. ; 1544 - Use $$ISA^USRLM (Authorization/Subscription)
  1. ENROLL ; Enroll in / Disenroll from a group
  1. N DIC,Y,XMABORT,XMIEN,XMSELF,XMIA
  1. S XMABORT=0
  1. S:'$D(XMDUZ) XMDUZ=DUZ
  1. S XMSELF=+$P($G(^XMB(1,1,2)),U,2) ; Is self-disenrollment allowed in a non-self enrolling mail group?
  1. F D Q:XMABORT
  1. . S DIC="^XMB(3.8,",DIC(0)="AEQMZ"
  1. . S DIC("S")="I $S($P(^(0),U,2)=""PU"":1,$D(^XMB(3.8,+Y,1,""B"",XMDUZ)):1,1:0)"
  1. . S DIC("W")="W:$D(^XMB(3.8,+Y,1,""B"",XMDUZ)) ?35,"""_$$EZBLD^DIALOG(38020)_""" I $P(^XMB(3.8,+Y,0),U,3)'=""y"" W ?43,"""_$$EZBLD^DIALOG(38021)_"""" ; Member / ...Self Enrollment Not Allowed.
  1. . W !
  1. . D ^DIC I Y<0 S XMABORT=1 Q
  1. . S XMIEN=+Y
  1. . I $D(^XMB(3.8,XMIEN,1,"B",XMDUZ)) D Q
  1. . . I $P(^XMB(3.8,XMIEN,0),U,3)'="y",'XMSELF W !,$$EZBLD^DIALOG(38022.1) Q ;Self enrollment is not allowed for this mail group.
  1. . . D DROP(XMIEN,XMDUZ)
  1. . I $P(^XMB(3.8,XMIEN,0),U,3)'="y" W !,$$EZBLD^DIALOG(38022) Q ;Self enrollment is not allowed for this mail group.
  1. . D JOIN(XMIEN,XMDUZ)
  1. Q
  1. JOIN(XMIEN,XMDUZ) ; Enroll in a group
  1. N XMFDA
  1. S XMFDA(3.81,"+1,"_XMIEN_",",.01)=XMDUZ
  1. D UPDATE^DIE("","XMFDA")
  1. W !,$$EZBLD^DIALOG(38023) ;You are now a member.
  1. N DIR,X,Y
  1. S DIR(0)="Y"
  1. ; Do you want past messages to this group to be forwarded to you?
  1. D BLD^DIALOG(38023.1,"","","DIR(""A"")")
  1. S DIR("B")=$$EZBLD^DIALOG(39053) ; no
  1. D BLD^DIALOG(38232,"","","DIR(""?"")")
  1. ;Answer YES to forward past mail group messages.
  1. ;You will be asked for a time frame to search,
  1. ;and then MailMan will create a task to find and forward
  1. ;existing mail group messages.
  1. D ^DIR Q:$D(DIRUT)!'Y
  1. N XMINSTR,XMTSK,XMABORT
  1. I '$D(XMV) N XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV D INITAPI^XMVVITAE
  1. S XMABORT=0,XMINSTR("FLAGS")="F"
  1. D FWDBSKT(XMDUZ,.XMINSTR,.XMABORT) Q:XMABORT
  1. D FWDDATES^XMVGRP(XMDUZ,.XMINSTR,.XMABORT) Q:XMABORT
  1. D FAFMSGS^XMXGRP1(XMDUZ,$P($G(^XMB(3.8,XMIEN,0)),U,1),XMDUZ,.XMINSTR,.XMTSK)
  1. D FWDTSK(XMTSK)
  1. Q
  1. FWDBSKT(XMDUZ,XMINSTR,XMABORT) ; Select basket to forward to
  1. N XMDIC,XMK
  1. S XMDIC("B")=$$EZBLD^DIALOG(37005) ;IN
  1. D SELBSKT^XMJBU(XMDUZ,39022,"L",.XMDIC,.XMK) I XMK=U S XMABORT=1 Q
  1. S XMINSTR("SELF BSKT")=XMK
  1. Q
  1. FWDTSK(XMTSK) ;
  1. W !
  1. ;Task #|1| will find and forward past messages.
  1. N XMTEXT
  1. D BLD^DIALOG(38023.9,XMTSK,"","XMTEXT","F")
  1. D MSG^DIALOG("WM","",IOM,"","XMTEXT")
  1. Q
  1. DROP(XMIEN,XMDUZ) ; Disenroll from a group
  1. N DIR,X,Y
  1. S DIR(0)="Y"
  1. I $P(^XMB(3.8,XMIEN,0),U,3)'="y" D
  1. . ;You're a member. Self enrollment is not allowed for this mail group.
  1. . ;If you drop out, you will not be able to re-join. (To re-join later,
  1. . ;you will have to ask the group coordinator to re-enroll you.)
  1. . ;You are a member. Do you want to drop out
  1. . D BLD^DIALOG(38024.1,"","","DIR(""A"")")
  1. E D ;You are a member. Do you want to drop out
  1. . S DIR("A")=$$EZBLD^DIALOG(38024)
  1. S DIR("B")=$$EZBLD^DIALOG(39053) ;No
  1. ;Enter YES to remove yourself from the group; NO to remain a member.
  1. D BLD^DIALOG(38025,"","","DIR(""?"")")
  1. D ^DIR Q:$D(DIRUT)!'Y
  1. K DIR,X,Y
  1. N DA,DIK
  1. S DA(1)=XMIEN,DA=$O(^XMB(3.8,XMIEN,1,"B",XMDUZ,0)),DIK="^XMB(3.8,"_XMIEN_",1,"
  1. D ^DIK
  1. W !,$$EZBLD^DIALOG(38026) ;You are no longer a member.
  1. Q
  1. PERSONAL ; Enter/Edit Personal Group
  1. ; See entry EDIT for info on XMIA & XMTRKNEW
  1. N DIC,DLAYGO,X,Y,XMABORT,XMIA,XMTRKNEW
  1. S XMABORT=0,(XMIA,XMTRKNEW)=1
  1. S DIC="^XMB(3.8,",DIC(0)="AEQMZL",DLAYGO=3.8
  1. ; Group is private, and user is organizer
  1. S DIC("S")="I $P(^(0),U,2)=""PR"",$P($G(^XMB(3.8,+Y,3)),U)=$G(XMDUZ,DUZ)"
  1. F D Q:XMABORT
  1. . W !
  1. . D ^DIC I Y<0 S XMABORT=1 Q
  1. . N XMDR,XMNEW
  1. . S XMNEW=$P(Y,U,3)
  1. . S:XMNEW XMDR="4////PR;5////"_$G(XMDUZ,DUZ)_";10////1;"
  1. . S XMDR=$G(XMDR)_".01T;2;3" ; name, members, description
  1. . S XMDR=XMDR_";10;12" ; restrictions, remote members
  1. . D EDIT(+Y,XMDR,XMNEW)
  1. Q
  1. EDIT(XMG,DR,XMNEW) ; Edit mail group
  1. ; XMIA is used for interaction on the REMOTE MEMBER input transform
  1. ; to facilitate lookup. XMTRKNEW is used by the AC xref on the
  1. ; .01 field of the LOCAL MEMBER multiple. If local members are added
  1. ; to the group, XMNEWMBR is set by the AC xref.
  1. N DIE,DIDEL,Y,DIC,DA,XMNEWMBR
  1. S (DIDEL,DIE)=3.8,DA=XMG
  1. S:$P(^XMB(1,1,0),U,19) DR=DR_";14;15" ; fax recipients, fax groups
  1. D ^DIE
  1. I 'XMNEW,$D(XMNEWMBR) D FWD(XMG,.XMNEWMBR)
  1. Q
  1. FWD(XMG,XMTO) ; Forward past mail group messages to new local members
  1. N XMI
  1. S XMI=""
  1. F S XMI=$O(XMTO(XMI)) Q:'XMI K:'$D(^XMB(3.8,XMG,1,"B",XMI)) XMTO(XMI)
  1. Q:'$D(XMTO)
  1. I '$D(XMV) N XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV D INITAPI^XMVVITAE
  1. D NOTIFY^XMXGRP1(XMG,.XMTO)
  1. N XMINSTR,XMTSK,XMABORT
  1. S XMABORT=0
  1. D ENFWD^XMVGRP(XMDUZ,.XMINSTR,.XMABORT) Q:XMABORT
  1. D FAFMSGS^XMXGRP1(XMDUZ,$P(^XMB(3.8,XMG,0),U,1),.XMTO,.XMINSTR,.XMTSK)
  1. D FWDTSK(XMTSK)
  1. Q
  1. LAYGO(X) ; Prevent someone from adding a (private) group with the same name as a public one.
  1. ; This function is invoked by the LAYGO field of ^XMB(3.8,.01)
  1. ; Returns 1 if group X may be created; 0 if not.
  1. N IEN,LAYGO
  1. S IEN="",LAYGO=1
  1. F S IEN=$O(^XMB(3.8,"B",X,IEN)) Q:IEN="" D Q:'LAYGO
  1. . Q:$P(^XMB(3.8,IEN,0),U,2)="PR"
  1. . S LAYGO=0 ;Can't add it because public group '|1|' already exists.
  1. . D EN^DDIOL($$EZBLD^DIALOG(38027,X),"","!,$C(7)")
  1. Q LAYGO
  1. REMOTE(XMADDR,XMIA) ; Serves as input transform for 'remote member'
  1. ; Allow remote addressees or local devices or local servers
  1. N XMERROR,XMRESTR,XMINSTR,XMFULL,XMPREFIX,DIX,DO,XMFWDADD
  1. S XMINSTR("ADDR FLAGS")="X" ; do not create ^TMP(, just check.
  1. I XMADDR[":" D Q:'$D(XMADDR)
  1. . D RTYPE^XMXADDR($P(XMADDR,":")) I $D(XMERROR) K XMADDR Q
  1. . D PREFIX^XMXADDR(.XMADDR,.XMPREFIX) I $D(XMERROR) K XMADDR Q
  1. I XMADDR'["@",".D.d.H.h.S.s."'[("."_$E(XMADDR,1,2)),'$D(XMPREFIX) K XMADDR Q
  1. D ADDRESS^XMXADDR(DUZ,XMADDR,.XMFULL,.XMERROR)
  1. I $D(XMERROR) K XMADDR Q
  1. I XMFULL'["@" D
  1. . I ".D.H.S."[("."_$E(XMFULL,1,2)) S XMFULL=XMFULL_"@"_^XMB("NETNAME") Q
  1. . ;I $G(XMPREFIX)'="" S XMFULL=XMFULL_"@"_^XMB("NETNAME") Q
  1. I XMFULL'["@" D Q
  1. . K XMADDR
  1. . D EN^DDIOL($$EZBLD^DIALOG(38028)) ;It can't be a local address, except for Device or Server.
  1. . I $E(XMFULL,1,2)="G." D EN^DDIOL($$EZBLD^DIALOG(38029)) ;Put the group in the MEMBER GROUP multiple.
  1. . E D EN^DDIOL($$EZBLD^DIALOG(38030)) ;Put the person in the MEMBER multiple.
  1. . I $G(XMPREFIX)'="" D EN^DDIOL($$EZBLD^DIALOG(38031,XMPREFIX)) ;Put '|1|' in the TYPE field.
  1. I $G(XMPREFIX)'="" S XMFULL=XMPREFIX_":"_XMFULL
  1. S XMADDR=XMFULL
  1. Q
  1. EDITMG ; Mail Group Edit
  1. ; See entry EDIT for info on XMIA & XMTRKNEW
  1. N DIC,XMABORT,DLAYGO,X,Y,XMIA,XMTRKNEW,XMREC
  1. S XMABORT=0,(XMIA,XMTRKNEW)=1,DLAYGO=3.8
  1. S DIC(0)="AEQLM",DIC="^XMB(3.8,"
  1. S DIC("S")=$$GRPSCR(0)
  1. F D Q:XMABORT
  1. . W !
  1. . D ^DIC I Y<0 S XMABORT=1 Q
  1. . N XMDR
  1. . S XMDR=".01T;2;3" ; name, members, description
  1. . ; type - if type is public, ask about self enrollment,
  1. . ; else ask about restrictions.
  1. . S XMDR=XMDR_";4;I X=""PU"" S Y=7;10;S Y=5;7"
  1. . S XMDR=XMDR_";5:6.9" ; organizer, coordinator, authorized senders
  1. . S XMDR=XMDR_";10.1:13.9" ; member groups, remote members, distr list
  1. . D EDIT(+Y,XMDR,$P(Y,U,3))
  1. Q
  1. GRPSCR(XMCOORD) ; Who may edit a mail group?
  1. N XMSCR,XMOK
  1. S XMOK=0
  1. I $T(ISA^USRLM)'="" S XMOK=$$ISA^USRLM(DUZ,"CLINICAL COORDINATOR")
  1. I $D(^XUSEC("XMMGR",DUZ))!$D(^XUSEC("XM GROUP EDIT MASTER",DUZ))!XMOK D
  1. . ; Screen whether group is public or (private and) unrestricted
  1. . S XMSCR="N XMREC S XMREC=^(0) I $P(XMREC,U,2)=""PU""!'$P(XMREC,U,6)!"
  1. E S XMSCR="I " ; Or, at the very minimum,
  1. ; Screen whether user is organizer or coordinator.
  1. Q XMSCR_"($P($G(^XMB(3.8,+Y,3)),U,1)=$G(XMDUZ,DUZ))"_$S($G(XMCOORD):"!$D(^XMB(3.8,""AC"",$G(XMDUZ,DUZ),+Y))",1:"")
  1. ;
  1. LCOORD ; Mail Group Coordinator edit w/o remote members
  1. D COORD(0)
  1. Q
  1. RCOORD ; Mail Group Coordinator edit w/remote members
  1. D COORD(1)
  1. Q
  1. COORD(XMREMOTE) ;
  1. ; See entry EDIT for info on XMIA & XMTRKNEW
  1. N DIC,XMABORT,DLAYGO,X,Y,XMIA,XMTRKNEW
  1. S XMABORT=0,(XMIA,XMTRKNEW)=1
  1. S DIC(0)="AEQM",DIC="^XMB(3.8,"
  1. S DIC("S")=$$GRPSCR(1)
  1. F D Q:XMABORT
  1. . W !
  1. . D ^DIC I Y<0 S XMABORT=1 Q
  1. . ; edit local members, member groups, & perhaps, remote members
  1. . D EDIT(+Y,"2;11"_$S(XMREMOTE:";12",1:""),0)
  1. Q