Two routines modified: C0CRXNRD and C0CRXNLK.
C0CRXNRD (loader utility): - Can now import RxNorm prescribably subset - Will import public domain by default except if RESTRICTED is passed to IMPORT as 1 (second parameter). C0CRXNLK (lookup utilities): - FDB Unit Tests don't run if FDB from RxNorm isn't loaded. - New API: $$RXN2GCN - Get GCNs from RXNCUI (+UT). - New API: $$VUI2GCN - Get VUIDs from GCN (No UT supplied). - New API: $$RXN2NDC - Get NDCs for a given RxNorm CUI (+UT).
This commit is contained in:
parent
57db47a584
commit
bd0d503cc5
|
@ -1,5 +1,5 @@
|
|||
C0CRXNAD ; VEN/SMH - Add a drug to VISTA from RxNorm;2013-04-19 5:39 PM
|
||||
;;1.0;RX NORM;;Apr 25, 2012;Build 99
|
||||
;;2.2;RXNORM FOR VISTA;;Nov 14, 2013;Build 8
|
||||
; (C) 2013 Sam Habiel
|
||||
; Proprietary Code. Don't use if license terms aren't supplied.
|
||||
;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
C0CRXNLK ; VEN/SMH - RxNorm Lookup Utilities ;2013-04-10 7:01 PM
|
||||
;;1.0;RX NORM;;Apr 25, 2012;Build 99
|
||||
C0CRXNLK ; VEN/SMH - RxNorm Lookup Utilities ;2013-11-14 2:43 PM
|
||||
;;2.2;RXNORM FOR VISTA;;Nov 14, 2013;Build 8
|
||||
;(c) Sam Habiel 2013
|
||||
; See accompanying license. Don't use otherwise.
|
||||
;
|
||||
|
@ -22,6 +22,7 @@ GCN2RXN(GCN) ; $$ Public - Get RxNorm CUI using GCN
|
|||
Q ^(IEN)
|
||||
;
|
||||
GCN2RXNT ; @TEST - Test Get RxNorm CUI using GCN
|
||||
Q:'$D(^C0CRXN(176.001,"STC","NDDF"))
|
||||
N L F L=1:1 N LN S LN=$T(GCN2RXND+L) Q:LN["<<END>>" Q:LN="" D
|
||||
. N GCN S GCN=$P(LN,";",3)
|
||||
. N RXN S RXN=$P(LN,";",4)
|
||||
|
@ -38,6 +39,34 @@ GCN2RXND ; @DATA - Data for Tests ;;GCN;EXPECTED RXNCUI
|
|||
;
|
||||
;
|
||||
;
|
||||
RXN2GCN(RXNCUI) ; $$ Public - Get GCN(s) given an RxNorm Number
|
||||
; Input: RXNCUI by Value
|
||||
; Output: Caret delimited Extrinsic
|
||||
N GCNS S GCNS=""
|
||||
N I S I=""
|
||||
F S I=$O(^C0CRXN(176.001,"STX","NDDF","CDC",RXNCUI,I)) Q:I="" S GCNS=GCNS_+^(I)_U ; + b/c we want the GCN w/o leading zeros
|
||||
S GCNS=$E(GCNS,1,$L(GCNS)-1) ; remove trailing ^
|
||||
Q GCNS
|
||||
;
|
||||
RXN2GCNT ; @TEST - Test Get GCN from RXNCUI
|
||||
Q:'$D(^C0CRXN(176.001,"STX","NDDF"))
|
||||
N L F L=1:1 N LN S LN=$T(RXN2GCND+L) Q:LN["<<END>>" Q:LN="" D
|
||||
. N RXN S RXN=$P(LN,";",3)
|
||||
. N GCN S GCN=$P(LN,";",4)
|
||||
. D CHKEQ^XTMUNIT($$RXN2GCN(RXN),GCN,"Translation from RXCUI to GCN failed")
|
||||
QUIT
|
||||
;
|
||||
;
|
||||
RXN2GCND ; @DATA - Data for Tests ;;RXNORM CUI;Expected GCN; Human Readable Drug name for dear reader
|
||||
;;998689;5145;Acetabulol 200mg tab
|
||||
;;745679;5037;Albuterol Inhaler
|
||||
;;197320;2536;Allopurinol 300mg tab
|
||||
;;993691;3948^46236;Bupropion 75mg tab
|
||||
;;197591;3768;Diazepam 5mg tab
|
||||
;;<<END>>
|
||||
;
|
||||
;
|
||||
;
|
||||
RXN2VUI(RXNCUI) ; $$ Public - Get VUID(s) for given RXNCUI for Clinical Drug
|
||||
; Input: RXNCUI by Value
|
||||
; Output: Caret delimited extrinsic. Should not be more than 2 entries.
|
||||
|
@ -122,7 +151,7 @@ RXN2MEDS(RXNCUI) ; $$ Public - Convert RxNorm value to currently existing drugs
|
|||
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.
|
||||
. I '$L(VAPRODS) S $ECODE=",U-NO-VA-PRODUCT-CORRUPT-NDF," ; 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
|
||||
|
@ -137,6 +166,7 @@ FDI2RXN(BASE) ; $$ Public - Get RxNorm CUI for FDB Ingredient/Base
|
|||
N IEN S IEN=$O(^C0CRXN(176.001,"STC","NDDF","IN",BASE,"")) Q ^(IEN)
|
||||
;
|
||||
FDI2RXNT ; @TEST - Test Get RxNorm CUI for FDB Ingredient/Base
|
||||
Q:'$D(^C0CRXN(176.001,"STC","NDDF"))
|
||||
D CHKEQ^XTMUNIT($$FDI2RXN(14739),1362160,"$$FDI2RXN failed")
|
||||
QUIT
|
||||
;
|
||||
|
@ -201,6 +231,16 @@ VUI2RXN(VUID) ; $$ Public - Get RXNCUI for VUID (any VUID type)
|
|||
S RXNS=$E(RXNS,1,$L(RXNS)-1)
|
||||
QUIT RXNS
|
||||
;
|
||||
VUI2GCN(VUID) ; $$ Public - Get GCNs for a given VUID (any VUID type)
|
||||
; Input: VUID by Value
|
||||
; Output: GCNs delimited by ^
|
||||
; TODO: Unit Test
|
||||
N RXNS S RXNS=$$VUI2RXN(VUID)
|
||||
N GCNS S GCNS=""
|
||||
N I F I=1:1:$L(RXNS,U) S GCNS=GCNS_$$RXN2GCN($P(RXNS,U,I))_U
|
||||
S GCNS=$E(GCNS,1,$L(GCNS)-1)
|
||||
QUIT GCNS
|
||||
;
|
||||
MED2RXN(DA) ; $$ Public - Get RxNorm CUI for Drug
|
||||
; Input: DA - Medication IEN
|
||||
; Output: RXNCUIs delimited by ^
|
||||
|
@ -299,3 +339,14 @@ RXN2BNS(RXN) ; $$ Public - Get all Brand Names associated with an RXN
|
|||
RXN2BNST ; @TEST - Test Get all Brand Names associated with an RXN
|
||||
D CHKTF^XTMUNIT($$RXN2BNS(205535)["Prozac","$$RXN2BNS failed")
|
||||
QUIT
|
||||
;
|
||||
; ---
|
||||
;
|
||||
RXN2NDC(RXN) ; Get NDC codes for RxNorm code
|
||||
N NDCS S NDCS=""
|
||||
N I F I=0:0 S I=$O(^C0CRXN(176.002,"ASAR","RXNORM","NDC",RXN,I)) Q:'I S NDCS=NDCS_^(I)_"^"
|
||||
S $E(NDCS,$L(NDCS))=""
|
||||
QUIT NDCS
|
||||
RXN2NDCT ; @TEST - Test Get NDC codes for RxNorm code
|
||||
D CHKTF^XTMUNIT($$RXN2NDC(197379)["^"_16714003309,"$$RXN2NDC failed")
|
||||
QUIT
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
C0CRXNRD ; VEN/SMH - RxNorm Utilities: Routine to Read RxNorm files;2013-03-06 4:32 PM
|
||||
;;2.0;RX NORM;;May 11, 2012;Build 50
|
||||
C0CRXNRD ; VEN/SMH - RxNorm Utilities: Routine to Read RxNorm files;2013-11-14 1:23 PM
|
||||
;;2.2;RXNORM FOR VISTA;;Nov 14, 2013;Build 8
|
||||
; (C) Sam Habiel 2013
|
||||
; See license for terms of use.
|
||||
;
|
||||
W "No entry from top" Q
|
||||
IMPORT(PATH) ; PUBLIC ENTRY POINT. Rest are private
|
||||
IMPORT(PATH,RESTRICTED) ; PUBLIC ENTRY POINT. Rest are private
|
||||
I PATH="" QUIT
|
||||
S RESTRICTED=$G(RESTRICTED,0)
|
||||
S U="^"
|
||||
N STARTTIME S STARTTIME=$P($H,",")*24*60*60+$P($H,",",2)
|
||||
D SAB(PATH),CONSO(PATH),SAT(PATH),STY(PATH),REL(PATH),DOC(PATH)
|
||||
N SABS
|
||||
D SAB(PATH,.SABS) ; Load restriction values into SAB. ; 176.006
|
||||
D CONSO(PATH,.SABS,RESTRICTED),SAT(PATH,.SABS,RESTRICTED) ; 176.001,176.002
|
||||
D STY(PATH),REL(PATH),DOC(PATH) ; 176.003-5
|
||||
N ENDTIME S ENDTIME=$P($H,",")*24*60*60+$P($H,",",2)
|
||||
W !,(ENDTIME-STARTTIME)/60_" minutes elapsed"
|
||||
QUIT
|
||||
|
@ -24,17 +28,19 @@ DELFILED(FN) ; Delete file data; PEP procedure; only for RxNorm files
|
|||
S @ROOT@(0)=ZERO ; It riseth again!
|
||||
QUIT
|
||||
GETLINES(PATH,FILENAME) ; Get number of lines in a file
|
||||
N POP
|
||||
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
||||
Q:POP
|
||||
U IO
|
||||
N I,LINE
|
||||
F I=1:1 R LINE:0 Q:$$STATUS^%ZISH
|
||||
D CLOSE^%ZISH("FILE")
|
||||
Q I-1
|
||||
CONSO(PATH,INCRES) ; Open and read concepts file: RXNCONSO.RRF
|
||||
CONSO(PATH,SABS,RESTRICTED) ; Open and read concepts file: RXNCONSO.RRF
|
||||
; PATH ByVal, path of RxNorm files
|
||||
; INCRES ByVal, include restricted sources. 1 for yes, 0 for no
|
||||
; SABS ByRef, arrays of SABS(SAB)=restriction level
|
||||
; RESTRICTED ByVal, include restricted sources. 1 for yes, 0 for no
|
||||
I PATH="" QUIT
|
||||
S INCRES=+$G(INCRES) ; if not passed, becomes zero.
|
||||
N FILENAME S FILENAME="RXNCONSO.RRF"
|
||||
D DELFILED(176.001) ; delete data
|
||||
N LINES S LINES=$$GETLINES(PATH,FILENAME)
|
||||
|
@ -47,20 +53,22 @@ CONSO(PATH,INCRES) ; Open and read concepts file: RXNCONSO.RRF
|
|||
. N LINE R LINE:0
|
||||
. IF $$STATUS^%ZISH QUIT
|
||||
. I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
|
||||
. ;
|
||||
. ; Deal with restriction level
|
||||
. N SAB S SAB=$P(LINE,"|",12)
|
||||
. I 'RESTRICTED,SABS(SAB) QUIT ; If not include restricted, and SABS(SAB) is not zero, quit
|
||||
. ;
|
||||
. ; Save data
|
||||
. S ^C0CRXN(176.001,C0CCOUNT,0)=$TR(LINE,"|^","^|")
|
||||
. ; TODO Implement Filtering:
|
||||
. ; If the source is a restricted source, decide what to do based on what's asked.
|
||||
. ; N SRCIEN S SRCIEN=$$FIND1^DIC(176.003,"","QX",SAB,"B") ; SrcIEN in RXNORM SOURCES file
|
||||
. ; N RESTRIC S RESTRIC=$$GET1^DIQ(176.003,SRCIEN,14,"I") ; 14 is restriction field; values 0-4
|
||||
. ; If RESTRIC is zero, then it's unrestricted. Everything else is restricted.
|
||||
. ; If user didn't ask to include restricted sources, and the source is restricted, then quit
|
||||
. ; I 'INCRES,RESTRIC QUIT
|
||||
EX D CLOSE^%ZISH("FILE")
|
||||
N DIK S DIK="^C0CRXN(176.001," D IXALL^DIK
|
||||
QUIT
|
||||
;
|
||||
;
|
||||
SAT(PATH) ; Open and read Concept and Atom attributes: RXNSAT.RRF
|
||||
SAT(PATH,SABS,RESTRICTED) ; Open and read Concept and Atom attributes: RXNSAT.RRF
|
||||
; PATH ByVal, path of RxNorm files
|
||||
; SABS ByRef, arrays of SABS(SAB)=restriction level
|
||||
; RESTRICTED ByVal, include restricted sources. 1 for yes, 0 for no
|
||||
I PATH="" QUIT
|
||||
N FILENAME S FILENAME="RXNSAT.RRF"
|
||||
D DELFILED(176.002) ; delete data
|
||||
|
@ -81,6 +89,10 @@ SAT(PATH) ; Open and read Concept and Atom attributes: RXNSAT.RRF
|
|||
. S $P(LINE,"|",1)=ATN9
|
||||
. S $P(LINE,"|",9)=RXCUI1
|
||||
. ;
|
||||
. ; Deal with restricted sources
|
||||
. N SAB S SAB=$P(LINE,"|",10)
|
||||
. I 'RESTRICTED,SABS(SAB) QUIT ; If not include restricted, and SABS(SAB) is not zero, quit
|
||||
. ;
|
||||
. ; Save off
|
||||
. S ^C0CRXN(176.002,C0CCOUNT,0)=$TR(LINE,"|^","^|")
|
||||
EX2 D CLOSE^%ZISH("FILE")
|
||||
|
@ -88,7 +100,7 @@ EX2 D CLOSE^%ZISH("FILE")
|
|||
QUIT
|
||||
;
|
||||
;
|
||||
SAB(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
||||
SAB(PATH,SABS) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
||||
I PATH="" QUIT
|
||||
N FILENAME S FILENAME="RXNSAB.RRF"
|
||||
D DELFILED(176.003) ; delete data
|
||||
|
@ -108,6 +120,8 @@ SAB(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
|||
. S ^C0CRXN(176.003,I,0)=$TR(LINE,"^|","|^")
|
||||
EX3 D CLOSE^%ZISH("FILE")
|
||||
N DIK S DIK="^C0CRXN(176.003," D IXALL^DIK
|
||||
N C0CI F C0CI=0:0 S C0CI=$O(^C0CRXN(176.003,C0CI)) Q:'C0CI D
|
||||
. S SABS($$GET1^DIQ(176.003,C0CI,.01))=$$GET1^DIQ(176.003,C0CI,"SRL")
|
||||
QUIT
|
||||
STY(PATH) ; Open and read RxNorm Semantic types file: RXNSTY.RRF
|
||||
I PATH="" QUIT
|
||||
|
|
Loading…
Reference in New Issue