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

BPCGDX.m

Go to the documentation of this file.
  1. BPCGDX ; IHS/OIT/MJL - PROGRAM TO GET LIST OF DIAGNOSES ;
  1. ;;1.5;BPC;;MAY 26, 2005
  1. DXLIST(BPCRES,BPCX,BPCMAX,BPCMORE,BPCPARAM) ;EP REMOTE PROC: BPC GETDIAGNOSISLIST
  1. S BPCGUI=1
  1. ;
  1. ; BPCRES - The output array (ICD9 code data)
  1. ; BPCRES(1) - Total number of entries (BPCMAX or less)
  1. ; subscript - sequence number (2 thru value of BPCMAX +1)
  1. ; Piece (delimited by "^")
  1. ; 1 - Description
  1. ; 2 - IEN
  1. ; 3 - Category (e.g.
  1. ; 4 - Data (in ^ICD9(code,0) )
  1. ; BPCX - Input string (e.g. 250,DIAB,etc.)
  1. ; BPCMAX - Maximum number of elements to return in BPCRES
  1. ; BPCMORE - More data
  1. ; Piece (delimited by "|")
  1. ; 1 - Next IEN
  1. ; 2 - Next ICD9 code
  1. ; 3 - Next description ref
  1. ; BPCPARAM - Reserved for future use
  1. ;
  1. EN ;
  1. S U="^",XWBWRAP=1,BPCCTR=0,BPCSUB=$J,BPCGUI=$G(BPCGUI),BPCLEN=$L(BPCX),BPCC="",BPCMORE=$G(BPCMORE)
  1. K:'BPCMORE ^BGUTMP(BPCSUB,1) K BPCRES S BPCSEQ=$G(^BGUTMP(BPCSUB,1)),BPCLSQP=$P(BPCSEQ,U,2),BPCLSQA=BPCSEQ
  1. I BPCX="" S BPCRES(0)=-1,BPCRES(1)="NO SEARCH PARAMETER GIVEN!" D KILL Q
  1. S BPCMAX=$G(BPCMAX) S:'BPCMAX BPCMAX=$S(BPCGUI:50,1:1E10)
  1. I 'BPCMORE,BPCPARAM'="" S BPCPVS="" F BPCN=1:1:$L(BPCPARAM,"|") S BPCPRM1=$P(BPCPARAM,"|",BPCN),BPCPV=$P(BPCPRM1,"="),BPCPVS=BPCPVS_$S(BPCN>1:",",1:"")_BPCPV,@BPCPV=$P(BPCPRM1,"=",2)
  1. D @$S(BPCMORE:"SETRES",BPCX?.N.1"."1N.N:"GETNUM",$D(^AICDKWLC(1,1,"B",BPCX)):"KWLC",$D(^ICD9("AIHS",BPCX)):"GETKWD",1:"GETTXT"),SETRES:'BPCMORE,KILL
  1. Q
  1. ;
  1. GETNUM ; Handles numeric entries
  1. ;
  1. S BPCC=$O(^ICD9("BA",BPCX),-1),BPCNEXT=$O(^ICD9("BA",BPCC)),BPCFND=$E(BPCNEXT,1,BPCLEN)=BPCX
  1. I 'BPCFND F S BPCNEXT=$O(^ICD9("BA",BPCNEXT)) Q:BPCNEXT="" I $E(BPCNEXT,1,BPCLEN)=BPCX S BPCC=$O(^ICD9("BA",BPCNEXT),-1) S BPCFND=1 Q
  1. I BPCFND F S BPCC=$O(^ICD9("BA",BPCC)) Q:BPCC=""!($E(BPCC,1,BPCLEN)'=BPCX) S BPCI="" F S BPCI=$O(^ICD9("BA",BPCC,BPCI)) Q:BPCI="" D SETMATCH
  1. K BPCC,BPCFND,BPCNEXT
  1. Q
  1. ;
  1. KWLC ; Look in Keyword Lookup Control file for synonyms
  1. ;
  1. S BPCSVX=BPCX,BPCN=0
  1. S BPCN="" F S BPCN=$O(^AICDKWLC(1,1,"B",BPCSVX,BPCN)) Q:BPCN="" S BPCN1=0 F S BPCN1=$O(^AICDKWLC(1,1,BPCN,1,BPCN1)) Q:BPCN1="" S BPCX=^(BPCN1,0) D @$S($D(^ICD9("AIHS",BPCX)):"GETKWD",1:"GETTXT")
  1. K BPCN,BPCN1,BPCSVX
  1. Q
  1. ;
  1. GETKWD ; Handles keywords
  1. ;
  1. S BPCI="" F S BPCI=$O(^ICD9("AIHS",BPCX,BPCI)) Q:BPCI="" D SETMATCH
  1. Q
  1. ;
  1. GETTXT ; Handles text entries
  1. ;
  1. S BPCC=$O(^ICD9("D",BPCX),-1) F S BPCC=$O(^ICD9("D",BPCC)) Q:BPCC=""!($E(BPCC,1,BPCLEN)'=BPCX) S BPCI="" F S BPCI=$O(^ICD9("D",BPCC,BPCI)) Q:BPCI="" D SETMATCH
  1. Q
  1. ;
  1. SETMATCH ;
  1. ; Validate the ICD9 code : It doesn't start with an E, It's not
  1. ; inactive, and if Patient sex is set, and if sex is defined for this
  1. ; code, they're equal.
  1. S BPCDATA=$G(^ICD9(BPCI,0))
  1. Q:$E(BPCDATA)="E" Q:$P(BPCDATA,U,9)'="" I $G(BPCPSEX)'="",$P(BPCDATA,U,10)'="",BPCPSEX'=$P(BPCDATA,U,10) Q
  1. S BPCDESC=$G(^ICD9(BPCI,1)),BPCCAT=$P(BPCDATA,U,5),BPCCDE=$P(BPCDATA,U,1) S:BPCCAT'="" BPCCAT=$G(^ICM(BPCCAT,0))
  1. S:BPCCDE BPCCDE=+BPCCDE
  1. S:'$D(^BGUTMP(BPCSUB,1,BPCCDE)) BPCSEQ=BPCCDE,^BGUTMP(BPCSUB,1,BPCCDE)=BPCDESC_U_BPCI_U_BPCCAT_U_BPCDATA
  1. Q
  1. ;
  1. SETRES ; Copy from ^BPCTMP to BPCRES
  1. ;
  1. I BPCSEQ="" S BPCRES(0)=-1,BPCRES(1)="vEnter another Selection, Code or Diagnosis!" Q
  1. S:'BPCMORE BPCSEQ=BPCCDE,$P(^BGUTMP(BPCSUB,1),U,1)=BPCSEQ,BPCLSQA=BPCSEQ
  1. S BPCSEQ=BPCLSQP F BPCCTR=1:1:BPCMAX S BPCSEQ=$O(^BGUTMP(BPCSUB,1,BPCSEQ)) Q:BPCSEQ="" S BPCRES(BPCCTR)=^(BPCSEQ)
  1. S:BPCSEQ="" BPCCTR=BPCCTR-1 S BPCRES(0)=BPCCTR
  1. I BPCSEQ'="" S BPCCTR=BPCCTR+1,BPCRES(0)=BPCCTR,BPCRES(BPCCTR)="..MORE",$P(^BGUTMP(BPCSUB,1),U,2)=BPCSEQ Q
  1. K @BPCPVS,BPCPV,BPCPVS,^BGUTMP(BPCSUB,1)
  1. Q
  1. ;
  1. KILL ;
  1. K BPCC,BPCCAT,BPCCDE,BPCCTR,BPCDATA,BPCDESC,BPCGUI,BPCI,BPCLEN,BPCLSQA,BPCLSQP,BPCMAX,BPCMORE,BPCN,BPCNEXT,BPCPARAM,BPCPRM1,BPCSEQ,BPCSUB,BPCX,BPCXS
  1. Q