VistA-WorldVistAEHR/r/MAILMAN-XM/XMJMFA.m

84 lines
3.6 KiB
Mathematica

XMJMFA ;ISC-SF/GMB-Find message: Subject starts with ;04/18/2002 07:47
;;8.0;MailMan;;Jun 28, 2002
; Search for message subjects that partial match input.
; Replaces ^XMA03 (ISC-WASH/CAP/THM)
FIND(XMDUZ,XMSTRING,XMWAIT) ;
N XMKZ,XMCNT,XMABORT,XMLEN,XMFIRST,XMPAGE,XMDETAIL,XMPMAX,XMMORE,XMFLAGS,XMSCREEN,XMFROM,XMZOOM,XMCD,XMOPT,XMOX
K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
S (XMKZ,XMZ,XMPAGE,XMCNT,XMZOOM,XMCD,XMABORT)=0,(XMDETAIL,XMMORE)=1,XMPMAX=IOSL-3
D SRCHINIT(XMDUZ,.XMFLAGS,.XMSCREEN)
D INIT(XMDUZ,XMDETAIL,.XMLEN)
D SETOPT^XMJMLR1(XMDUZ,0,.XMOPT,.XMOX)
F D Q:XMABORT
. I XMCD S XMCD=0,XMDETAIL='XMDETAIL D INIT(XMDUZ,XMDETAIL,.XMLEN)
. D DISPLAY(XMDUZ,XMSTRING,XMFLAGS,XMSCREEN,.XMFROM,XMDETAIL,.XMKZ,.XMCNT,.XMFIRST,.XMPAGE,.XMMORE,.XMLEN,XMZOOM,XMPMAX)
. I XMCNT=0 S XMABORT=1 Q
. D CHOOSE^XMJMLN(XMDUZ,1,0,.XMKZ,.XMFIRST,.XMPAGE,XMMORE,.XMLEN,.XMZOOM,.XMOPT,.XMOX,"READMSG^XMJMFA",.XMABORT)
. S:'$D(^TMP("XM",$J,"MSG")) XMABORT=1
I XMCNT=0 D
. W $$EZBLD^DIALOG(34401) ; No matches found.
. Q:'$G(XMWAIT)
. W ! D WAIT^XMXUTIL
K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
Q
SRCHINIT(XMDUZ,XMFLAGS,XMSCREEN) ;
S XMSCREEN="",XMFLAGS=$S(XMV("ORDER")=-1:"B",1:"")
I XMDUZ=.5 S XMFLAGS=XMFLAGS_"U" Q ; Ignore file screen
S XMSCREEN=XMSCREEN_"N X S X=^(0)"
N XMMIN
S XMMIN=$P(^XMB(3.7,XMDUZ,0),U,7)
; If minimum date, don't choose lower date unless already in user's bskt
I XMMIN>0 S XMSCREEN=" I ^(.6)'<"_XMMIN_"!$D(^XMB(3.7,""M"",Y,XMDUZ))"
; Msg must not be SPOOL, msg must not be a reply.
S XMSCREEN=XMSCREEN_" I $P(X,U,7)'=""S"",$S($P(X,U,8):0,$P(X,U)?1""R"".N:0,1:1)"
Q
INIT(XMDUZ,XMDETAIL,XMLEN) ;
S XMLEN("BSKT")=10
S XMLEN("XMKZ")=3
D INIT^XMJML(XMDUZ,"","",XMDETAIL,.XMLEN)
Q
DISPLAY(XMDUZ,XMSTRING,XMFLAGS,XMSCREEN,XMFROM,XMDETAIL,XMKZ,XMCNT,XMFIRST,XMPAGE,XMMORE,XMLEN,XMZOOM,XMPMAX) ;
N XMREC
S XMFIRST(XMPAGE)=XMKZ
D HEADER^XMJML(XMDETAIL,.XMLEN,$$EZBLD^DIALOG(34403)) ; All Messages Search
I XMZOOM D Q
. F S XMKZ=$O(^TMP("XM",$J,".",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
. . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
. . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
F S XMKZ=$O(^TMP("XM",$J,"MSG",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
. S XMREC=^TMP("XM",$J,"MSG",XMKZ)
. D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
Q:$Y>XMPMAX!'XMMORE
; File screen ^DD(3.9,0,"SCR") insists that user be author or recipient.
; If FLAGS["U", then file screen is ignored.
D LIST^DIC(3.9,"","@",XMFLAGS,XMPMAX-$Y+1,.XMFROM,XMSTRING,"",XMSCREEN)
S:$P(^TMP("DILIST",$J,0),U,3)=0 XMMORE=0
D LISTMSG(XMDUZ,XMDETAIL,.XMCNT,.XMLEN)
S XMKZ=XMCNT
K ^TMP("DILIST",$J)
W:'XMMORE !,$$EZBLD^DIALOG(34402) ; Search finished.
Q
LISTMSG(XMDUZ,XMDETAIL,XMCNT,XMLEN) ; Check and List
N XMK,XMKN,XMZ,I
S I=""
F S I=$O(^TMP("DILIST",$J,2,I),XMV("ORDER")) Q:I'>0 D
. S XMCNT=XMCNT+1
. S XMZ=^TMP("DILIST",$J,2,I)
. S XMK=+$O(^XMB(3.7,"M",XMZ,XMDUZ,0))
. S XMKN=$S(XMK:$P(^XMB(3.7,XMDUZ,2,XMK,0),U),1:$$EZBLD^DIALOG(34014)) ; * N/A *
. I XMK,'$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) D ADDITM^XMUT4A(XMDUZ,XMK,XMZ)
. D LISTMSG^XMJML(XMK,XMKN,XMCNT,XMZ,XMDETAIL,.XMLEN)
. S ^TMP("XM",$J,"MSG",XMCNT)=XMK_U_XMKN_U_XMZ
Q
READMSG ; (XMDUZ,XMKZ,XMREC) <- needed!
N XMK,XMKN,XMZ,XMRDR ; $G(XMRDR) is checked in READMSG^XMJBM
S XMK=$P(XMREC,U,1),XMKN=$P(XMREC,U,2),XMZ=$P(XMREC,U,3)
I XMDUZ=.5,'XMK,'$$ACCESS^XMXSEC(XMDUZ,XMZ,$G(^XMB(3.9,XMZ,0))) D Q
. D SHOW^XMJERR
. D WAIT^XMXUTIL
D READMSG^XMJBM(XMDUZ,XMK,XMKN,XMZ)
Q:$D(^XMB(3.7,"M",XMZ,XMDUZ,XMK))
S XMK=+$O(^XMB(3.7,"M",XMZ,XMDUZ,0))
S ^TMP("XM",$J,"MSG",XMKZ)=XMK_U_$S(XMK=0:$$EZBLD^DIALOG(34014),1:$P(^XMB(3.7,XMDUZ,2,XMK,0),U))_U_XMZ ; * N/A *
Q