LEXQHL3 ;ISL/KER - Query History - CPT/HCPCS Extract ;04/21/2014
;;2.0;LEXICON UTILITY;**62,80**;Sep 23, 1996;Build 10
;
; Global Variables
; ^ICPT( ICR 4489
; ^TMP("LEXQHL") SACC 2.3.2.5.1
;
; External References
; $$CPT^ICPTCOD ICR 1995
; $$UP^XLFSTR ICR 10104
;
Q
EN(X,Y) ; CPT/HCPCS Procedure File
N LEXIEN,LEXDISP,LEXIA,LEXEF,LEXCT,LEXC S LEXIEN=$G(X),LEXDISP=$G(Y),LEXIA="" Q:+LEXIEN'>0 Q:'$D(^ICPT(+LEXIEN,0)) S LEXC=$P($G(^ICPT(+LEXIEN,0)),U,1)
K ^TMP("LEXQHL",$J) S ^TMP("LEXQHL",$J,"IEN")=LEXIEN,^TMP("LEXQHL",$J,"CODE")=LEXC,^TMP("LEXQHL",$J,"NAME")=$P($$CPT^ICPTCOD(LEXC),U,3)
S:'$L(LEXDISP) LEXDISP="SB" D ST,NM,DS,CP^LEXQHL5(LEXC) D:$L($G(LEXDISP)) DP K ^TMP("LEXQHL",$J)
Q
ST ; 1 Status
N LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXMS,LEXN,LEXS,LEXT
S LEXCT=0,LEXEF="" F S LEXEF=$O(^ICPT(+LEXIEN,60,"B",LEXEF)) Q:'$L(LEXEF) D
. N LEXH S LEXH=0 F S LEXH=$O(^ICPT(+LEXIEN,60,"B",LEXEF,LEXH)) Q:+LEXH'>0 D
. . N LEXN,LEXS,LEXE,LEXT,LEXD,LEXMS S LEXN=$G(^ICPT(+LEXIEN,60,+LEXH,0)),LEXE=$P(LEXN,U,1),LEXS=$P(LEXN,U,2)
. . Q:+LEXS'>0&(LEXCT'>0) S LEXCT=LEXCT+1,LEXMS=$$MS^LEXQHLM(LEXE,1),LEXT=$S(+LEXS>0:"Activation",1:"Inactivation")
. . S:+LEXS>0&(LEXCT=1) LEXT="Initial Activation"_LEXMS,LEXIA=LEXE
. . S:$O(^ICPT(+LEXIEN,60,"B",LEXEF))=""&(LEXCT>1) LEXT=LEXT_" (final status change)"
. . S LEXD=$$SD^LEXQHLM(LEXE) S ^TMP("LEXQHL",$J,LEXEF,1,1)=LEXD_U_LEXT
Q
NM ; 2 Procedure Name
N LEX,LEXC,LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXI,LEXN,LEXS,LEXT
S LEXCT=0,LEXEF="" F S LEXEF=$O(^ICPT(+LEXIEN,61,"B",LEXEF)) Q:'$L(LEXEF) D
. N LEXH S LEXH=0 F S LEXH=$O(^ICPT(+LEXIEN,61,"B",LEXEF,LEXH)) Q:+LEXH'>0 D
. . N LEXN,LEXS,LEXE,LEXT,LEXD,LEX,LEXI S LEXN=$G(^ICPT(+LEXIEN,61,+LEXH,0)),LEXE=$P(LEXN,U,1),LEXT=$$UP^XLFSTR($P(LEXN,U,2))
. . S LEXCT=LEXCT+1,LEX(1)=LEXT D PR^LEXQHLM(.LEX,63)
. . S LEXS=$S(+LEXCT=1:"Initial Procedure Name",+LEXCT>1:"Updated Procedure Name",1:"Procedure Name")
. . S:$O(^ICPT(+LEXIEN,61,"B",LEXEF))=""&(LEXCT>1) LEXS=LEXS_" (final change)"
. . S LEXD=$$SD^LEXQHLM(LEXE) S ^TMP("LEXQHL",$J,LEXEF,2,1)=LEXD_U_LEXS
. . S LEXI=0 F S LEXI=$O(LEX(LEXI)) Q:+LEXI'>0 D
. . . N LEXC S LEXT=$G(LEX(LEXI)) Q:'$L(LEXT) S LEXC=$O(^TMP("LEXQHL",$J,LEXEF,2," "),-1)+1
. . . S ^TMP("LEXQHL",$J,LEXEF,2,LEXC)=U_LEXT
Q
DS ; 3 Description
N LEX,LEXC,LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXI,LEXN,LEXS,LEXT
S LEXCT=0,LEXEF="" F S LEXEF=$O(^ICPT(+LEXIEN,62,"B",LEXEF)) Q:'$L(LEXEF) D
. N LEXH S LEXH=0 F S LEXH=$O(^ICPT(+LEXIEN,62,"B",LEXEF,LEXH)) Q:+LEXH'>0 D
. . N LEXC,LEXN,LEXS,LEXE,LEXT,LEXD,LEX,LEXI S LEXN=$G(^ICPT(+LEXIEN,62,+LEXH,0))
. . S LEXE=$P(LEXN,U,1) S (LEXC,LEXI)=0 F S LEXI=$O(^ICPT(+LEXIEN,62,+LEXH,1,LEXI)) Q:+LEXI'>0 D
. . . S LEXT=$$TM^LEXQHLM($$UP^XLFSTR($G(^ICPT(+LEXIEN,62,+LEXH,1,LEXI,0)))) Q:'$L(LEXT) S LEXC=LEXC+1,LEX(LEXC)=LEXT
. . S LEXCT=LEXCT+1 D PR^LEXQHLM(.LEX,63)
. . S LEXS=$S(+LEXCT=1:"Initial Description",+LEXCT>1:"Updated Description",1:"Description")
. . S:$O(^ICPT(+LEXIEN,62,"B",LEXEF))=""&(LEXCT>1) LEXS=LEXS_" (final change)"
. . S LEXD=$$SD^LEXQHLM(LEXE) S ^TMP("LEXQHL",$J,LEXEF,3,1)=LEXD_U_LEXS
. . S LEXI=0 F S LEXI=$O(LEX(LEXI)) Q:+LEXI'>0 D
. . . N LEXC S LEXT=$G(LEX(LEXI)) Q:'$L(LEXT) S LEXC=$O(^TMP("LEXQHL",$J,LEXEF,3," "),-1)+1
. . . S ^TMP("LEXQHL",$J,LEXEF,3,LEXC)=U_LEXT
Q
;
DP ; Display
S LEXDISP=$G(LEXDISP) Q:$L(LEXDISP)>8 Q:$L(LEXDISP)<2 Q:LEXDISP["^" N LEXL S LEXL=$T(@LEXDISP+0) Q:'$L(LEXL)
D @LEXDISP
Q
SB ; Subjective
N LEX1,LEX2,LEX3,LEXC,LEXCT,LEXD,LEXE,LEXEC,LEXG,LEXHDR,LEXI,LEXID,LEXM,LEXN,LEXN1,LEXN2,LEXN3,LEXO1,LEXO2,LEXO3,LEXP,LEXS,LEXT
S LEXC=$G(^TMP("LEXQHL",$J,"CODE")),LEXI=$G(^TMP("LEXQHL",$J,"IEN")),LEXN=$G(^TMP("LEXQHL",$J,"NAME"))
S LEXT="Code: "_LEXC,LEXT=LEXT_$J(" ",(16-$L(LEXT)))_LEXN D TL^LEXQHLM(LEXT) S LEXT="",LEXT=LEXT_$J(" ",(16-$L(LEXT)))_"IEN: "_LEXI D TL^LEXQHLM(LEXT)
F LEXID=1:1:4 D
. N LEXHDR,LEXCT,LEXEC S (LEXEC,LEXCT)=0,LEXHDR=$$HD(LEXID) Q:'$L(LEXHDR) S LEXP="",LEX1=0 F S LEX1=$O(^TMP("LEXQHL",$J,LEX1)) Q:+LEX1'>0 D
. . S LEXEC=LEXEC+1 I LEXID=1 D Q
. . . S LEXN=$G(^TMP("LEXQHL",$J,LEX1,LEXID,1)) Q:'$L(LEXN) S LEXE=$P(LEXN,U,1),LEXS=$P(LEXN,U,2) Q:'$L(LEXE) Q:'$L(LEXS) S LEXCT=LEXCT+1
. . . D:LEXCT=1 BL^LEXQHLM,TL^LEXQHLM((" "_LEXHDR)) S LEXT=LEXE,LEXT=LEXT_$J(" ",(11-$L(LEXT)))_" "_LEXS,LEXT=" "_LEXT D TL^LEXQHLM(LEXT)
. . N LEX2 S LEX2=0,LEXE="" F S LEX2=$O(^TMP("LEXQHL",$J,LEX1,LEXID,LEX2)) Q:+LEX2'>0 D
. . . S LEXN=$G(^TMP("LEXQHL",$J,LEX1,LEXID,LEX2)) S:LEX2=1 LEXE=$P(LEXN,U,1) Q:LEX2=1 Q:'$L(LEXE)
. . . I LEX2=2 D Q
. . . . S LEXCT=LEXCT+1,LEXT=$G(LEXE),LEXS=$P(LEXN,U,2),LEXT=LEXT_$J(" ",(11-$L(LEXT)))_" "_LEXS,LEXT=" "_LEXT
. . . . D:LEXCT=1 BL^LEXQHLM,TL^LEXQHLM((" "_LEXHDR)) D TL^LEXQHLM(LEXT)
. . . I LEX2>2 D Q
. . . . S LEXCT=LEXCT+1,LEXT="",LEXS=$P(LEXN,U,2),LEXT=LEXT_$J(" ",(11-$L(LEXT)))_" "_LEXS,LEXT=" "_LEXT
. . . . D:LEXCT=1 BL^LEXQHLM,TL^LEXQHLM((" "_LEXHDR)) D TL^LEXQHLM(LEXT)
Q
CH ; Chronological
N LEX1,LEX2,LEX3,LEXC,LEXD,LEXDC,LEXI,LEXL1,LEXL2,LEXL3,LEXN,LEXP,LEXS,LEXT,LEXT1,LEXT2,LEXT3
S LEXC=$G(^TMP("LEXQHL",$J,"CODE")),LEXI=$G(^TMP("LEXQHL",$J,"IEN")),LEXN=$G(^TMP("LEXQHL",$J,"NAME"))
S LEXT="Code: "_LEXC,LEXT=LEXT_$J(" ",(16-$L(LEXT)))_LEXN D TL^LEXQHLM(LEXT) S LEXT="",LEXT=LEXT_$J(" ",(16-$L(LEXT)))_"IEN: "_LEXI D TL^LEXQHLM(LEXT)
S LEXP="",LEX1=0 F S LEX1=$O(^TMP("LEXQHL",$J,LEX1)) Q:+LEX1'>0 D
. D BL^LEXQHLM N LEX2,LEXDC S (LEXDC,LEX2)=0 F S LEX2=$O(^TMP("LEXQHL",$J,LEX1,LEX2)) Q:+LEX2'>0 D
. . N LEX3 S LEX3=0 F S LEX3=$O(^TMP("LEXQHL",$J,LEX1,LEX2,LEX3)) Q:+LEX3'>0 D
. . . N LEXN,LEXD,LEXS S LEXN=$G(^TMP("LEXQHL",$J,LEX1,LEX2,LEX3)),LEXD=$P(LEXN,U,1),LEXS=$P(LEXN,U,2)
. . . S LEXT=$S(LEXD'=LEXP:LEXD,1:""),LEXT=LEXT_$J(" ",(11-$L(LEXT)))_$S($L(LEXD):"- ",1:" ")_LEXS S LEXT=" "_LEXT D TL^LEXQHLM(LEXT)
. . . S:LEXD'="" LEXP=LEXD
Q
;
; Miscellaneous
IA(X) ; Initial Activation
N LEXEF,LEXH,LEXN,LEXS,LEXE,LEXIEN S LEXIEN=+($G(X)),LEXE="" Q:+LEXIEN'>0 "" Q:'$D(^ICPT(+LEXIEN,60,0)) "" S LEXEF="" F S LEXEF=$O(^ICPT(+LEXIEN,60,"B",LEXEF)) Q:'$L(LEXEF) D Q:$G(LEXE)?7N
. S LEXH=0 F S LEXH=$O(^ICPT(+LEXIEN,60,"B",LEXEF,LEXH)) Q:+LEXH'>0 S LEXN=$G(^ICPT(+LEXIEN,60,+LEXH,0)) S:+($P(LEXN,U,2))>0 LEXE=$P(LEXN,U,1) Q:$G(LEXE)?7N
S X="" S:$G(LEXE)?7N X=$G(LEXE)
Q X
HD(X) ; Header
Q:+($G(X))=1 "Status" Q:+($G(X))=2 "Procedure Name" Q:+($G(X))=3 "Description" Q:+($G(X))=4 "Lexicon Expression"
Q ""
LEXQHL3 ;ISL/KER - Query History - CPT/HCPCS Extract ;04/21/2014
+1 ;;2.0;LEXICON UTILITY;**62,80**;Sep 23, 1996;Build 10
+2 ;
+3 ; Global Variables
+4 ; ^ICPT( ICR 4489
+5 ; ^TMP("LEXQHL") SACC 2.3.2.5.1
+6 ;
+7 ; External References
+8 ; $$CPT^ICPTCOD ICR 1995
+9 ; $$UP^XLFSTR ICR 10104
+10 ;
+11 QUIT
EN(X,Y) ; CPT/HCPCS Procedure File
+1 NEW LEXIEN,LEXDISP,LEXIA,LEXEF,LEXCT,LEXC
SET LEXIEN=$GET(X)
SET LEXDISP=$GET(Y)
SET LEXIA=""
IF +LEXIEN'>0
QUIT
IF '$DATA(^ICPT(+LEXIEN,0))
QUIT
SET LEXC=$PIECE($GET(^ICPT(+LEXIEN,0)),U,1)
+2 KILL ^TMP("LEXQHL",$JOB)
SET ^TMP("LEXQHL",$JOB,"IEN")=LEXIEN
SET ^TMP("LEXQHL",$JOB,"CODE")=LEXC
SET ^TMP("LEXQHL",$JOB,"NAME")=$PIECE($$CPT^ICPTCOD(LEXC),U,3)
+3 IF '$LENGTH(LEXDISP)
SET LEXDISP="SB"
DO ST
DO NM
DO DS
DO CP^LEXQHL5(LEXC)
IF $LENGTH($GET(LEXDISP))
DO DP
KILL ^TMP("LEXQHL",$JOB)
+4 QUIT
ST ; 1 Status
+1 NEW LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXMS,LEXN,LEXS,LEXT
+2 SET LEXCT=0
SET LEXEF=""
FOR
SET LEXEF=$ORDER(^ICPT(+LEXIEN,60,"B",LEXEF))
IF '$LENGTH(LEXEF)
QUIT
Begin DoDot:1
+3 NEW LEXH
SET LEXH=0
FOR
SET LEXH=$ORDER(^ICPT(+LEXIEN,60,"B",LEXEF,LEXH))
IF +LEXH'>0
QUIT
Begin DoDot:2
+4 NEW LEXN,LEXS,LEXE,LEXT,LEXD,LEXMS
SET LEXN=$GET(^ICPT(+LEXIEN,60,+LEXH,0))
SET LEXE=$PIECE(LEXN,U,1)
SET LEXS=$PIECE(LEXN,U,2)
+5 IF +LEXS'>0&(LEXCT'>0)
QUIT
SET LEXCT=LEXCT+1
SET LEXMS=$$MS^LEXQHLM(LEXE,1)
SET LEXT=$SELECT(+LEXS>0:"Activation",1:"Inactivation")
+6 IF +LEXS>0&(LEXCT=1)
SET LEXT="Initial Activation"_LEXMS
SET LEXIA=LEXE
+7 IF $ORDER(^ICPT(+LEXIEN,60,"B",LEXEF))=""&(LEXCT>1)
SET LEXT=LEXT_" (final status change)"
+8 SET LEXD=$$SD^LEXQHLM(LEXE)
SET ^TMP("LEXQHL",$JOB,LEXEF,1,1)=LEXD_U_LEXT
End DoDot:2
End DoDot:1
+9 QUIT
NM ; 2 Procedure Name
+1 NEW LEX,LEXC,LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXI,LEXN,LEXS,LEXT
+2 SET LEXCT=0
SET LEXEF=""
FOR
SET LEXEF=$ORDER(^ICPT(+LEXIEN,61,"B",LEXEF))
IF '$LENGTH(LEXEF)
QUIT
Begin DoDot:1
+3 NEW LEXH
SET LEXH=0
FOR
SET LEXH=$ORDER(^ICPT(+LEXIEN,61,"B",LEXEF,LEXH))
IF +LEXH'>0
QUIT
Begin DoDot:2
+4 NEW LEXN,LEXS,LEXE,LEXT,LEXD,LEX,LEXI
SET LEXN=$GET(^ICPT(+LEXIEN,61,+LEXH,0))
SET LEXE=$PIECE(LEXN,U,1)
SET LEXT=$$UP^XLFSTR($PIECE(LEXN,U,2))
+5 SET LEXCT=LEXCT+1
SET LEX(1)=LEXT
DO PR^LEXQHLM(.LEX,63)
+6 SET LEXS=$SELECT(+LEXCT=1:"Initial Procedure Name",+LEXCT>1:"Updated Procedure Name",1:"Procedure Name")
+7 IF $ORDER(^ICPT(+LEXIEN,61,"B",LEXEF))=""&(LEXCT>1)
SET LEXS=LEXS_" (final change)"
+8 SET LEXD=$$SD^LEXQHLM(LEXE)
SET ^TMP("LEXQHL",$JOB,LEXEF,2,1)=LEXD_U_LEXS
+9 SET LEXI=0
FOR
SET LEXI=$ORDER(LEX(LEXI))
IF +LEXI'>0
QUIT
Begin DoDot:3
+10 NEW LEXC
SET LEXT=$GET(LEX(LEXI))
IF '$LENGTH(LEXT)
QUIT
SET LEXC=$ORDER(^TMP("LEXQHL",$JOB,LEXEF,2," "),-1)+1
+11 SET ^TMP("LEXQHL",$JOB,LEXEF,2,LEXC)=U_LEXT
End DoDot:3
End DoDot:2
End DoDot:1
+12 QUIT
DS ; 3 Description
+1 NEW LEX,LEXC,LEXCT,LEXD,LEXE,LEXEF,LEXH,LEXI,LEXN,LEXS,LEXT
+2 SET LEXCT=0
SET LEXEF=""
FOR
SET LEXEF=$ORDER(^ICPT(+LEXIEN,62,"B",LEXEF))
IF '$LENGTH(LEXEF)
QUIT
Begin DoDot:1
+3 NEW LEXH
SET LEXH=0
FOR
SET LEXH=$ORDER(^ICPT(+LEXIEN,62,"B",LEXEF,LEXH))
IF +LEXH'>0
QUIT
Begin DoDot:2
+4 NEW LEXC,LEXN,LEXS,LEXE,LEXT,LEXD,LEX,LEXI
SET LEXN=$GET(^ICPT(+LEXIEN,62,+LEXH,0))
+5 SET LEXE=$PIECE(LEXN,U,1)
SET (LEXC,LEXI)=0
FOR
SET LEXI=$ORDER(^ICPT(+LEXIEN,62,+LEXH,1,LEXI))
IF +LEXI'>0
QUIT
Begin DoDot:3
+6 SET LEXT=$$TM^LEXQHLM($$UP^XLFSTR($GET(^ICPT(+LEXIEN,62,+LEXH,1,LEXI,0))))
IF '$LENGTH(LEXT)
QUIT
SET LEXC=LEXC+1
SET LEX(LEXC)=LEXT
End DoDot:3
+7 SET LEXCT=LEXCT+1
DO PR^LEXQHLM(.LEX,63)
+8 SET LEXS=$SELECT(+LEXCT=1:"Initial Description",+LEXCT>1:"Updated Description",1:"Description")
+9 IF $ORDER(^ICPT(+LEXIEN,62,"B",LEXEF))=""&(LEXCT>1)
SET LEXS=LEXS_" (final change)"
+10 SET LEXD=$$SD^LEXQHLM(LEXE)
SET ^TMP("LEXQHL",$JOB,LEXEF,3,1)=LEXD_U_LEXS
+11 SET LEXI=0
FOR
SET LEXI=$ORDER(LEX(LEXI))
IF +LEXI'>0
QUIT
Begin DoDot:3
+12 NEW LEXC
SET LEXT=$GET(LEX(LEXI))
IF '$LENGTH(LEXT)
QUIT
SET LEXC=$ORDER(^TMP("LEXQHL",$JOB,LEXEF,3," "),-1)+1
+13 SET ^TMP("LEXQHL",$JOB,LEXEF,3,LEXC)=U_LEXT
End DoDot:3
End DoDot:2
End DoDot:1
+14 QUIT
+15 ;
DP ; Display
+1 SET LEXDISP=$GET(LEXDISP)
IF $LENGTH(LEXDISP)>8
QUIT
IF $LENGTH(LEXDISP)<2
QUIT
IF LEXDISP["^"
QUIT
NEW LEXL
SET LEXL=$TEXT(@LEXDISP+0)
IF '$LENGTH(LEXL)
QUIT
+2 DO @LEXDISP
+3 QUIT
SB ; Subjective
+1 NEW LEX1,LEX2,LEX3,LEXC,LEXCT,LEXD,LEXE,LEXEC,LEXG,LEXHDR,LEXI,LEXID,LEXM,LEXN,LEXN1,LEXN2,LEXN3,LEXO1,LEXO2,LEXO3,LEXP,LEXS,LEXT
+2 SET LEXC=$GET(^TMP("LEXQHL",$JOB,"CODE"))
SET LEXI=$GET(^TMP("LEXQHL",$JOB,"IEN"))
SET LEXN=$GET(^TMP("LEXQHL",$JOB,"NAME"))
+3 SET LEXT="Code: "_LEXC
SET LEXT=LEXT_$JUSTIFY(" ",(16-$LENGTH(LEXT)))_LEXN
DO TL^LEXQHLM(LEXT)
SET LEXT=""
SET LEXT=LEXT_$JUSTIFY(" ",(16-$LENGTH(LEXT)))_"IEN: "_LEXI
DO TL^LEXQHLM(LEXT)
+4 FOR LEXID=1:1:4
Begin DoDot:1
+5 NEW LEXHDR,LEXCT,LEXEC
SET (LEXEC,LEXCT)=0
SET LEXHDR=$$HD(LEXID)
IF '$LENGTH(LEXHDR)
QUIT
SET LEXP=""
SET LEX1=0
FOR
SET LEX1=$ORDER(^TMP("LEXQHL",$JOB,LEX1))
IF +LEX1'>0
QUIT
Begin DoDot:2
+6 SET LEXEC=LEXEC+1
IF LEXID=1
Begin DoDot:3
+7 SET LEXN=$GET(^TMP("LEXQHL",$JOB,LEX1,LEXID,1))
IF '$LENGTH(LEXN)
QUIT
SET LEXE=$PIECE(LEXN,U,1)
SET LEXS=$PIECE(LEXN,U,2)
IF '$LENGTH(LEXE)
QUIT
IF '$LENGTH(LEXS)
QUIT
SET LEXCT=LEXCT+1
+8 IF LEXCT=1
DO BL^LEXQHLM
DO TL^LEXQHLM((" "_LEXHDR))
SET LEXT=LEXE
SET LEXT=LEXT_$JUSTIFY(" ",(11-$LENGTH(LEXT)))_" "_LEXS
SET LEXT=" "_LEXT
DO TL^LEXQHLM(LEXT)
End DoDot:3
QUIT
+9 NEW LEX2
SET LEX2=0
SET LEXE=""
FOR
SET LEX2=$ORDER(^TMP("LEXQHL",$JOB,LEX1,LEXID,LEX2))
IF +LEX2'>0
QUIT
Begin DoDot:3
+10 SET LEXN=$GET(^TMP("LEXQHL",$JOB,LEX1,LEXID,LEX2))
IF LEX2=1
SET LEXE=$PIECE(LEXN,U,1)
IF LEX2=1
QUIT
IF '$LENGTH(LEXE)
QUIT
+11 IF LEX2=2
Begin DoDot:4
+12 SET LEXCT=LEXCT+1
SET LEXT=$GET(LEXE)
SET LEXS=$PIECE(LEXN,U,2)
SET LEXT=LEXT_$JUSTIFY(" ",(11-$LENGTH(LEXT)))_" "_LEXS
SET LEXT=" "_LEXT
+13 IF LEXCT=1
DO BL^LEXQHLM
DO TL^LEXQHLM((" "_LEXHDR))
DO TL^LEXQHLM(LEXT)
End DoDot:4
QUIT
+14 IF LEX2>2
Begin DoDot:4
+15 SET LEXCT=LEXCT+1
SET LEXT=""
SET LEXS=$PIECE(LEXN,U,2)
SET LEXT=LEXT_$JUSTIFY(" ",(11-$LENGTH(LEXT)))_" "_LEXS
SET LEXT=" "_LEXT
+16 IF LEXCT=1
DO BL^LEXQHLM
DO TL^LEXQHLM((" "_LEXHDR))
DO TL^LEXQHLM(LEXT)
End DoDot:4
QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+17 QUIT
CH ; Chronological
+1 NEW LEX1,LEX2,LEX3,LEXC,LEXD,LEXDC,LEXI,LEXL1,LEXL2,LEXL3,LEXN,LEXP,LEXS,LEXT,LEXT1,LEXT2,LEXT3
+2 SET LEXC=$GET(^TMP("LEXQHL",$JOB,"CODE"))
SET LEXI=$GET(^TMP("LEXQHL",$JOB,"IEN"))
SET LEXN=$GET(^TMP("LEXQHL",$JOB,"NAME"))
+3 SET LEXT="Code: "_LEXC
SET LEXT=LEXT_$JUSTIFY(" ",(16-$LENGTH(LEXT)))_LEXN
DO TL^LEXQHLM(LEXT)
SET LEXT=""
SET LEXT=LEXT_$JUSTIFY(" ",(16-$LENGTH(LEXT)))_"IEN: "_LEXI
DO TL^LEXQHLM(LEXT)
+4 SET LEXP=""
SET LEX1=0
FOR
SET LEX1=$ORDER(^TMP("LEXQHL",$JOB,LEX1))
IF +LEX1'>0
QUIT
Begin DoDot:1
+5 DO BL^LEXQHLM
NEW LEX2,LEXDC
SET (LEXDC,LEX2)=0
FOR
SET LEX2=$ORDER(^TMP("LEXQHL",$JOB,LEX1,LEX2))
IF +LEX2'>0
QUIT
Begin DoDot:2
+6 NEW LEX3
SET LEX3=0
FOR
SET LEX3=$ORDER(^TMP("LEXQHL",$JOB,LEX1,LEX2,LEX3))
IF +LEX3'>0
QUIT
Begin DoDot:3
+7 NEW LEXN,LEXD,LEXS
SET LEXN=$GET(^TMP("LEXQHL",$JOB,LEX1,LEX2,LEX3))
SET LEXD=$PIECE(LEXN,U,1)
SET LEXS=$PIECE(LEXN,U,2)
+8 SET LEXT=$SELECT(LEXD'=LEXP:LEXD,1:"")
SET LEXT=LEXT_$JUSTIFY(" ",(11-$LENGTH(LEXT)))_$SELECT($LENGTH(LEXD):"- ",1:" ")_LEXS
SET LEXT=" "_LEXT
DO TL^LEXQHLM(LEXT)
+9 IF LEXD'=""
SET LEXP=LEXD
End DoDot:3
End DoDot:2
End DoDot:1
+10 QUIT
+11 ;
+12 ; Miscellaneous
IA(X) ; Initial Activation
+1 NEW LEXEF,LEXH,LEXN,LEXS,LEXE,LEXIEN
SET LEXIEN=+($GET(X))
SET LEXE=""
IF +LEXIEN'>0
QUIT ""
IF '$DATA(^ICPT(+LEXIEN,60,0))
QUIT ""
SET LEXEF=""
FOR
SET LEXEF=$ORDER(^ICPT(+LEXIEN,60,"B",LEXEF))
IF '$LENGTH(LEXEF)
QUIT
Begin DoDot:1
+2 SET LEXH=0
FOR
SET LEXH=$ORDER(^ICPT(+LEXIEN,60,"B",LEXEF,LEXH))
IF +LEXH'>0
QUIT
SET LEXN=$GET(^ICPT(+LEXIEN,60,+LEXH,0))
IF +($PIECE(LEXN,U,2))>0
SET LEXE=$PIECE(LEXN,U,1)
IF $GET(LEXE)?7N
QUIT
End DoDot:1
IF $GET(LEXE)?7N
QUIT
+3 SET X=""
IF $GET(LEXE)?7N
SET X=$GET(LEXE)
+4 QUIT X
HD(X) ; Header
+1 IF +($GET(X))=1
QUIT "Status"
IF +($GET(X))=2
QUIT "Procedure Name"
IF +($GET(X))=3
QUIT "Description"
IF +($GET(X))=4
QUIT "Lexicon Expression"
+2 QUIT ""