DIEH ;SFISC-HELP ;13APR2004
 ;;22.0;VA FileMan;**1004**;Mar 30, 1999
GET(DIEHF,DIEHIEN,DIEHFLD,DIEHFLG,DIEHOUT) ;
GETX ;
 N DIEHZ,DIEHD,DIEHEXIT,DIEHPF,DIEHUFLG
 S DIEHUFLG=$G(DIEHFLG)
 I '$G(DIQUIET) N DIQUIET S DIQUIET=1
 I '$G(DIFM) N DIFM S DIFM=1 D INIZE^DIEFU
 I $G(DIEHIEN)]"" N DA,C,D,I D DA^DIEFU(DIEHIEN,.DA) S C=$L(DIEHIEN,",")-1 F I=1:1:C S D="D"_(C-I) N @D S @D=$P(DIEHIEN,",",I)
 S DIEHZ=$$ZERO(DIEHF,DIEHFLD) I DIEHZ=0 G GETOUT
 S DIEHD=$P(DIEHZ,U,2)
 D BLDFLGS G:$G(DIEHEXIT) GETOUT
 I DIEHD["P" S DIEHPF=+$P(DIEHD,"P",2)
 S DIHELP=+$O(^TMP("DIHELP",$J,""),-1)
 I DIEHUFLG["F",DIEHFLD=.01 D PXREFS(DIEHF,DIEHFLD)
 I DIEHUFLG["H" D HPROMPT(DIEHF,DIEHFLD)
 I DIEHUFLG["X" D XHLP(DIEHF,DIEHFLD)
 I DIEHUFLG["D" D DESCR(DIEHF,DIEHFLD)
 I DIEHUFLG["P" D SCRNDES(DIEHF,DIEHFLD)
 I DIEHUFLG["C" D SCRNDES(DIEHF,DIEHFLD)
 I DIEHUFLG["T" N DIEHDT S DIEHDT=$P($P($P(DIEHZ,U,5,99),"%DT=""",2),"""",1)  D DT^DIEH1(DIEHDT)
 I DIEHUFLG["S" D SCRNCD(DIEHF,DIEHFLD,DIEHZ)
 I DIEHUFLG["U" D UNSCRNCD(DIEHZ)
 I DIEHUFLG["V" D VPMSG(DIEHF,DIEHFLD)
 I DIEHUFLG["B",DIEHUFLG'["b" D BLD^DIALOG(9115)
 I DIEHUFLG["M" D BLD^DIALOG(9116)
 I DIEHUFLG["G",DIEHFLG'["g",$G(DIEHPF) D FOLLOW(DIEHPF,DIEHFLG)
 I '$G(DIHELP) K DIHELP
GETOUT I $D(DIEHOUT) D CALLOUT^DIEFU(DIEHOUT)
 Q
 ;
BLDFLGS ;
 N A1,A2,C1,C2,DIEHGFLG
 S C1="HX",C2="XD",(A1,A2)=""
 I DIEHD S DIEHF=+DIEHD,DIEHFLD=.01,DIEHD=$P(^DD(DIEHF,.01,0),U,2)
 I DIEHD["W" S (A1,A2)="HD"
 E  I DIEHD["D" S (A1,A2)="T"
 E  I DIEHD["S" S A1="CS",A2="S",DIEHGFLG="U"
 E  I DIEHD["P" S A1="PG",A2="G",DIEHGFLG="F"
 E  I DIEHD="V" S A1="VB",A2="VMB"
 I DIEHFLD=.01,'$D(^DD(DIEHF,0,"UP")) S A1=A1_"F",A2=A2_"F"
 I DIEHUFLG'["r",'$$VERFLG^DIEFU(DIEHUFLG,"bgA?"_C1_C2_A1_A2_$G(DIEHGFLG)) S DIEHEXIT=1
 I DIEHUFLG["??" S DIEHUFLG=DIEHUFLG_C2_A2
 E  I DIEHUFLG["?" S DIEHUFLG=DIEHUFLG_C1_A1
 E  I DIEHUFLG["A" S DIEHUFLG=$TR(C1_C2_A1_A2,"S","U")
 Q
 ;
ZERO(F,D) ;
 I '$$VFILE^DIEFU(F,"D") Q 0
 I '$$VFIELD^DIEFU(F,D,"D") Q 0
 Q ^DD(F,D,0)
 ;
BN ;Insert blank node.
 S:DIHELP DIHELP=DIHELP+1,^TMP("DIHELP",$J,DIHELP)=""
 Q
 ;
HPROMPT(F,D) ;
 N T
 S T=$$HELP^DIALOGZ(F,D)
 I $L(T) D
 . D BN
 . S DIHELP=DIHELP+1,^TMP("DIHELP",$J,DIHELP)=T
 Q
 ;
XHLP(DIEHF,DIEHFLD) ;
 ;DA() and D0,D1,etc. passed thru symbol table.
 N DIEHXH S DIEHXH=$G(^DD(DIEHF,DIEHFLD,4))
 I $L(DIEHXH) D
 . D BN
 . N DIEHECNT S DIEHECNT=$G(DIERR)
 . N DDIOLFLG S DDIOLFLG="H" X DIEHXH
 . I DIEHECNT'=$G(DIERR) D HKERR^DILIBF(DIEHF,"",DIEHFLD,"Xecutable Help")
 Q
 ;
DESCR(F,D) ;
 N L
 S L=$P($G(^DD(F,D,21,0)),U,3)
 I L D
 . D BN
 . N I F I=1:1:L S DIHELP=DIHELP+1,^TMP("DIHELP",$J,DIHELP)=^DD(F,D,21,I,0)
 . Q
 Q
 ;
PXREFS(DIEHF,DIEHFLD) ;
 N DIF,DIFD,DIEHROOT,DIEHIXID,DIEHIXP,DIEHIXNM,DIFULL
 S DIEHIXP=$$FILENM^DIEFU(DIEHF)_" "
 D GETIXNM(DIEHF,.DIEHIXNM)
 S DIF=""
 F  S DIF=$O(DIEHIXNM(DIF)) Q:DIF=""  D  Q:$D(DIFULL)
 . S DIFD=""
 . F  S DIFD=$O(DIEHIXNM(DIF,DIFD)) Q:DIFD=""  D  Q:$D(DIFULL)
 . . I $L(DIEHIXP)+$L(DIEHIXNM(DIF,DIFD))>240 D  Q
 . . . S DIEHIXP=DIEHIXP_", etc     "
 . . . S DIFULL=1
 . . S DIEHIXP=DIEHIXP_DIEHIXNM(DIF,DIFD)_", or "
 S DIEHIXP=$E(DIEHIXP,1,$L(DIEHIXP)-5)
 D BLD^DIALOG(9105,DIEHIXP)
 Q
 ;
GETIXNM(DIEHF,DIEHIXNM) ;
 S DIEHROOT=$$ROOT^DIQGU(DIEHF,"",1)
 S DIEHIXID="Az"
 F  S DIEHIXID=$O(@DIEHROOT@(DIEHIXID)) Q:DIEHIXID=""  D
 . N DIEHIXF,DIEHIXFD
 . S DIEHIXF=$O(^DD(DIEHF,0,"IX",DIEHIXID,"")) Q:DIEHIXF=""
 . S DIEHIXFD=$O(^DD(DIEHF,0,"IX",DIEHIXID,DIEHIXF,"")) Q:DIEHIXFD=""
 . S DIEHIXNM(DIEHIXF,DIEHIXFD)=$$FLDNM^DIEFU(DIEHIXF,DIEHIXFD)
 Q
 ;
SCRNDES(F,D) ;
 N T
 S T=$G(^DD(F,D,12))
 I $L(T) D
 . D BN
 . S DIHELP=DIHELP+1,^TMP("DIHELP",$J,DIHELP)=T
 . Q
 Q
 ;
SCRNCD(F,D,DIEHZ) ;
 N S,DIC,Y,A,T,I
 I $P(DIEHZ,U,2)'["*" D UNSCRNCD(DIEHZ) Q
 S S=$G(^DD(F,D,12.1))
 I S="" D UNSCRNCD(DIEHZ) Q
 D CODES
 I $D(Y) D
 . N DIEHECNT S DIEHECNT=$G(DIERR)
 . D SETSCR^DIR(F,D)
 . D BLD^DIALOG(9101)
 . F I=1:1:T D
 . . S Y=$P(Y(I),";",1)
 . . X DIC("S") I  D CODESOUT
 . I DIEHECNT'=$G(DIERR) D HKERR^DILIBF(F,"",D,"set of codes screen")
 Q
UNSCRNCD(DIEHZ) ;
 N Y,A,T,I
 D CODES
 I $D(Y) D
 . D BLD^DIALOG(9101)
 . F I=1:1:T D CODESOUT
 . Q
 Q
 ;
CODES ;
 S A=$P(DIEHZ,U,3) I $G(DUZ("LANG"))>1,A=$P(^DD(DIEHF,DIEHFLD,0),U,3) S A=$$SETIN^DIALOGZ_";" ;NAKED
 I A]"" D
 . S T=$L(A,";")-1
 . F I=1:1:T S Y(I)=$P(A,";",I)
 . Q
 Q
 ;
CODESOUT ;
 S DIHELP=DIHELP+1,^TMP("DIHELP",$J,DIHELP)=$P(Y(I),":",1)_"        "_$P(Y(I),":",2)
 Q
 ;
VPMSG(F,D) ;
 N I,N,P,L
 D BLD^DIALOG(9103)
 S I=0 F  S I=$O(^DD(F,D,"V",I)) Q:I="B"  S N=^(I,0) D
 . S P(1)=$P(N,U,4),P(2)=$P(N,U,2),L=$S(I=1:"",1:"S")
 . D BLD^DIALOG(9117,.P,.P,"",L)
 . Q
 Q
 ;
FOLLOW(DIEHPF,DIEHUFLG) ;
 D GET(DIEHPF,"",.01,DIEHUFLG_"r")
 Q
