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

LEX10DBR.m

Go to the documentation of this file.
  1. LEX10DBR ;ISL/KER - ICD-10 Diagnosis Lookup by Root ;04/21/2014
  1. ;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 1
  1. ;
  1. ; Global Variables
  1. ; ^LEX(757.033) N/A
  1. ; ^TMP("LEXDX") SACC 2.3.2.5.1
  1. ; ^TMP("LEXSCH") Suggest SACC 2.3.2.5.1
  1. ;
  1. ; External References
  1. ; $$ICDDX^ICDEX ICR 5747
  1. ; $$LD^ICDEX ICR 5747
  1. ; $$SD^ICDEX ICR 5747
  1. ;
  1. Q
  1. MAJ(X,LEXA,LEXVDT) ; Lookup by Root, Major Categories (3 digit/decimal)
  1. K ^TMP("LEXSCH",$J) N LEXC,LEXO,LEXT,LEXCT,LEXFND,LEXTOT S LEXCT=0
  1. D GETCAT($G(X),$G(LEXVDT)),GETCOD($G(X),$G(LEXVDT)) S LEXFND=+($G(LEXCT))
  1. D ARY^LEX10DU S LEXC=+($O(LEXA(" "),-1)) S:LEXC'>0 LEXC=-1 S LEXA(0)=LEXC
  1. K ^TMP("LEXSCH",$J) S:LEXC>0 $P(LEXA(0),"^",2)=1
  1. Q
  1. GETCAT(X,LEXVDT) ; Get Categories
  1. N LEXC,LEXCTL,LEXO S LEXC=$E(X,1,2) Q:$L(LEXC)'=2 S (LEXCTL,LEXO)=LEXC,LEXO=LEXO_" "
  1. F S LEXO=$O(^LEX(757.033,"AFRAG",30,LEXO)) Q:'$L(LEXO)!($E(LEXO,1,$L(LEXCTL))'=LEXCTL) D
  1. . N LEXQ,LEXE,LEXI,LEXNE,LEXNI,LEXN,LEXIS,LEXCN,LEX
  1. . S LEXQ=$TR(LEXO," ","")
  1. . S:$L(LEXQ)=3&(LEXQ'[".") LEXQ=LEXQ_"."
  1. . Q:$L(LEXQ)'=4
  1. . S LEXE=$P($O(^LEX(757.033,"AFRAG",30,(LEXQ_" ")," "),-1),".",1)
  1. . Q:LEXE'?7N I $P($G(LEXVDT),".",1)?7N Q:LEXE>LEXVDT
  1. . S LEXI=$O(^LEX(757.033,"AFRAG",30,(LEXQ_" "),LEXE," "),-1)
  1. . S LEXNE=$O(^LEX(757.033,+LEXI,2,"B",(LEXVDT+.0001)),-1)
  1. . S LEXNI=$O(^LEX(757.033,+LEXI,2,"B",+LEXNE," "),-1)
  1. . I LEXNI'>0 D Q:LEXNI'>0
  1. . . S LEXNE=$O(^LEX(757.033,+LEXI,2,"B",9999999),-1)
  1. . . S LEXNI=$O(^LEX(757.033,+LEXI,2,"B",+LEXNE," "),-1)
  1. . S LEXN=$G(^LEX(757.033,LEXI,2,LEXNI,1)) Q:'$L(LEXN)
  1. . S LEXCN=$$CODES^LEX10DU(LEXQ),LEX="^"_LEXE_"^"_LEXN
  1. . S:+LEXCN>0 $P(LEX,"^",4)=+LEXCN
  1. . S ^TMP("LEXDX",$J,(LEXQ_" "))=LEX S LEXCT=LEXCT+1
  1. Q
  1. GETCOD(X,LEXVDT) ; Get Codes
  1. N LEXC,LEXCTL,LEXO S LEXC=$E(X,1,2) Q:$L(LEXC)'=2 S (LEXCTL,LEXO)=LEXC,LEXO=LEXO_" "
  1. F S LEXO=$O(^LEX(757.02,"ADX",LEXO)) Q:'$L(LEXO)!($E(LEXO,1,$L(LEXCTL))'=LEXCTL) D
  1. . N LEXQ,LEXE,LEXI,LEXN,LEXSTA,LEX,LEXT
  1. . S LEXQ=$TR(LEXO," ","") S:$L(LEXQ)=3&(LEXQ'[".") LEXQ=LEXQ_"." Q:$L(LEXQ)'=4
  1. . S LEXSTA=$$STATCHK^LEXSRC2(LEXQ,$G(LEXVDT),,30) Q:+LEXSTA'>0
  1. . S LEXE=$P(LEXSTA,"^",3),LEXI=$P(LEXSTA,"^",2) Q:+LEXI'>0
  1. . S LEXT=+($G(^LEX(757.02,+LEXI,0))) Q:+LEXT'>0
  1. . Q:LEXE'?7N I $P($G(LEXVDT),".",1)?7N Q:LEXE>LEXVDT
  1. . S LEXN=$P($G(^LEX(757.01,+LEXT,0)),"^",1) Q:'$L(LEXN)
  1. . S ^TMP("LEXDX",$J,(LEXQ_" "))=LEXI_"^"_LEXE_"^"_LEXN S LEXCT=LEXCT+1
  1. Q
  1. ST ;
  1. N LEXNN,LEXNC
  1. S LEXNN="^TMP(""LEXSCH"","_$J_")",LEXNC="^TMP(""LEXSCH"","_$J_","
  1. F S LEXNN=$Q(@LEXNN) Q:'$L(LEXNN)!(LEXNN'[LEXNC) D
  1. . W !,LEXNN,"=",@LEXNN
  1. Q
  1. TM(X,Y) ; Trim Character Y - Default " "
  1. S X=$G(X) Q:X="" X 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