source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHVXRX.m@ 613

Last change on this file since 613 was 613, checked in by George Lilly, 14 years ago

initial load of WorldVistAEHR

File size: 3.5 KB
Line 
1MHVXRX ;WAS/GPM - Prescription extract ; [12/14/06 11:38am]
2 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ;
7PROFILE(QRY,ERR,DATAROOT) ; Entry point to get prescription profile
8 ; Retrieves requested prescription data and returns it in DATAROOT
9 ; Retrieves all prescriptions with an active status
10 ;
11 ; Integration Agreements:
12 ; 3768 : AP2^PSOPRA,AP5^PSOPRA
13 ; 4687 : EN^PSOMHV1
14 ;
15 ; Input:
16 ; QRY - Query array
17 ; QRY(DFN) - (required) Pointer to PATIENT (#2) file
18 ; DATAROOT - Root of array to hold extract data
19 ;
20 ; Output:
21 ; DATAROOT - Populated data array, includes # of hits
22 ; ERR - Errors during extraction
23 ;
24 N U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
25 ;
26 D LOG^MHVUL2("MHVXRX PROFILE","BEGIN","S","TRACE")
27 S U="^",DT=$$DT^XLFDT
28 S ERR=0,HIT=0
29 K @DATAROOT
30 K ^TMP("PSO",$J)
31 S DFN=$G(QRY("DFN"))
32 S FROM=DT
33 S TO=""
34 ;
35 D EN^PSOMHV1(DFN,FROM,TO)
36 ;
37 S STA="",INDEX=""
38 F STA="ACT","SUS" F S INDEX=$O(^TMP("PSO",$J,STA,INDEX)) Q:INDEX="" D SET
39 ;
40 K ^TMP("PSO",$J)
41 S @DATAROOT=HIT
42 D LOG^MHVUL2("MHVXRX PROFILE",HIT_" HITS","S","TRACE")
43 D LOG^MHVUL2("MHVXRX PROFILE","END","S","TRACE")
44 Q
45 ;
46EXTRACT(QRY,ERR,DATAROOT) ; Entry point to extract prescription data
47 ; Retrieves requested prescription data and returns it in DATAROOT
48 ; Retrieves all prescriptions of all statuses in given date range
49 ; Statuses of deleted are filtered by the pharmacy API.
50 ;
51 ; Integration Agreements:
52 ; 3768 : AP2^PSOPRA,AP5^PSOPRA
53 ; 4687 : EN3^PSOMHV1
54 ;
55 ; Input:
56 ; QRY - Query array
57 ; QRY(DFN) - (required) Pointer to PATIENT (#2) file
58 ; QRY(FROM) - Date to start from
59 ; QRY(TO) - Date to go to
60 ; DATAROOT - Root of array to hold extract data
61 ;
62 ; Output:
63 ; DATAROOT - Populated data array, includes # of hits
64 ; ERR - Errors during extraction
65 ;
66 N U,DT,HIT,DFN,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX
67 ;
68 D LOG^MHVUL2("MHVXRX EXTRACT","BEGIN","S","TRACE")
69 S U="^",DT=$$DT^XLFDT
70 S ERR=0,HIT=0
71 K @DATAROOT
72 K ^TMP("PS",$J)
73 S DFN=$G(QRY("DFN"))
74 S FROM=$G(QRY("FROM"))
75 S TO=$G(QRY("TO"))
76 ;
77 I FROM="" S FROM=2000101 ;01/01/1900
78 ;
79 ; The EN3^PSOMHV1 call uses RX IEN instead of DRUG as a
80 ; subscript in ^TMP("PSO",$J). This was a late breaking change to
81 ; PSOMHV1 to support historical extracts.
82 D EN3^PSOMHV1(DFN,FROM,TO)
83 ;
84 S STA="",INDEX=""
85 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
86 ;
87 K ^TMP("PSO",$J)
88 S @DATAROOT=HIT
89 D LOG^MHVUL2("MHVXRX EXTRACT",HIT_" HITS","S","TRACE")
90 D LOG^MHVUL2("MHVXRX EXTRACT","END","S","TRACE")
91 Q
92 ;
93SET ;
94 ;INDEX will be RXIEN if called from EXTRACT
95 ;INDEX will be drug name if called from PROFILE
96 S RXN=$P($G(^TMP("PSO",$J,STA,INDEX,"RXN",0)),"^")
97 I RXN="" Q
98 I $D(QRY("RXLIST")) Q:'$D(QRY("RXLIST",RXN))
99 S MHVSTAT=$$AP2^PSOPRA(DFN,RXN)
100 S MHVDATE=$P(MHVSTAT,"^",2)
101 S MHVSTAT=$P(MHVSTAT,"^",1)
102 I MHVSTAT>0 I $$AP5^PSOPRA(DFN,RXN) ;Clear RXN from queue
103 S DRUG=$P($G(^TMP("PSO",$J,STA,INDEX,0)),"^",1) ;Drug Name
104 S HIT=HIT+1
105 S @DATAROOT@(HIT)=RXN_U_DRUG_U_MHVSTAT_U_MHVDATE
106 S @DATAROOT@(HIT,0)=$G(^TMP("PSO",$J,STA,INDEX,0))
107 S @DATAROOT@(HIT,"P")=$G(^TMP("PSO",$J,STA,INDEX,"P",0))
108 S @DATAROOT@(HIT,"RXN")=$G(^TMP("PSO",$J,STA,INDEX,"RXN",0))
109 S @DATAROOT@(HIT,"DIV")=$G(^TMP("PSO",$J,STA,INDEX,"DIV",0))
110 I '$D(^TMP("PSO",$J,STA,INDEX,"SIG")) S @DATAROOT@(HIT,"SIG",0)=0
111 E M @DATAROOT@(HIT,"SIG")=^TMP("PSO",$J,STA,INDEX,"SIG")
112 Q
113 ;
Note: See TracBrowser for help on using the repository browser.