Improvements to bugs found in RxNorm lookups

This commit is contained in:
sam 2013-04-11 01:52:03 +00:00
parent 1e98fe7212
commit a3b271e74c
1 changed files with 26 additions and 7 deletions

View File

@ -1,4 +1,4 @@
C0CRXNLK ; VEN/SMH - RxNorm Lookup Utilities ;2013-04-08 5:00 PM
C0CRXNLK ; VEN/SMH - RxNorm Lookup Utilities ;2013-04-10 7:01 PM
;;1.0;RX NORM;;Apr 25, 2012;Build 99
;(c) Sam Habiel 2013
; See accompanying license. Don't use otherwise.
@ -9,6 +9,11 @@ C0CRXNLK ; VEN/SMH - RxNorm Lookup Utilities ;2013-04-08 5:00 PM
D EN^XTMUNIT($T(+0),1)
QUIT
;
EXIST(RXN) ; $$ Public - Does this RxNorm CUI exist?
; Input: RxNorm CUI by value
; Output: Extrinsic
Q ''$D(^C0CRXN(176.001,"B",RXN))
;
GCN2RXN(GCN) ; $$ Public - Get RxNorm CUI using GCN
; Input: GCN by Value
; Output: Extrinsic
@ -61,10 +66,14 @@ RXN2VUID ; @DATA - Data items for previous test
;
;
;
VUI2VAP(VUID) ; $$ Public - Get VA Product IEN from VUID
VUI2VAP(VUID) ; $$ Public - Get VA Product IEN(s) from VUID
; Input VUID by Value
; Output: Extrinsic
Q $$FIND1^DIC(50.68,"","QX",VUID,"AVUID")
D FIND^DIC(50.68,,"@","QP",VUID,,"AVUID") ; Find all in VUID index
N O S O="" ; Output
N I F I=0:0 S I=$O(^TMP("DILIST",$J,I)) Q:'I S O=O_^(I,0)_U ; Concat results together
S O=$E(O,1,$L(O)-1) ; remove trailing ^
Q O
;
VUI2VAPT ; @TEST - Get VA Product IEN from VUID
N L F L=1:1 N LN S LN=$T(VUI2VAPD+L) Q:LN["<<END>>" Q:LN="" D
@ -79,6 +88,7 @@ VUI2VAPD ; @DATA - Data for above test
;;4000874;252
;;4003335;2756
;;4002469;1884
;;4009488;9046^10090
;;<<END>>
;
;
@ -105,10 +115,18 @@ RXN2MEDS(RXNCUI) ; $$ Public - Convert RxNorm value to currently existing drugs
; Input: SCD RXNCUI
; Output; Caret delimited extrinsic
; Un-unit testable
N VUIDS S VUIDS=$$RXN2VUI(RXNCUI) ; Get VUID from RXNCUI
; TODO: Decide which VUID to use!
N VAPROD S VAPROD=$$VUI2VAP(VUIDS) ; Get VA Product from VUID
N MEDS S MEDS=$$VAP2MED(VAPROD) ; Get Meds from VA Product
N VUIDS S VUIDS=$$RXN2VUI(RXNCUI) ; Get VUID from RXNCUI (multiple VUIDs per CUI)
Q:'VUIDS ""
N MEDS S MEDS=""
N DONE S DONE=0
N I F I=1:1:$L(VUIDS,U) D Q:DONE
. N VUID S VUID=$P(VUIDS,U,I)
. N VAPRODS S VAPRODS=$$VUI2VAP(VUID) ; Get VA Product from VUID (multiple products per VUID)
. I '$L(VAPRODS) S ^SAM(RXNCUI)="TELL SAM",DONE=1 QUIT ; MUST EXIST. Every VUID must have a product to go with it.
. N J F J=1:1:$L(VAPRODS,U) D Q:DONE
. . N VAPROD S VAPROD=$P(VAPRODS,U,J)
. . S MEDS=$$VAP2MED(VAPROD) ; Get Meds from VA Product
. . I $L(MEDS) S DONE=1
QUIT MEDS
;
FDI2RXN(BASE) ; $$ Public - Get RxNorm CUI for FDB Ingredient/Base
@ -270,6 +288,7 @@ RXN2BNS(RXN) ; $$ Public - Get all Brand Names associated with an RXN
N BNS S BNS=""
I $$ISBRAND(RXN) S RXN=$$BR2GEN(RXN)
N ALLBN S ALLBN=$$GEN2BR(RXN)
Q:ALLBN="" ""
N BNNO F BNNO=1:1:$L(ALLBN,U) D
. N EACHBN S EACHBN=$P(ALLBN,U,BNNO)
. N BNRXCUI S BNRXCUI=$O(^C0CRXN(176.005,"B",EACHBN,"ingredient_of",""))