Ignore:
Timestamp:
Nov 14, 2013, 5:40:26 PM (10 years ago)
Author:
Sam Habiel
Message:

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).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/rxnorm/trunk/routines/C0CRXNLK.m

    r1617 r1630  
    1 C0CRXNLK        ; VEN/SMH - RxNorm Lookup Utilities ;2013-04-10  7:01 PM
    2         ;;1.0;RX NORM;;Apr 25, 2012;Build 99
     1C0CRXNLK        ; VEN/SMH - RxNorm Lookup Utilities ;2013-11-14  2:43 PM
     2        ;;2.2;RXNORM FOR VISTA;;Nov 14, 2013;Build 8
    33        ;(c) Sam Habiel 2013
    44        ; See accompanying license. Don't use otherwise.
     
    1010        QUIT
    1111        ;
    12 EXIST(RXN) ; $$ Public - Does this RxNorm CUI exist?
     12EXIST(RXN)      ; $$ Public - Does this RxNorm CUI exist?
    1313        ; Input: RxNorm CUI by value
    1414        ; Output: Extrinsic
     
    2222        Q ^(IEN)
    2323        ;
    24 GCN2RXNT ; @TEST - Test Get RxNorm CUI using GCN
     24GCN2RXNT        ; @TEST - Test Get RxNorm CUI using GCN
     25        Q:'$D(^C0CRXN(176.001,"STC","NDDF"))
    2526        N L F L=1:1 N LN S LN=$T(GCN2RXND+L) Q:LN["<<END>>"  Q:LN=""  D
    2627        . N GCN S GCN=$P(LN,";",3)
     
    2930        QUIT
    3031        ;
    31 GCN2RXND ; @DATA - Data for Tests ;;GCN;EXPECTED RXNCUI
     32GCN2RXND        ; @DATA - Data for Tests ;;GCN;EXPECTED RXNCUI
    3233        ;;16033;991632
    3334        ;;8208;310429
     
    3536        ;;18;197604
    3637        ;;346;884173
     38        ;;<<END>>
     39        ;
     40        ;
     41        ;
     42RXN2GCN(RXNCUI) ; $$ Public - Get GCN(s) given an RxNorm Number
     43        ; Input: RXNCUI by Value
     44        ; Output: Caret delimited Extrinsic
     45        N GCNS S GCNS=""
     46        N I S I=""
     47        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
     48        S GCNS=$E(GCNS,1,$L(GCNS)-1) ; remove trailing ^
     49        Q GCNS
     50        ;
     51RXN2GCNT        ; @TEST - Test Get GCN from RXNCUI
     52        Q:'$D(^C0CRXN(176.001,"STX","NDDF"))
     53        N L F L=1:1 N LN S LN=$T(RXN2GCND+L) Q:LN["<<END>>"  Q:LN=""  D
     54        . N RXN S RXN=$P(LN,";",3)
     55        . N GCN S GCN=$P(LN,";",4)
     56        . D CHKEQ^XTMUNIT($$RXN2GCN(RXN),GCN,"Translation from RXCUI to GCN failed")
     57        QUIT
     58        ;
     59        ;
     60RXN2GCND        ; @DATA - Data for Tests ;;RXNORM CUI;Expected GCN; Human Readable Drug name for dear reader
     61        ;;998689;5145;Acetabulol 200mg tab
     62        ;;745679;5037;Albuterol Inhaler
     63        ;;197320;2536;Allopurinol 300mg tab
     64        ;;993691;3948^46236;Bupropion 75mg tab
     65        ;;197591;3768;Diazepam 5mg tab
    3766        ;;<<END>>
    3867        ;
     
    5079        Q C0PVUID
    5180        ;
    52 RXN2VUIT ; @TEST - Get VUIDs given RxNorm values
     81RXN2VUIT        ; @TEST - Get VUIDs given RxNorm values
    5382        N L F L=1:1 N LN S LN=$T(RXN2VUID+L) Q:LN["<<END>>"  Q:LN=""  D
    5483        . N RXN S RXN=$P(LN,";",3)
     
    5786        QUIT
    5887        ;
    59 RXN2VUID ; @DATA - Data items for previous test
     88RXN2VUID        ; @DATA - Data items for previous test
    6089        ;;991632;4006455
    6190        ;;310429;4002369^4013941
     
    76105        Q O
    77106        ;
    78 VUI2VAPT ; @TEST - Get VA Product IEN from VUID
     107VUI2VAPT        ; @TEST - Get VA Product IEN from VUID
    79108        N L F L=1:1 N LN S LN=$T(VUI2VAPD+L) Q:LN["<<END>>"  Q:LN=""  D
    80109        . N VUID S VUID=$P(LN,";",3)
     
    83112        QUIT
    84113        ;
    85 VUI2VAPD ; @DATA - Data for above test
     114VUI2VAPD        ; @DATA - Data for above test
    86115        ;;4006455;5932
    87116        ;;4002369;1784
     
    112141        ;
    113142        ;
    114 RXN2MEDS(RXNCUI) ; $$ Public - Convert RxNorm value to currently existing drugs in File 50.
     143RXN2MEDS(RXNCUI)        ; $$ Public - Convert RxNorm value to currently existing drugs in File 50.
    115144        ; Input: SCD RXNCUI
    116145        ; Output; Caret delimited extrinsic
     
    123152        . N VUID S VUID=$P(VUIDS,U,I)
    124153        . N VAPRODS S VAPRODS=$$VUI2VAP(VUID) ; Get VA Product from VUID (multiple products per VUID)
    125         . I '$L(VAPRODS) S ^SAM(RXNCUI)="TELL SAM",DONE=1 QUIT  ; MUST EXIST. Every VUID must have a product to go with it.
     154        . I '$L(VAPRODS) S $ECODE=",U-NO-VA-PRODUCT-CORRUPT-NDF,"  ; MUST EXIST. Every VUID must have a product to go with it.
    126155        . N J F J=1:1:$L(VAPRODS,U) D  Q:DONE
    127156        . . N VAPROD S VAPROD=$P(VAPRODS,U,J)
     
    138167        ;
    139168FDI2RXNT        ; @TEST - Test Get RxNorm CUI for FDB Ingredient/Base
     169        Q:'$D(^C0CRXN(176.001,"STC","NDDF"))
    140170        D CHKEQ^XTMUNIT($$FDI2RXN(14739),1362160,"$$FDI2RXN failed")
    141171        QUIT
     
    162192        Q C0PIEN_"^"_C0P01
    163193        ;
    164 VIN2VAGT ; @TEST - Test Get VA Generic for VUID Ingredient
     194VIN2VAGT        ; @TEST - Test Get VA Generic for VUID Ingredient
    165195        D CHKEQ^XTMUNIT(+$$VIN2VAG(4023636),2832,"$$VIN2VAG failed")
    166196        QUIT
     
    202232        QUIT RXNS
    203233        ;
    204 MED2RXN(DA) ; $$ Public - Get RxNorm CUI for Drug
     234VUI2GCN(VUID)   ; $$ Public - Get GCNs for a given VUID (any VUID type)
     235        ; Input: VUID by Value
     236        ; Output: GCNs delimited by ^
     237        ; TODO: Unit Test
     238        N RXNS S RXNS=$$VUI2RXN(VUID)
     239        N GCNS S GCNS=""
     240        N I F I=1:1:$L(RXNS,U) S GCNS=GCNS_$$RXN2GCN($P(RXNS,U,I))_U
     241        S GCNS=$E(GCNS,1,$L(GCNS)-1)
     242        QUIT GCNS
     243        ;
     244MED2RXN(DA)     ; $$ Public - Get RxNorm CUI for Drug
    205245        ; Input: DA - Medication IEN
    206246        ; Output: RXNCUIs delimited by ^
     
    212252        Q $$VUI2RXN(VUID)
    213253        ;
    214 MED2SCDN(DA) ; $$ Public - Medication to Semantic Clinical Drug Name
     254MED2SCDN(DA)    ; $$ Public - Medication to Semantic Clinical Drug Name
    215255        ; Input: DA - Medication IEN
    216256        ; Output: The Canonical Semantic Clinical Drug name
     
    239279        ; ---
    240280        ;
    241 NDC2RXN(NDC) ; $$ Public - Get RxCUI given the NDC
     281NDC2RXN(NDC)    ; $$ Public - Get RxCUI given the NDC
    242282        ; NB: Will only work if passed NDC is in 5-4-2 format.
    243283        ; Input: NDC By Value in 5-4-2 Format
     
    246286        N IEN S IEN=$O(^C0CRXN(176.002,"ASAA","RXNORM","NDC",NDC,"")) Q ^(IEN)
    247287        ;
    248 NDC2RXNT ; @TEST - Test Get RxCUI given the NDC
     288NDC2RXNT        ; @TEST - Test Get RxCUI given the NDC
    249289        D CHKEQ^XTMUNIT($$NDC2RXN("30142-0917-71"),198439,"$$NDC2RXN failed")
    250290        QUIT
     
    252292        ; ---
    253293        ;
    254 ISBRAND(RXN) ; $$ Public - Is this RxCUI for a brand drug?
     294ISBRAND(RXN)    ; $$ Public - Is this RxCUI for a brand drug?
    255295        ; Input: RxCUI
    256296        ; Output: 0 or 1
    257297        Q ''$D(^C0CRXN(176.001,"STC","RXNORM","SBD",RXN))
    258 ISBRANDT ; @TEST - Test Is this RxCUI for a brand drug?
     298ISBRANDT        ; @TEST - Test Is this RxCUI for a brand drug?
    259299        D CHKEQ^XTMUNIT($$ISBRAND(205535),1,"$$ISBRAND failed") ; Brand Prozac
    260300        D CHKEQ^XTMUNIT($$ISBRAND(310384),0,"$$ISBRAND failed") ; Generic Fluoxetine
     
    263303        ; ---
    264304        ;
    265 BR2GEN(RXN) ; $$ Public - Convert Brand RxCUI to Generic RxCUI (many to 1)
     305BR2GEN(RXN)     ; $$ Public - Convert Brand RxCUI to Generic RxCUI (many to 1)
    266306        ; Input: RxCUI of Brand
    267307        ; Output: RxCUI of Generic
    268308        Q $O(^C0CRXN(176.005,"B",RXN,"has_tradename",""))
    269 BR2GENT ; @TEST - Test Convert Brand RxCUI to Generic RxCUI (many to 1)
     309BR2GENT ; @TEST - Test Convert Brand RxCUI to Generic RxCUI (many to 1)
    270310        D CHKEQ^XTMUNIT($$BR2GEN(205535),310384,"$$BR2GEN failed")
    271311        QUIT
     
    273313        ; ---
    274314        ;
    275 GEN2BR(RXN) ; $$ Public - Convert Generic RxCUI to Brand RxCUIs (1 to many).
     315GEN2BR(RXN)     ; $$ Public - Convert Generic RxCUI to Brand RxCUIs (1 to many).
    276316        N RTN S RTN="" ; Return
    277317        N I S I="" F  S I=$O(^C0CRXN(176.005,"B",RXN,"tradename_of",I)) Q:'I  S RTN=RTN_I_U
     
    279319        Q RTN
    280320        ;
    281 GEN2BRT ; @TEST - Test Convert Generic RxCUI to Brand RxCUIs (1 to many).
     321GEN2BRT ; @TEST - Test Convert Generic RxCUI to Brand RxCUIs (1 to many).
    282322        D CHKTF^XTMUNIT($$GEN2BR(310384)[205535,"$$GEN2BR failed")
    283323        QUIT
     
    285325        ; ---
    286326        ;
    287 RXN2BNS(RXN) ; $$ Public - Get all Brand Names associated with an RXN
     327RXN2BNS(RXN)    ; $$ Public - Get all Brand Names associated with an RXN
    288328        N BNS S BNS=""
    289329        I $$ISBRAND(RXN) S RXN=$$BR2GEN(RXN)
     
    297337        . S BNS=BNS_$P(^C0CRXN(176.001,BNIEN,0),U,15)_U
    298338        QUIT $E(BNS,1,$L(BNS)-1)
    299 RXN2BNST ; @TEST - Test Get all Brand Names associated with an RXN
     339RXN2BNST        ; @TEST - Test Get all Brand Names associated with an RXN
    300340        D CHKTF^XTMUNIT($$RXN2BNS(205535)["Prozac","$$RXN2BNS failed")
    301341        QUIT
     342        ;
     343        ; ---
     344        ;
     345RXN2NDC(RXN)    ; Get NDC codes for RxNorm code
     346        N NDCS S NDCS=""
     347        N I F I=0:0 S I=$O(^C0CRXN(176.002,"ASAR","RXNORM","NDC",RXN,I)) Q:'I  S NDCS=NDCS_^(I)_"^"
     348        S $E(NDCS,$L(NDCS))=""
     349        QUIT NDCS
     350RXN2NDCT        ; @TEST - Test Get NDC codes for RxNorm code
     351        D CHKTF^XTMUNIT($$RXN2NDC(197379)["^"_16714003309,"$$RXN2NDC failed")
     352        QUIT
Note: See TracChangeset for help on using the changeset viewer.