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

BGOFHLK.m

Go to the documentation of this file.
  1. BGOFHLK ; IHS/BAO/TMD - FHL - PROGRAM TO GET LIST OF DIAGNOSES ;02-Apr-2013 09:12;MGH
  1. ;;1.1;BGO COMPONENTS;**6,12**;Mar 20, 2007;Build 5
  1. ;---------------------------------------------------------------
  1. ; Lookup ICD's matching input
  1. ; INP = Lookup Value [1] ^ Visit Date [2] ^ Patient Gender [3]
  1. ; ^ FROM [4], TO [5]
  1. ; Returned as a list of records in the format:
  1. ; Descriptive Text [1] ^ ICD IEN [2] ^ Narrative Text [3] ^ ICD Code [4]
  1. ; Patch 12 updated for new ICD lookup
  1. ICDLKUP(RET,INP) ;PEP - ICD lookup
  1. N LKUP,VDT,SEX,CNT,DIC,X,Y,I,ICD,FROM,TO,CNT
  1. N AICDRET,XTLKSAY,REC,DESC,CODE,NARR
  1. S RET=$$TMPGBL^BGOUTL
  1. S LKUP=$P(INP,U)
  1. S FROM=$P(INP,U,4)
  1. S TO=$P(INP,U,5)
  1. S VDT=$$CVTDATE^BGOUTL($P(INP,U,3))
  1. S SEX=$P(INP,U,3)
  1. S CNT=0
  1. I LKUP'="" D
  1. .I $G(DUZ("AG"))="I" D
  1. ..I $$AICD^BGOUTL2 D
  1. ...N HITS
  1. ...S HITS=0
  1. ...K ^TMP("ICD9")
  1. ...S HITS=$$LKTX^ICDEX(LKUP,"ICD9(",VDT,1,1,2)
  1. ...I HITS>0 D
  1. ....S X=0 F S X=$O(^TMP("ICD9",$J,"SEL",X)) Q:X="" D
  1. .....S ICD=$P($G(^TMP("ICD9",$J,"SEL",X)),U,1)
  1. .....D CHKHITS
  1. .E D
  1. ..S DIC="^ICD9(",DIC(0)="TM",X=LKUP,XTLKSAY=0
  1. ..K ^UTILITY("AICDHITS",$J),^TMP("XTLKHITS",$J)
  1. ..D ^DIC
  1. ..I Y'=-1 D
  1. ...S ICD=+Y
  1. ...D CHKHITS
  1. ..I 'CNT,$L(LKUP)>2 D
  1. ...N LK,LN
  1. ...S LK=LKUP,LN=$L(LKUP)
  1. ...F D S LK=$O(^ICD9("BA",LK)) Q:$E(LK,1,LN)'=LKUP
  1. ....S ICD=0
  1. ....F S ICD=$O(^ICD9("BA",LK,ICD)) Q:'ICD D CHKHITS
  1. I LKUP="" D
  1. . N LK,LK1
  1. .I FROM="" S FROM="V16"
  1. .I TO="" S TO="V20.0"
  1. .S LK=FROM F S LK=$O(^ICD9("AB",LK)) S LK1=$E(LK,2,$L(LK)) Q:LK=TO!(LK1>19.9) D
  1. ..S ICD="" F S ICD=$O(^ICD9("AB",LK,ICD)) Q:'ICD D CHKHITS
  1. K @RET@(0)
  1. Q
  1. CHKHITS ;Q:$D(@RET@(0,ICD)) S ^(ICD)=""
  1. N OK,RECN
  1. S REC=$G(^ICD9(ICD,0))
  1. Q:$P(REC,U,9)
  1. S RECN=$P(REC,U,1)
  1. S OK=$$CHKFH^AUPNSICD(ICD)
  1. I OK=0 Q
  1. I VDT,$P(REC,U,11),$$FMDIFF^XLFDT(VDT,$P(REC,U,11))>-1 Q
  1. I $L(SEX),$P(REC,U,10)'="",SEX'=$P(REC,U,10) Q
  1. I $$AICD^BGOUTL2 S NARR=$P($$ICDDX^ICDEX(ICD,VDT),U,4) ;Patch 12
  1. E S NARR=$G(^ICD9(ICD,1))
  1. S CODE=$P(REC,U),DESC=$P(REC,U,3)
  1. S CNT=CNT+1
  1. S @RET@(CNT)=DESC_U_ICD_U_NARR_U_CODE
  1. Q
  1. CHKFH ;Family history lookup