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

XMXGRP.m

Go to the documentation of this file.
  1. XMXGRP ;ISC-SF/GMB-Group creation/enrollment ;03/31/2003 13:38
  1. ;;8.0;MailMan;**16**;Jun 28, 2002
  1. ; Entry points used by MailMan options (not covered by DBIA):
  1. ; ADDMBRS - Add new members / Edit existing members
  1. ; DELMBRS - Delete existing members
  1. ; DROP - A user chooses to drop
  1. ; JOIN - A user chooses to join
  1. ;
  1. ; DBIAs:
  1. ; 1544 - Use $$ISA^USRLM (Authorization/Subscription)
  1. ADDMBRS(XMDUZ,XMGROUP,XMMBR,XMINSTR,XMTSK) ; Add users to groups, if they aren't
  1. ; already members. This API handles adding local users, devices,
  1. ; server options, mail groups, and remote users to mail groups.
  1. ; It does not handle adding distribution lists or fax recipients
  1. ; or fax groups.
  1. ;
  1. ; Optionally, forward existing messages which are addressed to the
  1. ; groups to the users, and/or add the users to the messages, so that
  1. ; they will receive responses. (LOCAL USERS ONLY!)
  1. ; XMDUZ - The user who is doing this. Must be authorized to edit
  1. ; the mail groups.
  1. ; XMGROUP - The name or IEN (or list of same) of the groups.
  1. ; XMMBR - The user (or list of users) to add to the groups.
  1. ; XMINSTR - Special instructions
  1. ; ("FLAGS") - Flags, may contain any combination of the following:
  1. ; "A" - Add users to messages, but don't forward.
  1. ; (Messages will be delivered the next time
  1. ; someone replies, and users will be able to
  1. ; Query/Search for them at any time.)
  1. ; "F" - Forward messages to users, if the users aren't
  1. ; already on the messages.
  1. ; Closed messages will be ignored. Users will not be
  1. ; added to them.
  1. ; Note: If FLAGS contains only an "A", then FDATE and TDATE apply.
  1. ; If FLAGS contains only an "F", then FDATE and TDATE apply.
  1. ; If FLAGS contains "A" and "F", then messages from FDATE thru
  1. ; TDATE will be "F"orwarded, and all other messages will have
  1. ; the users "A"dded to them, without forwarding.
  1. ; Note: Currently, FLAGS may not contain "A". We don't yet have a way
  1. ; to mark users (recipients) who have been added to a message, but will
  1. ; not receive them until someone replies on the message, or until the
  1. ; user searches for them and reads them. This is a problem, because
  1. ; if someone does a QD on them, they have no idea why these recipients
  1. ; haven't read the message. Perhaps we could mark them 'Parked until
  1. ; next reply.' That would require a new field, and other routines would
  1. ; have to be aware of and handle this new field. Until that happens,
  1. ; we are stripping any "A" from XMINSTR("FLAGS").
  1. ; ("FDATE") - Add users to messages originating on or after this
  1. ; date. Must be FM format. Default is from the
  1. ; beginning of time. Used in conjunction with FLAGS.
  1. ; ("TDATE") - Add users to messages originating on or before this
  1. ; date. Must be FM format. Default is to the present.
  1. ; Used in conjunction with FLAGS.
  1. ; XMTSK Output task number
  1. N XMGRP,XMTO,XMCUT
  1. D CHKGRPS(XMDUZ,.XMGROUP,.XMGRP) Q:'$D(XMGRP)
  1. D CHKMBRS(XMDUZ,.XMMBR) Q:'$D(^TMP("XMY0",$J))
  1. D ADD2GRPS(.XMGRP,.XMTO,.XMINSTR)
  1. Q:'$D(XMTO) ; Quit if no local users added to groups.
  1. Q:'$D(XMINSTR("FLAGS"))
  1. I $G(XMINSTR("FDATE"),$O(^XMB(3.9,"C",2500000)))>$G(XMINSTR("TDATE"),DT) Q ; Quit if 'from' date is greater than 'to' date.
  1. S XMCUT=$P(^XMB(3.7,XMDUZ,0),U,7)
  1. I XMCUT>$G(XMINSTR("FDATE")) D
  1. . S XMINSTR("FDATE")=XMCUT
  1. . D ERRSET^XMXUTIL(37100,$$FMTE^XLFDT(XMCUT,5))
  1. . ; You may not access any message prior to |1| unless someone forwards
  1. . ; it to you.
  1. D FAFMSGS^XMXGRP1(XMDUZ,.XMGRP,.XMTO,.XMINSTR,.XMTSK)
  1. Q
  1. CHKGRPS(XMDUZ,XMGROUP,XMGRP) ;
  1. I $G(XMGROUP)]"",$O(XMGROUP(""))="" D Q
  1. . D CHKGRP(XMDUZ,XMGROUP,.XMGRP)
  1. N XMI
  1. S XMI=""
  1. F S XMI=$O(XMGROUP(XMI)) Q:XMI="" D
  1. . D CHKGRP(XMDUZ,XMI,.XMGRP)
  1. Q
  1. CHKGRP(XMDUZ,XMGROUP,XMGRP) ;
  1. N XMGNAME,XMGIEN,XMABORT
  1. S XMABORT=0
  1. D GRPOK(XMGROUP,.XMGNAME,.XMGIEN,.XMABORT) Q:XMABORT
  1. D AUTHOK(XMDUZ,.XMGIEN,.XMABORT) Q:XMABORT
  1. S XMGRP(XMGNAME)=XMGIEN
  1. Q
  1. GRPOK(XMGROUP,XMGNAME,XMGIEN,XMABORT) ;
  1. ; make sure group name is good, translate to group ien.
  1. S XMGIEN=$$IEN^XMXAPIG(XMGROUP) I 'XMGIEN S XMABORT=1 Q
  1. S XMGNAME=$$NAME^XMXAPIG(XMGIEN)
  1. Q
  1. AUTHOK(XMDUZ,XMGIEN,XMABORT) ;
  1. ; make sure user is authorized to add members to group.
  1. N XMOK
  1. S XMOK=0
  1. I $T(ISA^USRLM)'="" S XMOK=$$ISA^USRLM(DUZ,"CLINICAL COORDINATOR") ; CAC?
  1. I $D(^XUSEC("XMMGR",DUZ))!$D(^XUSEC("XM GROUP EDIT MASTER",DUZ))!XMOK I $S($P(^XMB(3.8,XMGIEN,0),U,2)="PU":1,'$P(^(0),U,6):1,1:0) Q ; If holds proper key, then group must be public or (private and) unrestricted.
  1. I $D(^XMB(3.8,"AC",XMDUZ,XMGIEN)) Q ; User is coordinator
  1. I $P($G(^XMB(3.8,XMGIEN,3)),U,1)=XMDUZ Q ; User is organizer
  1. S XMABORT=1
  1. N XMP
  1. S XMP("PARAM","ID")="XMGROUP"
  1. S XMP("PARAM","VALUE")=$$NAME^XMXAPIG(XMGIEN)
  1. ; You are not authorized to edit this mail group
  1. D ERRSET^XMXUTIL(38200,.XMP)
  1. Q
  1. CHKMBRS(XMDUZ,XMMBR) ; Check the users to add.
  1. N XMINSTR
  1. D INIT^XMXADDR
  1. S XMINSTR("ADDR FLAGS")="XY" ; Create only the ^TMP("XMY0") global.
  1. D CHKADDR^XMXADDR(XMDUZ,.XMMBR,.XMINSTR)
  1. Q:$D(^TMP("XMY0",$J))
  1. D CLEANUP^XMXADDR
  1. Q
  1. ADD2GRPS(XMGRP,XMTO,XMINSTR) ; See if members already in the groups.
  1. ; If not, add them
  1. ; >> Question: May a broadcast or limited broadcast be added to a group?
  1. N XMGN,XMGI,XMM,XMTRKNEW
  1. S (XMGN,XMM)=""
  1. F S XMGN=$O(XMGRP(XMGN)) Q:XMGN="" S XMGI=XMGRP(XMGN) D
  1. . N XMNEWMBR
  1. . F S XMM=$O(^TMP("XMY0",$J,XMM)) Q:XMM="" D
  1. . . D AM(XMGI,XMM,^TMP("XMY0",$J,XMM),$G(^(XMM,1),"@"),.XMTO,.XMINSTR)
  1. ; If we added a member group, shouldn't we also forward the msgs to
  1. ; local members of the group, too?
  1. D CLEANUP^XMXADDR
  1. Q
  1. AM(XMG,XMM,XMMIEN,XMTYPE,XMTO,XMINSTR) ; Add/edit a member (not delete)
  1. N XMFDA,XMIEN,XMMULT,XMABORT
  1. S XMABORT=0
  1. D AMINIT(XMG,.XMM,XMMIEN,.XMMULT,.XMABORT) Q:$G(XMABORT)
  1. S XMFDA(XMMULT,"?+1,"_XMG_",",.01)=XMM
  1. S XMFDA(XMMULT,"?+1,"_XMG_",",1)=XMTYPE
  1. I "AF"[$G(XMINSTR("FLAGS"),U),XMMULT=3.81 S XMTO($S(XMTYPE?1U:XMTYPE_":",1:"")_XMM)=""
  1. D UPDATE^DIE("","XMFDA","XMIEN")
  1. ;I XMIEN(1,0)="+" S XMCNT=$G(XMCNT)+1
  1. ; Need to create array showing which were added and which were edited.
  1. ; Counts for each.
  1. Q
  1. AMINIT(XMG,XMM,XMMIEN,XMMULT,XMABORT) ;
  1. I XMM["@" S XMMULT=3.812 Q ; Remote member
  1. I ".D.H.S."[("."_$E(XMM,1,2)) D Q
  1. . S XMMULT=3.812 ; Remote member
  1. . S XMM=XMM_"@"_^XMB("NETNAME")
  1. I $E(XMM,1,2)="G." D Q
  1. . I XMMIEN=XMG D Q
  1. . . S XMABORT=1
  1. . . ; Group cannot be a member of itself.
  1. . S XMM=XMMIEN
  1. . S XMMULT=3.811 ; Group member
  1. S XMM=XMMIEN
  1. S XMMULT=3.81 ; Local member
  1. Q
  1. JOIN(XMDUZ,XMGROUP,XMINSTR,XMTSK) ; User chooses to join a group.
  1. ; XMGROUP - The name (or IEN) of the group. (Just one group!)
  1. ; XMINSTR - Special instructions. See ADDMBR, above
  1. ; Also, if XMINSTR("FLAGS")["F", may specify:
  1. ; ("SELF BSKT") - direct forwarded messages to a specific basket.
  1. N XMABORT,XMGNAME,XMGIEN,XMTYPE,XMSELF,XMMBR
  1. S XMABORT=0
  1. D GRPOK(XMGROUP,.XMGNAME,.XMGIEN,.XMABORT) Q:XMABORT
  1. D GRPINFO(XMDUZ,XMGIEN,.XMTYPE,.XMSELF,.XMMBR,.XMABORT) Q:XMABORT
  1. I 'XMMBR D Q:XMABORT
  1. . I 'XMSELF D Q
  1. . . S XMABORT=1
  1. . . N XMP
  1. . . S XMP("PARAM","ID")="XMGROUP"
  1. . . S XMP("PARAM","VALUE")=XMGNAME
  1. . . D ERRSET^XMXUTIL(38022,.XMP) ; Self enrollment not allowed.
  1. . N XMFDA ; Add user to group.
  1. . S XMFDA(3.81,"?+1,"_XMGIEN_",",.01)=XMDUZ
  1. . D UPDATE^DIE("","XMFDA")
  1. Q:'$D(XMINSTR("FLAGS"))
  1. D FAFMSGS^XMXGRP1(XMDUZ,XMGNAME,XMDUZ,.XMINSTR,.XMTSK)
  1. Q
  1. DROP(XMDUZ,XMGROUP) ; User chooses to drop from a group.
  1. ; XMGROUP - The name (or IEN) of the group.
  1. N XMABORT,XMGNAME,XMGIEN,XMTYPE,XMSELF,XMMBR
  1. S XMABORT=0
  1. D GRPOK(XMGROUP,.XMGNAME,.XMGIEN,.XMABORT) Q:XMABORT
  1. D GRPINFO(XMDUZ,XMGIEN,.XMTYPE,.XMSELF,.XMMBR,.XMABORT) Q:XMABORT
  1. I XMMBR D
  1. . I 'XMSELF,'$P($G(^XMB(1,1,2)),U,2) D Q
  1. . . S XMABORT=1
  1. . . N XMP
  1. . . S XMP("PARAM","ID")="XMGROUP"
  1. . . S XMP("PARAM","VALUE")=XMGNAME
  1. . . D ERRSET^XMXUTIL(38022.1,.XMP) ; Self dis-enrollment not allowed.
  1. . N DIR,X,Y,DA,DIK ; Drop user from group.
  1. . S DA(1)=XMGIEN,DA=XMMBR,DIK="^XMB(3.8,"_XMGIEN_",1,"
  1. . D ^DIK
  1. Q
  1. GRPINFO(XMDUZ,XMGIEN,XMTYPE,XMSELF,XMMBR,XMABORT) ;
  1. N XMREC
  1. S XMMBR=+$O(^XMB(3.8,XMGIEN,1,"B",XMDUZ,0)) ; Is user a member?
  1. S XMREC=^XMB(3.8,XMGIEN,0)
  1. S XMSELF=($P(XMREC,U,3)="y") ; Self enrollment allowed?
  1. S XMTYPE=$P(XMREC,U,2) ; Public or Private?
  1. I XMTYPE="PU"
  1. E I XMTYPE="PR" D
  1. . Q:XMMBR
  1. . S XMABORT=1
  1. . N XMP
  1. . S XMP("PARAM","ID")="XMGROUP"
  1. . S XMP("PARAM","VALUE")=$P(XMREC,U,1)
  1. . D ERRSET^XMXUTIL(38201) ; Group is private.
  1. ;E D
  1. ;. S XMABORT=1
  1. ;. D ERRSET^XMXUTIL() ; Group must be designated as PUBLIC or PRIVATE.
  1. Q
  1. ADD2GRPZ(XMGRP,XMMBR,XMTO) ; See if members already in the groups.
  1. ; If not, add them
  1. N XMGN,XMGI,XMM,XMTRKNEW
  1. S (XMGN,XMM)="",XMTRKNEW=1
  1. F S XMGN=$O(XMGRP(XMGN)) Q:XMGN="" S XMGI=XMGRP(XMGN) D
  1. . N XMNEWMBR
  1. . F S XMM=$O(XMMBR(XMM)) Q:XMM="" D
  1. . . D AMZ(XMGI,XMMBR(XMM),$G(XMMBR(XMM,1),"@"),.XMTO)
  1. . I $G(XMNEWMBR) D NOTIFY^XMXGRP1(XMGI,.XMNEWMBR)
  1. Q
  1. AMZ(XMG,XMM,XMTYPE,XMTO) ; Add/edit a member (not delete)
  1. N XMFDA,XMIEN
  1. S XMFDA(3.81,"?+1,"_XMG_",",.01)=XMM
  1. S XMFDA(3.81,"?+1,"_XMG_",",1)=XMTYPE
  1. S XMTO($S(XMTYPE?1U:XMTYPE_":",1:"")_XMM)=""
  1. D UPDATE^DIE("","XMFDA","XMIEN")
  1. ;I XMIEN(1,0)="+" S XMCNT=$G(XMCNT)+1
  1. ; Need to create array showing which were added and which were edited.
  1. ; Counts for each.
  1. Q