Updated CCRMEDS

This commit is contained in:
sam 2008-08-29 22:11:36 +00:00
parent c1a4e7946e
commit 327153a58e
1 changed files with 137 additions and 119 deletions

View File

@ -1,119 +1,137 @@
CCRMEDS ; WV/CCDCCR/SMH,CJE,GPL - CCR/CCD PROCESSING FOR MEDICATIONS ;08/24/08 CCRMEDS ; WV/CCDCCR/SMH,CJE,GPL - CCR/CCD PROCESSING FOR MEDICATIONS ;08/24/08
;;0.1;CCDCCR;;JUL 16,2008; ;;0.1;CCDCCR;;JUL 16,2008;
; Copyright 2008 WorldVistA. Licensed under the terms of the GNU ; Copyright 2008 WorldVistA. Licensed under the terms of the GNU
; General Public License See attached copy of the License. ; General Public License See attached copy of the License.
; ;
; This program is free software; you can redistribute it and/or modify ; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by ; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or ; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. ; (at your option) any later version.
; ;
; This program is distributed in the hope that it will be useful, ; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of ; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details. ; GNU General Public License for more details.
; ;
; You should have received a copy of the GNU General Public License along ; You should have received a copy of the GNU General Public License along
; with this program; if not, write to the Free Software Foundation, Inc., ; with this program; if not, write to the Free Software Foundation, Inc.,
; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; ;
W "NO ENTRY FROM TOP",! W "NO ENTRY FROM TOP",!
Q Q
; ;
EXTRACT(INXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE EXTRACT(INXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
; ;
; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE ; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
; ;
; MEDS is return array from RPC. ; MEDS is return array from RPC.
; MAP is a mapping variable map (store result) for each med ; MAP is a mapping variable map (store result) for each med
; MED is holds each array element from MEDS(J), one medicine ; MED is holds each array element from MEDS(J), one medicine
; J is a counter. ; J is a counter.
; ;
; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all ; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all
; med data available. ; med data available.
; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS). ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
N MEDS,MAP N MEDS,MAP
K ^TMP($J) K ^TMP($J)
D RX^PSO52API(DFN,"CCDCCR") D RX^PSO52API(DFN,"CCDCCR")
M MEDS=^TMP($J,"CCDCCR",DFN) M MEDS=^TMP($J,"CCDCCR",DFN)
; @(0) contains the number of meds. ; @(0) contains the number of meds or -1^NO DATA FOUND
; If there are no meds (@(0)=0), we quit. ; If it is -1, we quit.
I 'MEDS(0) S @OUTXML@(0)=0 QUIT I $P(MEDS(0),U)=-1 S @OUTXML@(0)=0 QUIT
I DEBUG ZWR MEDS I DEBUG ZWR MEDS
N RXIEN S RXIEN=0 N RXIEN S RXIEN=0
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST
. I DEBUG W "RXIEN IS ",RXIEN,! . I DEBUG W "RXIEN IS ",RXIEN,!
. S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",J)) . S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",J))
. K @MAP . K @MAP
. I DEBUG W "MAP= ",MAP,! . I DEBUG W "MAP= ",MAP,!
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM . N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
. S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number . S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number
. S @MAP@("MEDISSUEDATETXT")="Issue Date" . S @MAP@("MEDISSUEDATETXT")="Issue Date"
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($P(MED(1),U)) . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($P(MED(1),U))
. S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date" . S @MAP@("MEDLASTFILLDATETXT")="Last Fill Date"
. S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^CCRUTIL($P(MED(101),U)) . S @MAP@("MEDLASTFILLDATE")=$$FMDTOUTC^CCRUTIL($P(MED(101),U))
. S @MAP@("MEDRXNOTXT")="Prescription Number" . S @MAP@("MEDRXNOTXT")="Prescription Number"
. S @MAP@("MEDRXNO")=MED(.01) . S @MAP@("MEDRXNO")=MED(.01)
. S @MAP@("MEDTYPETEXT")="Medication" . S @MAP@("MEDTYPETEXT")="Medication"
. S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses . S @MAP@("MEDDETAILUNADORNED")="" ; Leave blank, field has its uses
. S @MAP@("MEDSTATUSTEXT")=$P(MED(100),U,2) . S @MAP@("MEDSTATUSTEXT")=$P(MED(100),U,2)
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$P(MED(4),U) . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$P(MED(4),U)
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(6),U,2) . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(6),U,2)
. S @MAP@("MEDPRODUCTNAMECODEVALUE")=MED(27) . S @MAP@("MEDPRODUCTNAMECODEVALUE")=MED(27)
. S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC" . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC"
. S @MAP@("MEDPRODUCTNAMECODEVERSION")="none" . S @MAP@("MEDPRODUCTNAMECODEVERSION")="none"
. S @MAP@("MEDBRANDNAMETEXT")=MED(6.5) . S @MAP@("MEDBRANDNAMETEXT")=MED(6.5)
. N MEDIEN S MEDIEN=$P(MED(6),U) . N MEDIEN S MEDIEN=$P(MED(6),U)
. D DOSE^PSS50(MEDIEN,,,,,"DOSE") . D DOSE^PSS50(MEDIEN,,,,,"DOSE")
. N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN) . N DOSEDATA M DOSEDATA=^TMP($J,"DOSE",MEDIEN)
. S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901) . S @MAP@("MEDSTRENGTHVALUE")=DOSEDATA(901)
. S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2) . S @MAP@("MEDSTRENGTHUNIT")=$P(DOSEDATA(902),U,2)
. S @MAP@("MEDFORMTEXT")=$P(MED("OI"),U,4) . ; Units, concentration, etc, come from another call
. S @MAP@("MEDCONCVALUE") . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
. S @MAP@("MEDCONCUNIT") . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
. S @MAP@("MEDSIZETEXT") . ; NDF Entry IEN, and VA Product Name
. S @MAP@("MEDQUANTITYVALUE") . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
. S @MAP@("MEDQUANTITYUNIT") . ; Documented in the same manual.
. S @MAP@("MEDDIRECTIONDESCRIPTIONTEXT") . N IEN S IEN=^PSDRUG($P(MED(6),U))
. S @MAP@("MEDDOSEINDICATOR") . D NDF^PSS50(IEN,,,,,"CONC")
. S @MAP@("MEDDELIVERYMETHOD") . N NDFDATA M NDFDATA=^TMP($J,"CONC",IEN)
. S @MAP@("MEDDOSEVALUE") . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
. S @MAP@("MEDDOSEUNIT") . N VAPROD S VAPROD=$P(NDFDATA(22),U)
. S @MAP@("MEDRATEVALUE") . N CONCDATA S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
. S @MAP@("MEDRATEUNIT") . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
. S @MAP@("MEDVEHICLETEXT") . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
. S @MAP@("MEDDIRECTIONROUTETEXT") . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
. S @MAP@("MEDFREQUENCYVALUE") . S @MAP@("MEDSIZETEXT")=$P(NDFDATA(23),U,2)_" "_$P(NDFDATA(24),U,2)
. S @MAP@("MEDFREQUENCYUNIT") . S @MAP@("MEDQUANTITYVALUE")=MED(7)
. S @MAP@("MEDINTERVALVALUE") . ; Oddly, there is no easy place to find the dispense unit.
. S @MAP@("MEDINTERVALUNIT") . ; It's not included in the original call, so we have to go to the drug file.
. S @MAP@("MEDDURATIONVALUE") . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
. S @MAP@("MEDDURATIONUNIT") . ; Node 14.5 is the Dispense Unit
. S @MAP@("MEDPRNFLAG") . D DATA^PSS50(IEN,,,,,"QTY")
. S @MAP@("MEDPROBLEMOBJECTID")="" . N QTYDATA M QTYDATA=^TMP($J,"QTY",IEN)
. S @MAP@("MEDPROBLEMDESCRIPTION")="" . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
. S @MAP@("MEDPROBLEMCODEVALUE")="" . S @MAP@("MEDDIRECTIONDESCRIPTIONTEXT")=""
. S @MAP@("MEDPROBLEMCODINGSYSTEM")="" . S @MAP@("MEDDOSEINDICATOR")
. S @MAP@("MEDPROBLEMCODINGVERSION")="" . S @MAP@("MEDDELIVERYMETHOD")
. S @MAP@("MEDPROBLEMSOURCEACTORID")="" . S @MAP@("MEDDOSEVALUE")
. S @MAP@("MEDSTOPINDICATOR") . S @MAP@("MEDDOSEUNIT")
. S @MAP@("MEDDIRSEQ") . S @MAP@("MEDRATEVALUE")
. S @MAP@("MEDMULDIRMOD") . S @MAP@("MEDRATEUNIT")
. S @MAP@("MEDPTINSTRUCTIONS") . S @MAP@("MEDVEHICLETEXT")
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS") . S @MAP@("MEDDIRECTIONROUTETEXT")
. S @MAP@("MEDRFNO") . S @MAP@("MEDFREQUENCYVALUE")
. N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"RESULT",J)) . S @MAP@("MEDFREQUENCYUNIT")
. K @RESULT . S @MAP@("MEDINTERVALVALUE")
. D MAP^GPLXPATH(INXML,MAP,RESULT) . S @MAP@("MEDINTERVALUNIT")
. D:J=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy . S @MAP@("MEDDURATIONVALUE")
. D:J>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML . S @MAP@("MEDDURATIONUNIT")
N MEDTMP,MEDI . S @MAP@("MEDPRNFLAG")
D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS . S @MAP@("MEDPROBLEMOBJECTID")=""
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . S @MAP@("MEDPROBLEMDESCRIPTION")=""
. W "MEDICATION MISSING ",! . S @MAP@("MEDPROBLEMCODEVALUE")=""
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! . S @MAP@("MEDPROBLEMCODINGSYSTEM")=""
Q . S @MAP@("MEDPROBLEMCODINGVERSION")=""
; . S @MAP@("MEDPROBLEMSOURCEACTORID")=""
. S @MAP@("MEDSTOPINDICATOR")
. S @MAP@("MEDDIRSEQ")
. S @MAP@("MEDMULDIRMOD")
. S @MAP@("MEDPTINSTRUCTIONS")
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")
. S @MAP@("MEDRFNO")=MED(9)
. N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"RESULT",J))
. K @RESULT
. D MAP^GPLXPATH(INXML,MAP,RESULT)
. D:J=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
. D:J>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
N MEDTMP,MEDI
D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
. W "MEDICATION MISSING ",!
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
Q
;