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

XBMAIL.m

Go to the documentation of this file.
  1. XBMAIL ; IHS/ADC/GTH - MAIL MESSAGE TO SECURITY KEY HOLDERS ; [ 02/07/97 3:02 PM ]
  1. ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
  1. ;
  1. ; This utility generates a mail message to everyone on the
  1. ; local machine that holds a security key according to the
  1. ; namespace, range, or single key provided in the parameter.
  1. ; The text of the mail messages must be provided by you, and
  1. ; passed to the utility as a line reference. The utility
  1. ; uses the first line after the line reference as the mail
  1. ; message subject, and subsequent lines as the body of the
  1. ; message, until a null string is encountered. This places
  1. ; an implicit limit on your mail messages to the maximum
  1. ; size of a routine. Suggested text would be to inform the
  1. ; users that a patch has been installed, and describe any
  1. ; changes in displays or functionality, or problems
  1. ; addressed, and provide a contact number for questions,
  1. ; e.g:
  1. ; ------------------------------------------------------------------
  1. ; Please direct your questions or comments about RPMS software to:
  1. ; OIRM / DSD (Division of Systems Development)
  1. ; 5300 Homestead Road NE
  1. ; Albuquerque NM 87110
  1. ; 505-837-4189
  1. ; ------------------------------------------------------------------
  1. ;
  1. ; Call examples are:
  1. ;
  1. ; D MAIL^XBMAIL("ACHS*","MSG^ACHSP56")
  1. ; D MAIL^XBMAIL("AG*,XUMGR-XUPROGMODE,APCDZMENU","LABEL^AGP5")
  1. ;
  1. ; The second example would deliver a mail message containing
  1. ; the text beginning at LABEL+2^AGP5, and continuing to the
  1. ; end of routine AGP5, to each local user that holds a
  1. ; security key in the AG namespace, in the range from XUMGR
  1. ; to XUPROGMODE (inclusive), and to holders of the APCDZMENU
  1. ; security key.
  1. ;
  1. ; If you are indicating a namespace, your namespace must end
  1. ; with a star ("*") character.
  1. ;
  1. ; If you are indicating a range of security keys, the
  1. ; beginning and ending keys must be separated with a dash
  1. ; ("-"). If the utility encounters a dash in a comma-piece
  1. ; of the first parameter, it will consider it to be
  1. ; range-indicated, and not part of the name of the key.
  1. ; Use caution not to begin or end with a key that has a dash
  1. ; in it's name.
  1. ;
  1. ; If a comma-piece does not contain a star or dash, a single
  1. ; key is assumed.
  1. ;
  1. ; The subject of the message is assumed to be the first line
  1. ; after LABEL^AGP5:
  1. ; LABEL ;EP - Mail msg text.
  1. ; ;;PATIENT REG, PATCH 5 CHANGES.
  1. ;
  1. ; The utility will return Y=0 if successful, and Y=-1 if not
  1. ; successful. The message "Message delivered." will be
  1. ; displayed if the routine is called interactively.
  1. ;
  1. ;
  1. Q
  1. ;
  1. MAIL(XBNS,XBREF) ;PEP - XBNS is namespace, XBREF is line reference.
  1. ;
  1. NEW XBLAB,XBRTN,XMSUB,XMDUZ,XMTEXT,XMY
  1. S XBLAB=$P(XBREF,U),XBRTN=$P(XBREF,U,2)
  1. I XBLAB=""!(XBRTN="") S Y=-1 Q ; Invalid label reference.
  1. I '$L($T(@XBLAB+1^@XBRTN)) S Y=-1 Q ; No text to send.
  1. S XMSUB=$P($T(@XBLAB+1^@XBRTN),";",3)
  1. KILL ^TMP("XBMAIL",$J)
  1. D WRITDESC,GETRECIP
  1. I '$D(XMY) S Y=-1 Q ; No recipients.
  1. S XMDUZ=$S($G(DUZ):DUZ,1:.5),XMTEXT="^TMP(""XBMAIL"",$J,"
  1. D ^XMD
  1. KILL ^TMP("XBMAIL",$J)
  1. I '$D(ZTQUEUED) W !!,"Message delivered.",!
  1. S Y=0
  1. Q
  1. ;
  1. GETRECIP ;
  1. NEW X,XBCTR,Y
  1. F XBCTR=1:1 S %=$P(XBNS,",",XBCTR) Q:%="" D
  1. . I %["*" D NS(%) Q
  1. . I %["-" D RANGE(%) Q
  1. . D SINGLE(%)
  1. .Q
  1. Q
  1. ;
  1. SINGLE(K) ; Get holders of a single key K.
  1. S Y=0
  1. Q:'$D(^XUSEC(K))
  1. F S Y=$O(^XUSEC(K,Y)) Q:'Y S XMY(Y)=""
  1. Q
  1. ;
  1. RANGE(R) ; Get holders of a range of keys.
  1. S X=$P(R,"-",1),R=$P(R,"-",2)
  1. D SINGLE(X)
  1. F S X=$O(^XUSEC(X)) Q:X=R!(X="") S Y=0 F S Y=$O(^XUSEC(X,Y)) Q:'Y S XMY(Y)=""
  1. D SINGLE(R)
  1. Q
  1. ;
  1. NS(N) ; Get holders of keys in namespace N.
  1. S (X,N)=$P(N,"*",1),Y=0
  1. D SINGLE(X)
  1. F S X=$O(^XUSEC(X)) Q:'($E(X,1,$L(N))=N) S Y=0 F S Y=$O(^XUSEC(X,Y)) Q:'Y S XMY(Y)=""
  1. Q
  1. ;
  1. ;
  1. WRITDESC ;
  1. F %=2:1 S X=$P($T(@XBLAB+%^@XBRTN),";",3) Q:X="" S ^TMP("XBMAIL",$J,%)=X
  1. Q
  1. ;