med directions working

This commit is contained in:
george 2008-10-06 15:46:35 +00:00
parent 80bdc77c6c
commit 9a7a927275
3 changed files with 422 additions and 396 deletions

View File

@ -1,182 +1,182 @@
CCRMEDS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR MEDICATIONS ;07/23/08 14:33 CCRMEDS ; CCDCCR/GPL - CCR/CCD PROCESSING FOR MEDICATIONS ;07/23/08 14:33
;;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(MEDXML,DFN,MEDOUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE EXTRACT(MEDXML,DFN,MEDOUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
; ;
; MEDXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED ; MEDXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IMEDXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE ; IMEDXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
; ;
N HASOP S HASOP=0 ; FLAG FOR HAS OUTPATIENT MEDS N HASOP S HASOP=0 ; FLAG FOR HAS OUTPATIENT MEDS
N MEDCNT S MEDCNT=0 ; COUNT FOR MEDS ALREADY PROCESSED N MEDCNT S MEDCNT=0 ; COUNT FOR MEDS ALREADY PROCESSED
; OUTPATIENT ACTIVE MEDS ARE PROCESSED IN EXTRACT^CCRMEDS1 ; OUTPATIENT ACTIVE MEDS ARE PROCESSED IN EXTRACT^CCRMEDS1
; OUTPATIENT PENDING MEDS IN EXTRACT^CCRMEDS2 ; OUTPATIENT PENDING MEDS IN EXTRACT^CCRMEDS2
; NON-VA MEDS IN EXTRACT^CCRMEDS3 ; NON-VA MEDS IN EXTRACT^CCRMEDS3
; INPATIENT MEDS IN EXTRACT^CCRMEDS4 ; INPATIENT MEDS IN EXTRACT^CCRMEDS4
; ALL OTHERS HERE ; ALL OTHERS HERE
D EXTRACT^CCRMEDS1(MEDXML,DFN,MEDOUTXML) ; FIRST EXTRACT OUTPATIENT MEDS D EXTRACT^CCRMEDS1(MEDXML,DFN,MEDOUTXML) ; FIRST EXTRACT OUTPATIENT MEDS
I @MEDOUTXML@(0)>0 D ; CCRMEDS FOUND ACTIVE OP MEDS I @MEDOUTXML@(0)>0 D ; CCRMEDS FOUND ACTIVE OP MEDS
. S HASOP=1 ; SET FLAG TO KNOW HOW TO ADD XML . S HASOP=1 ; SET FLAG TO KNOW HOW TO ADD XML
. S MEDCNT=@MEDOUTXML@(0) ; SAVE COUNT TO KNOW HOW TO ADD TO MAP . S MEDCNT=@MEDOUTXML@(0) ; SAVE COUNT TO KNOW HOW TO ADD TO MAP
. W "HAS ACTIVE OP MEDS",! . W "HAS ACTIVE OP MEDS",!
N PENDINGXML,MEDPENDING N PENDINGXML,MEDPENDING
S PENDINGXML="MEDPENDING" ;NAME FOR ARRAY S PENDINGXML="MEDPENDING" ;NAME FOR ARRAY
D EXTRACT^CCRMEDS2(MEDXML,DFN,PENDINGXML) ; FIRST EXTRACT OUTPATIENT MEDS D EXTRACT^CCRMEDS2(MEDXML,DFN,PENDINGXML) ; FIRST EXTRACT OUTPATIENT MEDS
I @PENDINGXML@(0)>0 D ; CCRMEDS FOUND PENDING OP MEDS I @PENDINGXML@(0)>0 D ; CCRMEDS FOUND PENDING OP MEDS
. S HASOP=1 ; SET FLAG TO KNOW HOW TO ADD XML . S HASOP=1 ; SET FLAG TO KNOW HOW TO ADD XML
. I @MEDOUTXML@(0)>0 D ; IF WE NEED TO COMBINE MEDS . I @MEDOUTXML@(0)>0 D ; IF WE NEED TO COMBINE MEDS
. . D INSINNER^GPLXPATH(MEDOUTXML,PENDINGXML) ;ADD PENDING TO ACTIVE . . D INSINNER^GPLXPATH(MEDOUTXML,PENDINGXML) ;ADD PENDING TO ACTIVE
. E D CP^GPLXPATH(PENDINGXML,MEDOUTXML) ; NO ACTIVE MEDS, JUST COPY . E D CP^GPLXPATH(PENDINGXML,MEDOUTXML) ; NO ACTIVE MEDS, JUST COPY
. S MEDCNT=@MEDOUTXML@(0) ; SAVE COUNT TO KNOW HOW TO ADD TO MAP . S MEDCNT=@MEDOUTXML@(0) ; SAVE COUNT TO KNOW HOW TO ADD TO MAP
. W "HAS OP PENDING MEDS",! . W "HAS OP PENDING MEDS",!
N MEDRSLT,I,J,K,MEDPTMP,X,MEDVMAP,TBUF N MEDRSLT,I,J,K,MEDPTMP,X,MEDVMAP,TBUF
D ACTIVE^ORWPS(.MEDRSLT,DFN) D ACTIVE^ORWPS(.MEDRSLT,DFN)
I '$D(MEDRSLT(1)) D ; NO MEDS FOR THIS PATIENT, EXIT I '$D(MEDRSLT(1)) D ; NO MEDS FOR THIS PATIENT, EXIT
. I DEBUG W "MEDICATIONS RPC RETURNED NULL",! . I DEBUG W "MEDICATIONS RPC RETURNED NULL",!
. S @MEDOUTXML@(0)=0 . S @MEDOUTXML@(0)=0
. Q . Q
; I DEBUG ZWR MEDRSLT ; I DEBUG ZWR MEDRSLT
M GPLMEDS=MEDRSLT M GPLMEDS=MEDRSLT
S MEDTVMAP=$NA(^TMP("GPLCCR",$J,"MEDMAP")) S MEDTVMAP=$NA(^TMP("GPLCCR",$J,"MEDMAP"))
S MEDTARYTMP=$NA(^TMP("GPLCCR",$J,"MEDARYTMP")) S MEDTARYTMP=$NA(^TMP("GPLCCR",$J,"MEDARYTMP"))
I 'HASOP K @MEDTVMAP,@MEDTARYTMP I 'HASOP K @MEDTVMAP,@MEDTARYTMP
; FIRST GO THROUGH MEDRSLT ARRAY AND COUNT MEDS AND LINES IN MEDS ; FIRST GO THROUGH MEDRSLT ARRAY AND COUNT MEDS AND LINES IN MEDS
; ZA(0) IS TOTAL NUMBER OF MEDS ZA(ZI) IS LINES IN MED ZI ; ZA(0) IS TOTAL NUMBER OF MEDS ZA(ZI) IS LINES IN MED ZI
N ZA,ZI,ZJ,ZK,ZN S (ZI,ZJ,ZK,ZN)=0 ; ZI IS MED NUMBER, ZJ IS LINE IN MED N ZA,ZI,ZJ,ZK,ZN S (ZI,ZJ,ZK,ZN)=0 ; ZI IS MED NUMBER, ZJ IS LINE IN MED
; ZK IS THE NUMBER OF LINES IN A MED AND ZN IS COUNTER THROUGH LINES ; ZK IS THE NUMBER OF LINES IN A MED AND ZN IS COUNTER THROUGH LINES
S ZA(0)=0 ; ZA IS ARRAY OF MED LINE COUNTS S ZA(0)=0 ; ZA IS ARRAY OF MED LINE COUNTS
F ZJ=1:1 Q:'$D(MEDRSLT(ZJ)) D ; COUNT THE MEDS AND LINES F ZJ=1:1 Q:'$D(MEDRSLT(ZJ)) D ; COUNT THE MEDS AND LINES
. I MEDRSLT(ZJ)?1"~".E D ; FOUND NEW MED . I MEDRSLT(ZJ)?1"~".E D ; FOUND NEW MED
. . S ZI=ZI+1 ; INCREMENT MED COUNT . . S ZI=ZI+1 ; INCREMENT MED COUNT
. . S ZA(0)=ZI ; NEW TOTAL FOR MEDS . . S ZA(0)=ZI ; NEW TOTAL FOR MEDS
. . S ZA(ZI)=ZJ_U_1 ; EACH ZA(X) IS Y^Z WHERE Y IS START LINE AND Z IS COUNT . . S ZA(ZI)=ZJ_U_1 ; EACH ZA(X) IS Y^Z WHERE Y IS START LINE AND Z IS COUNT
. E D ; FOR EVERY LINE NOT A FIRST LINE IN MED . E D ; FOR EVERY LINE NOT A FIRST LINE IN MED
. . S ZK=$P(ZA(ZI),U,2)+1 ; INCREMENT LINE COUNT FOR CURRENT MED . . S ZK=$P(ZA(ZI),U,2)+1 ; INCREMENT LINE COUNT FOR CURRENT MED
. . S $P(ZA(ZI),U,2)=ZK ; AND STORE IT IN ARRAY . . S $P(ZA(ZI),U,2)=ZK ; AND STORE IT IN ARRAY
;ZWR ZA ;ZWR ZA
S @MEDTVMAP@(0)=ZA(0) ; SAVE NUMBER OF MEDS S @MEDTVMAP@(0)=ZA(0) ; SAVE NUMBER OF MEDS
F ZI=1:1:ZA(0) D ; FOR EACH MED F ZI=1:1:ZA(0) D ; FOR EACH MED
. I DEBUG W "ZI IS ",ZI,! . I DEBUG W "ZI IS ",ZI,!
. S MEDVMAP=$NA(@MEDTVMAP@(ZI+MEDCNT)) ; START PAST OP ACTIVE MEDS . S MEDVMAP=$NA(@MEDTVMAP@(ZI+MEDCNT)) ; START PAST OP ACTIVE MEDS
. K @MEDVMAP . K @MEDVMAP
. I DEBUG W "VMAP= ",MEDVMAP,! . I DEBUG W "VMAP= ",MEDVMAP,!
. S ZJ=$P(ZA(ZI),U,1) ; INDEX OF FIRST LINE OF MED IN MEDRSLT . S ZJ=$P(ZA(ZI),U,1) ; INDEX OF FIRST LINE OF MED IN MEDRSLT
. S MEDPTMP=MEDRSLT(ZJ) ; PULL OUT FIRST LINE OF MED . S MEDPTMP=MEDRSLT(ZJ) ; PULL OUT FIRST LINE OF MED
. I $P(MEDPTMP,U,1)?1"~OP" Q ; SKIP OP ACTIVE AND PENDING . I $P(MEDPTMP,U,1)?1"~OP" Q ; SKIP OP ACTIVE AND PENDING
. S @MEDVMAP@("MEDOBJECTID")="MED"_(ZI+MEDCNT) ; UNIQUE OBJID FOR MEDS . S @MEDVMAP@("MEDOBJECTID")="MED"_(ZI+MEDCNT) ; UNIQUE OBJID FOR MEDS
. I $P(MEDPTMP,"^",11)="" S @MEDVMAP@("MEDISSUEDATETXT")="" . I $P(MEDPTMP,"^",11)="" S @MEDVMAP@("MEDISSUEDATETXT")=""
. E S @MEDVMAP@("MEDISSUEDATETXT")=$$FMDTOUTC^CCRUTIL($P(MEDPTMP,"^",11),"DT") ; GETS LAST FILL DATE . E S @MEDVMAP@("MEDISSUEDATETXT")=$$FMDTOUTC^CCRUTIL($P(MEDPTMP,"^",11),"DT") ; GETS LAST FILL DATE
. S @MEDVMAP@("MEDISSUEDATE")="" . S @MEDVMAP@("MEDISSUEDATE")=""
. S @MEDVMAP@("MEDLASTFILLDATETXT")="" . S @MEDVMAP@("MEDLASTFILLDATETXT")=""
. S @MEDVMAP@("MEDLASTFILLDATE")="" . S @MEDVMAP@("MEDLASTFILLDATE")=""
. S @MEDVMAP@("MEDRXNOTXT")="" . S @MEDVMAP@("MEDRXNOTXT")=""
. S @MEDVMAP@("MEDRXNO")="" . S @MEDVMAP@("MEDRXNO")=""
. S @MEDVMAP@("MEDDETAILUNADORNED")="" . S @MEDVMAP@("MEDDETAILUNADORNED")=""
. S @MEDVMAP@("MEDCONCVALUE")="" . S @MEDVMAP@("MEDCONCVALUE")=""
. S @MEDVMAP@("MEDCONCUNIT")="" . S @MEDVMAP@("MEDCONCUNIT")=""
. S @MEDVMAP@("MEDSIZETEXT")="" . S @MEDVMAP@("MEDSIZETEXT")=""
. S @MEDVMAP@("MEDDOSEINDICATOR")="" . S @MEDVMAP@("MEDDOSEINDICATOR")=""
. S @MEDVMAP@("MEDDELIVERYMETHOD")="" . S @MEDVMAP@("MEDDELIVERYMETHOD")=""
. S @MEDVMAP@("MEDRATEVALUE")="" . S @MEDVMAP@("MEDRATEVALUE")=""
. S @MEDVMAP@("MEDRATEUNIT")="" . S @MEDVMAP@("MEDRATEUNIT")=""
. S @MEDVMAP@("MEDVEHICLETEXT")="" . S @MEDVMAP@("MEDVEHICLETEXT")=""
. S @MEDVMAP@("MEDFREQUENCYUNIT")="" . S @MEDVMAP@("MEDFREQUENCYUNIT")=""
. S @MEDVMAP@("MEDINTERVALVALUE")="" . S @MEDVMAP@("MEDINTERVALVALUE")=""
. S @MEDVMAP@("MEDINTERVALUNIT")="" . S @MEDVMAP@("MEDINTERVALUNIT")=""
. S @MEDVMAP@("MEDPRNFLAG")="" . S @MEDVMAP@("MEDPRNFLAG")=""
. S @MEDVMAP@("MEDPROBLEMOBJECTID")="" . S @MEDVMAP@("MEDPROBLEMOBJECTID")=""
. S @MEDVMAP@("MEDPROBLEMTYPETXT")="" . S @MEDVMAP@("MEDPROBLEMTYPETXT")=""
. S @MEDVMAP@("MEDPROBLEMDESCRIPTION")="" . S @MEDVMAP@("MEDPROBLEMDESCRIPTION")=""
. S @MEDVMAP@("MEDPROBLEMCODEVALUE")="" . S @MEDVMAP@("MEDPROBLEMCODEVALUE")=""
. S @MEDVMAP@("MEDPROBLEMCODINGSYSTEM")="" . S @MEDVMAP@("MEDPROBLEMCODINGSYSTEM")=""
. S @MEDVMAP@("MEDPROBLEMCODINGVERSION")="" . S @MEDVMAP@("MEDPROBLEMCODINGVERSION")=""
. S @MEDVMAP@("MEDPROBLEMSOURCEACTORID")="" . S @MEDVMAP@("MEDPROBLEMSOURCEACTORID")=""
. S @MEDVMAP@("MEDSTOPINDICATOR")="" . S @MEDVMAP@("MEDSTOPINDICATOR")=""
. S @MEDVMAP@("MEDDIRSEQ")="" . S @MEDVMAP@("MEDDIRSEQ")=""
. S @MEDVMAP@("MEDMULDIRMOD")="" . S @MEDVMAP@("MEDMULDIRMOD")=""
. S @MEDVMAP@("MEDPTINSTRUCTIONS")="" . S @MEDVMAP@("MEDPTINSTRUCTIONS")=""
. S @MEDVMAP@("MEDFULLFILLMENTINSTRUCTIONS")="" . S @MEDVMAP@("MEDFULLFILLMENTINSTRUCTIONS")=""
. S @MEDVMAP@("MEDDATETIMEAGE")="" . S @MEDVMAP@("MEDDATETIMEAGE")=""
. S @MEDVMAP@("MEDDATETIMEAGEUNITS")="" . S @MEDVMAP@("MEDDATETIMEAGEUNITS")=""
. S @MEDVMAP@("MEDTYPETEXT")="Medication" . S @MEDVMAP@("MEDTYPETEXT")="Medication"
. S @MEDVMAP@("MEDSTATUSTEXT")=$P(MEDPTMP,"^",10) ; STATUS FROM RPC . S @MEDVMAP@("MEDSTATUSTEXT")=$P(MEDPTMP,"^",10) ; STATUS FROM RPC
. S @MEDVMAP@("MEDSOURCEACTORID")="ACTORSYSTEM_1" . S @MEDVMAP@("MEDSOURCEACTORID")="ACTORSYSTEM_1"
. S @MEDVMAP@("MEDPRODUCTNAMETEXT")=$P(MEDPTMP,"^",3) . S @MEDVMAP@("MEDPRODUCTNAMETEXT")=$P(MEDPTMP,"^",3)
. S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")="" ; DEFAULT VALUE . S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")="" ; DEFAULT VALUE
. S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="" . S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=""
. S @MEDVMAP@("MEDPRODUCTNAMECODEVERSION")="" . S @MEDVMAP@("MEDPRODUCTNAMECODEVERSION")=""
. I $P(MEDPTMP,U,1)?1"~OP" D ; IS OUTPATIENT, MIGHT HAVE CODE . I $P(MEDPTMP,U,1)?1"~OP" D ; IS OUTPATIENT, MIGHT HAVE CODE
. . I $P(MEDPTMP,"^",10)="ACTIVE" D ; ONLY ACTIVE MEDS HAVE CODES . . I $P(MEDPTMP,"^",10)="ACTIVE" D ; ONLY ACTIVE MEDS HAVE CODES
. . . N RXIEN ; IEN TO RX, EXAMPLE "~OP^13R;O^IBUPROFEN 400MG^" 13 IS IT . . . N RXIEN ; IEN TO RX, EXAMPLE "~OP^13R;O^IBUPROFEN 400MG^" 13 IS IT
. . . S RXIEN=$$DIGITS($P($P(MEDPTMP,U,2),";",1)) ; GET JUST LEADING DIGITS . . . S RXIEN=$$DIGITS($P($P(MEDPTMP,U,2),";",1)) ; GET JUST LEADING DIGITS
. . . I DEBUG W "RXIEN=",RXIEN,! ; . . . I DEBUG W "RXIEN=",RXIEN,! ;
. . . D RX^PSO52API(DFN,"MEDCODE",RXIEN) ; EXTRACT THE RX RECORD TO ^TMP . . . D RX^PSO52API(DFN,"MEDCODE",RXIEN) ; EXTRACT THE RX RECORD TO ^TMP
. . . I $D(^TMP($J,"MEDCODE",DFN,RXIEN,27)) D ; IF SUCCESS . . . I $D(^TMP($J,"MEDCODE",DFN,RXIEN,27)) D ; IF SUCCESS
. . . . S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")=^TMP($J,"MEDCODE",DFN,RXIEN,27) . . . . S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")=^TMP($J,"MEDCODE",DFN,RXIEN,27)
. . . . S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC" . . . . S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC"
. S @MEDVMAP@("MEDBRANDNAMETEXT")="" . S @MEDVMAP@("MEDBRANDNAMETEXT")=""
. S @MEDVMAP@("MEDBRANDNAMECODEVALUE")="" . S @MEDVMAP@("MEDBRANDNAMECODEVALUE")=""
. S @MEDVMAP@("MEDBRANDNAMECODINGSYSTEM")="" . S @MEDVMAP@("MEDBRANDNAMECODINGSYSTEM")=""
. S @MEDVMAP@("MEDBRANDNAMECODEVERSION")="" . S @MEDVMAP@("MEDBRANDNAMECODEVERSION")=""
. S @MEDVMAP@("MEDSTRENGTHVALUE")="" . S @MEDVMAP@("MEDSTRENGTHVALUE")=""
. S @MEDVMAP@("MEDSTRENGTHUNIT")="" . S @MEDVMAP@("MEDSTRENGTHUNIT")=""
. S @MEDVMAP@("MEDFORMTEXT")="" . S @MEDVMAP@("MEDFORMTEXT")=""
. S @MEDVMAP@("MEDQUANTITYVALUE")="" . S @MEDVMAP@("MEDQUANTITYVALUE")=""
. S @MEDVMAP@("MEDQUANTITYUNIT")="" . S @MEDVMAP@("MEDQUANTITYUNIT")=""
. S @MEDVMAP@("MEDRFNO")="" . S @MEDVMAP@("MEDRFNO")=""
. S ZK=$P(ZA(ZI),U,2) ; NUMBER OF LINES IN MED . S ZK=$P(ZA(ZI),U,2) ; NUMBER OF LINES IN MED
. I ZK>1 D ; MORE THAN ONE LINE IN MED . I ZK>1 D ; MORE THAN ONE LINE IN MED
. . S @MEDVMAP@("MEDDESCRIPTIONTEXT")=$P(MEDRSLT(ZJ+1)," *",2) . . S @MEDVMAP@("MEDDESCRIPTIONTEXT")=$P(MEDRSLT(ZJ+1)," *",2)
. I ZK>2 D ; THIRD THROUGH 2+N LINES OF MED ARE INSTRUCTIONS . I ZK>2 D ; THIRD THROUGH 2+N LINES OF MED ARE INSTRUCTIONS
. . N TMPTXT S TMPTXT="" ; BUILD UP INSTRUCTION LINE . . N TMPTXT S TMPTXT="" ; BUILD UP INSTRUCTION LINE
. . F ZN=2:1:ZK-1 D ; REMAINING LINES IN EACH MED . . F ZN=2:1:ZK-1 D ; REMAINING LINES IN EACH MED
. . . I MEDRSLT(ZJ+ZN)]"\ Sig: " D ; REMOVE THIS MARKUP . . . I MEDRSLT(ZJ+ZN)]"\ Sig: " D ; REMOVE THIS MARKUP
. . . . S TMPTXT=TMPTXT_$P(MEDRSLT(ZJ+ZN),"\ Sig: ",2)_" " ; APPEND 2 TMPTXT . . . . S TMPTXT=TMPTXT_$P(MEDRSLT(ZJ+ZN),"\ Sig: ",2)_" " ; APPEND 2 TMPTXT
. . . E S TMPTXT=TMPTXT_MEDRSLT(ZJ+ZN)_" " ; SEPARATE LINES WITH SPACE . . . E S TMPTXT=TMPTXT_MEDRSLT(ZJ+ZN)_" " ; SEPARATE LINES WITH SPACE
. . S @MEDVMAP@("MEDDIRECTIONDESCRIPTIONTEXT")=TMPTXT ; CP TO MAP VAR . . S @MEDVMAP@("MEDDIRECTIONDESCRIPTIONTEXT")=TMPTXT ; CP TO MAP VAR
. S @MEDVMAP@("MEDDOSEVALUE")="" . S @MEDVMAP@("MEDDOSEVALUE")=""
. S @MEDVMAP@("MEDDOSEUNIT")="" . S @MEDVMAP@("MEDDOSEUNIT")=""
. S @MEDVMAP@("MEDFREQUENCYVALUE")="" . S @MEDVMAP@("MEDFREQUENCYVALUE")=""
. S @MEDVMAP@("MEDDURATIONVALUE")="" . S @MEDVMAP@("MEDDURATIONVALUE")=""
. S @MEDVMAP@("MEDDURATIONUNIT")="" . S @MEDVMAP@("MEDDURATIONUNIT")=""
. S @MEDVMAP@("MEDDIRECTIONROUTETEXT")="" . S @MEDVMAP@("MEDDIRECTIONROUTETEXT")=""
. S @MEDVMAP@("MEDDIRECTIONFREQUENCYVALUE")="" . S @MEDVMAP@("MEDDIRECTIONFREQUENCYVALUE")=""
. S MEDARYTMP=$NA(@MEDTARYTMP@(ZI)) . S MEDARYTMP=$NA(@MEDTARYTMP@(ZI))
. K @MEDARYTMP . K @MEDARYTMP
. D MAP^GPLXPATH(MEDXML,MEDVMAP,MEDARYTMP) . D MAP^GPLXPATH(MEDXML,MEDVMAP,MEDARYTMP)
. I ZI=1&('HASOP) D ; FIRST ONE IS JUST A COPY MAKE SURE OP IS NOT THERE . I ZI=1&('HASOP) D ; FIRST ONE IS JUST A COPY MAKE SURE OP IS NOT THERE
. . ; W "FIRST ONE",! . . ; W "FIRST ONE",!
. . D CP^GPLXPATH(MEDARYTMP,MEDOUTXML) . . D CP^GPLXPATH(MEDARYTMP,MEDOUTXML)
. E D ; AFTER THE FIRST OR IF THERE ARE OP, INSERT INNER XML . E D ; AFTER THE FIRST OR IF THERE ARE OP, INSERT INNER XML
. . D INSINNER^GPLXPATH(MEDOUTXML,MEDARYTMP) . . D INSINNER^GPLXPATH(MEDOUTXML,MEDARYTMP)
N MEDTMP,MEDI N MEDTMP,MEDI
D MISSING^GPLXPATH(MEDOUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS D MISSING^GPLXPATH(MEDOUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
. W "MEDICATION MISSING ",! . W "MEDICATION MISSING ",!
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
Q Q
; ;
DIGITS(INSTR) ; RETURN JUST THE LEADING DIGITS OF THE STRING DIGITS(INSTR) ; RETURN JUST THE LEADING DIGITS OF THE STRING
; EXAMPLE: $$DIGITS("13R") RETURNS 13 ; EXAMPLE: $$DIGITS("13R") RETURNS 13
N ALPHA ; CONTANT TO HOLD ALL ALPHA CHARACTERS N ALPHA ; CONTANT TO HOLD ALL ALPHA CHARACTERS
S ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; ALPHAS S ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ; ALPHAS
Q $TR(INSTR,ALPHA) ; LEAVE ONLY THE DIGITS Q $TR(INSTR,ALPHA) ; LEAVE ONLY THE DIGITS
; ;

View File

@ -112,18 +112,20 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
. ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^ . ; ==>[7P:51.2] ^ (#7) SCHEDULE [8F] ^ (#8) VERB [9F] ^
. ; . ;
. N DIRNUM S DIRNUM=0 ; Sigline number . N DIRNUM S DIRNUM=0 ; Sigline number
. S DIRCNT=0 ; COUNT OF MULTIPLE DIRECTIONS
. F S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM="" D . F S DIRNUM=$O(^PSRX(RXIEN,6,DIRNUM)) Q:DIRNUM="" D
. . S @MAP@("M",DIRNUM,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. . . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
. . S @MAP@("M",DIRNUM,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. . . 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.
. . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0) . . N SIGDATA S SIGDATA=^PSRX(RXIEN,6,DIRNUM,0)
. . S @MAP@("M",DIRNUM,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=$P(SIGDATA,U,9)
. . S @MAP@("M",DIRNUM,"MEDDOSEVALUE")=$P(SIGDATA,U,1) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=$P(SIGDATA,U,1)
. . S @MAP@("M",DIRNUM,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT") . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
. . S @MAP@("M",DIRNUM,"MEDRATEVALUE")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
. . S @MAP@("M",DIRNUM,"MEDRATEUNIT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
. . S @MAP@("M",DIRNUM,"MEDVEHICLETEXT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
. . S @MAP@("M",DIRNUM,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=$$GET1^DIQ(51.2,$P(SIGDATA,U,7),.01)
. . S @MAP@("M",DIRNUM,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=$P(SIGDATA,U,8)
. . ; Invervals... again another call. . . ; Invervals... again another call.
. . ; In the wisdom of the original programmers, the schedule is a free text field . . ; 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 . . ; However, it gets translated by a call to the administration schedule file
@ -140,22 +142,22 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
. . E D . . E D
. . . N SUB S SUB=$O(SCHEDATA(0)) . . . N SUB S SUB=$O(SCHEDATA(0))
. . . S INTERVAL=SCHEDATA(SUB,2) . . . S INTERVAL=SCHEDATA(SUB,2)
. . S @MAP@("M",DIRNUM,"MEDINTERVALVALUE")=INTERVAL . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
. . S @MAP@("M",DIRNUM,"MEDINTERVALUNIT")="Minute" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
. . S @MAP@("M",DIRNUM,"MEDDURATIONVALUE")=$P(SIGDATA,U,5) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$P(SIGDATA,U,5)
. . S @MAP@("M",DIRNUM,"MEDDURATIONUNIT")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=""
. . S @MAP@("M",DIRNUM,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=$P(SIGDATA,U,8)["PRN"
. . S @MAP@("M",DIRNUM,"MEDPROBLEMOBJECTID")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMTYPETXT")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMDESCRIPTION")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODEVALUE")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGSYSTEM")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGVERSION")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMSOURCEACTORID")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
. . S @MAP@("M",DIRNUM,"MEDSTOPINDICATOR")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")=""
. . S @MAP@("M",DIRNUM,"MEDDIRSEQ")=DIRNUM . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
. . N DIRMOD S DIRMOD=$P(SIGDATA,U,6) . . N DIRMOD S DIRMOD=$P(SIGDATA,U,6)
. . S @MAP@("M",DIRNUM,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"") . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=$S(DIRMOD="T":"THEN",DIRMOD="A":"AND",DIRMOD="X":"EXCEPT",1:"")
. ; . ;
. ; --- END OF DIRECTIONS --- . ; --- END OF DIRECTIONS ---
. ; . ;
@ -168,6 +170,17 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
. K @RESULT . K @RESULT
. D MAP^GPLXPATH(MINXML,MAP,RESULT) . D MAP^GPLXPATH(MINXML,MAP,RESULT)
. ; D PARY^GPLXPATH(RESULT) . ; D PARY^GPLXPATH(RESULT)
. ; MAPPING DIRECTIONS
. N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
. N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
. D QUERY^GPLXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
. D REPLACE^GPLXPATH(RESULT,"","//Medications/Medication/Directions")
. ; N MDZ1,MDZNA
. I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
. . . D MAP^GPLXPATH(DIRXML1,MDZNA,DIRXML2)
. . . D INSINNER^GPLXPATH(RESULT,DIRXML2)
. D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy . D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
. D:MEDCOUNT>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML . D:MEDCOUNT>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
N MEDTMP,MEDI N MEDTMP,MEDI

View File

@ -1,194 +1,207 @@
CCRMEDS2 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS - Pending Meds;08/24/08 CCRMEDS2 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS - Pending Meds;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(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
; ;
; MINXML is the Input XML Template, passed by name ; MINXML is the Input XML Template, passed by name
; DFN is Patient IEN ; DFN is Patient IEN
; OUTXML is the resultant XML. ; OUTXML is the resultant XML.
; ;
; 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, one medicine ; MED is holds each array element from MEDS, one medicine
; ;
; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending ; PEN^PSO5241 is a Pharmacy Re-Enginnering (PRE) API to get Pending
; meds data available. ; meds 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).
; File for pending meds is 52.41 ; File for pending meds is 52.41
; Unfortuantely, API does not supply us with any useful info beyond ; Unfortuantely, API does not supply us with any useful info beyond
; the IEN in 52.41, and the Med Name, and route. ; the IEN in 52.41, and the Med Name, and route.
; So, most of the info is going to get pulled from 52.41. ; So, most of the info is going to get pulled from 52.41.
N MEDS,MAP N MEDS,MAP
K ^TMP($J) K ^TMP($J)
D PEN^PSO5241(DFN,"CCDCCR") D PEN^PSO5241(DFN,"CCDCCR")
M MEDS=^TMP($J,"CCDCCR",DFN) M MEDS=^TMP($J,"CCDCCR",DFN)
; @(0) contains the number of meds or -1^NO DATA FOUND ; @(0) contains the number of meds or -1^NO DATA FOUND
; If it is -1, we quit. ; If it is -1, we quit.
I $P(MEDS(0),U)=-1 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
N MEDCOUNT S MEDCOUNT=0 N MEDCOUNT S MEDCOUNT=0
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B" D ; FOR EACH MEDICATION IN THE LIST F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="B" D ; FOR EACH MEDICATION IN THE LIST
. I $$GET1^DIQ(52.41,RXIEN,2,"I")="RF" QUIT ; Dont' want refill request as a "pending" order . I $$GET1^DIQ(52.41,RXIEN,2,"I")="RF" QUIT ; Dont' want refill request as a "pending" order
. S MEDCOUNT=MEDCOUNT+1 . S MEDCOUNT=MEDCOUNT+1
. I DEBUG W "RXIEN IS ",RXIEN,! . I DEBUG W "RXIEN IS ",RXIEN,!
. S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",MEDCOUNT)) . S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",MEDCOUNT))
. 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_PENDING"_MED(.01) ;Pending IEN . S @MAP@("MEDOBJECTID")="MED_PENDING"_MED(.01) ;Pending IEN
. S @MAP@("MEDISSUEDATETXT")="Issue Date" . S @MAP@("MEDISSUEDATETXT")="Issue Date"
. ; Field 6 is "Effective date", and we pull it in timson format w/ I . ; Field 6 is "Effective date", and we pull it in timson format w/ I
. S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($$GET1^DIQ(52.41,RXIEN,6,"I")) . S @MAP@("MEDISSUEDATE")=$$FMDTOUTC^CCRUTIL($$GET1^DIQ(52.41,RXIEN,6,"I"))
. ; Med never filled; next 4 fields are not applicable. . ; Med never filled; next 4 fields are not applicable.
. S @MAP@("MEDLASTFILLDATETXT")="" . S @MAP@("MEDLASTFILLDATETXT")=""
. S @MAP@("MEDLASTFILLDATE")="" . S @MAP@("MEDLASTFILLDATE")=""
. S @MAP@("MEDRXNOTXT")="" . S @MAP@("MEDRXNOTXT")=""
. S @MAP@("MEDRXNO")="" . S @MAP@("MEDRXNO")=""
. 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")="On Hold" ; nearest status for pending meds . S @MAP@("MEDSTATUSTEXT")="On Hold" ; nearest status for pending meds
. S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I") . S @MAP@("MEDSOURCEACTORID")="ACTORPROVIDER_"_$$GET1^DIQ(52.41,RXIEN,5,"I")
. S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2) . S @MAP@("MEDPRODUCTNAMETEXT")=$P(MED(11),U,2)
. ; NDC not supplied in API, but is rather trivial to obtain . ; NDC not supplied in API, but is rather trivial to obtain
. ; MED(11) piece 1 has the IEN of the drug (file 50) . ; MED(11) piece 1 has the IEN of the drug (file 50)
. ; IEN is field 31 in the drug file. . ; IEN is field 31 in the drug file.
. N MEDIEN S MEDIEN=$P(MED(11),U) . N MEDIEN S MEDIEN=$P(MED(11),U)
. S @MAP@("MEDPRODUCTNAMECODEVALUE")=$$GET1^DIQ(50,MEDIEN,31,"E") . S @MAP@("MEDPRODUCTNAMECODEVALUE")=$$GET1^DIQ(50,MEDIEN,31,"E")
. S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC" . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")="NDC"
. S @MAP@("MEDPRODUCTNAMECODEVERSION")="none" . S @MAP@("MEDPRODUCTNAMECODEVERSION")="none"
. S @MAP@("MEDBRANDNAMETEXT")="" . S @MAP@("MEDBRANDNAMETEXT")=""
. 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)
. ; Units, concentration, etc, come from another call . ; Units, concentration, etc, come from another call
. ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit . ; $$CPRS^PSNAPIS which returns dosage-form^va class^strengh^unit
. ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters . ; This call takes nodes 1 and 3 of ^PSDRUG(D0,"ND") as parameters
. ; NDF Entry IEN, and VA Product Name . ; NDF Entry IEN, and VA Product Name
. ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT") . ; These can be obtained using NDF^PSS50 (IEN,,,,,"SUBSCRIPT")
. ; Documented in the same manual. . ; Documented in the same manual.
. D NDF^PSS50(MEDIEN,,,,,"CONC") . D NDF^PSS50(MEDIEN,,,,,"CONC")
. N NDFDATA M NDFDATA=^TMP($J,"CONC",MEDIEN) . N NDFDATA M NDFDATA=^TMP($J,"CONC",MEDIEN)
. N NDFIEN S NDFIEN=$P(NDFDATA(20),U) . N NDFIEN S NDFIEN=$P(NDFDATA(20),U)
. N VAPROD S VAPROD=$P(NDFDATA(22),U) . N VAPROD S VAPROD=$P(NDFDATA(22),U)
. N CONCDATA . N CONCDATA
. ; If a drug was not matched to NDF, then the NDFIEN is gonna be "" . ; If a drug was not matched to NDF, then the NDFIEN is gonna be ""
. ; and this will crash the call. So... . ; and this will crash the call. So...
. I NDFIEN="" S CONCDATA="" . I NDFIEN="" S CONCDATA=""
. E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD) . E S CONCDATA=$$CPRS^PSNAPIS(NDFIEN,VAPROD)
. S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1) . S @MAP@("MEDFORMTEXT")=$P(CONCDATA,U,1)
. S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3) . S @MAP@("MEDCONCVALUE")=$P(CONCDATA,U,3)
. S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4) . S @MAP@("MEDCONCUNIT")=$P(CONCDATA,U,4)
. S @MAP@("MEDSIZETEXT")=$P(NDFDATA(23),U,2)_" "_$P(NDFDATA(24),U,2) . S @MAP@("MEDSIZETEXT")=$P(NDFDATA(23),U,2)_" "_$P(NDFDATA(24),U,2)
. S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12) . S @MAP@("MEDQUANTITYVALUE")=$$GET1^DIQ(52.41,RXIEN,12)
. ; Oddly, there is no easy place to find the dispense unit. . ; Oddly, there is no easy place to find the dispense unit.
. ; It's not included in the original call, so we have to go to the drug file. . ; It's not included in the original call, so we have to go to the drug file.
. ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT") . ; That would be DATA^PSS50(IEN,,,,,"SUBSCRIPT")
. ; Node 14.5 is the Dispense Unit . ; Node 14.5 is the Dispense Unit
. D DATA^PSS50(MEDIEN,,,,,"QTY") . D DATA^PSS50(MEDIEN,,,,,"QTY")
. N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN) . N QTYDATA M QTYDATA=^TMP($J,"QTY",MEDIEN)
. S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5) . S @MAP@("MEDQUANTITYUNIT")=QTYDATA(14.5)
. ; . ;
. ; --- START OF DIRECTIONS --- . ; --- START OF DIRECTIONS ---
. ; Sig data is not in any API. We obtain it using the IEN from . ; Sig data is not in any API. We obtain it using the IEN from
. ; the PEN API to file 52.41. It's in field 3, which is a multiple. . ; the PEN API to file 52.41. It's in field 3, which is a multiple.
. ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT) . ; I will be using FM call GETS^DIQ(FILE,IENS,FIELD,FLAGS,TARGET_ROOT)
. K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call . K FMSIG ; it's passed via the symbol table, so remove any leftovers from last call
. D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG") . D GETS^DIQ(52.41,RXIEN,"3*",,"FMSIG")
. N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman. . N FMSIGNUM S FMSIGNUM=0 ; Sigline number in fileman.
. ; FMSIGNUM gets outputted as "IEN,RXIEN,". . ; FMSIGNUM gets outputted as "IEN,RXIEN,".
. ; DIRNUM will be first piece for IEN. . ; DIRNUM will be first piece for IEN.
. ; DIRNUM is the proper Sigline numer. . ; DIRNUM is the proper Sigline numer.
. ; SIGDATA is the simplfied array. Subscripts are really field numbers . ; SIGDATA is the simplfied array. Subscripts are really field numbers
. ; in subfile 52.413. . ; in subfile 52.413.
. F S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM="" D . N DIRCNT S DIRCNT=0 ; COUNT OF DIRECTIONS
. . N DIRNUM S DIRNUM=$P(FMSIGNUM,",") . F S FMSIGNUM=$O(FMSIG(52.413,FMSIGNUM)) Q:FMSIGNUM="" D
. . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM) . . N DIRNUM S DIRNUM=$P(FMSIGNUM,",")
. . ; If this is an order for a refill; it's not really a new order; move on to next . . S DIRCNT=DIRCNT+1 ; INCREMENT DIRECTIONS COUNT
. . S @MAP@("M",DIRNUM,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components. . . N SIGDATA M SIGDATA=FMSIG(52.413,FMSIGNUM)
. . S @MAP@("M",DIRNUM,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05. . . ; If this is an order for a refill; it's not really a new order; move on to next
. . S @MAP@("M",DIRNUM,"MEDDELIVERYMETHOD")=SIGDATA(13) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONDESCRIPTIONTEXT")="" ; This is reserved for systems not able to generate the sig in components.
. . S @MAP@("M",DIRNUM,"MEDDOSEVALUE")=SIGDATA(8) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEINDICATOR")="1" ; means that we are specifying it. See E2369-05.
. . S @MAP@("M",DIRNUM,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT") . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDELIVERYMETHOD")=SIGDATA(13)
. . S @MAP@("M",DIRNUM,"MEDRATEVALUE")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEVALUE")=SIGDATA(8)
. . S @MAP@("M",DIRNUM,"MEDRATEUNIT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDOSEUNIT")=@MAP@("MEDCONCUNIT")
. . S @MAP@("M",DIRNUM,"MEDVEHICLETEXT")="" ; For inpatient . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEVALUE")="" ; For inpatient
. . S @MAP@("M",DIRNUM,"MEDDIRECTIONROUTETEXT")=SIGDATA(10) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDRATEUNIT")="" ; For inpatient
. . S @MAP@("M",DIRNUM,"MEDFREQUENCYVALUE")=SIGDATA(1) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDVEHICLETEXT")="" ; For inpatient
. . ; Invervals... again another call. . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRECTIONROUTETEXT")=SIGDATA(10)
. . ; The schedule is a free text field . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDFREQUENCYVALUE")=SIGDATA(1)
. . ; However, it gets translated by a call to the administration . . ; Invervals... again another call.
. . ; schedule file to see if that schedule exists. . . ; The schedule is a free text field
. . ; That's the same thing I am going to do. . . ; However, it gets translated by a call to the administration
. . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ). . . ; schedule file to see if that schedule exists.
. . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO-- . . ; That's the same thing I am going to do.
. . ; I looked), PSSFT is the name, . . ; The call is AP^PSS51P1(PSSPP,PSSFT,PSSWDIEN,PSSSTPY,LIST,PSSFREQ).
. . ; and list is the ^TMP name to store the data in. . . ; PSSPP is "PSJ" (for some reason, schedules are stored as PSJ, not PSO--
. . ; Also, freqency may have "PRN" in it, so strip that out . . ; I looked), PSSFT is the name,
. . N FREQ S FREQ=SIGDATA(1) . . ; and list is the ^TMP name to store the data in.
. . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp . . ; Also, freqency may have "PRN" in it, so strip that out
. . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE") . . N FREQ S FREQ=SIGDATA(1)
. . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE") . . I FREQ["PRN" S FREQ=$E(FREQ,1,$F(FREQ,"PRN")-5) ; 5 for $L("PRN") + 1 + sp
. . N INTERVAL . . D AP^PSS51P1("PSJ",FREQ,,,"SCHEDULE")
. . I $P(SCHEDATA(0),U)=-1 S INTERVAL="" . . N SCHEDATA M SCHEDATA=^TMP($J,"SCHEDULE")
. . E D . . N INTERVAL
. . . N SUB S SUB=$O(SCHEDATA(0)) . . I $P(SCHEDATA(0),U)=-1 S INTERVAL=""
. . . S INTERVAL=SCHEDATA(SUB,2) . . E D
. . S @MAP@("M",DIRNUM,"MEDINTERVALVALUE")=INTERVAL . . . N SUB S SUB=$O(SCHEDATA(0))
. . S @MAP@("M",DIRNUM,"MEDINTERVALUNIT")="Minute" . . . S INTERVAL=SCHEDATA(SUB,2)
. . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALVALUE")=INTERVAL
. . N DUR S DUR=SIGDATA(2) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDINTERVALUNIT")="Minute"
. . S @MAP@("M",DIRNUM,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR)) . . ; Duration comes as M2,H2,D2,W2,L2 for 2 minutes,hours,days,weeks,months
. . N DURUNIT S DURUNIT=$E(DUR) . . N DUR S DUR=SIGDATA(2)
. . S @MAP@("M",DIRNUM,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"") . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONVALUE")=$E(DUR,2,$L(DUR))
. . S @MAP@("M",DIRNUM,"MEDPRNFLAG")=SIGDATA(1)["PRN" . . N DURUNIT S DURUNIT=$E(DUR)
. . S @MAP@("M",DIRNUM,"MEDPROBLEMOBJECTID")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDURATIONUNIT")=$S(DURUNIT="M":"Minutes",DURUNIT="H":"Hours",DURUNIT="D":"Days",DURUNIT="W":"Weeks",DURUNIT="L":"Months",1:"")
. . S @MAP@("M",DIRNUM,"MEDPROBLEMTYPETXT")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPRNFLAG")=SIGDATA(1)["PRN"
. . S @MAP@("M",DIRNUM,"MEDPROBLEMDESCRIPTION")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMOBJECTID")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODEVALUE")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMTYPETXT")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGSYSTEM")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMDESCRIPTION")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMCODINGVERSION")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODEVALUE")=""
. . S @MAP@("M",DIRNUM,"MEDPROBLEMSOURCEACTORID")="" . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGSYSTEM")=""
. . S @MAP@("M",DIRNUM,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMCODINGVERSION")=""
. . S @MAP@("M",DIRNUM,"MEDDIRSEQ")=DIRNUM . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDPROBLEMSOURCEACTORID")=""
. . S @MAP@("M",DIRNUM,"MEDMULDIRMOD")=SIGDATA(6) . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDSTOPINDICATOR")="" ; Vista doesn't have that field
. ; . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDDIRSEQ")=DIRNUM
. ; --- END OF DIRECTIONS --- . . S @MAP@("M","DIRECTIONS",DIRCNT,"MEDMULDIRMOD")=SIGDATA(6)
. ; . ;
. S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105" . ; --- END OF DIRECTIONS ---
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9" . ;
. S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13) . S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
. N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED")) . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
. K @RESULT . S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
. D MAP^GPLXPATH(MINXML,MAP,RESULT) . N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED"))
. ; D PARY^GPLXPATH(RESULT) . K @RESULT
. D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy . D MAP^GPLXPATH(MINXML,MAP,RESULT)
. D:MEDCOUNT>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML . ; D PARY^GPLXPATH(RESULT)
N MEDTMP,MEDI . ; MAPPING DIRECTIONS
D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS . N MEDDIR1,DIRXML1 S DIRXML1="MEDDIR1" ; VARIABLE AND NAME VARIABLE TEMPLATE
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . N MEDDIR2,DIRXML2 S DIRXML2="MEDDIR2" ; VARIABLE AND NAME VARIABLE RESULT
. W "MEDICATION MISSING ",! . D QUERY^GPLXPATH(MINXML,"//Medications/Medication/Directions",DIRXML1)
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),! . D REPLACE^GPLXPATH(RESULT,"","//Medications/Medication/Directions")
Q . ; N MDZ1,MDZNA
; . I DIRCNT>0 D ; IF THERE ARE DIRCTIONS
. . F MDZ1=1:1:DIRCNT D ; FOR EACH DIRECTION
. . . S MDZNA=$NA(@MAP@("M","DIRECTIONS",MDZ1))
. . . D MAP^GPLXPATH(DIRXML1,MDZNA,DIRXML2)
. . . D INSINNER^GPLXPATH(RESULT,DIRXML2)
. D:MEDCOUNT=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
. D:MEDCOUNT>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
;