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

XMJMFB.m

Go to the documentation of this file.
  1. XMJMFB ;ISC-SF/GMB-Find message: multiple conditions ;07/12/2002 10:40
  1. ;;8.0;MailMan;;Jun 28, 2002
  1. ; Replaces ^XMAL0,^XMAL0A (ISC-WASH/JSH/CAP)
  1. ; XMF("BSKT") =number - Look in this basket ONLY
  1. ; =* - Look in all baskets
  1. ; XMF("SUBJ") Subject contains this string
  1. ; XMF("SUBJ","S") Look for this string in the subject
  1. ; XMF("FLINE") Message has this many or more lines
  1. ; XMF("TLINE") Message has this many or fewer lines
  1. ; XMF("FROM") Message is from this person
  1. ; XMF("TO") Message is to this person
  1. ; XMF("FDATE") Message was sent on or after this date
  1. ; XMF("TDATE") Message was sent on or before this date
  1. ; XMF("RFROM") Message has a response from this person
  1. ; XMF("TEXT") Message contains this string
  1. ; XMF("TEXT","S") Look for this string in the message
  1. ; XMF("TEXT","L") =1 - Look in message only
  1. ; =2 - Look in both message and responses
  1. ; =3 - Look in responses only
  1. ; XMF("TEXT","C") =0 - Search is not case-sensitive
  1. ; =1 - Search is case-sensitive
  1. FIND1(XMDUZ,XMF,XMWAIT) ;
  1. N XMK,XMKN,XMKZ,XMCNT,XMABORT,XMLEN,XMFIRST,XMPAGE,XMDETAIL,XMPMAX,XMMORE,XMZOOM,XMCD,XMOPT,XMOX
  1. K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
  1. S XMKZ="",(XMPAGE,XMCNT,XMZOOM,XMCD,XMABORT)=0,(XMDETAIL,XMMORE)=1,XMPMAX=IOSL-3
  1. D INIT1(XMDUZ,.XMF,XMDETAIL,XMPMAX,.XMK,.XMKN,.XMLEN)
  1. D SETOPT^XMJMLR1(XMDUZ,$S(XMDUZ'=.5:0,XMK<1000:0,1:XMK),.XMOPT,.XMOX)
  1. F D Q:XMABORT
  1. . I XMCD S XMCD=0,XMDETAIL='XMDETAIL D INIT1(XMDUZ,.XMF,XMDETAIL,XMPMAX,.XMK,.XMKN,.XMLEN)
  1. . D DISPLAY1(XMDUZ,.XMF,XMDETAIL,.XMK,XMKN,.XMKZ,.XMCNT,.XMFIRST,.XMPAGE,.XMMORE,.XMLEN,XMZOOM,XMPMAX)
  1. . I XMCNT=0 S XMABORT=1 Q
  1. . D CHOOSE^XMJMLN(XMDUZ,0,XMK,.XMKZ,.XMFIRST,.XMPAGE,XMMORE,.XMLEN,.XMZOOM,.XMOPT,.XMOX,"READMSG^XMJMFB",.XMABORT)
  1. . S:'$D(^TMP("XM",$J,"MSG")) XMABORT=1
  1. I XMCNT=0 D
  1. . W $C(7),$$EZBLD^DIALOG(34401) ; No matches found.
  1. . Q:'$G(XMWAIT)
  1. . W ! D WAIT^XMXUTIL
  1. K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
  1. Q
  1. INIT1(XMDUZ,XMF,XMDETAIL,XMPMAX,XMK,XMKN,XMLEN) ;
  1. S:$D(XMF("SUBJ")) XMF("SUBJ","S")=$$UP^XLFSTR(XMF("SUBJ"))
  1. S:$D(XMF("TEXT")) XMF("TEXT","S")=$S('XMF("TEXT","C"):$$UP^XLFSTR(XMF("TEXT")),1:XMF("TEXT"))
  1. S XMK=XMF("BSKT")
  1. S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
  1. D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN,1)
  1. Q
  1. DISPLAY1(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZ,XMCNT,XMFIRST,XMPAGE,XMMORE,XMLEN,XMZOOM,XMPMAX) ;
  1. N XMREC,XMZ
  1. S XMFIRST(XMPAGE)=XMKZ
  1. D HEADER^XMJML(XMDETAIL,.XMLEN,$$EZBLD^DIALOG(34404,XMKN)) ; XMKN_ Basket Search
  1. I XMZOOM D Q
  1. . F S XMKZ=$O(^TMP("XM",$J,".",XMKZ),XMV("ORDER")) Q:XMKZ="" D Q:$Y>XMPMAX
  1. . . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
  1. . . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
  1. F S XMKZ=$O(^TMP("XM",$J,"MSG",XMKZ),XMV("ORDER")) Q:XMKZ="" D Q:$Y>XMPMAX
  1. . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
  1. . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
  1. Q:$Y>XMPMAX!'XMMORE
  1. D CHKNLST1(XMDUZ,.XMF,XMDETAIL,XMK,XMKN,.XMKZ,.XMCNT,XMPMAX,.XMLEN)
  1. S:XMKZ'>0 XMMORE=0
  1. W:'XMMORE !,$$EZBLD^DIALOG(34402) ; Search finished.
  1. Q
  1. CHKNLST1(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZ,XMCNT,XMPMAX,XMLEN) ; Check and List
  1. N XMZ
  1. S:XMKZ="" XMKZ=$O(^TMP("XM",$J,"MSG",""),-XMV("ORDER"))
  1. F S XMKZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZ),XMV("ORDER")) Q:XMKZ'>0 D Q:$Y>XMPMAX
  1. . S XMZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZ,0))
  1. . I '$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) D ADDITC^XMUT4A(XMDUZ,XMK,XMZ,XMKZ)
  1. . Q:'$$GOODMSG(XMDUZ,XMK,XMZ,.XMF)
  1. . S XMCNT=XMCNT+1
  1. . D LISTMSG^XMJML(XMK,XMKN,XMKZ,XMZ,XMDETAIL,.XMLEN)
  1. . S ^TMP("XM",$J,"MSG",XMKZ)=XMK_U_XMKN_U_XMZ
  1. Q
  1. FINDALL(XMDUZ,XMF) ;
  1. N XMK,XMKN,XMKZZ,XMKZ,XMCNT,XMABORT,XMLEN,XMFIRST,XMPAGE,XMDETAIL,XMPMAX,XMMORE,XMZOOM,XMCD,XMOPT,XMOX
  1. S (XMKZ,XMKZZ)="",(XMK,XMPAGE,XMCNT,XMZOOM,XMCD,XMABORT)=0,(XMDETAIL,XMMORE)=1,XMPMAX=IOSL-3
  1. D INITA(XMDUZ,.XMF,.XMK,.XMKN,.XMKZZ,.XMLEN,.XMABORT) Q:XMABORT
  1. D SETOPT^XMJMLR1(XMDUZ,0,.XMOPT,.XMOX)
  1. K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
  1. F D Q:XMABORT
  1. . D DISPLAYA(XMDUZ,.XMF,.XMDETAIL,.XMK,XMKN,.XMKZZ,.XMKZ,.XMCNT,.XMFIRST,.XMPAGE,.XMMORE,.XMLEN,XMZOOM,XMPMAX)
  1. . D CHOOSE^XMJMLN(XMDUZ,1,0,.XMKZ,.XMFIRST,.XMPAGE,XMMORE,.XMLEN,.XMZOOM,.XMOPT,.XMOX,"READMSG^XMJMFB",.XMABORT)
  1. . S:'$D(^TMP("XM",$J,"MSG")) XMABORT=1
  1. K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
  1. Q
  1. INITA(XMDUZ,XMF,XMK,XMKN,XMKZZ,XMLEN,XMABORT) ;
  1. S:$D(XMF("SUBJ")) XMF("SUBJ","S")=$$UP^XLFSTR(XMF("SUBJ"))
  1. S:$D(XMF("TEXT")) XMF("TEXT","S")=$S('XMF("TEXT","C"):$$UP^XLFSTR(XMF("TEXT")),1:XMF("TEXT"))
  1. S XMLEN("XMKZ")=0
  1. F S XMK=$O(^XMB(3.7,XMDUZ,2,XMK)) Q:XMK'>0 D Q:$D(XMKN)
  1. . F S XMKZZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZZ),XMV("ORDER")) Q:XMKZZ'>0 D Q:$D(XMKN)
  1. . . S XMZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZZ,0))
  1. . . Q:'$$GOODMSG(XMDUZ,XMK,XMZ,.XMF)
  1. . . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
  1. I $D(XMKN) S XMKZZ=XMKZZ-XMV("ORDER") Q
  1. S XMABORT=1
  1. W $C(7),$$EZBLD^DIALOG(34401),! ; No matches found.
  1. D WAIT^XMXUTIL
  1. Q
  1. DISPLAYA(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZZ,XMKZ,XMCNT,XMFIRST,XMPAGE,XMMORE,XMLEN,XMZOOM,XMPMAX) ;
  1. N XMREC,XMZ
  1. S XMFIRST(XMPAGE)=XMKZ
  1. I XMCD D
  1. . S XMCD=0,XMDETAIL='XMDETAIL
  1. . D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN)
  1. E I $L(XMCNT+XMPMAX)>XMLEN("XMKZ") D
  1. . S XMLEN("XMKZ")=$L(XMCNT+XMPMAX)
  1. . D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN)
  1. D HEADER^XMJML(XMDETAIL,.XMLEN,$$EZBLD^DIALOG(34405)) ; All Baskets Search
  1. I XMZOOM D Q
  1. . F S XMKZ=$O(^TMP("XM",$J,".",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
  1. . . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
  1. . . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
  1. F S XMKZ=$O(^TMP("XM",$J,"MSG",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
  1. . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
  1. . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
  1. Q:$Y>XMPMAX!'XMMORE
  1. S XMK=XMK-.01
  1. F S XMK=$O(^XMB(3.7,XMDUZ,2,XMK)) Q:XMK'>0 D Q:$Y>XMPMAX
  1. . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
  1. . D CHKNLSTA(XMDUZ,.XMF,XMDETAIL,XMK,XMKN,.XMKZZ,.XMCNT,XMPMAX,.XMLEN)
  1. I XMK'>0,XMKZZ'>0 S XMMORE=0
  1. S XMKZ=XMCNT
  1. W:'XMMORE !,$$EZBLD^DIALOG(34402) ; Search finished.
  1. Q
  1. CHKNLSTA(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZZ,XMCNT,XMPMAX,XMLEN) ; Check and List
  1. N XMZ
  1. F S XMKZZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZZ),XMV("ORDER")) Q:XMKZZ'>0 D Q:$Y>XMPMAX
  1. . S XMZ=$O(^XMB(3.7,XMDUZ,2,XMK,1,"C",XMKZZ,0))
  1. . I '$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) D ADDITC^XMUT4A(XMDUZ,XMK,XMZ,XMKZZ)
  1. . Q:'$$GOODMSG(XMDUZ,XMK,XMZ,.XMF)
  1. . I $L(XMKN)>$G(XMLEN("BSKT")) D
  1. . . S XMLEN("BSKT")=$$MIN^XLFMTH($L(XMKN),10)
  1. . . D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN)
  1. . S XMCNT=XMCNT+1
  1. . D LISTMSG^XMJML(XMK,XMKN,XMCNT,XMZ,XMDETAIL,.XMLEN)
  1. . S ^TMP("XM",$J,"MSG",XMCNT)=XMK_U_XMKN_U_XMZ
  1. Q
  1. GOODMSG(XMDUZ,XMK,XMZ,XMF) ;
  1. N XMZREC,XMNOGOOD,XMZFROM,XMZDATE
  1. S XMZREC=$G(^XMB(3.9,XMZ,0))
  1. I XMZREC="",XMK D ZAPIT^XMXMSGS2(XMDUZ,XMK,XMZ) Q 0
  1. I $D(XMF("SUBJ")),$$UP^XLFSTR($P(XMZREC,U,1))'[XMF("SUBJ","S") Q 0
  1. I $D(XMF("FROM")) Q:'$$GOODFROM(XMZREC,XMF("FROM")) 0
  1. I $D(XMF("FLINE"))!$D(XMF("TLINE")) D Q:XMNOGOOD 0
  1. . N XMLINES
  1. . S XMNOGOOD=1
  1. . S XMLINES=$$LINE^XMXUTIL2(XMZ)
  1. . I $D(XMF("FLINE")),XMLINES<XMF("FLINE") Q
  1. . I $D(XMF("TLINE")),XMF("TLINE")<XMLINES Q
  1. . S XMNOGOOD=0
  1. I $D(XMF("FDATE"))!$D(XMF("TDATE")) D Q:XMNOGOOD 0
  1. . S XMNOGOOD=1
  1. . S XMZDATE=$P(XMZREC,U,3)
  1. . S:XMZDATE'=+XMZDATE XMZDATE=$$CONVERT^XMXUTIL1(XMZDATE)
  1. . S XMZDATE=$P(XMZDATE,".")
  1. . I $D(XMF("FDATE")),XMZDATE<XMF("FDATE") Q
  1. . I $D(XMF("TDATE")),XMF("TDATE")<XMZDATE Q
  1. . S XMNOGOOD=0
  1. I $D(XMF("TO")) D Q:XMNOGOOD 0
  1. . I $D(^XMB(3.9,XMZ,6,"B",XMF("TO"))) S XMNOGOOD=0 Q
  1. . I $L(XMF("TO"))>30,$D(^XMB(3.9,XMZ,6,"B",$E(XMF("TO"),1,30))),XMF("TO")=$P($G(^XMB(3.9,XMZ,6,+$O(^XMB(3.9,XMZ,6,"B",$E(XMF("TO"),1,30),0)),0)),U,1) S XMNOGOOD=0 Q
  1. . S XMNOGOOD=1
  1. . Q:XMF("TO")'["@"
  1. . N XMTOX,XMTO
  1. . S XMTO=""
  1. . F S XMTO=$O(^XMB(3.9,XMZ,6,"B",XMTO)) Q:XMTO="" D Q:'XMNOGOOD
  1. . . Q:XMTO'["@"
  1. . . S XMTOX=$$UP^XLFSTR(XMTO)
  1. . . Q:$P(XMTOX,"@")'[$P(XMF("TO"),"@")
  1. . . Q:$P(XMTOX,"@",2)'[$P(XMF("TO"),"@",2)
  1. . . S XMNOGOOD=0
  1. I $D(XMF("RFROM")) D Q:XMNOGOOD 0
  1. . N XMIEN,XMZR
  1. . S XMNOGOOD=1
  1. . S XMIEN=0
  1. . F S XMIEN=$O(^XMB(3.9,XMZ,3,XMIEN)) Q:'XMIEN S XMZR=^(XMIEN,0) I $$GOODFROM($G(^XMB(3.9,XMZR,0)),XMF("RFROM")) S XMNOGOOD=0 Q
  1. I $D(XMF("TEXT")) D Q:XMNOGOOD 0
  1. . S XMNOGOOD=1
  1. . I XMF("TEXT","L")<3 D Q:XMF("TEXT","L")=1!(XMNOGOOD=0)
  1. . . S:$$GOODTEXT(XMZ,XMF("TEXT","S"),XMF("TEXT","C")) XMNOGOOD=0
  1. . N XMIEN,XMZR
  1. . S XMIEN=0
  1. . F S XMIEN=$O(^XMB(3.9,XMZ,3,XMIEN)) Q:'XMIEN S XMZR=^(XMIEN,0) I $$GOODTEXT(XMZR,XMF("TEXT","S"),XMF("TEXT","C")) S XMNOGOOD=0 Q
  1. Q 1
  1. GOODFROM(XMZREC,XMF) ; Returns 1 if msg is from XMF; 0 if not
  1. N XMZFROM
  1. S XMZFROM=$P(XMZREC,U,2)
  1. I XMF=+XMF,XMF=XMZFROM Q 1
  1. Q:XMF'["@" 0
  1. S XMZFROM=$$UP^XLFSTR(XMZFROM)
  1. Q:$P(XMZFROM,"@")'[$P(XMF,"@") 0
  1. Q:$P(XMZFROM,"@",2)'[$P(XMF,"@",2) 0
  1. Q 1
  1. GOODTEXT(XMZ,XMF,XMFMATTR) ; Returns positive number if msg contains XMF; 0 if not
  1. N I
  1. S I=.999999
  1. I XMFMATTR D
  1. . F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I Q:^(I,0)[XMF
  1. E D
  1. . F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I Q:$$UP^XLFSTR(^(I,0))[XMF
  1. Q +I
  1. READMSG ; (XMDUZ,XMKZ,XMREC) <- needed!
  1. N XMK,XMKN,XMZ,XMRDR ; $G(XMRDR) is checked in READMSG^XMJBM
  1. S XMK=$P(XMREC,U,1),XMKN=$P(XMREC,U,2),XMZ=$P(XMREC,U,3)
  1. D READMSG^XMJBM(XMDUZ,XMK,XMKN,XMZ)
  1. Q:$D(^XMB(3.7,"M",XMZ,XMDUZ,XMK))
  1. I XMF("BSKT")=XMK K ^TMP("XM",$J,"MSG",XMKZ) Q
  1. S XMK=+$O(^XMB(3.7,"M",XMZ,XMDUZ,0))
  1. 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 *
  1. Q