Changeset 373 for ccr/trunk/p


Ignore:
Timestamp:
Feb 22, 2009, 4:17:54 PM (16 years ago)
Author:
Sam Habiel
Message:

Waaaaay too much work in this to get RxNorm working...
Untested!!! I just want to save my work for now; I will refactor
and test later. --Sam

File:
1 edited

Legend:

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

    r359 r373  
    9696 . ; We obviously need the NDC. That is easily obtained from the prescription.
    9797 . ; Field 27 in file 52
    98  . ; N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I")
    99  . ; S NDC=$TR(NDC,"-")  ; Remove dashes
    100  . ; NDC="0"_NDC  ; Add an extra zero to front; don't ask, that's how RxNorm has it
    101  . N NDC S NDC=0 ; TODO:Remove this line after I fix the RxNorm 176.002 file.
    102  . N RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER
     98 . N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I")
     99 . S NDC=$TR(NDC,"-")  ; Remove dashes
     100 . ; I discovered that file 176.002 might give you two codes for the NDC
     101 . ; One for the Clinical Drug, and one for the ingredient.
     102 . ; So the plan is to get the two RxNorm codes, and then find from
     103 . ; file 176.001 which one is the Clinical Drug.
     104 . N C0CZRXN,DIERR
     105 . N RXNORM,SRCIEN,RXNNAME,RXNVER
    103106 . I +NDC,$D(^C0CRXN) D  ; $Data is for Systems that don't have our RxNorm file yet.
    104  . . S RXNIEN=$$FIND1^DIC(176.002,,,NDC,"NDC")
    105  . . S RXNORM=$$GET1^DIQ(176.002,RXNIEN,.01)
     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=""
    106123 . . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B")
    107124 . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6)
     
    178195 . ;
    179196 . N RAWDATA
    180  . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA")
     197 . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA","DIERR")
     198 . D:$D(DIERR) ^%ZTER  ; Log if there's an error in retrieving sig field
     199 . ; none the less, continue; some parts are retrievable.
    181200 . N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile...
    182201 . K RAWDATA
     
    190209 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")=""  ; This is reserved for systems not able to generate the sig in components.
    191210 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1"  ; means that we are specifying it. See E2369-05.
    192  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(8)
    193  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(.01)
    194  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=SIGDATA(2)
     211 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$G(SIGDATA(8))
     212 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$G(SIGDATA(.01))
     213 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=$G(SIGDATA(2))
    195214 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")=""  ; For inpatient
    196215 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")=""  ; For inpatient
    197216 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")=""  ; For inpatient
    198217 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$G(SIGDATA(6))
    199  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(7)
     218 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$G(SIGDATA(7))
    200219 . . ; Invervals... again another call.
    201220 . . ; In the wisdom of the original programmers, the schedule is a free text field
     
    206225 . . ; First, remove "PRN" if it exists (don't ask, that's how the file
    207226 . . ; works; I wouldn't do it that way).
    208  . . N SCHNOPRN S SCHNOPRN=SIGDATA(7)
     227 . . N SCHNOPRN S SCHNOPRN=$G(SIGDATA(7))
    209228 . . I SCHNOPRN["PRN" S SCHNOPRN=$E(SCHNOPRN,1,$F(SCHNOPRN,"PRN")-5)
    210229 . . ; Super call below:
     
    226245 . . ; 10W for weeks, 10L for months. I smell $Select
    227246 . . ; But we don't need to do that if there isn't a duration
    228  . . I +SIGDATA(4) D
     247 . . I +$G(SIGDATA(4)) D
    229248 . . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char
    230249 . . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days")
     
    234253 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=""
    235254 . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
    236  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(4)["PRN"
     255 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$G(SIGDATA(4))["PRN"
    237256 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" ; when avail
    238257 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
     
    248267 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=""  ; Default
    249268 . . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT
    250  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(5)
     269 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$G(SIGDATA(5))
    251270 . ;
    252271 . ; --- END OF DIRECTIONS ---
Note: See TracChangeset for help on using the changeset viewer.