Ignore:
Timestamp:
Dec 4, 2009, 12:11:15 AM (14 years ago)
Author:
George Lilly
Message:

revised back to 6/30/08 version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHVXRX.m

    r613 r623  
    1 MHVXRX  ;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         ;
    7 PROFILE(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         ;
    46 EXTRACT(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         ;
    93 SET     ;
    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         ;
     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 TracChangeset for help on using the changeset viewer.