TIUALFUN ; SLC/AJB - TIU ALERT FUNCTIONS ;01/30/23  12:28
 ;;1.0;TEXT INTEGRATION UTILITIES;**158,355**;Jun 20, 1997;Build 11
 ;
 Q
ALRTDEL ;
 S TIU("DELETE")=1
 S TIU("MSG")="     Delete Alerts for the following documents:"
 D RESEND
 K TIU("DELETE"),TIU("MSG")
 Q
ASKUSR ;
 N TIUTMP
 D   I TIUTMP("ASK")=-1 S TIU("QUIT")=1 Q
 . N DIR,POP,TIUCONT,X,Y
 . S DIR(0)="SA^1:Browse Document;2:Combination Alerts;3:Delete Alerts;4:Detailed Display;5:Edit a Document;6:Identify Signers;7:Resend Alerts;8:Third Party Alerts"
 . S DIR("A")="Select ACTION: "
 . S DIR("B")="RESEND ALERTS"
 . S DIR("L",1)="1.  Browse a Document   4.  Detailed Display    7.  Resend Alerts"
 . S DIR("L",2)="2.  Combination Alerts  5.  Edit a Document     8.  Third Party Alerts"
 . S DIR("L",3)="3.  Delete Alerts       6.  Identify Signers"
 . S DIR("L",4)=""
 . S DIR("L")="Enter selection by typing the name, number, or abbreviation"
 . S DIR("?",1)="The following actions are available:"
 . S DIR("?",2)="Browse a Document  - View a selected document (if authorized)"
 . S DIR("?",3)="Combination Alerts - Send alerts to expected signers and 3rd parties"
 . S DIR("?",4)="Delete Alerts      - Delete a document's alerts"
 . S DIR("?",5)="Detailed Display   - View detailed display of a document (if authorized)"
 . S DIR("?",6)="Edit a Document    - Edit a selected document (if authorized)"
 . S DIR("?",7)="Identify Signers   - Identify/Change Signers of a document (if authorized)"
 . S DIR("?",8)="Resend Alerts      - Resend alerts to expected signers"
 . S DIR("?")="Third Party Alerts - Send alerts to one or more 3rd parties"
 . F  D ^DIR D  Q:$G(TIUCONT)!$D(DIRUT)
 . . I $D(TIUC(2)),+Y=1 W !,"You can only browse one document at a time.  Select another action." Q
 . . I $D(TIUC(2)),+Y=4 W !,"You can only view the detailed display of one document at a time.",!,"Select another action." Q
 . . I $D(TIUC(2)),+Y=5 W !,"You can only edit one document at a time.  Select another action." Q
 . . I $D(TIUC(2)),+Y=6 W !,"You can only identify signers one document at a time.  Select another action." Q
 . . S TIUCONT=1
 . S TIUTMP("ASK")=$S(+Y=1:"BROWSE",+Y=2:"COMBO",+Y=3:"ALRTDEL",+Y=4:"DETDISP^TIUALSET",+Y=5:"EDIT^TIUAL1",+Y=6:"IDSIGNER",+Y=7:"RESEND",+Y=8:"THIRD",Y=U:-1,1:-1)
 D @TIUTMP("ASK")
 Q
BROWSE ;
 N TEMP,TIUCNT,TIUSEL,TIUQUIK,TIUDA,TIUPRM0,TIUPRM1,TIUPRM3,RSTOK S TIUQUIK=1
 K TIUC
 D FULL^VALM1
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 S TIUSEL=$P(XQORNOD(0),"=",2)
 I TIUSEL="" D  Q:TIUSEL=U!($D(DIRUT))
 . N DIR,X,Y
 . S DIR("A")="Select Document: (1-"_VALMLST_") "
 . S DIR(0)="NA^1:"_VALMLST
 . D ^DIR S TIUSEL=Y
 I $A($E(TIUSEL,$L(TIUSEL)))<48!($A($E(TIUSEL,$L(TIUSEL)))>57) S TIUSEL=$E(TIUSEL,1,$L(TIUSEL)-1)
 F X=1:1  Q:$P(TIUSEL,",",X)=""  S TIUC($P(TIUSEL,",",X))=$O(@VALMAR@("IDX",$P(TIUSEL,",",X),""))
 S TIUDA=TIUC(TIUSEL)
 S RSTOK=$$DOCCHK^TIULRR(TIUDA)
 I RSTOK'>0 D  Q
 . W !!,$C(7),"Ok, no harm done...",! ; Echo denial message
 . I $$READ^TIUU("EA","RETURN to continue...") ; pause
 I $P(^TIU(8925,+TIUDA,0),U,5)'<7,'+$$ISSIGNR^TIUALRT(TIUDA,DUZ)
 D:'$D(TIUPRM0)!'$D(TIUPRM1) SETPARM^TIULE
 S TEMP("CNT")=TIU("CNT"),TEMP("P")=TIU("P"),TEMP("S")=TIU("S")
 S TEMP("D",1)=TIU("D",1),TEMP("D",2)=TIU("D",2)
 S TEMP=""
 F  S TEMP=$O(TIU("C",TEMP)) Q:TEMP=""  S TEMP("C",TEMP)=TIU("C",TEMP)
 F TIUCNT=1:1:TIU("S") S TEMP("S",TIUCNT)=TIU("S",TIUCNT) S $P(TEMP("S",TIUCNT),U)=$S(+TEMP("S",TIUCNT)=10:14,+TEMP("S",TIUCNT)=11:15,1:+TEMP("S",TIUCNT))
 K TIU D EN^VALM("TIU BROWSE FOR READ ONLY")
 S TIU("CNT")=TEMP("CNT"),TIU("P")=TEMP("P"),TIU("S")=TEMP("S")
 S TEMP=""
 F  S TEMP=$O(TEMP("C",TEMP)) Q:TEMP=""  S TIU("C",TEMP)=TEMP("C",TEMP)
 S TIU("D",1)=TEMP("D",1),TIU("D",2)=TEMP("D",2)
 F TIUCNT=1:1:TEMP("S") S TIU("S",TIUCNT)=TEMP("S",TIUCNT) S $P(TIU("S",TIUCNT),U)=$S(+TIU("S",TIUCNT)=10:14,+TIU("S",TIUCNT)=11:15,1:+TIU("S",TIUCNT))
 Q
COMBO ;
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 S TIUTMP("CMSG")=1,TIU("MSG")="     Send COMBINATION Alerts for the following documents:"
 S TIUTMP("THIRD PARTY ALERTS")="",TIUTMP("NODEL")=""
 D USERS
 K TIUTMP("CMSG"),TIU("MSG")
 Q
RESEND ;
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 N DIR,TIUCNT,TIUDA,TIUDIV1,TIUOD,TIUPRM0,TIUPRM1,TIUQUIT,X,Y
 ;
 I '$D(TIU("MSG")) S TIU("MSG")="     Resend Alerts for the following documents:"
 W @IOF,!,TIU("MSG"),!!
 S TIUCNT="",TIUCNT(1)=0,TIUCNT(2)=19
 F  S TIUCNT(1)=TIUCNT(1)+1,TIUCNT=$O(TIUC(TIUCNT)) W:TIUCNT=""&($G(Y)'=0) ! Q:TIUCNT=""  W $E(@VALMAR@(TIUCNT,0),1,80) D:TIUCNT(1)#TIUCNT(2)=0
 . S TIUCNT(2)=TIUCNT(2)+21
 . N DIR S DIR(0)="E" W ! D ^DIR W !! I Y=0 S TIUCNT="",TIUCNT=$O(TIUC(TIUCNT),-1)
 S DIR(0)="Y",DIR("A")="     Send these alerts as OVERDUE",DIR("B")="NO"
 I '$D(TIU("DELETE")) D ^DIR S TIUOD=+Y Q:TIUOD=U!($D(DIRUT))  W !
 S DIR(0)="Y",DIR("A")="     Is this correct",DIR("B")="YES"
 D ^DIR I +Y'=1 S TIUQUIT=1 Q
 I $G(TIUTMP("CMSG"))=1 F  S TIUCNT=$O(TIUC(TIUCNT)) Q:TIUCNT=""  D ALERTDEL^TIUALRT(TIUC(TIUCNT))
 I '$D(TIU("DELETE")) W !!,"     Sending Alerts..."
 I $D(TIU("DELETE")) W !!,"     Deleting Alerts..."
 S TIUCNT=""
 I '$D(TIU("DELETE")) D
 . S TIUXQA=$S($D(TIUTMP("CMSG")):0,'$D(TIUXQA):0,1:1)
 . F  S TIUCNT=$O(TIUC(TIUCNT)) Q:TIUCNT=""  W "." D SEND^TIUALRT(TIUC(TIUCNT),TIUOD,.TIUXQA) ; *355, pass recipients by reference
 I $D(TIU("DELETE")) F  S TIUCNT=$O(TIUC(TIUCNT)) Q:TIUCNT=""  W "." D ALERTDEL^TIUALRT(TIUC(TIUCNT))
 W !!,"     Finished.",!
 K DIR S DIR("A")="     Enter RETURN to continue or '^' to exit",DIR(0)="E" D ^DIR
 K TIUTMP("NODEL"),TIUXQA
 Q
SELECT(TIUACT) ;
 N TIUSEL,X,Y
 K TIUC
 D FULL^VALM1
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 S TIUSEL=$P(XQORNOD(0),"=",2)
 I TIUSEL="" D  Q:Y=U
 . N DIR
 . S DIR("A")="Select Document(s): (1-"_VALMLST_") "
 . S DIR(0)="LAC^1:"_VALMLST
 . D ^DIR I $D(DIRUT)!(Y=U) S Y=U Q
 . S TIUSEL=Y(0)
 I $A($E(TIUSEL,$L(TIUSEL)))<48!($A($E(TIUSEL,$L(TIUSEL)))>57) S TIUSEL=$E(TIUSEL,1,$L(TIUSEL)-1)
 F X=1:1  Q:$P(TIUSEL,",",X)=""  D
 . N TIUCNT
 . I $P(TIUSEL,",",X)["-" F TIUCNT=+$P(TIUSEL,",",X):1:$P($P(TIUSEL,",",X),"-",2) S TIUC(TIUCNT)=$O(@VALMAR@("IDX",TIUCNT,""))
 . E  S TIUC($P(TIUSEL,",",X))=$O(@VALMAR@("IDX",$P(TIUSEL,",",X),""))
 D @TIUACT
 Q
THIRD ;
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 S TIU("MSG")="     Send 3rd Party Alerts for the following documents:"
 S TIUTMP("THIRD PARTY ALERTS")="",TIUTMP("NODEL")=""
 D USERS
 K TIU("MSG")
 Q
USERS ;
 N TIUQUIT,TIUREM,TIUXQA
 K TIU("3RD"),TIU("CONTINUE")
 F  D  Q:$G(TIUQUIT)=1!($G(TIU("CONTINUE"))=1)
 . N DIC,DIR,POP,TIUCNT,X,Y
 . W @IOF,!
 . W "     Enter the name(s) of individuals to receive an alert for the selected",!
 . W "     document(s).",!!
 . W "     Kernel will not send alerts to Inactive users; they cannot be",!
 . W "     selected.",!!
 . W "     Enter RETURN or '^' to finish selections.",!
 . S TIUCNT=0,DIC="^VA(200,",DIC("S")="I '$P(^(0),U,7)"
 . S DIC(0)="AEMQ",DIC("A")="     Enter 3RD PARTY RECIPIENT(S): "
 . F  D ^DIC Q:Y=-1  D  Q:$G(TIUQUIT)=1  K TIUREM
 . . N TIUDA,TIUASK S TIUDA="" F  S TIUDA=$O(TIUC(TIUDA)) Q:TIUDA=""  I '$G(TIUASK),'$$CANDO(TIUC(TIUDA),+Y) D
 . . . S TIUASK=1
 . . . W !!?5,"Because ",$E($$GET1^DIQ(200,+Y,.01),1,15)," may not be able to SIGN/COSIGN some or all of the"
 . . . W !?5,"selected documents, they may be unable to resolve the resulting alerts.",!
 . . . N DIR,X,Y S DIR(0)="Y",DIR("A")="     Remove",DIR("B")="YES"
 . . . D ^DIR I Y=U!($D(DIRUT)) S TIUQUIT=1 Q
 . . . I +Y S TIUREM=1 W !
 . . S:'$G(TIUREM) TIUCNT=TIUCNT+1,TIU("3RD",+Y)="" S:TIUCNT=1 DIC("A")="                              and  "
 . Q:$G(TIUQUIT)=1
 . I TIUCNT=0 W !!,"     No selections made.",! S DIR("A")="     Enter RETURN to continue or '^' to exit",DIR(0)="E" D ^DIR S TIUQUIT=1 Q
 . W !!,$S(TIUCNT>1:"     Send 3rd Party Alerts to the following individuals: ",1:"     Send 3rd Party Alerts to the following individual: "),!!
 . S X="" F  S X=$O(TIU("3RD",X)) Q:X=""  S TIUXQA(X)="" W ?5,$$GET1^DIQ(200,X_",",.01),!
 . S DIR(0)="Y",DIR("A")="     Is this correct",DIR("B")="YES"
 . D ^DIR I +Y'=1 W !! K TIU("3RD"),TIUXQA S:Y=U TIUQUIT=1 Q
 . S TIU("CONTINUE")=1
 Q:$G(TIUQUIT)=1
 D RESEND
 Q
 ;
CANDO(TIUDA,PERSON) ;
 N TIUACT
 S TIUACT="SIGNATURE" I $$CANDO^TIULP(TIUDA,TIUACT,PERSON) Q 1
 S TIUACT="COSIGNATURE" I $$CANDO^TIULP(TIUDA,TIUACT,PERSON) Q 1
 Q 0
IDSIGNER ;
 N D,DIC,TIUCHNG,TIUDA,TIUDCSNR,TIUDIV1,TIUFPRIV,TIUPRM0,TIUPRM1,TIUSEL,X,Y
 D FULL^VALM1
 I TIU("CNT")=0 W !,"No documents to select." H 3 Q
 S TIUSEL=$P(XQORNOD(0),"=",2)
 I TIUSEL="" D  Q:TIUSEL=U!($D(DIRUT))
 . N DIR,X,Y
 . S DIR("A")="Select Document: (1-"_VALMLST_") "
 . S DIR(0)="NA^1:"_VALMLST
 . D ^DIR S TIUSEL=Y
 I $A($E(TIUSEL,$L(TIUSEL)))<48!($A($E(TIUSEL,$L(TIUSEL)))>57) S TIUSEL=$E(TIUSEL,1,$L(TIUSEL)-1)
 F X=1:1  Q:$P(TIUSEL,",",X)=""  S TIUC($P(TIUSEL,",",X))=$O(@VALMAR@("IDX",$P(TIUSEL,",",X),""))
 S TIUDA=TIUC(TIUSEL)
 D SIGNER^TIURA1
 D UPDATE^TIUALSET
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIUALFUN   9086     printed  Sep 23, 2025@20:15:06                                                                                                                                                                                                    Page 2
TIUALFUN  ; SLC/AJB - TIU ALERT FUNCTIONS ;01/30/23  12:28
 +1       ;;1.0;TEXT INTEGRATION UTILITIES;**158,355**;Jun 20, 1997;Build 11
 +2       ;
 +3        QUIT 
ALRTDEL   ;
 +1        SET TIU("DELETE")=1
 +2        SET TIU("MSG")="     Delete Alerts for the following documents:"
 +3        DO RESEND
 +4        KILL TIU("DELETE"),TIU("MSG")
 +5        QUIT 
ASKUSR    ;
 +1        NEW TIUTMP
 +2        Begin DoDot:1
 +3            NEW DIR,POP,TIUCONT,X,Y
 +4            SET DIR(0)="SA^1:Browse Document;2:Combination Alerts;3:Delete Alerts;4:Detailed Display;5:Edit a Document;6:Identify Signers;7:Resend Alerts;8:Third Party Alerts"
 +5            SET DIR("A")="Select ACTION: "
 +6            SET DIR("B")="RESEND ALERTS"
 +7            SET DIR("L",1)="1.  Browse a Document   4.  Detailed Display    7.  Resend Alerts"
 +8            SET DIR("L",2)="2.  Combination Alerts  5.  Edit a Document     8.  Third Party Alerts"
 +9            SET DIR("L",3)="3.  Delete Alerts       6.  Identify Signers"
 +10           SET DIR("L",4)=""
 +11           SET DIR("L")="Enter selection by typing the name, number, or abbreviation"
 +12           SET DIR("?",1)="The following actions are available:"
 +13           SET DIR("?",2)="Browse a Document  - View a selected document (if authorized)"
 +14           SET DIR("?",3)="Combination Alerts - Send alerts to expected signers and 3rd parties"
 +15           SET DIR("?",4)="Delete Alerts      - Delete a document's alerts"
 +16           SET DIR("?",5)="Detailed Display   - View detailed display of a document (if authorized)"
 +17           SET DIR("?",6)="Edit a Document    - Edit a selected document (if authorized)"
 +18           SET DIR("?",7)="Identify Signers   - Identify/Change Signers of a document (if authorized)"
 +19           SET DIR("?",8)="Resend Alerts      - Resend alerts to expected signers"
 +20           SET DIR("?")="Third Party Alerts - Send alerts to one or more 3rd parties"
 +21           FOR 
                   DO ^DIR
                   Begin DoDot:2
 +22                   IF $DATA(TIUC(2))
                           IF +Y=1
                               WRITE !,"You can only browse one document at a time.  Select another action."
                               QUIT 
 +23                   IF $DATA(TIUC(2))
                           IF +Y=4
                               WRITE !,"You can only view the detailed display of one document at a time.",!,"Select another action."
                               QUIT 
 +24                   IF $DATA(TIUC(2))
                           IF +Y=5
                               WRITE !,"You can only edit one document at a time.  Select another action."
                               QUIT 
 +25                   IF $DATA(TIUC(2))
                           IF +Y=6
                               WRITE !,"You can only identify signers one document at a time.  Select another action."
                               QUIT 
 +26                   SET TIUCONT=1
                   End DoDot:2
                   if $GET(TIUCONT)!$DATA(DIRUT)
                       QUIT 
 +27           SET TIUTMP("ASK")=$SELECT(+Y=1:"BROWSE",+Y=2:"COMBO",+Y=3:"ALRTDEL",+Y=4:"DETDISP^TIUALSET",+Y=5:"EDIT^TIUAL1",+Y=6:"IDSIGNER",+Y=7:"RESEND",+Y=8:"THIRD",Y=U:-1,1:-1)
           End DoDot:1
           IF TIUTMP("ASK")=-1
               SET TIU("QUIT")=1
               QUIT 
 +28       DO @TIUTMP("ASK")
 +29       QUIT 
BROWSE    ;
 +1        NEW TEMP,TIUCNT,TIUSEL,TIUQUIK,TIUDA,TIUPRM0,TIUPRM1,TIUPRM3,RSTOK
           SET TIUQUIK=1
 +2        KILL TIUC
 +3        DO FULL^VALM1
 +4        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +5        SET TIUSEL=$PIECE(XQORNOD(0),"=",2)
 +6        IF TIUSEL=""
               Begin DoDot:1
 +7                NEW DIR,X,Y
 +8                SET DIR("A")="Select Document: (1-"_VALMLST_") "
 +9                SET DIR(0)="NA^1:"_VALMLST
 +10               DO ^DIR
                   SET TIUSEL=Y
               End DoDot:1
               if TIUSEL=U!($DATA(DIRUT))
                   QUIT 
 +11       IF $ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))<48!($ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))>57)
               SET TIUSEL=$EXTRACT(TIUSEL,1,$LENGTH(TIUSEL)-1)
 +12       FOR X=1:1
               if $PIECE(TIUSEL,",",X)=""
                   QUIT 
               SET TIUC($PIECE(TIUSEL,",",X))=$ORDER(@VALMAR@("IDX",$PIECE(TIUSEL,",",X),""))
 +13       SET TIUDA=TIUC(TIUSEL)
 +14       SET RSTOK=$$DOCCHK^TIULRR(TIUDA)
 +15       IF RSTOK'>0
               Begin DoDot:1
 +16      ; Echo denial message
                   WRITE !!,$CHAR(7),"Ok, no harm done...",!
 +17      ; pause
                   IF $$READ^TIUU("EA","RETURN to continue...")
               End DoDot:1
               QUIT 
 +18       IF $PIECE(^TIU(8925,+TIUDA,0),U,5)'<7
               IF '+$$ISSIGNR^TIUALRT(TIUDA,DUZ)
 +19       if '$DATA(TIUPRM0)!'$DATA(TIUPRM1)
               DO SETPARM^TIULE
 +20       SET TEMP("CNT")=TIU("CNT")
           SET TEMP("P")=TIU("P")
           SET TEMP("S")=TIU("S")
 +21       SET TEMP("D",1)=TIU("D",1)
           SET TEMP("D",2)=TIU("D",2)
 +22       SET TEMP=""
 +23       FOR 
               SET TEMP=$ORDER(TIU("C",TEMP))
               if TEMP=""
                   QUIT 
               SET TEMP("C",TEMP)=TIU("C",TEMP)
 +24       FOR TIUCNT=1:1:TIU("S")
               SET TEMP("S",TIUCNT)=TIU("S",TIUCNT)
               SET $PIECE(TEMP("S",TIUCNT),U)=$SELECT(+TEMP("S",TIUCNT)=10:14,+TEMP("S",TIUCNT)=11:15,1:+TEMP("S",TIUCNT))
 +25       KILL TIU
           DO EN^VALM("TIU BROWSE FOR READ ONLY")
 +26       SET TIU("CNT")=TEMP("CNT")
           SET TIU("P")=TEMP("P")
           SET TIU("S")=TEMP("S")
 +27       SET TEMP=""
 +28       FOR 
               SET TEMP=$ORDER(TEMP("C",TEMP))
               if TEMP=""
                   QUIT 
               SET TIU("C",TEMP)=TEMP("C",TEMP)
 +29       SET TIU("D",1)=TEMP("D",1)
           SET TIU("D",2)=TEMP("D",2)
 +30       FOR TIUCNT=1:1:TEMP("S")
               SET TIU("S",TIUCNT)=TEMP("S",TIUCNT)
               SET $PIECE(TIU("S",TIUCNT),U)=$SELECT(+TIU("S",TIUCNT)=10:14,+TIU("S",TIUCNT)=11:15,1:+TIU("S",TIUCNT))
 +31       QUIT 
COMBO     ;
 +1        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +2        SET TIUTMP("CMSG")=1
           SET TIU("MSG")="     Send COMBINATION Alerts for the following documents:"
 +3        SET TIUTMP("THIRD PARTY ALERTS")=""
           SET TIUTMP("NODEL")=""
 +4        DO USERS
 +5        KILL TIUTMP("CMSG"),TIU("MSG")
 +6        QUIT 
RESEND    ;
 +1        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +2        NEW DIR,TIUCNT,TIUDA,TIUDIV1,TIUOD,TIUPRM0,TIUPRM1,TIUQUIT,X,Y
 +3       ;
 +4        IF '$DATA(TIU("MSG"))
               SET TIU("MSG")="     Resend Alerts for the following documents:"
 +5        WRITE @IOF,!,TIU("MSG"),!!
 +6        SET TIUCNT=""
           SET TIUCNT(1)=0
           SET TIUCNT(2)=19
 +7        FOR 
               SET TIUCNT(1)=TIUCNT(1)+1
               SET TIUCNT=$ORDER(TIUC(TIUCNT))
               if TIUCNT=""&($GET(Y)'=0)
                   WRITE !
               if TIUCNT=""
                   QUIT 
               WRITE $EXTRACT(@VALMAR@(TIUCNT,0),1,80)
               if TIUCNT(1)#TIUCNT(2)=0
                   Begin DoDot:1
 +8                    SET TIUCNT(2)=TIUCNT(2)+21
 +9                    NEW DIR
                       SET DIR(0)="E"
                       WRITE !
                       DO ^DIR
                       WRITE !!
                       IF Y=0
                           SET TIUCNT=""
                           SET TIUCNT=$ORDER(TIUC(TIUCNT),-1)
                   End DoDot:1
 +10       SET DIR(0)="Y"
           SET DIR("A")="     Send these alerts as OVERDUE"
           SET DIR("B")="NO"
 +11       IF '$DATA(TIU("DELETE"))
               DO ^DIR
               SET TIUOD=+Y
               if TIUOD=U!($DATA(DIRUT))
                   QUIT 
               WRITE !
 +12       SET DIR(0)="Y"
           SET DIR("A")="     Is this correct"
           SET DIR("B")="YES"
 +13       DO ^DIR
           IF +Y'=1
               SET TIUQUIT=1
               QUIT 
 +14       IF $GET(TIUTMP("CMSG"))=1
               FOR 
                   SET TIUCNT=$ORDER(TIUC(TIUCNT))
                   if TIUCNT=""
                       QUIT 
                   DO ALERTDEL^TIUALRT(TIUC(TIUCNT))
 +15       IF '$DATA(TIU("DELETE"))
               WRITE !!,"     Sending Alerts..."
 +16       IF $DATA(TIU("DELETE"))
               WRITE !!,"     Deleting Alerts..."
 +17       SET TIUCNT=""
 +18       IF '$DATA(TIU("DELETE"))
               Begin DoDot:1
 +19               SET TIUXQA=$SELECT($DATA(TIUTMP("CMSG")):0,'$DATA(TIUXQA):0,1:1)
 +20      ; *355, pass recipients by reference
                   FOR 
                       SET TIUCNT=$ORDER(TIUC(TIUCNT))
                       if TIUCNT=""
                           QUIT 
                       WRITE "."
                       DO SEND^TIUALRT(TIUC(TIUCNT),TIUOD,.TIUXQA)
               End DoDot:1
 +21       IF $DATA(TIU("DELETE"))
               FOR 
                   SET TIUCNT=$ORDER(TIUC(TIUCNT))
                   if TIUCNT=""
                       QUIT 
                   WRITE "."
                   DO ALERTDEL^TIUALRT(TIUC(TIUCNT))
 +22       WRITE !!,"     Finished.",!
 +23       KILL DIR
           SET DIR("A")="     Enter RETURN to continue or '^' to exit"
           SET DIR(0)="E"
           DO ^DIR
 +24       KILL TIUTMP("NODEL"),TIUXQA
 +25       QUIT 
SELECT(TIUACT) ;
 +1        NEW TIUSEL,X,Y
 +2        KILL TIUC
 +3        DO FULL^VALM1
 +4        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +5        SET TIUSEL=$PIECE(XQORNOD(0),"=",2)
 +6        IF TIUSEL=""
               Begin DoDot:1
 +7                NEW DIR
 +8                SET DIR("A")="Select Document(s): (1-"_VALMLST_") "
 +9                SET DIR(0)="LAC^1:"_VALMLST
 +10               DO ^DIR
                   IF $DATA(DIRUT)!(Y=U)
                       SET Y=U
                       QUIT 
 +11               SET TIUSEL=Y(0)
               End DoDot:1
               if Y=U
                   QUIT 
 +12       IF $ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))<48!($ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))>57)
               SET TIUSEL=$EXTRACT(TIUSEL,1,$LENGTH(TIUSEL)-1)
 +13       FOR X=1:1
               if $PIECE(TIUSEL,",",X)=""
                   QUIT 
               Begin DoDot:1
 +14               NEW TIUCNT
 +15               IF $PIECE(TIUSEL,",",X)["-"
                       FOR TIUCNT=+$PIECE(TIUSEL,",",X):1:$PIECE($PIECE(TIUSEL,",",X),"-",2)
                           SET TIUC(TIUCNT)=$ORDER(@VALMAR@("IDX",TIUCNT,""))
 +16              IF '$TEST
                       SET TIUC($PIECE(TIUSEL,",",X))=$ORDER(@VALMAR@("IDX",$PIECE(TIUSEL,",",X),""))
               End DoDot:1
 +17       DO @TIUACT
 +18       QUIT 
THIRD     ;
 +1        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +2        SET TIU("MSG")="     Send 3rd Party Alerts for the following documents:"
 +3        SET TIUTMP("THIRD PARTY ALERTS")=""
           SET TIUTMP("NODEL")=""
 +4        DO USERS
 +5        KILL TIU("MSG")
 +6        QUIT 
USERS     ;
 +1        NEW TIUQUIT,TIUREM,TIUXQA
 +2        KILL TIU("3RD"),TIU("CONTINUE")
 +3        FOR 
               Begin DoDot:1
 +4                NEW DIC,DIR,POP,TIUCNT,X,Y
 +5                WRITE @IOF,!
 +6                WRITE "     Enter the name(s) of individuals to receive an alert for the selected",!
 +7                WRITE "     document(s).",!!
 +8                WRITE "     Kernel will not send alerts to Inactive users; they cannot be",!
 +9                WRITE "     selected.",!!
 +10               WRITE "     Enter RETURN or '^' to finish selections.",!
 +11               SET TIUCNT=0
                   SET DIC="^VA(200,"
                   SET DIC("S")="I '$P(^(0),U,7)"
 +12               SET DIC(0)="AEMQ"
                   SET DIC("A")="     Enter 3RD PARTY RECIPIENT(S): "
 +13               FOR 
                       DO ^DIC
                       if Y=-1
                           QUIT 
                       Begin DoDot:2
 +14                       NEW TIUDA,TIUASK
                           SET TIUDA=""
                           FOR 
                               SET TIUDA=$ORDER(TIUC(TIUDA))
                               if TIUDA=""
                                   QUIT 
                               IF '$GET(TIUASK)
                                   IF '$$CANDO(TIUC(TIUDA),+Y)
                                       Begin DoDot:3
 +15                                       SET TIUASK=1
 +16                                       WRITE !!?5,"Because ",$EXTRACT($$GET1^DIQ(200,+Y,.01),1,15)," may not be able to SIGN/COSIGN some or all of the"
 +17                                       WRITE !?5,"selected documents, they may be unable to resolve the resulting alerts.",!
 +18                                       NEW DIR,X,Y
                                           SET DIR(0)="Y"
                                           SET DIR("A")="     Remove"
                                           SET DIR("B")="YES"
 +19                                       DO ^DIR
                                           IF Y=U!($DATA(DIRUT))
                                               SET TIUQUIT=1
                                               QUIT 
 +20                                       IF +Y
                                               SET TIUREM=1
                                               WRITE !
                                       End DoDot:3
 +21                       if '$GET(TIUREM)
                               SET TIUCNT=TIUCNT+1
                               SET TIU("3RD",+Y)=""
                           if TIUCNT=1
                               SET DIC("A")="                              and  "
                       End DoDot:2
                       if $GET(TIUQUIT)=1
                           QUIT 
                       KILL TIUREM
 +22               if $GET(TIUQUIT)=1
                       QUIT 
 +23               IF TIUCNT=0
                       WRITE !!,"     No selections made.",!
                       SET DIR("A")="     Enter RETURN to continue or '^' to exit"
                       SET DIR(0)="E"
                       DO ^DIR
                       SET TIUQUIT=1
                       QUIT 
 +24               WRITE !!,$SELECT(TIUCNT>1:"     Send 3rd Party Alerts to the following individuals: ",1:"     Send 3rd Party Alerts to the following individual: "),!!
 +25               SET X=""
                   FOR 
                       SET X=$ORDER(TIU("3RD",X))
                       if X=""
                           QUIT 
                       SET TIUXQA(X)=""
                       WRITE ?5,$$GET1^DIQ(200,X_",",.01),!
 +26               SET DIR(0)="Y"
                   SET DIR("A")="     Is this correct"
                   SET DIR("B")="YES"
 +27               DO ^DIR
                   IF +Y'=1
                       WRITE !!
                       KILL TIU("3RD"),TIUXQA
                       if Y=U
                           SET TIUQUIT=1
                       QUIT 
 +28               SET TIU("CONTINUE")=1
               End DoDot:1
               if $GET(TIUQUIT)=1!($GET(TIU("CONTINUE"))=1)
                   QUIT 
 +29       if $GET(TIUQUIT)=1
               QUIT 
 +30       DO RESEND
 +31       QUIT 
 +32      ;
CANDO(TIUDA,PERSON) ;
 +1        NEW TIUACT
 +2        SET TIUACT="SIGNATURE"
           IF $$CANDO^TIULP(TIUDA,TIUACT,PERSON)
               QUIT 1
 +3        SET TIUACT="COSIGNATURE"
           IF $$CANDO^TIULP(TIUDA,TIUACT,PERSON)
               QUIT 1
 +4        QUIT 0
IDSIGNER  ;
 +1        NEW D,DIC,TIUCHNG,TIUDA,TIUDCSNR,TIUDIV1,TIUFPRIV,TIUPRM0,TIUPRM1,TIUSEL,X,Y
 +2        DO FULL^VALM1
 +3        IF TIU("CNT")=0
               WRITE !,"No documents to select."
               HANG 3
               QUIT 
 +4        SET TIUSEL=$PIECE(XQORNOD(0),"=",2)
 +5        IF TIUSEL=""
               Begin DoDot:1
 +6                NEW DIR,X,Y
 +7                SET DIR("A")="Select Document: (1-"_VALMLST_") "
 +8                SET DIR(0)="NA^1:"_VALMLST
 +9                DO ^DIR
                   SET TIUSEL=Y
               End DoDot:1
               if TIUSEL=U!($DATA(DIRUT))
                   QUIT 
 +10       IF $ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))<48!($ASCII($EXTRACT(TIUSEL,$LENGTH(TIUSEL)))>57)
               SET TIUSEL=$EXTRACT(TIUSEL,1,$LENGTH(TIUSEL)-1)
 +11       FOR X=1:1
               if $PIECE(TIUSEL,",",X)=""
                   QUIT 
               SET TIUC($PIECE(TIUSEL,",",X))=$ORDER(@VALMAR@("IDX",$PIECE(TIUSEL,",",X),""))
 +12       SET TIUDA=TIUC(TIUSEL)
 +13       DO SIGNER^TIURA1
 +14       DO UPDATE^TIUALSET
 +15       QUIT