MHVXRX ;WAS/GPM - Prescription extract ; [12/14/06 11:38am]
;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;
PROFILE(QRY,ERR,DATAROOT) ; Entry point to get prescription profile
; Retrieves requested prescription data and returns it in DATAROOT
; Retrieves all prescriptions with an active status
;
; Integration Agreements:
; 3768 : AP2^PSOPRA,AP5^PSOPRA
; 4687 : EN^PSOMHV1
;
; Input:
; QRY - Query array
; QRY(DFN) - (required) Pointer to PATIENT (#2) file
; DATAROOT - Root of array to hold extract data
;
; Output:
; DATAROOT - Populated data array, includes # of hits
; ERR - Errors during extraction
;
N U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
;
D LOG^MHVUL2("MHVXRX PROFILE","BEGIN","S","TRACE")
S U="^",DT=$$DT^XLFDT
S ERR=0,HIT=0
K @DATAROOT
K ^TMP("PSO",$J)
S DFN=$G(QRY("DFN"))
S FROM=DT
S TO=""
;
D EN^PSOMHV1(DFN,FROM,TO)
;
S STA="",INDEX=""
F STA="ACT","SUS" F S INDEX=$O(^TMP("PSO",$J,STA,INDEX)) Q:INDEX="" D SET
;
K ^TMP("PSO",$J)
S @DATAROOT=HIT
D LOG^MHVUL2("MHVXRX PROFILE",HIT_" HITS","S","TRACE")
D LOG^MHVUL2("MHVXRX PROFILE","END","S","TRACE")
Q
;
; Retrieves requested prescription data and returns it in DATAROOT
; Retrieves all prescriptions of all statuses in given date range
; Statuses of deleted are filtered by the pharmacy API.
;
; Integration Agreements:
; 3768 : AP2^PSOPRA,AP5^PSOPRA
; 4687 : EN3^PSOMHV1
;
; Input:
; QRY - Query array
; QRY(DFN) - (required) Pointer to PATIENT (#2) file
; QRY(FROM) - Date to start from
; QRY(TO) - Date to go to
; DATAROOT - Root of array to hold extract data
;
; Output:
; DATAROOT - Populated data array, includes # of hits
; ERR - Errors during extraction
;
N U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
;
D LOG^MHVUL2("MHVXRX EXTRACT","BEGIN","S","TRACE")
S U="^",DT=$$DT^XLFDT
S ERR=0,HIT=0
K @DATAROOT
K ^TMP("PS",$J)
S DFN=$G(QRY("DFN"))
S FROM=$G(QRY("FROM"))
S TO=$G(QRY("TO"))
;
I FROM="" S FROM=2000101 ;01/01/1900
;
; The EN3^PSOMHV1 call uses RX IEN instead of DRUG as a
; subscript in ^TMP("PSO",$J). This was a late breaking change to
; PSOMHV1 to support historical extracts.
D EN3^PSOMHV1(DFN,FROM,TO)
;
S STA="",INDEX=""
F S STA=$O(^TMP("PSO",$J,STA)) Q:STA="" I STA'="PEN" F S INDEX=$O(^TMP("PSO",$J,STA,INDEX)) Q:INDEX="" D SET
;
K ^TMP("PSO",$J)
S @DATAROOT=HIT
D LOG^MHVUL2("MHVXRX EXTRACT",HIT_" HITS","S","TRACE")
D LOG^MHVUL2("MHVXRX EXTRACT","END","S","TRACE")
Q
;
SET ;
;INDEX will be RXIEN if called from EXTRACT
;INDEX will be drug name if called from PROFILE
S RXN=$P($G(^TMP("PSO",$J,STA,INDEX,"RXN",0)),"^")
I RXN="" Q
I $D(QRY("RXLIST")) Q:'$D(QRY("RXLIST",RXN))
S MHVSTAT=$$AP2^PSOPRA(DFN,RXN)
S MHVDATE=$P(MHVSTAT,"^",2)
S MHVSTAT=$P(MHVSTAT,"^",1)
I MHVSTAT>0 I $$AP5^PSOPRA(DFN,RXN) ;Clear RXN from queue
S DRUG=$P($G(^TMP("PSO",$J,STA,INDEX,0)),"^",1) ;Drug Name
S HIT=HIT+1
S @DATAROOT@(HIT)=RXN_U_DRUG_U_MHVSTAT_U_MHVDATE
S @DATAROOT@(HIT,0)=$G(^TMP("PSO",$J,STA,INDEX,0))
S @DATAROOT@(HIT,"P")=$G(^TMP("PSO",$J,STA,INDEX,"P",0))
S @DATAROOT@(HIT,"RXN")=$G(^TMP("PSO",$J,STA,INDEX,"RXN",0))
S @DATAROOT@(HIT,"DIV")=$G(^TMP("PSO",$J,STA,INDEX,"DIV",0))
I '$D(^TMP("PSO",$J,STA,INDEX,"SIG")) S @DATAROOT@(HIT,"SIG",0)=0
E M @DATAROOT@(HIT,"SIG")=^TMP("PSO",$J,STA,INDEX,"SIG")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHVXRX 3705 printed Sep 15, 2024@21:40:25 Page 2
MHVXRX ;WAS/GPM - Prescription extract ; [12/14/06 11:38am]
+1 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
PROFILE(QRY,ERR,DATAROOT) ; Entry point to get prescription profile
+1 ; Retrieves requested prescription data and returns it in DATAROOT
+2 ; Retrieves all prescriptions with an active status
+3 ;
+4 ; Integration Agreements:
+5 ; 3768 : AP2^PSOPRA,AP5^PSOPRA
+6 ; 4687 : EN^PSOMHV1
+7 ;
+8 ; Input:
+9 ; QRY - Query array
+10 ; QRY(DFN) - (required) Pointer to PATIENT (#2) file
+11 ; DATAROOT - Root of array to hold extract data
+12 ;
+13 ; Output:
+14 ; DATAROOT - Populated data array, includes # of hits
+15 ; ERR - Errors during extraction
+16 ;
+17 NEW U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
+18 ;
+19 DO LOG^MHVUL2("MHVXRX PROFILE","BEGIN","S","TRACE")
+20 SET U="^"
SET DT=$$DT^XLFDT
+21 SET ERR=0
SET HIT=0
+22 KILL @DATAROOT
+23 KILL ^TMP("PSO",$JOB)
+24 SET DFN=$GET(QRY("DFN"))
+25 SET FROM=DT
+26 SET TO=""
+27 ;
+28 DO EN^PSOMHV1(DFN,FROM,TO)
+29 ;
+30 SET STA=""
SET INDEX=""
+31 FOR STA="ACT","SUS"
FOR
SET INDEX=$ORDER(^TMP("PSO",$JOB,STA,INDEX))
if INDEX=""
QUIT
DO SET
+32 ;
+33 KILL ^TMP("PSO",$JOB)
+34 SET @DATAROOT=HIT
+35 DO LOG^MHVUL2("MHVXRX PROFILE",HIT_" HITS","S","TRACE")
+36 DO LOG^MHVUL2("MHVXRX PROFILE","END","S","TRACE")
+37 QUIT
+38 ;
+1 ; Retrieves requested prescription data and returns it in DATAROOT
+2 ; Retrieves all prescriptions of all statuses in given date range
+3 ; Statuses of deleted are filtered by the pharmacy API.
+4 ;
+5 ; Integration Agreements:
+6 ; 3768 : AP2^PSOPRA,AP5^PSOPRA
+7 ; 4687 : EN3^PSOMHV1
+8 ;
+9 ; Input:
+10 ; QRY - Query array
+11 ; QRY(DFN) - (required) Pointer to PATIENT (#2) file
+12 ; QRY(FROM) - Date to start from
+13 ; QRY(TO) - Date to go to
+14 ; DATAROOT - Root of array to hold extract data
+15 ;
+16 ; Output:
+17 ; DATAROOT - Populated data array, includes # of hits
+18 ; ERR - Errors during extraction
+19 ;
+20 NEW U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
+21 ;
+22 DO LOG^MHVUL2("MHVXRX EXTRACT","BEGIN","S","TRACE")
+23 SET U="^"
SET DT=$$DT^XLFDT
+24 SET ERR=0
SET HIT=0
+25 KILL @DATAROOT
+26 KILL ^TMP("PS",$JOB)
+27 SET DFN=$GET(QRY("DFN"))
+28 SET FROM=$GET(QRY("FROM"))
+29 SET TO=$GET(QRY("TO"))
+30 ;
+31 ;01/01/1900
IF FROM=""
SET FROM=2000101
+32 ;
+33 ; The EN3^PSOMHV1 call uses RX IEN instead of DRUG as a
+34 ; subscript in ^TMP("PSO",$J). This was a late breaking change to
+35 ; PSOMHV1 to support historical extracts.
+36 DO EN3^PSOMHV1(DFN,FROM,TO)
+37 ;
+38 SET STA=""
SET INDEX=""
+39 FOR
SET STA=$ORDER(^TMP("PSO",$JOB,STA))
if STA=""
QUIT
IF STA'="PEN"
FOR
SET INDEX=$ORDER(^TMP("PSO",$JOB,STA,INDEX))
if INDEX=""
QUIT
DO SET
+40 ;
+41 KILL ^TMP("PSO",$JOB)
+42 SET @DATAROOT=HIT
+43 DO LOG^MHVUL2("MHVXRX EXTRACT",HIT_" HITS","S","TRACE")
+44 DO LOG^MHVUL2("MHVXRX EXTRACT","END","S","TRACE")
+45 QUIT
+46 ;
SET ;
+1 ;INDEX will be RXIEN if called from EXTRACT
+2 ;INDEX will be drug name if called from PROFILE
+3 SET RXN=$PIECE($GET(^TMP("PSO",$JOB,STA,INDEX,"RXN",0)),"^")
+4 IF RXN=""
QUIT
+5 IF $DATA(QRY("RXLIST"))
if '$DATA(QRY("RXLIST",RXN))
QUIT
+6 SET MHVSTAT=$$AP2^PSOPRA(DFN,RXN)
+7 SET MHVDATE=$PIECE(MHVSTAT,"^",2)
+8 SET MHVSTAT=$PIECE(MHVSTAT,"^",1)
+9 ;Clear RXN from queue
IF MHVSTAT>0
IF $$AP5^PSOPRA(DFN,RXN)
+10 ;Drug Name
SET DRUG=$PIECE($GET(^TMP("PSO",$JOB,STA,INDEX,0)),"^",1)
+11 SET HIT=HIT+1
+12 SET @DATAROOT@(HIT)=RXN_U_DRUG_U_MHVSTAT_U_MHVDATE
+13 SET @DATAROOT@(HIT,0)=$GET(^TMP("PSO",$JOB,STA,INDEX,0))
+14 SET @DATAROOT@(HIT,"P")=$GET(^TMP("PSO",$JOB,STA,INDEX,"P",0))
+15 SET @DATAROOT@(HIT,"RXN")=$GET(^TMP("PSO",$JOB,STA,INDEX,"RXN",0))
+16 SET @DATAROOT@(HIT,"DIV")=$GET(^TMP("PSO",$JOB,STA,INDEX,"DIV",0))
+17 IF '$DATA(^TMP("PSO",$JOB,STA,INDEX,"SIG"))
SET @DATAROOT@(HIT,"SIG",0)=0
+18 IF '$TEST
MERGE @DATAROOT@(HIT,"SIG")=^TMP("PSO",$JOB,STA,INDEX,"SIG")
+19 QUIT
+20 ;