PRC0A ;WISC/PLT-General Questions Utility ; 24-Aug-1994 10:34 AM
V ;;5.1;IFCAP;;Oct 20, 2000
 ;Per VHA Directive 10-93-142, this routine should not be modified.
 QUIT  ;invalid entry
 ;the following are for DIR call for data type D,E,F,L,N,P,S,Y,#
 ;A for DIR("A") - prompt text.
 ;B for DIR(0) without 1st characters - input modifiers^parameters^transform.
 ;  modifiers A: prompt not append, O:response optional
 ; set of codes    X: exact match, B: code listed horizontally
 ;                 M: mix case match without X
 ; free text    U: if '^' allowed in free text
 ;C for DIR("B") - default response
 ;.x(1...) for DIR("A") propmt array or value returned
 ;.y(1...) for DIR("?") array or value returned 
 ;
 ;date
 ;B is ^1=A, O or "", ^2=mini date:maximum date, ^3=mumps code
DT(X,Y,A,B,C) N DIR,D S DIR(0)="D"_B,DIR("A")=A S:$G(C)]"" DIR("B")=C
 S DIR("?")="Enter a date",D=$P(B,U,2,3)
 I $P(D,":")]"" S Y=$P(D,":") D DD^%DT S Y=$S($P(D,":",2)]"":" between ",1:" after ")_Y,DIR("?")=DIR("?")_Y
 I $P(D,":",2)]"" S Y=$P(B,":",2) D DD^%DT S Y=$S($P(D,":",1)="":" before ",1:" and ")_Y,DIR("?")=DIR("?")_Y
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;end of page
 ;B is ^1= A OR "", ^2="", ^3=""
EOP(X,Y,A,B,C) N DIR S DIR(0)="E"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 S DIR("?")="Enter 'return' to continue or '^' to exit."
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;free text
 ;B is ^1=A, O or U, ^2=minimum legth:maximum length, ^3=mumps code
FT(X,Y,A,B,C) N DIR S DIR(0)="F"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;list of range
 ;B is ^1=A, O or "", ^2=mini value:maxi value, ^3=mumps code
LR(X,Y,A,B,C) N DIR S DIR(0)="L"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;numeric
 ;B is ^1=A, O or "", ^2=mini value:maxi value:maxi decimals, ^3=mumps code
NUM(X,Y,A,B,C) N DIR S DIR(0)="N"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;pointer
 ;B is ^1=A, O or "", ^2=file #/subfile root:dic(0) data, ^3=mumps code
PTR(X,Y,A,B,C) N DIR S DIR(0)="P"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;set of codes
 ;B is ^1=A,O,X,B, or M, ^2=code:description;code:description;..., ^3=mumps code
SC(X,Y,A,B,C) N DIR S DIR(0)="S"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;yes/no
 ;B is ^1=A, O or "", ^2"", ^3=""
YN(X,Y,A,B,C) N DIR S DIR(0)="Y"_B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 S DIR("?")="Enter 'Y' for yes, 'N' for no."
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
 ;data field definition
 ;B is ^1=(sub)file number,field numberAO, ^2="", ^3=""
DD(X,Y,A,B,C) N DIR S DIR(0)=B S:A]"" DIR("A")=A S:$G(C)]"" DIR("B")=C
 D DIRA:$D(X(1)),DIRQ:$D(Y(1)),^DIR
 QUIT
 ;
DIRA N A S A=0 F  S A=$O(X(A)) Q:A=""  S DIR("A",A)=X(A)
 K X
 QUIT
DIRQ N A F A=1:1 Q:'$D(Y(A))  S DIR("?",A)=Y(A)
 S DIR("?")=Y(A-1) K DIR("?",A-1)
 K Y
 QUIT
 ;
 ;.x user typed value, .y=-1 if invalid, yymmdd.hhmmss
 ;A=prompt text, B=^1:fault value (external form), ^2=[-]fm date
 ;C=string of AEFNPRST, any combination
 ;  A for ask, E for echo, F for future assum, N for pure num not allowed
 ;  P for past assum, R time required, S seconds required
 ;  T time is optional
 ;D= Y if year only, YM if year and month only, YMD if date[@time] only
YMDT(X,Y,A,B,C,D) ;reader for year/month/date/time
 N %DT,DTOUT
YMDT1 S %DT("A")=A,%DT("B")=$P(B,"^") S:$P(B,"^",2)]"" %DT(0)=$P(B,"^",2)
 S %DT=C S:$G(D)="YMD" %DT=%DT_"X"
 D ^%DT
 I Y'=-1,$G(D)="Y",Y#10000'=0 W "   Enter year only!" G YMDT1
 I Y'=-1,$G(D)="YM",Y#100'=0 W "   Enter month and year only!" G YMDT1
 QUIT
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRC0A   3778     printed  Sep 23, 2025@19:35:15                                                                                                                                                                                                       Page 2
PRC0A     ;WISC/PLT-General Questions Utility ; 24-Aug-1994 10:34 AM
V         ;;5.1;IFCAP;;Oct 20, 2000
 +1       ;Per VHA Directive 10-93-142, this routine should not be modified.
 +2       ;invalid entry
           QUIT 
 +3       ;the following are for DIR call for data type D,E,F,L,N,P,S,Y,#
 +4       ;A for DIR("A") - prompt text.
 +5       ;B for DIR(0) without 1st characters - input modifiers^parameters^transform.
 +6       ;  modifiers A: prompt not append, O:response optional
 +7       ; set of codes    X: exact match, B: code listed horizontally
 +8       ;                 M: mix case match without X
 +9       ; free text    U: if '^' allowed in free text
 +10      ;C for DIR("B") - default response
 +11      ;.x(1...) for DIR("A") propmt array or value returned
 +12      ;.y(1...) for DIR("?") array or value returned 
 +13      ;
 +14      ;date
 +15      ;B is ^1=A, O or "", ^2=mini date:maximum date, ^3=mumps code
DT(X,Y,A,B,C)  NEW DIR,D
           SET DIR(0)="D"_B
           SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        SET DIR("?")="Enter a date"
           SET D=$PIECE(B,U,2,3)
 +2        IF $PIECE(D,":")]""
               SET Y=$PIECE(D,":")
               DO DD^%DT
               SET Y=$SELECT($PIECE(D,":",2)]"":" between ",1:" after ")_Y
               SET DIR("?")=DIR("?")_Y
 +3        IF $PIECE(D,":",2)]""
               SET Y=$PIECE(B,":",2)
               DO DD^%DT
               SET Y=$SELECT($PIECE(D,":",1)="":" before ",1:" and ")_Y
               SET DIR("?")=DIR("?")_Y
 +4        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +5        QUIT 
 +6       ;
 +7       ;end of page
 +8       ;B is ^1= A OR "", ^2="", ^3=""
EOP(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="E"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        SET DIR("?")="Enter 'return' to continue or '^' to exit."
 +2        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +3        QUIT 
 +4       ;
 +5       ;free text
 +6       ;B is ^1=A, O or U, ^2=minimum legth:maximum length, ^3=mumps code
FT(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="F"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
 +4       ;list of range
 +5       ;B is ^1=A, O or "", ^2=mini value:maxi value, ^3=mumps code
LR(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="L"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
 +4       ;numeric
 +5       ;B is ^1=A, O or "", ^2=mini value:maxi value:maxi decimals, ^3=mumps code
NUM(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="N"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
 +4       ;pointer
 +5       ;B is ^1=A, O or "", ^2=file #/subfile root:dic(0) data, ^3=mumps code
PTR(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="P"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
 +4       ;set of codes
 +5       ;B is ^1=A,O,X,B, or M, ^2=code:description;code:description;..., ^3=mumps code
SC(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="S"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
 +4       ;yes/no
 +5       ;B is ^1=A, O or "", ^2"", ^3=""
YN(X,Y,A,B,C)  NEW DIR
           SET DIR(0)="Y"_B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        SET DIR("?")="Enter 'Y' for yes, 'N' for no."
 +2        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +3        QUIT 
 +4       ;
 +5       ;data field definition
 +6       ;B is ^1=(sub)file number,field numberAO, ^2="", ^3=""
DD(X,Y,A,B,C)  NEW DIR
           SET DIR(0)=B
           if A]""
               SET DIR("A")=A
           if $GET(C)]""
               SET DIR("B")=C
 +1        if $DATA(X(1))
               DO DIRA
           if $DATA(Y(1))
               DO DIRQ
           DO ^DIR
 +2        QUIT 
 +3       ;
DIRA       NEW A
           SET A=0
           FOR 
               SET A=$ORDER(X(A))
               if A=""
                   QUIT 
               SET DIR("A",A)=X(A)
 +1        KILL X
 +2        QUIT 
DIRQ       NEW A
           FOR A=1:1
               if '$DATA(Y(A))
                   QUIT 
               SET DIR("?",A)=Y(A)
 +1        SET DIR("?")=Y(A-1)
           KILL DIR("?",A-1)
 +2        KILL Y
 +3        QUIT 
 +4       ;
 +5       ;.x user typed value, .y=-1 if invalid, yymmdd.hhmmss
 +6       ;A=prompt text, B=^1:fault value (external form), ^2=[-]fm date
 +7       ;C=string of AEFNPRST, any combination
 +8       ;  A for ask, E for echo, F for future assum, N for pure num not allowed
 +9       ;  P for past assum, R time required, S seconds required
 +10      ;  T time is optional
 +11      ;D= Y if year only, YM if year and month only, YMD if date[@time] only
YMDT(X,Y,A,B,C,D) ;reader for year/month/date/time
 +1        NEW %DT,DTOUT
YMDT1      SET %DT("A")=A
           SET %DT("B")=$PIECE(B,"^")
           if $PIECE(B,"^",2)]""
               SET %DT(0)=$PIECE(B,"^",2)
 +1        SET %DT=C
           if $GET(D)="YMD"
               SET %DT=%DT_"X"
 +2        DO ^%DT
 +3        IF Y'=-1
               IF $GET(D)="Y"
                   IF Y#10000'=0
                       WRITE "   Enter year only!"
                       GOTO YMDT1
 +4        IF Y'=-1
               IF $GET(D)="YM"
                   IF Y#100'=0
                       WRITE "   Enter month and year only!"
                       GOTO YMDT1
 +5        QUIT