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

Last change on this file since 823 was 623, checked in by George Lilly, 15 years ago

revised back to 6/30/08 version

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