Changeset 323


Ignore:
Timestamp:
Jan 12, 2009, 12:04:14 AM (16 years ago)
Author:
Sam Habiel
Message:

Meds for RPMS, CCRMEDS6, continued...

File:
1 edited

Legend:

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

    r322 r323  
    1 CCRMEDS6 ; WV/CCDCCR/SMH - Meds from RPMS;01/10/09
     1CCRMEDS6 ; WV/CCDCCR/SMH - Meds from RPMS: Outpatient Meds;01/10/09
    22 ;;0.1;CCDCCR;;JUL 16,2008;
    33 ; Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
     
    3434 ; This API has been developed by Medsphere for IHS for getting
    3535 ; Medications from RPMS. It has most of what we need.
     36 ; API written by Doug Martin when he worked for Medsphere (thanks Doug!)
    3637 ; -- ARRAYNAME is passed by name (required)
    3738 ; -- DFN is passed by value (required)
     
    5051 N MEDCNT S MEDCNT=0 ; Med Count
    5152 ; The next line is a super line. It goes through the array return
    52  ; and if the first character is a ~, it grabs the line.
     53 ; and if the first characters are ~OP, it grabs the line.
     54 ; This means that line is for a dispensed Outpatient Med.
    5355 ; That line has the metadata about the med that I need.
    5456 ; The next lines, however many, are the med and the sig.
    5557 ; I won't be using those because I have to get the sig parsed exactly.
    56  N J S J="" F  S J=$O(MEDS1(J)) Q:J=""  I $E(MEDS1(J))="~" S MEDCNT=MEDCNT+1 S MED(MEDCNT)=MEDS1(J)
     58 N J S J="" F  S J=$O(MEDS1(J)) Q:J=""  I $E(MEDS1(J),1,3)="~OP" S MEDCNT=MEDCNT+1 S MED(MEDCNT)=MEDS1(J)
    5759 S MEDMAP=$NA(^TMP("GPLCCR",$J,"MEDMAP")) ; this is the variable map
    5860 S @MEDMAP@(0)=0 ; Initial count of meds
     
    126128 . ; -- Conc is 2 concatenated with 3
    127129 . ;
    128  . N MEDIEN S MEDIEN=$P(MED(6),U)
    129  . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
    130  . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
    131  . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
    132  . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
    133  . ; Units, concentration, etc, come from another call
    134  . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
    135  . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
    136  . ; NDF Entry IEN, and VA Product Name
    137  . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
    138  . ; Documented in the same manual.
    139  . D NDF^PSS50(MEDIEN,,,,,"CONC")
    140  . N NDFDATA M NDFDATA=^TMP($J,"CONC",MEDIEN)
    141  . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
    142  . N VAPROD S VAPROD=$P(NDFDATA(22),U)
    143  . N CONCDATA
    144  . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
    145  . ; and this will crash the call. So...
    146  . I NDFIEN="" S CONCDATA=""
    147  . E  S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
    148  . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
    149  . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
    150  . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
    151  . S @MAP@("MEDQUANTITYVALUE")=MED(7)
    152  . ; Oddly, there is no easy place to find the dispense unit.
    153  . ; It's not included in the original call, so we have to go to the drug file.
    154  . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
    155  . ; Node 14.5 is the Dispense Unit
    156  . D DATA^PSS50(MEDIEN,,,,,"QTY")
    157  . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
    158  . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
     130 . ; *** If Drug is not matched to NDF, then VA Product will be "" ***
     131 . ;
     132 . N MEDIEN S MEDIEN=$$GET1^DIQ(52,RXIEN,6,"I") ; Drug IEN in 50
     133 . N VAPROD S VAPROD=$$GET1^DIQ(50,MEDIEN,22,"I") ; VA Product in file 50.68
     134 . I +VAPROD D
     135 . . S @MAP@("MEDSTRENGTHVALUE")=$$GET1^DIQ(50.68,VAPROD,2)
     136 . . S @MAP@("MEDSTRENGTHUNIT")=$$GET1^DIQ(50.68,VAPROD,3)
     137 . . S @MAP@("MEDFORMTEXT")=$$GET1^DIQ(50.68,VAPROD,1)
     138 . . S @MAP@("MEDCONCVALUE")=@MAP@("MEDSTRENGTHVALUE")
     139 . . S @MAP@("MEDCONCUNIT")=@MAP@("MEDSTRENGTHUNIT")
     140 . E  D
     141 . . S @MAP@("MEDSTRENGTHVALUE")=""
     142 . . S @MAP@("MEDSTRENGTHUNIT")=""
     143 . . S @MAP@("MEDFORMTEXT")=""
     144 . . S @MAP@("MEDCONCVALUE")=""
     145 . . S @MAP@("MEDCONCUNIT")=""
     146 . ; End Strengh/Conc stuff
     147 . ;
     148 . ; Quantity is in the prescription, field 7
     149 . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52,RXIEN,7)
     150 . ; Dispense unit is in the drug file, field 14.5
     151 . S @MAP@("MEDQUANTITYUNIT")=$$GET1^DIQ(50,MEDIEN,14.5)
    159152 . ;
    160153 . ; --- START OF DIRECTIONS ---
    161154 . ; Sig data not in any API :-(  Oh yes, you can get the whole thing, but...
    162155 . ; we want the compoenents.
    163  . ; It's in node 6 of ^PSRX(IEN)
    164  . ; So, here we go again
    165  . ; ^PSRX(D0,6,D1,0)= (#.01) DOSAGE ORDERED [1F] ^ (#1) DISPENSE UNITS PER DOSE
    166  . ; ==>[2N] ^ (#2) UNITS [3P:50.607] ^ (#3) NOUN [4F] ^ (#4)
    167  . ; ==>DURATION [5F] ^ (#5) CONJUNCTION [6S] ^ (#6) ROUTE
    168  . ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^
    169  . ;
    170  . N DIRNUM S DIRNUM=0 ; Sigline number
    171  . S DIRCNT=0 ; COUNT OF MULTIPLE DIRECTIONS
    172  . F  S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM=""  D
    173  . . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
     156 . ; It's in multiple 113 in the Prescription File (52)
     157 . ; #.01 DOSAGE ORDERED [1F]                   "20"
     158 . ; #1 DISPENSE UNITS PER DOSE [2N]    "1"
     159 . ; #2 UNITS [3P:50.607]                               "MG"
     160 . ; #3 NOUN [4F]                                               "TABLET"
     161 . ; #4 DURATION [5F]                                   "10D"
     162 . ; #5 CONJUNCTION [6S]                                "AND"
     163 . ; #6 ROUTE [7P:51.2]                                 "ORAL"
     164 . ; #7 SCHEDULE [8F]                                   "BID"
     165 . ; #8 VERB [9F]                                               "TAKE"
     166 . ;
     167 . ; Will use GETS^DIQ to get fields.
     168 . ; Data comes out like this:
     169 . ; SAMINS(52.0113,"1,23,",.01)=20
     170 . ; SAMINS(52.0113,"1,23,",1)=1
     171 . ; SAMINS(52.0113,"1,23,",2)="MG"
     172 . ; SAMINS(52.0113,"1,23,",3)="TABLET"
     173 . ; SAMINS(52.0113,"1,23,",4)="5D"
     174 . ; SAMINS(52.0113,"1,23,",5)="THEN"
     175 . ;
     176 . N RAWDATA
     177 . D GETS^DIQ(52,RXIEN,"113*",,"RAWDATA")
     178 . N FMSIG M FMSIG=RAWDATA(52.0113) ; Merge into subfile...
     179 . K RAWDATA
     180 . N FMSIGNUM S FMSIGNUM="" ; Sigline number in fileman.
     181 . ; FMSIGNUM gets outputted as "IEN,RXIEN,".
     182 . ; DIRCNT is the proper Sigline numer.
     183 . ; SIGDATA is the simplfied array.
     184 . F  S FMSIGNUM=$O(FMSIG(FMSIGNUM)) Q:FMSIGNUM=""  D
     185 . . N DIRCNT S DIRCNT=$P(FMSIGNUM,",")
     186 . . N SIGDATA M SIGDATA=FMSIG(FMSIGNUM)
    174187 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")=""  ; This is reserved for systems not able to generate the sig in components.
    175188 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1"  ; means that we are specifying it. See E2369-05.
    176  . . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0)
    177  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9)
    178  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$P(SIGDATA,U,1)
    179  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
     189 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(8)
     190 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(.01)
     191 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=SIGDATA(2)
    180192 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")=""  ; For inpatient
    181193 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")=""  ; For inpatient
    182194 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")=""  ; For inpatient
    183  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01)
    184  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8)
     195 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=SIGDATA(6)
     196 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(7)
    185197 . . ; Invervals... again another call.
    186198 . . ; In the wisdom of the original programmers, the schedule is a free text field
     
    188200 . . ; to see if that schedule exists.
    189201 . . ; That's the same thing I am going to do.
    190  . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
    191  . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
    192  . . ; I looked), PSSFT is the name, and list is the ^TMP name to store the data in.
    193  . . ; So...
    194  . . D AP^PSS51P1("PSJ",$P(SIGDATA,U,8),,,"SCHEDULE")
    195  . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
    196  . . N INTERVAL
    197  . . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
    198  . . E  D
    199  . . . N SUB S SUB=$O(SCHEDATA(0))
    200  . . . S INTERVAL=SCHEDATA(SUB,2)
     202 . . ; Search B index of 51.1 (Admin Schedule) with first abbr of schedule
     203 . . N SCHEDIEN=$$FIND^DIC(51.1,,,$P(SIGDATA(7)," "),"B")
     204 . . N INTERVAL S INTERVAL="" ; Default
     205 . . S:SCEHDIEN INTERVAL=$$GET1^DIQ(51.1,SCHEDIEN,2)
    201206 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
    202207 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
    203  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$P(SIGDATA,U,5)
    204  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
    205  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN"
     208 . . ; Duration is 10M minutes, 10H hours, 10D for Days
     209 . . ; 10W for weeks, 10L for months. I smell $Select
     210 . . N DURUNIT S DURUNIT=$E(SIGDATA(4),$L(SIGDATA(4))) ; get last char
     211 . . N DURTXT S DURTXT=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"Days")
     212 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=+SIGDATA(4)
     213 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=DURTXT
     214 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(4)["PRN"
    206215 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
    207216 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
     
    211220 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
    212221 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
    213  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")=""
    214  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
    215  . . N DIRMOD S DIRMOD=$P(SIGDATA,U,6)
    216  . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"")
     222 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; not stored
     223 . . ; Another confusing line; I am pretty bad:
     224 . . ; If there is another entry in the FMSIG array (i.e. another line
     225 . . ; in the sig), set the direction count indicator.
     226 . . S:+$O(FMSIG(FMSIGNUM)) @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRCNT
     227 . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(5)
    217228 . ;
    218229 . ; --- END OF DIRECTIONS ---
Note: See TracChangeset for help on using the changeset viewer.