| 1 | XMB ;ISC-SF/GMB-Send Bulletin APIs ;04/17/2002  07:38 | 
|---|
| 2 | ;;8.0;MailMan;;Jun 28, 2002 | 
|---|
| 3 | ; Was (WASH ISC)/THM/RWF/CAP | 
|---|
| 4 | ; | 
|---|
| 5 | ; Entry points are (DBIA 10069): | 
|---|
| 6 | ; ^XMB     Create and deliver a bulletin in the background (task). | 
|---|
| 7 | ; EN^XMB   Create a bulletin in the foreground (now) and send it in | 
|---|
| 8 | ;          the background (task) | 
|---|
| 9 | ; BULL^XMB Interactive create and send a bulletin | 
|---|
| 10 | ; | 
|---|
| 11 | ; The recipients of the bulletin include any entries in the XMY | 
|---|
| 12 | ; array that the caller has defined and the members of mail group | 
|---|
| 13 | ; that are included in the definition of the entry in the Bulletin | 
|---|
| 14 | ; file (#3.6) at the time of delivery.  There must be valid | 
|---|
| 15 | ; recipients or the message will not be delivered. | 
|---|
| 16 | ; | 
|---|
| 17 | ; I/O Variables: | 
|---|
| 18 | ; XMB             (in) Bulletin name (an entry in File #3.6) | 
|---|
| 19 | ; XMB(parameter#) (in, optional) Value to be stuffed into the bulletin | 
|---|
| 20 | ;                 for each required parameter | 
|---|
| 21 | ;                 eg. XMB(1)=data for parameter#1 | 
|---|
| 22 | ; XMTEXT          (in, optional) Name of array containing | 
|---|
| 23 | ;                 additional bulletin text | 
|---|
| 24 | ; XMY             (in, optional) Array of additional recipients of a | 
|---|
| 25 | ;                 bulletin | 
|---|
| 26 | ; XMDUZ           (in, optional) Sender # or string saying who or what | 
|---|
| 27 | ;                 sent the bulletin (default=DUZ) | 
|---|
| 28 | ; XMDT            (in, optional) Date/time to send bulletin (default=now) | 
|---|
| 29 | ; XMYBLOB         (in, optional) MIME array | 
|---|
| 30 | ; XMZ             (out) Message number (if successful) | 
|---|
| 31 | ; | 
|---|
| 32 | ; Entry ^XMB: | 
|---|
| 33 | ; Needs:    XMB | 
|---|
| 34 | ; Accepts:  XMDUZ,XMTEXT,XMY,XMDT,XMYBLOB | 
|---|
| 35 | ; Returns:  (XMB=-1 if bulletin does not exist in file 3.6) | 
|---|
| 36 | ; Kills:    XMTEXT,XMY | 
|---|
| 37 | N XMINSTR,XMATTACH,XMTASK | 
|---|
| 38 | K XMERR,^TMP("XMERR",$J) | 
|---|
| 39 | I '$O(^XMB(3.6,"B",XMB,"")) S XMB=-1 Q | 
|---|
| 40 | I '$G(DUZ) N DUZ D DUZ^XUP(.5) | 
|---|
| 41 | I $G(XMDUZ)=""!($G(XMDUZ)=0) S XMDUZ=DUZ | 
|---|
| 42 | I XMDUZ'?.N S %=XMDUZ N XMDUZ S XMDUZ=% K % | 
|---|
| 43 | D:$D(XMYBLOB) SETBLOB(.XMYBLOB,.XMATTACH) | 
|---|
| 44 | D:$D(XMDT) SETLATER(XMDT,.XMINSTR) | 
|---|
| 45 | I XMDUZ'?.N D SETFROM^XMD(.XMDUZ,.XMINSTR) Q:$G(XMMG)["Error =" | 
|---|
| 46 | D INITAPI^XMVVITAE | 
|---|
| 47 | S:$D(XMTEXT) XMTEXT=$$CREF^DILF(XMTEXT) | 
|---|
| 48 | S:$D(XMDF) XMINSTR("ADDR FLAGS")="R" ; Ignore addressee restrictions | 
|---|
| 49 | S:$D(XMBTMP) XMINSTR("ADDR FLAGS")=$G(XMINSTR("ADDR FLAGS"))_"I" ; Don't initialize (kill) the ^TMP addressee global | 
|---|
| 50 | D TASKBULL^XMXBULL(XMDUZ,XMB,.XMB,.XMTEXT,.XMY,.XMINSTR,.XMTASK,.XMATTACH) | 
|---|
| 51 | K:$D(XMERR) XMERR,^TMP("XMERR",$J) | 
|---|
| 52 | K XMTEXT,XMY | 
|---|
| 53 | Q | 
|---|
| 54 | EN ;Interactive Bulletin Entry Point | 
|---|
| 55 | ; Needs:    XMB | 
|---|
| 56 | ; Accepts:  XMDUZ,XMTEXT,XMY,XMDT,XMYBLOB | 
|---|
| 57 | ; Returns:  XMZ,(XMB=-1 if bulletin does not exist in file 3.6) | 
|---|
| 58 | ; Kills:    XMB,XMTEXT,XMY | 
|---|
| 59 | N XMBIEN,XMINSTR | 
|---|
| 60 | K XMERR,^TMP("XMERR",$J) | 
|---|
| 61 | S XMBIEN=$O(^XMB(3.6,"B",XMB,"")) I XMBIEN="" S XMB=-1 Q | 
|---|
| 62 | I '$G(DUZ) N DUZ D DUZ^XUP(.5) | 
|---|
| 63 | I $G(XMDUZ)=""!($G(XMDUZ)=0) S XMDUZ=DUZ | 
|---|
| 64 | I XMDUZ'?.N S %=XMDUZ N XMDUZ S XMDUZ=% K % | 
|---|
| 65 | D:$D(XMYBLOB) SETBLOB(.XMYBLOB,.XMATTACH) | 
|---|
| 66 | I XMDUZ'?.N D SETFROM^XMD(.XMDUZ,.XMINSTR) Q:$G(XMMG)["Error =" | 
|---|
| 67 | S:$D(XMTEXT) XMTEXT=$$CREF^DILF(XMTEXT) | 
|---|
| 68 | S:$D(XMDF) XMINSTR("ADDR FLAGS")="R" ; Ignore addressee restrictions | 
|---|
| 69 | S:$D(XMBTMP) XMINSTR("ADDR FLAGS")=$G(XMINSTR("ADDR FLAGS"))_"I" ; Don't initialize (kill) the ^TMP addressee global | 
|---|
| 70 | D SEND^XMXBULL(XMDUZ,XMBIEN,.XMB,.XMTEXT,.XMY,.XMINSTR,.XMZ,.XMATTACH) | 
|---|
| 71 | K:$D(XMERR) XMERR,^TMP("XMERR",$J) | 
|---|
| 72 | K XMB,XMTEXT,XMY | 
|---|
| 73 | Q | 
|---|
| 74 | SETBLOB(XMYBLOB,XMATTACH) ; | 
|---|
| 75 | N %X,%Y | 
|---|
| 76 | S %X="XMYBLOB(",%Y="XMATTACH(""IMAGE""," D %XY^%RCR | 
|---|
| 77 | Q | 
|---|
| 78 | SETLATER(XMDT,XMINSTR) ; | 
|---|
| 79 | S XMINSTR("LATER")=$$XMDATE^XMXPARM("XMDT",XMDT) | 
|---|
| 80 | I $D(XMERR) K XMINSTR("LATER"),XMERR,^TMP("XMERR",$J) | 
|---|
| 81 | Q | 
|---|
| 82 | BULL ; Manually post a bulletin | 
|---|
| 83 | D BULLETIN^XMJMBULL | 
|---|
| 84 | Q | 
|---|
| 85 | ZTSK ; Entry point for TaskMan to transmit messages to a site. | 
|---|
| 86 | ; Needed for transition from v7.1 to v8.0.  Once site has transitioned, | 
|---|
| 87 | ; this entry point can be deleted. | 
|---|
| 88 | S ZTREQ="@" | 
|---|
| 89 | S XMINST=XMB("XMSCR") | 
|---|
| 90 | Q:$$OBE^XMTDR(XMINST) | 
|---|
| 91 | S XMTREC=$G(^XMBS(4.2999,XMINST,4)) | 
|---|
| 92 | S ^XMBS(4.2999,XMINST,4)=$P(XMTREC,U,1,2)_U_XMB("SCRIPT",0)_U_XMB("TRIES")_U_U_XMB("ITERATIONS")_U_XMB("FIRST SCRIPT")_U_$P(XMB("SCRIPT"),U,6) | 
|---|
| 93 | S ^XMBS(4.2999,XMINST,5)=XMB("SCRIPT") | 
|---|
| 94 | K XMB,XMTREC | 
|---|
| 95 | G TASK^XMTDR | 
|---|
| 96 | Q | 
|---|