Changeset 374 for ccr/trunk/p


Ignore:
Timestamp:
Feb 22, 2009, 7:47:40 PM (16 years ago)
Author:
Sam Habiel
Message:

I can finally extract a correct RxNorm code from the NDC. Whole routine still untested, but should work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/CCRMEDS6.m

    r373 r374  
    9797 . ; Field 27 in file 52
    9898 . N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I")
    99  . S NDC=$TR(NDC,"-")  ; Remove dashes
    10099 . ; I discovered that file 176.002 might give you two codes for the NDC
    101100 . ; One for the Clinical Drug, and one for the ingredient.
    102101 . ; So the plan is to get the two RxNorm codes, and then find from
    103102 . ; file 176.001 which one is the Clinical Drug.
    104  . N C0CZRXN,DIERR
     103 . ; ... I refactored this into GETRXN
    105104 . N RXNORM,SRCIEN,RXNNAME,RXNVER
    106105 . I +NDC,$D(^C0CRXN) D  ; $Data is for Systems that don't have our RxNorm file yet.
    107  . . D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR")
    108  . . B:$D(DIERR)
    109  . . S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries
    110  . . N I S I=0
    111  . . F  S I=$O(C0CZRXN("DILIST",I)) Q:I=""  S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2)
    112  . . ; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries
    113  . . ; If RxNorm(0) is 1, then we only have one entry, and that's it.
    114  . . I RXNORM(0)=1 S RXNORM=RXNORM(1)
    115  . . ; Otherwise, we need to find out which is the clinical drug
    116  . . I RXNORM(0)>1 D
    117  . . . S I=0
    118  . . . F  S I=$O(RXNORM(I)) Q:I=""  Q:$L($G(RXNORM))  D
    119  . . . . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"B")
    120  . . . . N RXNTTY S RXNTTY=$$GET1^DIQ(176.001,RXNIEN,3)
    121  . . . . I RXNTTY="CD" S RXNORM=RXNORM(I) QUIT
    122  . . I $L($G(RXNORM))=0 S RXNORM=""
     106 . . S RXNORM=$$GETRXN(NDC)
    123107 . . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B")
    124108 . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
     
    315299 Q
    316300 ;
     301GETRXN(NDC) ; Extrinsic Function; PUBLIC; NDC to RxNorm
     302 ;; Get RxNorm Concept Number for a Given NDC
     303 ;
     304 S NDC=$TR(NDC,"-")  ; Remove dashes
     305 N RXNORM,C0CZRXN,DIERR
     306 D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR")
     307 I $D(DIERR) D ^%ZTER BREAK
     308 S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries
     309 N I S I=0
     310 F  S I=$O(C0CZRXN("DILIST",I)) Q:I=""  S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2)
     311 ; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries
     312 ; If RxNorm(0) is 1, then we only have one entry, and that's it.
     313 I RXNORM(0)=1 QUIT RXNORM(1)  ; RETURN RXNORM(1)
     314 ; Otherwise, we need to find out which one is the semantic
     315 ; clinical drug. I built an index on 176.001 (RxNorm Concepts)
     316 ; for that purpose.
     317 I RXNORM(0)>1 D
     318 . S I=0
     319 . F  S I=$O(RXNORM(I)) Q:I=""  D  Q:$G(RXNORM)
     320 . . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"SCD")
     321 . . I +$G(RXNIEN)=0 QUIT  ; try the next entry...
     322 . . E  S RXNORM=RXNORM(I) QUIT  ; We found the right code
     323 QUIT +$G(RXNORM)  ; RETURN RXNORM; if we couldn't find a clnical drug, return with 0
     324 
Note: See TracChangeset for help on using the changeset viewer.