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

LEXA1.m

Go to the documentation of this file.
  1. LEXA1 ;ISL/KER - Lexicon Look-up (Loud) ;04/21/2014
  1. ;;2.0;LEXICON UTILITY;**3,4,6,11,15,38,55,73,80**;Sep 23, 1996;Build 10
  1. ;
  1. ; Global Variables
  1. ; ^DISV( ICR 510
  1. ; ^TMP("LEXFND" SACC 2.3.2.5.1
  1. ; ^TMP("LEXHIT" SACC 2.3.2.5.1
  1. ; ^TMP("LEXSCH" SACC 2.3.2.5.1
  1. ;
  1. ; External References
  1. ; ^DIR ICR 10026
  1. ; $$DT^XLFDT ICR 10103
  1. ;
  1. ; Local Variables NEWed or KILLed by calling application
  1. ;
  1. ; DIC,DTOUT,DUOUT,LEXCAT,LEXQUIET,LEXSRC
  1. ;
  1. EN ; Fileman Special Lookup
  1. ;
  1. ; ^LEXA1 is the Lexicon's special lookup routine
  1. ; established by Fileman Data Dictionary's node:
  1. ;
  1. ; ^DD(757.01,0,"DIC")=LEXA1
  1. ;
  1. ; Input All input variables are optional
  1. ;
  1. ; X User's input, if X does not exist the user
  1. ; will be prompted for textto search for.
  1. ;
  1. ; Fileman Variables used:
  1. ;
  1. ; DIC Global Root (default ^LEX(757.01,)
  1. ; DIC(0) DIC response string (default AEQM)
  1. ; DIC("A") Prompt (default "Enter Term/Concept:")
  1. ; DIC("B") Default lookup value
  1. ; DIC("S") Screen
  1. ; DIC("W") Output string
  1. ;
  1. ; Special Input Variables:
  1. ;
  1. ; LEXVDT Versioning Date - This is a date in
  1. ; Fileman format. If set it will force
  1. ; the lookup to be date sensitive,
  1. ; inactive and pending codes and terms
  1. ; will not display on the selection
  1. ; list.
  1. ;
  1. ; Developer Input Variables
  1. ;
  1. ; LEXIGN Ignore - This flag, if set will ignore
  1. ; deactivation flags. Deactivated terms
  1. ; will appear on the selection list. This
  1. ; is used by developers in the mainteance
  1. ; of the Code Sets.
  1. ;
  1. ; LEXDISP Display - Force overwrite of display default
  1. ; parameter.
  1. ;
  1. ; Output
  1. ;
  1. ; Fileman
  1. ;
  1. ; Y 2 piece string containing IEN and
  1. ; expression or -1 if X is not found
  1. ; or selection not made
  1. ;
  1. ; Y(0) If DIC(0) contains a Z this variable
  1. ; will be equal to the entire zero node
  1. ; of the entry that was selected
  1. ;
  1. ; Y(0,0) If DIC(0) contains a Z this variable
  1. ; will be equal to the external form of
  1. ; the .01 field of the entry that was
  1. ; selected
  1. ;
  1. ; Non-Fileman
  1. ;
  1. ; Y(1) This is the external form of the ICD-9
  1. ; diagnosis code when found
  1. ;
  1. ; Y(2) This is the external form of the ICD-9
  1. ; procedure code when found
  1. ;
  1. ; Y(30) This is the external form of the ICD-10
  1. ; diagnosis code when found
  1. ;
  1. ; Y(31) This is the external form of the ICD-10
  1. ; procedure code when found
  1. ;
  1. ; Y(81) This is the external form of the CPT-4
  1. ; or HCPCS code when found
  1. ;
  1. I $D(DIC(0)),$G(DIC(0))["A" K X
  1. ; Date Check
  1. N LEXTD,LEXQ S LEXQ=0 D VDT^LEXU
  1. ;
  1. ; LEXSUB Special variable from version 1.0 specifying the
  1. ; vocabulary subset to use during the search. It is
  1. ; a three character mnemonic taken from the Subset
  1. ; Definition file #757.2. The default is "WRD"
  1. S:'$L($G(LEXSUB)) LEXSUB="WRD"
  1. ;
  1. ; LEXAP Special variable from version 1.0 specifying the
  1. ; application using the Lexicon. It is a pointer
  1. ; value to the Subset Definition file #757.2.
  1. ; The default is 1 (Lexicon)
  1. S:'$L($G(LEXAP))&($L($G(^TMP("LEXSCH",$J,"APP",0)))) LEXAP=^TMP("LEXSCH",$J,"APP",0)
  1. S:'$L($G(LEXAP)) LEXAP=1
  1. ;
  1. ; LEXLL Special variable (new) specifying the length of the
  1. ; displayable list the user is to select from. Default
  1. ; is 5 (display 5 at a time until the entire list has
  1. ; been reviewed)
  1. S:'$L($G(LEXLL)) LEXLL=5
  1. ;
  1. ; LEXSRC Special variable specifying the source of the
  1. ; vocabulary to use during the search. It is
  1. ; an Internal Entry Number to the Source File
  1. ; #757.14. There is no default value.
  1. N LEXXSR S:$L($G(LEXSRC)) LEXXSR=$G(LEXSRC)
  1. ;
  1. ; LEXCAT Special variable specifying the source category of
  1. ; the vocabulary to use during the search. It is
  1. ; an Internal Entry Number in the Source Category
  1. ; file #757.13. There is no default value.
  1. N LEXXCT S:$L($G(LEXCAT)) LEXXCT=$G(LEXCAT)
  1. ;
  1. ; Check the DIC variables new LEXUR "user response"
  1. N LEXDICA,LEXDICB,LEXO,XTLKGBL,XTLKHLP,XTLKKSCH,XTLKSAY D CHK N LEXUR
  1. ;
  1. ; Save the value of X if "Ask" is not specified in DIC(0)
  1. I DIC(0)'["A",$L($G(X)) S LEXSAVE=X K X
  1. ;
  1. ; Save the prompt
  1. I $L($G(DIC("A"))) S LEXDICA=DIC("A")
  1. ;
  1. ; Continue to lookup until the dialog with the application
  1. ; ends. If there is nothing to lookup (X="") or an uparrow
  1. ; is detected, the Lexicon shuts down killing LEX.
  1. ;
  1. F D LK Q:'$D(LEX)!($D(LEX("SEL")))
  1. G EXIT
  1. LK ; Start Look-up
  1. ; X not provided
  1. D:'$D(LEXSAVE) ASK
  1. ; X provided
  1. S:$D(LEXSAVE) X=LEXSAVE K LEXSAVE
  1. ; X was null with a default provided
  1. S:$D(DIC("B"))&($G(X)="") X=DIC("B")
  1. ; Lookup X - LOOK(LEXX,LEXAP,LEXLL,LEXSUB,LEXVDT,LEXXSR,LEXXCT)
  1. D LOOK^LEXA(X,$G(LEXAP),$G(LEXLL),,$G(LEXVDT),$G(LEXXSR),$G(LEXXCT))
  1. K DIC("B")
  1. ;
  1. NOTFND ; If X was not found
  1. ;
  1. ; Write "??"
  1. ;
  1. ; Calling application uses Unresolved Narratives
  1. ; Prompt to "accept or reject" the narrative, if
  1. ; no selection is made continue the search
  1. ;
  1. ; Calling application does not use Unresolved Narratives
  1. ; Display help, Re-prompt and Continue search
  1. ;
  1. I '$D(LEX("LIST")),+($G(LEX))=0,$L(X),X'["^",$E(X,1)'=" " D K LEX S LEX=0 Q
  1. . K DIC("B"),LEX("SEL")
  1. . I +($G(^TMP("LEXSCH",$J,"UNR",0)))=0 I +($G(X))'=757.01 W " ??" D:$D(LEX("HLP")) DH^LEXA3 W ! Q
  1. . I +($G(^TMP("LEXSCH",$J,"UNR",0)))=1 W " ??" D EN^LEXA4 W !
  1. FOUND ; If X was found
  1. ;
  1. ; Begin user selection. Continue to display the list
  1. ; until the dialog with the user is terminated. The
  1. ; dialog is considered to be terminated if:
  1. ;
  1. ; The selection list does not exist '$D(LEX("LIST"))
  1. ; The user has made a selection $D(LEX("SEL")
  1. ;
  1. I $D(LEX("LIST")) F Q:+($G(LEX))=0 D SELECT^LEXA2
  1. Q:$D(LEX("SEL"))
  1. I '$L($G(LEX)) K LEX Q
  1. I $L($G(LEX)),'$D(LEX("SEL")),$D(^TMP("LEXSCH",$J)) D
  1. . D EN^LEXA4 S:'$D(LEX("SEL")) LEX=0
  1. Q
  1. EXIT ; Set/Kill variables Y, Y(0,0) from LEX("SEL")
  1. S:$L($G(LEXDICA)) DIC("A")=LEXDICA S:$L($G(LEXDICB)) DIC("B")=LEXDICB K Y
  1. I '$D(LEX("SEL","EXP",1)) K Y S Y=-1 D CL Q
  1. I $D(LEX("SEL","EXP",1)) S Y=LEX("SEL","EXP",1) D Y1,SSBR S:DIC(0)["Z" Y(0)=^LEX(757.01,+(LEX("SEL","EXP",1)),0),Y(0,0)=$P(^LEX(757.01,+(LEX("SEL","EXP",1)),0),"^",1)
  1. D CL
  1. Q
  1. CL ; Clear LEX and Multi-Term Lookup XTLK
  1. K LEX,LEXSUB,LEXAP,LEXLL D CLR
  1. Q
  1. CLR ; Clear ^TMP Global
  1. K ^TMP("LEXSCH",$J),^TMP("LEXHIT",$J),^TMP("LEXFND",$J)
  1. Q
  1. Y1 ; ICD-9 DX in Y(1), ICD-10 DX in Y(30)
  1. N LEXCT,LEXLC,LEXLDR,LEXSY,LEXB,LEXN S LEXB=$G(IOINHI),LEXN=$G(IOINORM)
  1. S LEXLC=0,LEXLDR=" >>> " I '$D(LEXQUIET) F LEXSY=1,2,30,31 D
  1. . N LEXI S (LEXCT,LEXI)=0 F S LEXI=$O(LEX("SEL","VAS","I",LEXSY,LEXI)) Q:+LEXI'>0 D
  1. . . N LEXD,LEXC,LEXS,LEXT S LEXD=$G(LEX("SEL","VAS",LEXI)),LEXC=$P(LEXD,"^",3),LEXS=$P(LEXD,"^",6)
  1. . . Q:'$L(LEXD) Q:'$L(LEXS) S LEXT=LEXLDR_LEXS_" Code:"
  1. . . S LEXT=LEXT_$J(" ",(23-$L(LEXT)))_$G(LEXB)_LEXC_$G(LEXN)
  1. . . S LEXCT=LEXCT+1,LEXLC=LEXLC+1 S:LEXLC>1 LEXLDR=" "
  1. . . Q:LEXCT>1 W:LEXCT=1 ! W !,LEXT
  1. . . S:'$L($G(Y(+LEXSY))) Y(+LEXSY)=LEXC
  1. Q
  1. ASK ; Get user input
  1. N DIR,DIRUT,DIROUT S:$L($G(LEXDICA)) DIC("A")=LEXDICA
  1. S DIR("A")=DIC("A") W:'$L($G(X))&('$L($G(LEXDICB))) !
  1. I '$L($G(X)),$L($G(LEXDICB)) S DIR("B")=LEXDICB
  1. S DIR("?")=" "_$$SQ^LEXHLP
  1. S DIR("??")="^D INPHLP^LEXA1",DIR("?")=$G(DIR("??"))
  1. N Y S DIR(0)="FAO^0:245" K X
  1. D ^DIR
  1. K DIC("B") D:$E(X,1)=" " RSBR
  1. W:$E(X,1)'=" " !
  1. F Q:$E(X,1)'=" " S X=$E(X,2,$L(X))
  1. W:$D(DTOUT) !,"Try later.",!
  1. I $D(DTOUT)!(X="^") S X=""
  1. S:X[U DUOUT=1 K DIRUT,DIROUT Q
  1. INPHLP ; Look-up help
  1. N IMP,CUT,FLG,LEXD S IMP=$$IMPDATE^LEXU(30) S CUR=$G(LEXVDT) S:CUR'?7N CUR=$$DT^XLFDT S FLG=$S(CUR<IMP:0,1:1)
  1. S LEXD=$G(^TMP("LEXSCH",$J,"FIL",0))
  1. I $G(X)["??",$L(LEXD),LEXD["LEXU(Y,""DS4""," K LEX("HLP") D Q
  1. . D QMH^LEXAR3(X) N LEXI S LEXI=0
  1. . F S LEXI=$O(LEX("HLP",LEXI)) Q:+LEXI'>0 W !,$G(LEX("HLP",LEXI))
  1. . K LEX("HLP")
  1. W !," Enter a ""free text"" term. Best results occur using one to "
  1. W !," three full or partial words without a suffix"
  1. W:$G(X)'["??" "."
  1. W:$G(X)["??" " (i.e., ""DIABETES"","
  1. W:$G(X)["??" !," ""DIAB MELL"",""DIAB MELL "_$S(FLG:"NEO",1:"INSUL")_")"
  1. W !," or "
  1. W !," Enter a classification code (ICD/DSM/CPT etc) to find the single "
  1. W !," term associated with the code."
  1. W:$G(X)["??" " Example, a lookup of code "_$S(FLG:"P70.2",1:"239.0")_" "
  1. W:$G(X)["??" !," returns one and only one term, that is the preferred term for"
  1. W:$G(X)["??" !," the code "_$S(FLG:"P70.2",1:"239.0")_", "
  1. W:$G(X)["??"&(FLG) """Neonatal Diabetes Mellitus"""
  1. W:$G(X)["??"&('FLG) """Neoplasm of unspecified nature",!," of digestive system"""
  1. Q:FLG
  1. W !," or "
  1. W !," Enter a classification code (ICD/DSM/CPT etc) followed by a plus"
  1. W !," sign (+) to retrieve all terms associated with the code."
  1. W:$G(X)["??" " Example,"
  1. W:$G(X)["??" !," a lookup of 239.0+ returns all terms that are linked to the "
  1. W:$G(X)["??" !," code 239.0."
  1. Q
  1. CHK ; Check Fileman look-up variables
  1. K DIC("DR"),DIC("P"),DIC("V"),DLAYGO,DINUM
  1. S:$L($G(X)) LEXSAVE=X S:$L($G(DIC("B"))) LEXDICB=DIC("B") K DIC("B")
  1. I $L($G(DIC(0))) D
  1. . F Q:DIC(0)'["L" S DIC(0)=$P(DIC(0),"L",1)_$P(DIC(0),"L",2)
  1. . F Q:DIC(0)'["I" S DIC(0)=$P(DIC(0),"I",1)_$P(DIC(0),"I",2)
  1. S:'$L($G(DIC(0))) DIC(0)="QEAMF" S:'$L($G(DIC)) DIC="^LEX(757.01,"
  1. S:DIC(0)'["F" DIC(0)=DIC(0)_"F" S:'$L($G(DIC("A"))) DIC("A")="Enter Term/Concept: "
  1. S LEXDICA=DIC("A")
  1. Q
  1. SSBR ; Store data for Space Bar Return
  1. Q:'$L($G(DUZ)) Q:+($G(DUZ))=0 Q:'$L($G(DIC)) Q:$G(DIC)'["757.01,"
  1. Q:$G(DIC(0))'["F" Q:+($G(Y))'>2 Q:$E($G(X),1)=" " S ^DISV(DUZ,DIC)=+($G(Y))
  1. Q
  1. RSBR ; Retrieve onSpace Bar Return
  1. Q:'$L($G(DUZ)) Q:$G(DIC)'="^LEX(757.01," Q:$G(DIC(0))'["F"
  1. Q:$E($G(X),1)'=" " S:+($G(^DISV(DUZ,DIC)))>2 X=@(DIC_+($G(^DISV(DUZ,DIC)))_",0)")
  1. Q