Changeset 179


Ignore:
Timestamp:
Oct 4, 2008, 5:52:28 PM (16 years ago)
Author:
Sam Habiel
Message:

Bug fixes for CCRMEDS2

File:
1 edited

Legend:

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

    r177 r179  
    1 CCRMEDS2  ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS - Pending Meds;08/24/08
    2  ;;0.1;CCDCCR;;JUL 16,2008;
    3  ; Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
    4  ; General Public License See attached copy of the License.
    5  ;
    6  ; This program is free software; you can redistribute it and/or modify
    7  ; it under the terms of the GNU General Public License as published by
    8  ; the Free Software Foundation; either version 2 of the License, or
    9  ; (at your option) any later version.
    10  ;
    11  ; This program is distributed in the hope that it will be useful,
    12  ; but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  ; GNU General Public License for more details.
    15  ;
    16  ; You should have received a copy of the GNU General Public License along
    17  ; with this program; if not, write to the Free Software Foundation, Inc.,
    18  ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    19  ;
    20  W "NO ENTRY FROM TOP",!
    21  Q
    22  ;
    23 EXTRACT(MINXML,DFN,OUTXML)      ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
    24  ;
    25  ; MINXML is the Input XML Template, passed by name
    26  ; DFN is Patient IEN
    27  ; OUTXML is the resultant XML.
    28  ;
    29  ; MEDS is return array from RPC.
    30  ; MAP is a mapping variable map (store result) for each med
    31  ; MED is holds each array element from MEDS, one medicine
    32  ;
    33  ; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending
    34  ; meds data available.
    35  ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
    36  ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
    37  ; File for pending meds is 52.41
    38  ; Unfortuantely, API does not supply us with any useful info beyond
    39  ; the IEN in 52.41, and the Med Name, and route.
    40  ; So, most of the info is going to get pulled from 52.41.
    41  N MEDS,MAP
    42  K ^TMP($J)
    43  D PEN^PSO5241(DFN,"CCDCCR")
    44  M MEDS=^TMP($J,"CCDCCR",DFN)
    45  ; @(0) contains the number of meds or -1^NO DATA FOUND
    46  ; If it is -1, we quit.
    47  I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
    48  I DEBUG ZWR MEDS
    49  N RXIEN S RXIEN=0
    50  N MEDCOUNT S MEDCOUNT=0
    51  F  S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B"  D  ; FOR EACH MEDICATION IN THE LIST
    52  . S MEDCOUNT=MEDCOUNT+1
    53  . I DEBUG W "RXIEN IS ",RXIEN,!
    54  . S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",MEDCOUNT))
    55  . K @MAP
    56  . I DEBUG W "MAP= ",MAP,!
    57  . N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
    58  . S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN
    59  . S @MAP@("MEDISSUEDATETXT")="Issue Date"
    60  . ; Field 6 is "Effective date", and we pull it in timson format w/ I
    61  . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"))
    62  . ; Med never filled; next 4 fields are not applicable.
    63  . S @MAP@("MEDLASTFILLDATETXT")=""
    64  . S @MAP@("MEDLASTFILLDATE")=""
    65  . S @MAP@("MEDRXNOTXT")=""
    66  . S @MAP@("MEDRXNO")=""
    67  . S @MAP@("MEDTYPETEXT")="Medication"
    68  . S @MAP@("MEDDETAILUNADORNED")=""  ; Leave blank, field has its uses
    69  . S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds
    70  . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I")
    71  . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2)
    72  . ; NDC not supplied in API, but is rather trivial to obtain
    73  . ; MED(11) piece 1 has the IEN of the drug (file 50)
    74  . ; IEN is field 31 in the drug file.
    75  . N MEDIEN S MEDIEN=$P(MED(11),U)
    76  . S @MAP@("MEDPRODUCTNAMECODEVALUE")=$$GET1^DIQ(50,MEDIEN,31,"E")
    77  . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC"
    78  . S @MAP@("MEDPRODUCTNAMECODEVERSION")="none"
    79  . S @MAP@("MEDBRANDNAMETEXT")=""
    80  . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
    81  . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
    82  . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
    83  . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
    84  . ; Units, concentration, etc, come from another call
    85  . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
    86  . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
    87  . ; NDF Entry IEN, and VA Product Name
    88  . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
    89  . ; Documented in the same manual.
    90  . D NDF^PSS50(MEDIEN,,,,,"CONC")
    91  . N NDFDATA M NDFDATA=^TMP($J,"CONC",MEDIEN)
    92  . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
    93  . N VAPROD S VAPROD=$P(NDFDATA(22),U)
    94  . N CONCDATA
    95  . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
    96  . ; and this will crash the call. So...
    97  . I NDFIEN="" S CONCDATA=""
    98  . E  S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
    99  . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
    100  . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
    101  . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
    102  . S @MAP@("MEDSIZETEXT")=$P(NDFDATA(23),U,2)_" "_$P(NDFDATA(24),U,2)
    103  . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12)
    104  . ; Oddly, there is no easy place to find the dispense unit.
    105  . ; It's not included in the original call, so we have to go to the drug file.
    106  . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
    107  . ; Node 14.5 is the Dispense Unit
    108  . D DATA^PSS50(MEDIEN,,,,,"QTY")
    109  . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
    110  . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
    111  . ;
    112  . ; --- START OF DIRECTIONS ---
    113  . ; Sig data is not in any API. We obtain it using the IEN from
    114  . ; the PEN API to file 52.41. It's in field 3, which is a multiple.
    115  . ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT)
    116  . D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG")
    117  . N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman.
    118  . ; FMSIGNUM gets outputted as "IEN,RXIEN,".
    119  . ; DIRNUM will be first piece for IEN.
    120  . ; DIRNUM is the proper Sigline numer.
    121  . ; SIGDATA is the simplfied array. Subscripts are really field numbers
    122  . ; in subfile 52.413.
    123  . F  S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM=""  D
    124  . . N DIRNUM S DIRNUM=$P(FMSIGNUM,",")
    125  . . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM)
    126  . . S @MAP@("M",DIRNUM,"MEDDIRECTIONDESCRIPTIONTEXT")=""  ; This is reserved for systems not able to generate the sig in components.
    127  . . S @MAP@("M",DIRNUM,"MEDDOSEINDICATOR")="1"  ; means that we are specifying it. See E2369-05.
    128  . . S @MAP@("M",DIRNUM,"MEDDELIVERYMETHOD")=SIGDATA(13)
    129  . . S @MAP@("M",DIRNUM,"MEDDOSEVALUE")=SIGDATA(8)
    130  . . S @MAP@("M",DIRNUM,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
    131  . . S @MAP@("M",DIRNUM,"MEDRATEVALUE")=""  ; For inpatient
    132  . . S @MAP@("M",DIRNUM,"MEDRATEUNIT")=""  ; For inpatient
    133  . . S @MAP@("M",DIRNUM,"MEDVEHICLETEXT")=""  ; For inpatient
    134  . . S @MAP@("M",DIRNUM,"MEDDIRECTIONROUTETEXT")=SIGDATA(10)
    135  . . S @MAP@("M",DIRNUM,"MEDFREQUENCYVALUE")=SIGDATA(1)
    136  . . ; Invervals... again another call.
    137  . . ; The schedule is a free text field
    138  . . ; However, it gets translated by a call to the administration
    139  . . ; schedule file to see if that schedule exists.
    140  . . ; That's the same thing I am going to do.
    141  . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
    142  . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
    143  . . ; I looked), PSSFT is the name,
    144  . . ; and list is the ^TMP name to store the data in.
    145  . . ; Also, freqency may have "PRN" in it, so strip that out
    146  . . N FREQ S FREQ=SIGDATA(1)
    147  . . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp
    148  . . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE")
    149  . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
    150  . . N INTERVAL
    151  . . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
    152  . . E  D
    153  . . . N SUB S SUB=$O(SCHEDATA(0))
    154  . . . S INTERVAL=SCHEDATA(SUB,2)
    155  . . S @MAP@("M",DIRNUM,"MEDINTERVALVALUE")=INTERVAL
    156  . . S @MAP@("M",DIRNUM,"MEDINTERVALUNIT")="Minute"
    157  . . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months
    158  . . N DUR S DUR=SIGDATA(2)
    159  . . S @MAP@("M",DIRNUM,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR))
    160  . . N DURUNIT S DURUNIT=$E(DUR)
    161  . . S @MAP@("M",DIRNUM,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"")
    162  . . S @MAP@("M",DIRNUM,"MEDPRNFLAG")=SIGDATA(1)["PRN"
    163  . . S @MAP@("M",DIRNUM,"MEDPROBLEMOBJECTID")=""
    164  . . S @MAP@("M",DIRNUM,"MEDPROBLEMTYPETXT")=""
    165  . . S @MAP@("M",DIRNUM,"MEDPROBLEMDESCRIPTION")=""
    166  . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODEVALUE")=""
    167  . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGSYSTEM")=""
    168  . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGVERSION")=""
    169  . . S @MAP@("M",DIRNUM,"MEDPROBLEMSOURCEACTORID")=""
    170  . . S @MAP@("M",DIRNUM,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field
    171  . . S @MAP@("M",DIRNUM,"MEDDIRSEQ")=DIRNUM
    172  . . S @MAP@("M",DIRNUM,"MEDMULDIRMOD")=SIGDATA(6)
    173  . ;
    174  . ; --- END OF DIRECTIONS ---
    175  . ;
    176  . S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
    177  . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
    178  . S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
    179  . N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED"))
    180  . K @RESULT
    181  . D MAP^GPLXPATH(MINXML,MAP,RESULT)
    182  . ; D PARY^GPLXPATH(RESULT)
    183  . D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
    184  . D:MEDCOUNT>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
    185  N MEDTMP,MEDI
    186  D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
    187  I MEDTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
    188  . W "MEDICATION MISSING ",!
    189  . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
    190  Q
    191  ;
     1CCRMEDS2         ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS - Pending Meds;08/24/08
     2        ;;0.1;CCDCCR;;JUL 16,2008;
     3        ; Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
     4        ; General Public License See attached copy of the License.
     5        ;
     6        ; This program is free software; you can redistribute it and/or modify
     7        ; it under the terms of the GNU General Public License as published by
     8        ; the Free Software Foundation; either version 2 of the License, or
     9        ; (at your option) any later version.
     10        ;
     11        ; This program is distributed in the hope that it will be useful,
     12        ; but WITHOUT ANY WARRANTY; without even the implied warranty of
     13        ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14        ; GNU General Public License for more details.
     15        ;
     16        ; You should have received a copy of the GNU General Public License along
     17        ; with this program; if not, write to the Free Software Foundation, Inc.,
     18        ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     19        ;
     20        W "NO ENTRY FROM TOP",!
     21        Q
     22        ;
     23EXTRACT(MINXML,DFN,OUTXML)           ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
     24        ;
     25        ; MINXML is the Input XML Template, passed by name
     26        ; DFN is Patient IEN
     27        ; OUTXML is the resultant XML.
     28        ;
     29        ; MEDS is return array from RPC.
     30        ; MAP is a mapping variable map (store result) for each med
     31        ; MED is holds each array element from MEDS, one medicine
     32        ;
     33        ; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending
     34        ; meds data available.
     35        ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
     36        ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
     37        ; File for pending meds is 52.41
     38        ; Unfortuantely, API does not supply us with any useful info beyond
     39        ; the IEN in 52.41, and the Med Name, and route.
     40        ; So, most of the info is going to get pulled from 52.41.
     41        N MEDS,MAP
     42        K ^TMP($J)
     43        D PEN^PSO5241(DFN,"CCDCCR")
     44        M MEDS=^TMP($J,"CCDCCR",DFN)
     45        ; @(0) contains the number of meds or -1^NO DATA FOUND
     46        ; If it is -1, we quit.
     47        I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
     48        I DEBUG ZWR MEDS
     49        N RXIEN S RXIEN=0
     50        N MEDCOUNT S MEDCOUNT=0
     51        F  S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B"  D  ; FOR EACH MEDICATION IN THE LIST
     52        . S MEDCOUNT=MEDCOUNT+1
     53        . I DEBUG W "RXIEN IS ",RXIEN,!
     54        . S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",MEDCOUNT))
     55        . K @MAP
     56        . I DEBUG W "MAP= ",MAP,!
     57        . N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
     58        . S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN
     59        . S @MAP@("MEDISSUEDATETXT")="Issue Date"
     60        . ; Field 6 is "Effective date", and we pull it in timson format w/ I
     61        . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"))
     62        . ; Med never filled; next 4 fields are not applicable.
     63        . S @MAP@("MEDLASTFILLDATETXT")=""
     64        . S @MAP@("MEDLASTFILLDATE")=""
     65        . S @MAP@("MEDRXNOTXT")=""
     66        . S @MAP@("MEDRXNO")=""
     67        . S @MAP@("MEDTYPETEXT")="Medication"
     68        . S @MAP@("MEDDETAILUNADORNED")=""  ; Leave blank, field has its uses
     69        . S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds
     70        . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I")
     71        . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2)
     72        . ; NDC not supplied in API, but is rather trivial to obtain
     73        . ; MED(11) piece 1 has the IEN of the drug (file 50)
     74        . ; IEN is field 31 in the drug file.
     75        . N MEDIEN S MEDIEN=$P(MED(11),U)
     76        . S @MAP@("MEDPRODUCTNAMECODEVALUE")=$$GET1^DIQ(50,MEDIEN,31,"E")
     77        . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC"
     78        . S @MAP@("MEDPRODUCTNAMECODEVERSION")="none"
     79        . S @MAP@("MEDBRANDNAMETEXT")=""
     80        . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
     81        . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
     82        . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
     83        . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
     84        . ; Units, concentration, etc, come from another call
     85        . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
     86        . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
     87        . ; NDF Entry IEN, and VA Product Name
     88        . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
     89        . ; Documented in the same manual.
     90        . D NDF^PSS50(MEDIEN,,,,,"CONC")
     91        . N NDFDATA M NDFDATA=^TMP($J,"CONC",MEDIEN)
     92        . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
     93        . N VAPROD S VAPROD=$P(NDFDATA(22),U)
     94        . N CONCDATA
     95        . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
     96        . ; and this will crash the call. So...
     97        . I NDFIEN="" S CONCDATA=""
     98        . E  S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
     99        . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
     100        . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
     101        . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
     102        . S @MAP@("MEDSIZETEXT")=$P(NDFDATA(23),U,2)_" "_$P(NDFDATA(24),U,2)
     103        . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12)
     104        . ; Oddly, there is no easy place to find the dispense unit.
     105        . ; It's not included in the original call, so we have to go to the drug file.
     106        . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
     107        . ; Node 14.5 is the Dispense Unit
     108        . D DATA^PSS50(MEDIEN,,,,,"QTY")
     109        . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
     110        . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
     111        . ;
     112        . ; --- START OF DIRECTIONS ---
     113        . ; Sig data is not in any API. We obtain it using the IEN from
     114        . ; the PEN API to file 52.41. It's in field 3, which is a multiple.
     115        . ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT)
     116        . K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call
     117        . D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG")
     118        . N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman.
     119        . ; FMSIGNUM gets outputted as "IEN,RXIEN,".
     120        . ; DIRNUM will be first piece for IEN.
     121        . ; DIRNUM is the proper Sigline numer.
     122        . ; SIGDATA is the simplfied array. Subscripts are really field numbers
     123        . ; in subfile 52.413.
     124        . F  S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM=""  D
     125        . . N DIRNUM S DIRNUM=$P(FMSIGNUM,",")
     126        . . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM)
     127        . . ; If this is an order for a refill; it's not really a new order; move on to next
     128        . . I SIGDATA(2)="RF" QUIT
     129        . . S @MAP@("M",DIRNUM,"MEDDIRECTIONDESCRIPTIONTEXT")=""  ; This is reserved for systems not able to generate the sig in components.
     130        . . S @MAP@("M",DIRNUM,"MEDDOSEINDICATOR")="1"  ; means that we are specifying it. See E2369-05.
     131        . . S @MAP@("M",DIRNUM,"MEDDELIVERYMETHOD")=SIGDATA(13)
     132        . . S @MAP@("M",DIRNUM,"MEDDOSEVALUE")=SIGDATA(8)
     133        . . S @MAP@("M",DIRNUM,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
     134        . . S @MAP@("M",DIRNUM,"MEDRATEVALUE")=""  ; For inpatient
     135        . . S @MAP@("M",DIRNUM,"MEDRATEUNIT")=""  ; For inpatient
     136        . . S @MAP@("M",DIRNUM,"MEDVEHICLETEXT")=""  ; For inpatient
     137        . . S @MAP@("M",DIRNUM,"MEDDIRECTIONROUTETEXT")=SIGDATA(10)
     138        . . S @MAP@("M",DIRNUM,"MEDFREQUENCYVALUE")=SIGDATA(1)
     139        . . ; Invervals... again another call.
     140        . . ; The schedule is a free text field
     141        . . ; However, it gets translated by a call to the administration
     142        . . ; schedule file to see if that schedule exists.
     143        . . ; That's the same thing I am going to do.
     144        . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
     145        . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
     146        . . ; I looked), PSSFT is the name,
     147        . . ; and list is the ^TMP name to store the data in.
     148        . . ; Also, freqency may have "PRN" in it, so strip that out
     149        . . N FREQ S FREQ=SIGDATA(1)
     150        . . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp
     151        . . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE")
     152        . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
     153        . . N INTERVAL
     154        . . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
     155        . . E  D
     156        . . . N SUB S SUB=$O(SCHEDATA(0))
     157        . . . S INTERVAL=SCHEDATA(SUB,2)
     158        . . S @MAP@("M",DIRNUM,"MEDINTERVALVALUE")=INTERVAL
     159        . . S @MAP@("M",DIRNUM,"MEDINTERVALUNIT")="Minute"
     160        . . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months
     161        . . N DUR S DUR=SIGDATA(2)
     162        . . S @MAP@("M",DIRNUM,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR))
     163        . . N DURUNIT S DURUNIT=$E(DUR)
     164        . . S @MAP@("M",DIRNUM,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"")
     165        . . S @MAP@("M",DIRNUM,"MEDPRNFLAG")=SIGDATA(1)["PRN"
     166        . . S @MAP@("M",DIRNUM,"MEDPROBLEMOBJECTID")=""
     167        . . S @MAP@("M",DIRNUM,"MEDPROBLEMTYPETXT")=""
     168        . . S @MAP@("M",DIRNUM,"MEDPROBLEMDESCRIPTION")=""
     169        . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODEVALUE")=""
     170        . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGSYSTEM")=""
     171        . . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGVERSION")=""
     172        . . S @MAP@("M",DIRNUM,"MEDPROBLEMSOURCEACTORID")=""
     173        . . S @MAP@("M",DIRNUM,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field
     174        . . S @MAP@("M",DIRNUM,"MEDDIRSEQ")=DIRNUM
     175        . . S @MAP@("M",DIRNUM,"MEDMULDIRMOD")=SIGDATA(6)
     176        . ;
     177        . ; --- END OF DIRECTIONS ---
     178        . ;
     179        . S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
     180        . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
     181        . S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
     182        . N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED"))
     183        . K @RESULT
     184        . D MAP^GPLXPATH(MINXML,MAP,RESULT)
     185        . ; D PARY^GPLXPATH(RESULT)
     186        . D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
     187        . D:MEDCOUNT>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
     188        N MEDTMP,MEDI
     189        D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
     190        I MEDTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
     191        . W "MEDICATION MISSING ",!
     192        . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
     193        Q
     194        ;
Note: See TracChangeset for help on using the changeset viewer.