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

ICDEXLK2.m

Go to the documentation of this file.
  1. ICDEXLK2 ;SLC/KER - ICD Extractor - Lookup, Ask ;04/21/2014
  1. ;;18.0;DRG Grouper;**57**;Oct 20, 2000;Build 7
  1. ;
  1. ; Global Variables
  1. ; ^TMP(SUB,$J SACC 2.3.2.5.1
  1. ;
  1. ; External References
  1. ; CLRMSG^DDS ICR 5846
  1. ; HLP^DDSMSG ICR 5847
  1. ; ^DIR ICR 10026
  1. ; $$DT^XLFDT ICR 10103
  1. ; $$FMADD^XLFDT ICR 10103
  1. ;
  1. ; Local Variables NEWed or KILLed Elsewhere
  1. ; DDS,DICR,FND,ICDCDT,ICDDIC0,ICDDICA,
  1. ; ICDDICB,ICDDICN,ICDISF,ICDOFND,ICDOREV,
  1. ; ICDOSEL,ICDOUT,ICDREDO,ICDX
  1. ;
  1. Q
  1. ASK ; Ask for Selection
  1. K X,Y N ANS S FND=+($G(FND)) Q:+FND'>0
  1. I FND=1,DIC(0)'["E" D Q
  1. . K X,Y D X(1,SUB) S (ICDOFND,ICDOSEL,ICDOREV)=1
  1. . D Y($G(ROOT),+($G(^TMP(SUB,$J,"SEL",1))),$G(ICDCDT))
  1. . I +($G(Y))'>0,$L($G(INP)) S X=$G(INP) Q
  1. . I +($G(Y))>0 D:$G(DIC(0))'["F" SAV^ICDEXLK6(+($G(Y)),ROOT)
  1. I FND>1,DIC(0)'["E" D Q
  1. . K Y S Y="-1^Selection not made" S ICDOSEL=0
  1. S:+FND=1 ANS=$$ONE S:+FND>1 ANS=$$MUL S ICDOSEL=0
  1. I ANS>0 D
  1. . D X(+ANS,SUB) S ICDOSEL=1
  1. . D Y($G(ROOT),+($G(^TMP(SUB,$J,"SEL",+ANS))),$G(ICDCDT))
  1. . I +($G(Y))'>0,$L($G(INP)) S X=$G(INP) Q
  1. . I +($G(Y))>0 D:$G(DIC(0))'["F" SAV^ICDEXLK6(+($G(Y)),ROOT)
  1. I ANS'>0 K INP,X,Y,^TMP(SUB,$J)
  1. Q
  1. SBR ; Space-Bar Return DIC(0) not contain "A"
  1. N SBI,SUB,OUT,ANS,SBS K Y S Y=-1 Q:'$L($G(ROOT)) Q:ROOT="^" Q:'$L($G(FILE))
  1. S SBI=$$RET^ICDEXLK6($G(FILE)),SUB=$TR($G(ROOT),"^(","") K:$L(SUB) ^TMP(SUB,$J) Q:+SBI'>0
  1. S SBS=$P($G(@(ROOT_+SBI_",1)")),"^",1) Q:+SBS'>0 Q:+SBI>0&(+SBS>0)&(+($G(ICDSYS))>0)&(+($G(ICDSYS))'=+SBS)
  1. D FND^ICDEXLK5($G(ROOT),+SBI,$G(ICDCDT),$G(ICDSYS),$G(ICDVER),0,$G(ICDOUT))
  1. D SEL^ICDEXLK5(ROOT,0) Q:'$D(^TMP(SUB,$J,"SEL",1)) S ANS=$$ONE I ANS>0 D
  1. . D X(1,SUB) S (ICDOFND,ICDOSEL,ICDOREV)=1
  1. . D Y($G(ROOT),+($G(^TMP(SUB,$J,"SEL",1))),$G(ICDCDT))
  1. . I +($G(Y))'>0,$L($G(INP)) S X=$G(INP) Q
  1. . I +($G(Y))>0 D:$G(DIC(0))'["F" SAV^ICDEXLK6(+($G(Y)),ROOT)
  1. S:+Y>0&($L($P(Y,"^",2))) X=$P(Y,"^",2)
  1. I ANS'>0 K INP,X,Y,^TMP(SUB,$J)
  1. Q
  1. ONE(X) ; One Entry Found
  1. S:'$D(DDS) X=$$ONERS S:$D(DDS) X=$$ONESM S ICDOREV=1
  1. Q X
  1. ONERS(X) ; One Entry Found Roll and Scroll
  1. N DIR,IEN,LN,LN2,ICDI,TEXT,TXT,TX,CT,Y S ICDOREV=1
  1. S TEXT=$G(^TMP(SUB,$J,"SEL",1)) Q:$G(DIC(0))'["E" 1
  1. S IEN=+TEXT,TEXT=$P(TEXT,U,2),TXT(1)=TEXT
  1. I $G(ICDFMT)=1!($G(ICDFMT)=2) D
  1. . K TX S TXT(1)=TEXT D PAR^ICDEX(.TXT,64) K TX2 F ICDI=2:1:8 D
  1. . . S:$L($G(TXT(ICDI))) TX2(1)=$G(TX2(1))_" "_$G(TXT(ICDI))
  1. . S TX(1)=$G(TXT(1)) I $D(TX2) D
  1. . . N SP S SP=" " D PAR^ICDEX(.TX2,54) S ICDI=0
  1. . . F S ICDI=$O(TX2(ICDI)) Q:+ICDI'>0 D
  1. . . . N CT Q:'$L($G(TX2(ICDI)))
  1. . . . S CT=$O(TX(" "),-1)+1 S TX(CT)=SP_$G(TX2(ICDI))
  1. I $G(ICDFMT)'=1&($G(ICDFMT)'=2) D
  1. . K TX N ICDI D PAR^ICDEX(.TXT,64) S ICDI=0 F S ICDI=$O(TXT(ICDI)) Q:+ICDI'>0 D
  1. . . N CT S CT=$O(TX(" "),-1)+1 S TX(CT)=$G(TXT(ICDI))
  1. S DIR("A",1)=" One match found",DIR("A",2)=" "
  1. S ICDI=0 F S ICDI=$O(TX(ICDI)) Q:+ICDI'>0 D
  1. . Q:'$L($G(TX(ICDI))) N CT S CT=$O(DIR("A"," "),-1)+1
  1. . S DIR("A",CT)=(" "_$G(TX(ICDI)))
  1. S CT=$O(DIR("A"," "),-1)+1,DIR("A",CT)=" ",DIR("A")=" OK? "
  1. S DIR("B")="Yes",DIR(0)="YAO" W !
  1. I $G(DICR(2,1))="^ACK(509850.1,",$G(DICR(1,1))["^ACK(509850.6," N ICDQUASR S ICDQUASR=DICR(1,1)_$C(34)_"B"_$C(34)_","_IEN_")" I $D(@ICDQUASR) D Q 1
  1. . S LN=$O(DIR("A"," "),-1) N LN2 F LN2=1:1:(LN-1) W !,DIR("A",LN2)
  1. K DIROUT,DIRUT,DUOUT,DTOUT D ^DIR
  1. S ICDOUPA=$S(X["^"&(X'["^^"):1,X["^^":2,1:0)
  1. S:X["^" ICDOUPA=1 S:X["^" ICDOUPA=1
  1. I $L($G(ICDX)),$L($G(DIC("S"))),$L($G(DICR(1))),$L($G(DICR(1,1))),+Y'>0 Q -1
  1. Q:+Y>0 1 Q:X["^^"!($D(DTOUT)) "^^"
  1. Q -1
  1. ONESM(X) ; One Entry Found ScreenMan
  1. N ANS,CODE,ICDMENU,IEN,ITEM,TEXT,VST S ICDOREV=1
  1. S ITEM=$G(^TMP(SUB,$J,"SEL",1)) Q:'$L(ITEM) -1
  1. S IEN=+ITEM,TEXT=$P(ITEM,U,2) S CODE=$$CODEC^ICDEX(+($G(FILE)),IEN)
  1. S VST=$$VST^ICDEX(+($G(FILE)),IEN,ICDCDT)
  1. I $L(CODE),$L(VST) S TEXT=CODE,TEXT=TEXT_$J(" ",(9-$L(TEXT)))_VST
  1. Q:'$L(TEXT) -1 S ICDMENU(1)=(" "_$G(TEXT)),ICDMENU(2)=" OK? Yes// "
  1. S ICDMENU="ICDMENU" K DTOUT,DUOUT,DIROUT,DIRUT
  1. D HLP^DDSMSG(.ICDMENU) S ICDOREV=1 R ANS:300 S:'$L(ANS) ANS="Y" D CLRMSG^DDS
  1. I '$T S X="^^",DTOUT=1,DIRUT=1 Q X
  1. I ANS["^",ANS'["^^" S X="^",DUOUT=1,DIRUT=1 Q X
  1. I ANS["^^" S X="^^",DIROUT=1,DUOUT=1,DIRUT=1 Q X
  1. S ANS=$E(ANS,1) S X=$S("^Y^y^"[("^"_ANS_"^"):1,1:-1)
  1. Q X
  1. MUL(X) ; Multiple Entries Found
  1. S:'$D(DDS) X=$$MULRS S:$D(DDS) X=$$MULSM
  1. Q X
  1. MULRS(X) ; Multiple Entries Found Roll and Scroll
  1. Q:+($G(EXIT))>0 "^^" N ENT,EXIT,IEN,ITEM,LEN,MAX,ROOT,SEL,TEXT,TOT,Y
  1. Q:$G(DIC(0))'["E" -1 S ROOT=$G(DIC),LEN=+($G(ICDDICN)) S:+LEN'>0 LEN=5
  1. S (MAX,ENT,SEL,EXIT)=0,U="^",TOT=$G(^TMP(SUB,$J,"SEL",0))
  1. S SEL=0 G:+TOT=0 MULQ W:+TOT>1 !!," ",TOT," matches found"
  1. F ENT=1:1:TOT Q:((SEL>0)&(SEL<ENT+1)) Q:EXIT D Q:EXIT
  1. . N ITEM,IEN,TEXT S ITEM=$G(^TMP(SUB,$J,"SEL",ENT))
  1. . S IEN=+ITEM,TEXT=$P(ITEM,U,2) Q:'$L(TEXT)
  1. . S MAX=ENT W:ENT#LEN=1 ! D MULRSW S:ENT=TOT ICDOREV=1
  1. . W:ENT#LEN=0 ! S:ENT#LEN=0 SEL=$$MULRSS(MAX,ENT) S:SEL["^" EXIT=1
  1. I ENT#LEN'=0,+SEL=0 W ! S SEL=$$MULRSS(MAX,ENT) S:SEL["^" EXIT=1
  1. G MULQ
  1. Q X
  1. MULRSW ; Write Multiple Roll and Scroll
  1. Q:+($G(IEN))'>0 Q:'$L($G(ROOT)) Q:'$L($G(TEXT))
  1. N ICDI,IND,NR,TAB,TX2,TXT,Y,RT S (TAB,IND)=8
  1. S RT=$$ROOT^ICDEX(ROOT)
  1. S:+($G(ICDOUT))<3 IND=18 W !,$J(ENT,5),".",?TAB
  1. I +($G(ICDISF))'>0,$L($G(DIC("W"))) D Q
  1. . N Y,NR D Y(ROOT,IEN,ICDCDT)
  1. . S NR=$G(@(RT_+IEN_",0)"))
  1. . W $P(NR,"^",1)," " X DIC("W") Q
  1. I +($G(ICDISF))'>0,$D(DIC("W")),DIC("W")="" D Q
  1. . W $P($G(@(RT_+IEN_",0)")),"^",1)
  1. I +($G(ICDOUT))<3 D Q
  1. . N ICDI S TXT(1)=TEXT D PAR^ICDEX(.TXT,64) K TX2 F ICDI=2:1:8 D
  1. . . S:$L($G(TXT(ICDI))) TX2(1)=$G(TX2(1))_" "_$G(TXT(ICDI))
  1. . W $G(TXT(1)) I $D(TX2) D
  1. . . D PAR^ICDEX(.TX2,54) S ICDI=0
  1. . . F S ICDI=$O(TX2(ICDI)) Q:+ICDI'>0 W !,?IND,$G(TX2(ICDI))
  1. S TXT(1)=TEXT
  1. D PAR^ICDEX(.TXT,64) S ICDI=0 F S ICDI=$O(TXT(ICDI)) Q:+ICDI'>0 D
  1. . Q:'$L($G(TXT(ICDI))) W:ICDI>1 ! W ?IND,$G(TXT(ICDI))
  1. Q
  1. MULRSS(LEX,LS) ; Select Multiple Roll and Scroll
  1. Q:+($G(EXIT))>0 "^^" N DIR,DIRB,HLP,LAST,MAX,NEXT,RAN,X,Y
  1. S MAX=+($G(LEX)),LAST=+($G(LS)) Q:MAX=0 -1
  1. S RAN=" Select 1-"_MAX_": ",NEXT=$O(^TMP(SUB,$J,"SEL",+LAST))
  1. S:+NEXT>0 DIR("A")=" Press <RETURN> for more, '^' to exit, or"_RAN
  1. S:+NEXT'>0 DIR("A")=RAN
  1. S HLP=" Answer must be from 1 to "_MAX_", or <Return> to continue"
  1. S DIR("PRE")="S:X[""?"" X=""??"""
  1. S (DIR("?"),DIR("??"))="^D MULRSSH^ICDEXLK2"
  1. S DIR(0)="NAO^1:"_MAX_":0" K DIROUT,DIRUT,DUOUT,DTOUT D ^DIR
  1. S ICDOUPA=$S(X["^"&(X'["^^"):1,X["^^":2,1:0)
  1. S:X["^"&(LS=+($G(TOT))) (X,Y)="^",DIROUT=1,DIRUT=1,DUOUT=1
  1. S:X["^^"&(LS=+($G(TOT))) (X,Y)="^^",DIROUT=1,DIRUT=1,DUOUT=1
  1. S:X["^"&(X'["^^") X="^",DUOUT=1,DIRUT=1,(X,Y)="^"
  1. S:X["^^"!($D(DTOUT)) EXIT=1,(X,Y)="^^"
  1. S LEX=+Y S:$D(DTOUT)!(X[U) LEX=U
  1. Q LEX
  1. MULRSSH ; Select Multiple Help Roll and Scroll
  1. I $L($G(HLP)) W !,$G(HLP) Q
  1. Q
  1. MULSM(X) ; Multiple Entries Found ScreenMan
  1. Q:+($G(EXIT))>0 "^^" N CODE,CTR,ENT,EXIT,ICDMENU,IEN,ITEM,LEN
  1. N MAX,ROOT,SEL,TEXT,TOT,VST,Y S ROOT=$G(DIC),(MAX,ENT,SEL,EXIT)=0
  1. S U="^",LEN=3,TOT=$G(^TMP(SUB,$J,"SEL",0)),SEL=0 G:+TOT=0 MULQ
  1. S CTR=0 F ENT=1:1:TOT Q:((SEL>0)&(SEL<ENT+1)) Q:EXIT D Q:EXIT
  1. . N ITEM,IEN,TEXT,CODE,VST S ITEM=$G(^TMP(SUB,$J,"SEL",ENT))
  1. . S IEN=+ITEM,TEXT=$P(ITEM,U,2) S CODE=$$CODEC^ICDEX(+($G(FILE)),IEN)
  1. . S VST=$$VST^ICDEX(+($G(FILE)),IEN,ICDCDT)
  1. . I $L(CODE),$L(VST) S TEXT=CODE,TEXT=TEXT_$J(" ",(9-$L(TEXT)))_VST
  1. . Q:'$L(TEXT) S MAX=ENT D MULSMW S:ENT=TOT ICDOREV=1
  1. . S:ENT#LEN=0 SEL=$$MULSMS(MAX,ENT)
  1. . S:SEL["^" (DUOUT,DIROUT,EXIT)=1
  1. K:$D(DUOUT) ICDMENU
  1. I ENT#LEN'=0,+SEL=0,'EXIT D
  1. . Q:$G(DUOUT)>0 Q:$G(DIROUT)>0
  1. . S SEL=$$MULSMS(MAX,ENT)
  1. . S:SEL["^" (DUOUT,DIROUT,EXIT)=1
  1. I EXIT>0 D G MULQ
  1. . K ICDMENU S:$L($G(DICR("1"))) DICR("1")="^^" S:$L($G(ICDOINP)) ICDOINP="^^"
  1. . ;D CLRMSG^DDS
  1. D CLRMSG^DDS
  1. G MULQ
  1. MULSMW ; Write Multiple ScreenMan
  1. Q:+($G(ENT))'>0 Q:'$L($G(TEXT)) N CTR S CTR=$O(ICDMENU(" "),-1)+1
  1. S ICDMENU(CTR)=$J(ENT,3)_"."_" "_$G(TEXT)
  1. Q
  1. MULSMS(LEX,LS) ; Select Multiple ScreenMan
  1. Q:+($G(EXIT))>0 "^^" N ANS,CTR,LAST,MAX,PMT,X Q:'$D(ICDMENU)
  1. S MAX=+($G(LEX)),LAST=+($G(LS)) Q:MAX=0 -1
  1. S PMT=" Select 1-"_MAX_", <RETURN> for more or '^' to exit: "
  1. S CTR=$O(ICDMENU(" "),-1)+1,ICDMENU(CTR)=PMT
  1. S ICDMENU="ICDMENU" D HLP^DDSMSG(.ICDMENU)
  1. K ICDMENU R ANS:300 D CLRMSG^DDS S X=""
  1. I '$T S X="^^",DTOUT=1,DIRUT=1 Q X
  1. I ANS["^",ANS'["^^" S X="^",DUOUT=1 Q X
  1. I ANS["^^" S X="^^",DIROUT=1,DUOUT=1,DIRUT=1 Q X
  1. S ANS=+ANS Q:ANS'>0 "" Q:ANS>MAX "" S X=ANS
  1. Q X
  1. MULQ ; Quit Multiple
  1. S X=+($G(SEL)) Q:X'>0 -1
  1. Q X
  1. ;
  1. INP(X,VER,CDT) ; Get User Input
  1. Q:$G(DIC(0))'["A" "" N DIR,DIRA,DIRB,SBR,SBT,FILE,ROOT
  1. S VER=+($G(VER)),CDT=+($G(CDT))
  1. S FILE=$G(X) Q:"^80^80.1^"'[("^"_FILE_"^") "" S ROOT=$$ROOT^ICDEX(FILE)
  1. S:$L($G(ICDDICB)) DIRB=ICDDICB S:$L($G(ICDDICA)) DIRA=ICDDICA
  1. S:'$L($G(DIRA))&(FILE=80) DIRA=" Select ICD Diagnosis: "
  1. S:'$L($G(DIRA))&(FILE=80.1) DIRA=" Select Procedure: "
  1. S:'$L($G(DIRA)) DIRA=" Select ICD Text or Code: "
  1. S SBT="",SBR=$$RET^ICDEXLK6($G(FILE))
  1. I SBR>0,VER>0,CDT?7N,$L(ROOT) D
  1. . N CODE,SYS,STA
  1. . S CODE=$G(@(ROOT_+SBR_",0)"))
  1. . S SYS=$P($G(@(ROOT_+SBR_",1)")),"^",1)
  1. . S STA=$$STATCHK^ICDEX(CODE,CDT,SYS)
  1. . S:STA'>0 SBR=0
  1. S:+SBR>0 SBT=$$LD^ICDEX(FILE,+SBR,$G(ICDCDT))
  1. S:$L($G(DIRB)) DIR("B")=DIRB
  1. S:$L($G(DIRA)) DIR("A")=DIRA W:'$L($G(DIRB)) !
  1. S DIR("PRE")="S X=$$INPRE^ICDEXLK2($G(X))"
  1. S (DIR("?"),DIR("??"))="^D INPH^ICDEXLK2($G(FILE))"
  1. S DIR("?")="^D INPH^ICDEXLK2($G(FILE))"
  1. S DIR("??")="^D INPH2^ICDEXLK2($G(FILE))"
  1. N Y S DIR(0)="FAO^0:245"
  1. K X,DIROUT,DIRUT,DUOUT,DTOUT D ^DIR
  1. S ICDOUPA=$S(X["^"&(X'["^^"):1,X["^^":2,1:0)
  1. Q:$D(DIROUT) "^^" Q:$D(DUOUT) "^" Q:$G(X)="" X
  1. S:X=""&('$L($G(DIR("B")))) X="^" S:X["^"&(X'["^^") X="^"
  1. S:X["^^" X="^^" Q:X["^" X
  1. I $E(X,1)=" ",$L(SBT),+SBR>0 S X=("`"_+SBR) Q X
  1. W:$G(DIC(0))'["Q"&($E(X,1)'=" ") ! S X=$$TM(X)
  1. S:$D(DTOUT)!(X="^") X="" S:X[U DUOUT=1
  1. Q X
  1. INPH(X) ; Input Help
  1. N FILE,TYPE,TMP,TXT S FILE=$G(X)
  1. S TYPE=$S(FILE=80:"Diagnosis ",FILE=80.1:"Procedure ",1:"")
  1. I '$L($G(TYPE)) D Q
  1. . S TMP="Enter a term (2-245 characters in length) or a code."
  1. . I +($G(VER))>0 S TMP=TMP_" Only active codes will be considered for selection."
  1. . S TXT(1)=TMP D PA^ICDEXLK6(.TXT,66)
  1. . S TMP=0 F S TMP=$O(TXT(TMP)) Q:+TMP'>0 W !,?4,$G(TXT(TMP))
  1. S TMP="Enter a "_TYPE_"(2-245 characters in length) or a "_TYPE_"code."
  1. I +($G(VER))>0 S TMP=TMP_" Only active "_TYPE_"codes will be considered for selection."
  1. S TXT(1)=TMP D PA^ICDEXLK6(.TXT,66)
  1. S TMP=0 F S TMP=$O(TXT(TMP)) Q:+TMP'>0 W !,?4,$G(TXT(TMP))
  1. Q
  1. INPH2(X) ; Input Help
  1. N FILE,TYPE,TMP,TXT S FILE=$G(X)
  1. S TYPE=$S(FILE=80:"Diagnosis ",FILE=80.1:"Procedure ",1:"")
  1. I '$L($G(TYPE)) D Q
  1. . S TMP="Enter a term (2-245 characters in length), a code or code fragment,"
  1. . S TMP=TMP_" phrase, or an accent grave character (`) followed by the"
  1. . S TMP=TMP_" IEN to select a specific entry"
  1. . I $G(ICDDIC0)'["F" D
  1. . . S TMP=TMP_", or press space bar and Enter/Return key to do a subsequent lookup of the same entry"
  1. . S TMP=TMP_"." I +($G(VER))>0 D
  1. . . S TMP=TMP_" Only active codes will be considered for selection."
  1. . S TXT(1)=TMP D PA^ICDEXLK6(.TXT,66)
  1. . S TMP=0 F S TMP=$O(TXT(TMP)) Q:+TMP'>0 W !,?4,$G(TXT(TMP))
  1. S TMP="Enter a "_TYPE_"name"
  1. S TMP=TMP_" (2-245 characters in length), a "_TYPE_"code or code fragment,"
  1. S TMP=TMP_" one or more keywords sufficient to select a "_TYPE
  1. S TMP=TMP_" name, or an accent grave character (`) followed by the"
  1. S TMP=TMP_" IEN to select a specific entry"
  1. I $G(ICDDIC0)'["F" D
  1. . S TMP=TMP_", or press space bar and Enter/Return key to do a subsequent lookup of the same entry"
  1. S TMP=TMP_"." I +($G(VER))>0 D
  1. . S TMP=TMP_" Only active "_TYPE_"codes will be considered for selection."
  1. S TXT(1)=TMP D PA^ICDEXLK6(.TXT,66)
  1. S TMP=0 F S TMP=$O(TXT(TMP)) Q:+TMP'>0 W !,?4,$G(TXT(TMP))
  1. Q
  1. INPRE(X) ; Input Pre-Processing
  1. Q:'$L($G(X)) "" N IN,IN1,IN2 S IN=$G(X)
  1. Q:IN["??" "??" Q:IN["?" "?"
  1. S IN1=$E(IN,1),IN2=$E(IN,2,$L(IN))
  1. I IN1["`",IN2?1N.N,$L($G(ROOT)) D Q X
  1. . Q:IN1="`"&(IN2?1N.N)&($D(@(ROOT_+IN2_",0)"))) S X="??"
  1. I $L($G(ROOT)) I IN1=" ",'$L(IN2) D Q:$E(X,1)="`"!($E(X,1)="?") X
  1. . N FI,CODE,SYS,STA,ND,SB,OUT S FI=$$FILE^ICDEX(ROOT)
  1. . Q:+FI'>0 S SB=$$RET^ICDEXLK6($G(FILE))
  1. . I SB>0,+($G(VER))'>0 S X="`"_+SB Q
  1. . I SB>0,+($G(VER))>0,+($G(CDT))?7N,$L(ROOT) D
  1. . . N CODE,SYS,STA
  1. . . S CODE=$G(@(ROOT_+SB_",0)")) Q:'$L(CODE)
  1. . . S SYS=$P($G(@(ROOT_+SB_",1)")),"^",1) Q:+SYS'>0
  1. . . S STA=$$STATCHK^ICDEX(CODE,CDT,SYS)
  1. . . S:STA'>0 SB=0 S:+SB>0 X="`"_+SB S:+SB'>0 X="??"
  1. Q X
  1. ;
  1. ; Miscellaneous
  1. OUT(X,Y,FMT,ARY) ; Output Array
  1. K ARY N FILE,TERM,ROOT,IEN S ROOT=$G(X),IEN=+($G(Y)) Q:'$L(ROOT)
  1. Q:"^ICD9(^ICD0(^"'[("^"_$E(ROOT,2,$L(ROOT))_"^")
  1. S FILE=$$FILE^ICDEX(ROOT) Q:"^80^80.1^"'[("^"_FILE_"^")
  1. S FMT=+($G(FMT)) S:FMT'>0 FMT=1 S:FMT>4 FMT=1 Q:'$D(@(ROOT_IEN_",0)"))
  1. I +($G(FMT))=1!(+($G(FMT))=3) S TERM=$$SD^ICDEX(FILE,IEN,CDT)
  1. I +($G(FMT))=2!(+($G(FMT))=4) S TERM=$$LD^ICDEX(FILE,IEN,CDT)
  1. Q:'$L(TERM) Q:$P(TERM,"^",1)=-1 S ARY(1)=TERM Q:+($G(FMT))=1!(+($G(FMT))=3)
  1. D:+($G(FMT))=2 PAR^ICDEX(.ARY,60) D:+($G(FMT))=4 PAR^ICDEX(.ARY,70)
  1. Q
  1. TM(X,Y) ; Trim Y
  1. S Y=$G(Y) S:'$L(Y) Y=" "
  1. F Q:$E(X,1)'=Y S X=$E(X,2,$L(X))
  1. F Q:$E(X,$L(X))'=Y S X=$E(X,1,($L(X)-1))
  1. Q X
  1. X(SEL,SUB) ; Set X
  1. K X N IEN S SEL=+($G(SEL)),SUB=$G(SUB) Q:'$L(SUB)
  1. S IEN=$G(^TMP(SUB,$J,"SEL",+SEL)) Q:+IEN'>0 S X=+IEN
  1. Q
  1. Y(ROOT,IEN,CDT,FMT) ; Set Y
  1. ;
  1. ; Input
  1. ;
  1. ; ROOT Global Root (DIC) or File Number
  1. ; IEN Internal Entry Number
  1. ; CDT Versioning Date (default TODAY)
  1. ; FMT Format of Output
  1. ; 0 Standard Fileman Y IEN ^ CODE
  1. ; 1 Expanded Y as if DIC(0) contained a "Z"
  1. ; Output
  1. ;
  1. ; Y IEN ^ Code Fileman
  1. ;
  1. ; If DIC(0) contains "Z" or input parameter FMT > 0
  1. ;
  1. ; Y(0) 0 Node (Code) Fileman
  1. ; Y(0,0) .01 Field (Code) Fileman
  1. ; Y(0,1) $$ICDDX or $$ICDOP Non-Fileman
  1. ; Y(0,2) Long Description Non-Fileman
  1. ;
  1. N CODE,NODE0,FILE,SHORT,FDAT,LONG,ICD10 K Y S Y=-1
  1. S:+($G(ICDOFND))>0&(+($G(ICDOSEL))'>0) Y="-1^No selection made"
  1. S IEN=+($G(IEN)),ROOT=$G(ROOT),CDT=+($G(CDT))
  1. S:CDT'?7N CDT=$$DT^XLFDT S ICD10=+($$IMP^ICDEX(30))
  1. S ROOT=$$ROOT^ICDEX(ROOT) Q:'$L(ROOT)
  1. S FILE=$$FILE^ICDEX(ROOT) Q:+FILE'>0
  1. S NODE0=$G(@(ROOT_+IEN_",0)")) Q:'$L(NODE0)
  1. S CODE=$$CODEC^ICDEX(FILE,IEN) Q:'$L(CODE)
  1. S SHORT=$$SD^ICDEX(FILE,IEN,CDT) Q:'$L(SHORT)
  1. S FMT=+($G(FMT)) I $P(SHORT,"^",1)=-1 D Q:'$L(SHORT)
  1. . S SHORT=$$SD^ICDEX(FILE,IEN,ICD10)
  1. . S:$P(SHORT,"^",1)=-1 SHORT="" Q:'$L(SHORT)
  1. . S SHORT=SHORT_" (Pending - "_$$FMTE^XLFDT($$IMP^ICDEX(30))_")"
  1. S Y=+IEN_"^"_CODE
  1. S:$G(DIC(0))["Z"!(+FMT>0) Y(0)=NODE0
  1. S CODE=$P(NODE0,"^",1) Q:'$L(CODE)
  1. S:FILE=80 FDAT=$$ICDDX^ICDEX(CODE,CDT,,"E")
  1. S:FILE=80.1 FDAT=$$ICDOP^ICDEX(CODE,CDT,,"E")
  1. S LONG=$$LD^ICDEX(ROOT,IEN,CDT)
  1. S:$G(DIC(0))["Z"!(+FMT>0) Y(0,0)=CODE
  1. S:$L(FDAT)&($L(LONG))&($G(DIC(0))["Z")!(+FMT>0) Y(0,1)=FDAT,Y(0,2)=LONG
  1. Q
  1. SH ; Show TMP
  1. N SUB,NN,NC S SUB="ICD9" S:'$D(^TMP(SUB)) SUB="ICD0" Q:'$D(^TMP(SUB))
  1. S NN="^TMP("""_SUB_""","_$J_")",NC="^TMP("""_SUB_""","_$J_","
  1. W:'$D(@NN) ! Q:'$D(@NN) F S NN=$Q(@NN) Q:'$L(NN)!(NN'[NC) W !,NN,"=",@NN
  1. W !
  1. Q