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

XMJBN.m

Go to the documentation of this file.
  1. XMJBN ;ISC-SF/GMB-Access new mail in mailbox ;05/18/2004 08:37
  1. ;;8.0;MailMan;**25**;Jun 28, 2002
  1. ; Replaces ^XMA (ISC-WASH/THM/CAP)
  1. ; Entry points used by MailMan options (not covered by DBIA):
  1. ; NEW XMNEW - Read new messages
  1. NEW ;
  1. ; XMNEW Number of new messages
  1. ; XMKMULT 1=New msgs in multiple baskets; 0=new msgs in one basket
  1. N XMABORT,XMK,XMKN,XMNEW,XMKMULT,XMNEWS
  1. S XMABORT=0
  1. D INIT^XMJBN1(XMDUZ,.XMK,.XMKN,.XMNEW,.XMKMULT,.XMABORT) Q:XMABORT
  1. S XMNEWS=1 ; Makes 'new'd msgs drop off list 'til next time
  1. I XMNEW=1 D Q
  1. . N XMZ
  1. . S XMZ=$O(^XMB(3.7,XMDUZ,"N0",XMK,""))
  1. . I XMDUZ'=DUZ,'$$SURRACC^XMXSEC(XMDUZ,"",XMZ,$G(XMB(3.9,XMZ,0))) D Q
  1. . . D ZSHOW^XMJERR
  1. . . D WAIT^XMXUTIL
  1. . I '$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) D ADDITN^XMUT4A(XMDUZ,"N0",XMK,XMZ)
  1. . D READNEW(XMDUZ,XMK,XMKN,XMZ)
  1. . D:$D(^XTMP("XM","MAKENEW",XMDUZ)) NEWAGAIN^XMJBN1(XMDUZ)
  1. F D Q:'$D(^XMB(3.7,XMDUZ,"N0"))!XMABORT
  1. . N XMDIR,XMOPT,XMOX,XMY
  1. . S XMDIR("A")=$$EZBLD^DIALOG(34085) ; Select New mail option
  1. . D SET^XMXSEC1("R",34086,.XMOPT,.XMOX) ; Read new mail by basket
  1. . D SET^XMXSEC1("LB",34087,.XMOPT,.XMOX) ; List Baskets with new mail
  1. . D SET^XMXSEC1("LN",34088,.XMOPT,.XMOX) ; List all new messages
  1. . D SET^XMXSEC1("LP",34089,.XMOPT,.XMOX) ; List all priority messages
  1. . I '$D(^XMB(3.7,XMDUZ,"N")) S XMOPT("LP","?")=$$EZBLD^DIALOG(34018) ; You have no new priority messages.
  1. . D SET^XMXSEC1("P",34090,.XMOPT,.XMOX) ; Print all new messages
  1. . D SET^XMXSEC1("S",34091,.XMOPT,.XMOX) ; Scan all new messages
  1. . D SET^XMXSEC1("Q",34092,.XMOPT,.XMOX) ; Quit
  1. . S XMDIR("B")=XMOX("O",XMV("NEW OPT"))_":"_XMOPT(XMV("NEW OPT"))
  1. . S XMDIR("??")="XM-U-R-READ NEW"
  1. . D XMDIR^XMJDIR(.XMDIR,.XMOPT,.XMOX,.XMY,.XMABORT) Q:XMABORT
  1. . K XMOPT,XMOX,XMDIR
  1. . D @XMY
  1. D:$D(^XTMP("XM","MAKENEW",XMDUZ)) NEWAGAIN^XMJBN1(XMDUZ)
  1. Q
  1. LB ; List Baskets with new mail (Replaces NEW^XMA0A)
  1. N DIC,D,DZ
  1. S DIC="^XMB(3.7,"_XMDUZ_",2,"
  1. S DIC(0)="AEQ",D="B",DZ="??"
  1. S DIC("S")="I $P(^(0),U,2)"
  1. S DIC("W")="W ?31,$$EZBLD^DIALOG($S($P(^(0),U,2)'=1:34027.2,1:34027.4),$P(^(0),U,2))" ; (|1| New)
  1. D DQ^DICQ
  1. Q
  1. LN ; List all new messages (Replaces LIST^XMA0A)
  1. D LISTALL^XMJMLN(XMDUZ,"N0")
  1. Q
  1. LP ; List all priority messages (Replaces PRIO^XMA0A)
  1. D LISTALL^XMJMLN(XMDUZ,"N")
  1. Q
  1. P ; Print all new messages
  1. ; Replaces PRINT^XMA0A
  1. N XMSAVE,I
  1. F I="XMV(","DUZ","XMDUZ","XMKMULT" S XMSAVE(I)=""
  1. D EN^XUTMDEVQ("PRTNEW^XMJBN",$$EZBLD^DIALOG(34501),.XMSAVE) ; MailMan: Print
  1. Q
  1. PRTNEW ; Print all new messages
  1. N XMSCAN,XMNEWPRT,XMFIRST
  1. S (XMSCAN,XMNEWPRT,XMFIRST)=1
  1. D R
  1. I $D(ZTQUEUED),$D(^XTMP("XM","MAKENEW",XMDUZ)) D NEWAGAIN^XMJBN1(XMDUZ)
  1. Q
  1. Q ; Quit
  1. S XMABORT=1
  1. Q
  1. S ; Scan all new messages
  1. N XMSCAN
  1. S XMSCAN=1
  1. D R
  1. Q
  1. R ; Read new mail by basket, priority first.
  1. N XMTYPE,XMK,XMKN,XMZ,XMIA,XMKPRI
  1. S XMABORT=0 ; (required when printing new messages)
  1. S XMIA='$D(ZTQUEUED)
  1. S XMKPRI=0,(XMKN,XMKPRI("XMKN"))="" K ^TMP("XM",$J,"APX")
  1. F D Q:'$D(^XMB(3.7,XMDUZ,"N0"))!XMABORT
  1. . S XMTYPE=$S($D(^XMB(3.7,XMDUZ,"N")):"N",$D(^XMB(3.7,XMDUZ,"N0")):"N0",1:"")
  1. . I XMTYPE="" S XMABORT=1 W:'$D(ZTQUEUED) !,$$EZBLD^DIALOG(34017) Q ; You have no new messages.
  1. . I 'XMKMULT D
  1. . . S XMK=$O(^XMB(3.7,XMDUZ,XMTYPE,0))
  1. . . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
  1. . E D Q:XMABORT
  1. . . D NXTBSKT^XMJBN1(XMDUZ,XMTYPE,.XMKN,.XMK,.XMKPRI) I 'XMK S XMABORT=1 Q
  1. . . Q:$G(XMSCAN)
  1. . . D ASKBSKT(XMDUZ,1,.XMK,.XMKN,.XMABORT) Q:XMABORT
  1. . . I XMTYPE="N",'$D(^XMB(3.7,XMDUZ,XMTYPE,XMK)) S XMTYPE="N0"
  1. . S XMZ=""
  1. . F S XMZ=$O(^XMB(3.7,XMDUZ,XMTYPE,XMK,XMZ),XMV("NEW ORDER")) Q:XMZ="" D Q:XMABORT
  1. . . I '$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) D ADDITN^XMUT4A(XMDUZ,XMTYPE,XMK,XMZ)
  1. . . I $G(XMNEWPRT) D Q
  1. . . . D PRTMULT^XMJMP(XMDUZ,XMK,XMKN,XMZ,0,1,.XMFIRST,"",.XMABORT)
  1. . . . I XMDUZ'=DUZ,$$SURRCONF^XMXSEC(XMDUZ,XMZ) D Q
  1. . . . . D NONEW^XMXUTIL(XMDUZ,XMK,XMZ,1)
  1. . . . . S ^XTMP("XM","MAKENEW",XMDUZ,XMZ)=""
  1. . . I XMDUZ'=DUZ,'$$SURRACC^XMXSEC(XMDUZ,"",XMZ,$G(XMB(3.9,XMZ,0))) D Q
  1. . . . D ZSHOW^XMJERR
  1. . . . D WAIT^XMXUTIL
  1. . . . D NONEW^XMXUTIL(XMDUZ,XMK,XMZ,1)
  1. . . . S ^XTMP("XM","MAKENEW",XMDUZ,XMZ)=""
  1. . . D READNEW(XMDUZ,XMK,XMKN,XMZ,.XMABORT)
  1. . Q:XMABORT
  1. . S:$D(^XMB(3.7,XMDUZ,"N0")) XMKMULT=1
  1. . Q:$G(XMSCAN)!'XMKMULT
  1. . W !!,$$EZBLD^DIALOG($S(XMTYPE="N0":34098,1:34099),XMKN) ; Done with new/priority mail in your '|1|' Basket.
  1. . W:$D(^XMB(3.7,XMDUZ,"N0")) !!
  1. K ^TMP("XM",$J,"APX")
  1. Q
  1. READNEW(XMDUZ,XMK,XMKN,XMZ,XMABORT) ;
  1. N XMSECURE,XMPAKMAN,XMSECBAD ; Important 'new' - part of scramble and packman handling
  1. I '$D(^XMB(3.9,XMZ,0)) D ZAPIT^XMXMSGS2(XMDUZ,XMK,XMZ) Q
  1. D DISPMSG^XMJMP(XMDUZ,XMK,XMKN,XMZ,.XMSECBAD) Q:$G(XMSECBAD)
  1. D READMSG^XMJMOI($G(XMNEWS),XMDUZ,XMK,XMKN,XMZ,.XMABORT)
  1. Q
  1. ASKBSKT(XMDUZ,XMNEWMSG,XMK,XMKN,XMABORT) ;
  1. ; XMNEWMSG 1=Read new mail; 0=Read any mail
  1. N XMDIC,XMPROMPT
  1. S XMDIC("W")="N XMPARM S XMPARM(2)=$P(^(0),U,2),XMPARM(1)=+$P($G(^(1,0)),U,4) W ?31,$$EZBLD^DIALOG($S(XMPARM(1)'=1:$S('XMPARM(2):34026,XMPARM(2)>1:34027,1:34027.3),XMPARM(2):34027.1,1:34026.1),.XMPARM)" ; (|1| messages, |2| new)
  1. I XMNEWMSG D
  1. . S XMPROMPT=34029 ; Read NEW mail in MAIL BASKET:
  1. . S XMDIC("S")="I $P(^(0),U,2)"
  1. . S XMDIC("B")=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
  1. E S XMPROMPT=34028 ; Read mail in MAIL BASKET:
  1. D SELBSKT^XMJBU(XMDUZ,XMPROMPT,"",.XMDIC,.XMK,.XMKN)
  1. I XMK=U S XMABORT=1
  1. Q
  1. NPBSKT(XMDUZ) ; Return the first priority read basket that has new messages.
  1. ; If none has new messages, return the first priority basket.
  1. N XMDEFALT
  1. S XMDEFALT=$$BNMSGCT^XMXUTIL(XMDUZ,1)_U_1_U_$$EZBLD^DIALOG(37005) ; IN
  1. I '$D(^XMB(3.7,XMDUZ,2,"AP")) Q XMDEFALT
  1. N XMK,XMKN
  1. S XMKN=""
  1. D NXTBSKT^XMJBN1(XMDUZ,"N0",.XMKN,.XMK)
  1. I $D(^TMP("XM",$J,"APX")) K ^TMP("XM",$J,"APX") Q $$BNMSGCT^XMXUTIL(XMDUZ,XMK)_U_XMK_U_XMKN
  1. N XMI
  1. S (XMI,XMK)=0
  1. S XMI=+$O(^XMB(3.7,XMDUZ,2,"AP",XMI))
  1. I 'XMI Q XMDEFALT
  1. F S XMK=$O(^XMB(3.7,XMDUZ,2,"AP",XMI,XMK)) Q:'XMK D
  1. . S XMK($$BSKTNAME^XMXUTIL(XMDUZ,XMK))=XMK
  1. S XMKN=$O(XMK(""))
  1. I XMKN="" Q XMDEFALT
  1. S XMK=XMK(XMKN)
  1. Q "0^"_XMK_U_XMKN