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