source: WorldVistAEHR/trunk/r/DSS_EXTRACTS-ECX/ECXSARXS.m@ 1476

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1ECXSARXS ;BIR/DMA-SAS Report from Prescription Extract; 22 Sep 95 / 10:27 AM
2 ;;3.0;DSS EXTRACTS;**8**;Dec 22, 1997
3 ;
4EN ;entry point from menu option
5 W @IOF,!!,"Prescription Extract SAS Report",!!
6 ;ecxaud=1 for 'sas' audit
7 S ECXHEAD="PRE",ECXAUD=1
8 ;select extract
9 D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
10 I ECXERR D AUDIT^ECXKILL Q
11 ;select all pharmacy sites/divisions
12 S ECXALL=1 D PRE^ECXDVSN1(.ECXDIV,ECXALL,.ECXERR)
13 I ECXERR D AUDIT^ECXKILL Q
14 W !!
15 S ECXPGM="PROCESS^ECXSARXS",ECXDESC="Prescription Extract SAS Report"
16 S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
17 W !
18 D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
19 I ECXSAVE("POP")=1 D Q
20 .W !!,?5,"Try agian later... exiting.",!
21 .D AUDIT^ECXKILL
22 I ECXSAVE("ZTSK")=0 D
23 .K ECXSAVE,ECXPGM,ECXDESC
24 .D PROCESS
25 I IO'=IO(0) D ^%ZISC
26 D HOME^%ZIS
27 D AUDIT^ECXKILL
28 Q
29 ;
30PROCESS ;queued entry
31 N J,X,Y,JJ,SS,LN,PG,DIV,EC,ECFK,ECFL,ECQ,MAIL,NEWRX,COPAY,DEA,TOT,QFLG,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT
32 K ^TMP($J,"ECXAUD")
33 S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
34 S (QFLG,PG)=0,$P(LN,"-",80)=""
35 ;get run date in external format
36 D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
37 ;process the extract records
38 S J="" F S J=$O(^ECX(727.81,"AC",ECXEXT,J)) Q:'J I $D(^ECX(727.81,J,0)) S EC=^(0) D
39 .S DIV=$P(EC,U,10),MAIL=+$P(EC,U,13),NEWRX=+$P(EC,U,15),COPAY=+$P(EC,U,27),DEA=$P(EC,U,29)
40 .;non-cmop rxs only
41 .;feeder location is always "pre"_div
42 .I MAIL'=2 D
43 ..S ECFL="PRE"_DIV,ECFK=$P(EC,U,28),ECQ=+$P(EC,U,17)
44 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
45 ..;additional feeder key records for non-cmop rx
46 ..S ECFK="BASIC",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
47 ..I MAIL=1 D
48 ...S ECFK="VAMAIL",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
49 ...I NEWRX=1 D
50 ....S ECFK="NEWVMOP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
51 ..I MAIL=0&(NEWRX=1) D
52 ...S ECFK="NEWWIN",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
53 ..I COPAY=1 D
54 ...S ECFK="COPAY",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
55 ..I DEA="I" D
56 ...S ECFK="PREDEASP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
57 .;cmop rxs only
58 .;feeder location is "cmopdsu"_div, "cmopdis"_div, and also "pre"_div
59 .I MAIL=2 D
60 ..S ECFL="CMOPDSU"_DIV,ECFK=$P(EC,U,28),ECQ=+$P(EC,U,17),^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
61 ..S ECFL="CMOPDIS"_DIV,ECFK="CMOPDISP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
62 ..S ECFL="PRE"_DIV D
63 ...;possibly three additional feeder key recods for cmop rx
64 ...I NEWRX=1 D
65 ....S ECFK="NEWCMOP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
66 ...I COPAY=1 D
67 ....S ECFK="COPAY",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
68 ...I DEA="I" D
69 ....S ECFK="PREDEASP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
70 ;print the report
71 U IO
72 S DIV="" F S DIV=$O(^TMP($J,"ECXAUD",DIV)) Q:DIV="" D Q:QFLG
73 .D HEADER
74 .S ECFL="" F S ECFL=$O(^TMP($J,"ECXAUD",DIV,ECFL)) Q:ECFL="" D Q:QFLG
75 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,ECFL
76 ..S ECFK="" F S ECFK=$O(^TMP($J,"ECXAUD",DIV,ECFL,ECFK)) Q:ECFK="" S TOT=^(ECFK) D Q:QFLG
77 ...D:($Y+3>IOSL) HEADER Q:QFLG W ?40,ECFK,?68,$$RJ^XLFSTR(TOT,5," "),!
78 ;close
79 I $E(IOST)'="C" W @IOF
80 I $E(IOST)="C",'QFLG D
81 .S SS=22-$Y F JJ=1:1:SS W !
82 .S DIR(0)="E" W ! D ^DIR K DIR
83 D AUDIT^ECXKILL
84 Q
85 ;
86HEADER ;print the header
87 D SASHEAD^ECXUTLA(DIV,ECXHEAD,.ECXDIV,.ECXARRAY,.PG)
88 Q
Note: See TracBrowser for help on using the repository browser.