Implemented Flags in VA Meds

This commit is contained in:
sam 2009-03-29 23:58:12 +00:00
parent 4ea7bebb1d
commit 4ab2c073d0
2 changed files with 23 additions and 7 deletions

View File

@ -40,6 +40,7 @@ EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML t
; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time.
;
; --Get parameters for meds
S @MEDOUTXML@(0)=0 ; By default, empty.
N C0CMFLAG
S C0CMFLAG=$$GET^C0CPARMS("MEDALL")_"^"_$$GET^C0CPARMS("MEDLIMIT")_"^"_$$GET^C0CPARMS("MEDACTIVE")_"^"_$$GET^C0CPARMS("MEDPENDING")
W:$G(DEBUG) "Med Parameters: ",!
@ -55,15 +56,16 @@ RPMS
D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT
VISTA
N MEDCOUNT S MEDCOUNT=0
K ^TMP($J,"MED")
N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed
N PEND S PEND=$NA(^TMP($J,"MED","PEND")) ; Pending Meds
N NVA S NVA=$NA(^TMP($J,"MED","NVA")) ; non-VA Meds
S @HIST@(0)=0,@PEND@(0)=0,@NVA@(0)=0 ; At first, they are all empty... (prevent undefined errors)
; N IPIV ; Inpatient IV Meds
; N IPUD ; Inpatient UD Meds
K ^TMP($J,"MED")
D EXTRACT^C0CMED1(MEDXML,DFN,HIST,.MEDCOUNT) ; Historical OP Meds
D EXTRACT^C0CMED2(MEDXML,DFN,PEND,.MEDCOUNT) ; Pending Meds
D EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds
D EXTRACT^C0CMED1(MEDXML,DFN,HIST,.MEDCOUNT,C0CMFLAG) ; Historical OP Meds
D:$P(C0CMFLAG,U,4) EXTRACT^C0CMED2(MEDXML,DFN,PEND,.MEDCOUNT) ; Pending Meds
D:+C0CMFLAG EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds
I @HIST@(0)>0 D
. D CP^C0CXPATH(HIST,MEDOUTXML)
. W:$G(DEBUG) "HAS ACTIVE OP MEDS",!

View File

@ -21,7 +21,7 @@ C0CMED1 ; WV/CCDCCR/SMH - CCR/CCD PROCESSING FOR MEDICATIONS ;01/10/09
W "NO ENTRY FROM TOP",!
Q
;
EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT,FLAGS) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
;
; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
@ -30,6 +30,8 @@ EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEM
; MAP is a mapping variable map (store result) for each med
; MED is holds each array element from MEDS(J), one medicine
; MEDCOUNT is a counter passed by Reference.
; FLAGS are: MEDALL(bool)^MEDLIMIT(int)^MEDACTIVE(bool)^MEDPENDING(bool)
; FLAGS are set-up in C0CMED.
;
; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all
; med data available.
@ -38,7 +40,18 @@ EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEM
; D PARY^C0CXPATH(MINXML)
N MEDS,MAP
K ^TMP($J,"CCDCCR") ; PLEASE DON'T KILL ALL OF ^TMP($J) HERE!!!!
D RX^PSO52API(DFN,"CCDCCR")
N ALL S ALL=+FLAGS
N ACTIVE S ACTIVE=$P(FLAGS,U,3)
; Below, X1 is today; X2 is the number of days we want to go back
; X is the result of this calculation using C^%DTC.
N X,X1,X2
S X1=DT
S X2=-$P($P(FLAGS,U,2),"-",2)
D C^%DTC
; I discovered that I shouldn't put an ending date (last parameter)
; because it seems that it will get meds whose beginning is after X but
; whose exipriation is before the ending date.
D RX^PSO52API(DFN,"CCDCCR","","","",X,"")
M MEDS=^TMP($J,"CCDCCR",DFN)
; @(0) contains the number of meds or -1^NO DATA FOUND
; If it is -1, we quit.
@ -46,12 +59,13 @@ EXTRACT(MINXML,DFN,OUTXML,MEDCOUNT) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEM
ZWRITE:$G(DEBUG) MEDS
N RXIEN S RXIEN=0
F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST
. N MED M MED=MEDS(RXIEN)
. I 'ALL,ACTIVE,$P(MED(100),U,2)'="ACTIVE" QUIT
. S MEDCOUNT=MEDCOUNT+1
. W:$G(DEBUG) "RXIEN IS ",RXIEN,!
. S MAP=$NA(^TMP("C0CCCR",$J,"MEDMAP",MEDCOUNT))
. ; K @MAP DO NOT KILL HERE, WAS CLEARED IN C0CMED
. W:$G(DEBUG) "MAP= ",MAP,!
. N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
. S @MAP@("MEDOBJECTID")="MED"_MEDCOUNT ; MEDCOUNT FOR ID
. ; S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number
. S @MAP@("MEDISSUEDATETXT")="Issue Date"