diff --git a/p/CCRMEDS6.m b/p/CCRMEDS6.m index 192a1cd..3cc97d2 100644 --- a/p/CCRMEDS6.m +++ b/p/CCRMEDS6.m @@ -95,14 +95,31 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . ; . ; We obviously need the NDC. That is easily obtained from the prescription. . ; Field 27 in file 52 - . ; N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I") - . ; S NDC=$TR(NDC,"-") ; Remove dashes - . ; NDC="0"_NDC ; Add an extra zero to front; don't ask, that's how RxNorm has it - . N NDC S NDC=0 ; TODO:Remove this line after I fix the RxNorm 176.002 file. - . N RXNIEN,RXNORM,SRCIEN,RXNNAME,RXNVER + . N NDC S NDC=$$GET1^DIQ(52,RXIEN,27,"I") + . S NDC=$TR(NDC,"-") ; Remove dashes + . ; I discovered that file 176.002 might give you two codes for the NDC + . ; One for the Clinical Drug, and one for the ingredient. + . ; So the plan is to get the two RxNorm codes, and then find from + . ; file 176.001 which one is the Clinical Drug. + . N C0CZRXN,DIERR + . N RXNORM,SRCIEN,RXNNAME,RXNVER . I +NDC,$D(^C0CRXN) D ; $Data is for Systems that don't have our RxNorm file yet. - . . S RXNIEN=$$FIND1^DIC(176.002,,,NDC,"NDC") - . . S RXNORM=$$GET1^DIQ(176.002,RXNIEN,.01) + . . D FIND^DIC(176.002,,"@;.01","PX",NDC,"*","NDC",,,"C0CZRXN","DIERR") + . . B:$D(DIERR) + . . S RXNORM(0)=+C0CZRXN("DILIST",0) ; RxNorm(0) will be # of entries + . . N I S I=0 + . . F S I=$O(C0CZRXN("DILIST",I)) Q:I="" S RXNORM(I)=$P(C0CZRXN("DILIST",I,0),U,2) + . . ; At this point, RxNorm(0) is # of entries; RxNorm(1...) are the entries + . . ; If RxNorm(0) is 1, then we only have one entry, and that's it. + . . I RXNORM(0)=1 S RXNORM=RXNORM(1) + . . ; Otherwise, we need to find out which is the clinical drug + . . I RXNORM(0)>1 D + . . . S I=0 + . . . F S I=$O(RXNORM(I)) Q:I="" Q:$L($G(RXNORM)) D + . . . . N RXNIEN S RXNIEN=$$FIND1^DIC(176.001,,,RXNORM(I),"B") + . . . . N RXNTTY S RXNTTY=$$GET1^DIQ(176.001,RXNIEN,3) + . . . . I RXNTTY="CD" S RXNORM=RXNORM(I) QUIT + . . I $L($G(RXNORM))=0 S RXNORM="" . . S SRCIEN=$$FIND1^DIC(176.003,,,"RXNORM","B") . . S RXNNAME=$$GET1^DIQ(176.003,SRCIEN,6) . . S RXNVER=$$GET1^DIQ(176.003,SRCIEN,7) @@ -177,7 +194,9 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . ; SAMINS(52.0113,"1,23,",5)="THEN" . ; . N RAWDATA - . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA") + . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA","DIERR") + . D:$D(DIERR) ^%ZTER ; Log if there's an error in retrieving sig field + . ; none the less, continue; some parts are retrievable. . N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile... . K RAWDATA . N FMSIGNUM S FMSIGNUM="" ; Sigline number in fileman. @@ -189,14 +208,14 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . . N SIGDATA M SIGDATA=FMSIG(FMSIGNUM) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(8) - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(.01) - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=SIGDATA(2) + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$G(SIGDATA(8)) + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$G(SIGDATA(.01)) + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=$G(SIGDATA(2)) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$G(SIGDATA(6)) - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(7) + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$G(SIGDATA(7)) . . ; Invervals... again another call. . . ; In the wisdom of the original programmers, the schedule is a free text field . . ; However, it gets translated by a call to the administration schedule file @@ -205,7 +224,7 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . . ; Search B index of 51.1 (Admin Schedule) with schedule . . ; First, remove "PRN" if it exists (don't ask, that's how the file . . ; works; I wouldn't do it that way). - . . N SCHNOPRN S SCHNOPRN=SIGDATA(7) + . . N SCHNOPRN S SCHNOPRN=$G(SIGDATA(7)) . . I SCHNOPRN["PRN" S SCHNOPRN=$E(SCHNOPRN,1,$F(SCHNOPRN,"PRN")-5) . . ; Super call below: . . ; 1=File 51.1 3=Field 2 (Frequency in Minutes) @@ -225,7 +244,7 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . . ; Duration is 10M minutes, 10H hours, 10D for Days . . ; 10W for weeks, 10L for months. I smell $Select . . ; But we don't need to do that if there isn't a duration - . . I +SIGDATA(4) D + . . I +$G(SIGDATA(4)) D . . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char . . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days") . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=+SIGDATA(4) @@ -233,7 +252,7 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . . E D . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")="" . . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")="" - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(4)["PRN" + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$G(SIGDATA(4))["PRN" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")="" ; when avail . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")="" @@ -247,7 +266,7 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE . . ; in the sig), set the direction count indicator. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")="" ; Default . . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT - . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(5) + . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$G(SIGDATA(5)) . ; . ; --- END OF DIRECTIONS --- . ;