source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOELPST.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1PSOELPST ;BIR/RTR-Status update ;11/27/01
2 ;;7.0;OUTPATIENT PHARMACY;**86**;DEC 1997
3 ;External reference to STATUS^ORQOR2 supported by DBIA 3458
4 ;External reference to ^OR(100 supported by DBIA 3463
5 ;CPRS/Outpatient status update
6 ;PSOCPRS = CPRS number (Placer)
7 ;PSORXNUM = Outpatient number (52 ien)
8 I '$G(XPDENV) Q
9 N PSOPACRF
10 S DIC=9.4,DIC(0)="Z",X="OUTPATIENT PHARMACY" D ^DIC K DIC I +Y'>0 W !!,"A problem was found when trying to identify a valid Outpatient Pharmacy",!,"package reference from the PACKAGE (#9.4) file." D S XPDQUIT=2 Q
11 .W !,"This Patch cannot be installed until this problem is resolved.",!
12 .K DIR S DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR K DIR
13 S PSOPACRF=+Y
14 W !,"This patch queues a job to find Outpatient Pharmacy orders that are expired or",!,"Discontinued, but are Active in CPRS. This patch will update the order in CPRS",!,"with the appropriate status."
15 W ! K ZTDTH S ZTRTN="EN^PSOELPST",ZTDESC="Pharmacy/CPRS status clean up",ZTIO="",ZTSAVE("PSOPACRF")="" D ^%ZTLOAD I '$G(ZTSK) D S XPDQUIT=2
16 .W !!,"Since this job was not queued, the patch will not be installed.",! K DIR S DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR K DIR
17 Q
18EN ;
19 N PSOCPRS,PSORXNUM,PSOXCOM,PSOXDT,PSOIJ,PSOJJ,PSOREAS,PSOACRL,PSOPHR,PSOALC,PSOADT,PSONAT,PSOCOMM,PSOZDUZ,PSOELSTA,PSOELSTP,PSOETEXT,PSOECT,PSOCSTAT
20 I '$G(DT) S DT=$$DT^XLFDT
21 D NOW^%DTC S PSOELSTA=%
22 S PSOECT=0
23 S PSOCPRS="" F S PSOCPRS=$O(^PSRX("APL",PSOCPRS)) Q:PSOCPRS="" S PSORXNUM="" F S PSORXNUM=$O(^PSRX("APL",PSOCPRS,PSORXNUM)) Q:PSORXNUM="" D
24 .I PSOCPRS'=$P($G(^PSRX(PSORXNUM,"OR1")),"^",2) Q
25 .I '$D(^PSRX(PSORXNUM,0)) Q
26 .I +$$STATUS^ORQOR2(PSOCPRS)'=6 Q
27 .I PSORXNUM'=$P($G(^OR(100,PSOCPRS,4)),"^") Q
28 .I PSOPACRF'=$P($G(^OR(100,PSOCPRS,0)),"^",14) Q
29 .S PSOCSTAT=$P($G(^PSRX(PSORXNUM,"STA")),"^")
30 .I PSOCSTAT=11 D Q
31 ..I $P(^PSRX(PSORXNUM,0),"^",19)=2 S $P(^(0),"^",19)=1
32 ..S PSOXCOM="Prescription past expiration date" D EN^PSOHLSN1(PSORXNUM,"SC","ZE",PSOXCOM) S PSOECT=PSOECT+1
33 ..S PSOXDT=$S($P($G(^PSRX(PSORXNUM,2)),"^",6):$E($P($G(^(2)),"^",6),1,7),1:DT)_".2200"
34 ..I $D(^OR(100,PSOCPRS,3)) S $P(^(3),"^")=PSOXDT
35 .I PSOCSTAT=12!(PSOCSTAT=14)!(PSOCSTAT=15) D
36 ..S (PSOIJ,PSOJJ,PSOPHR,PSOADT)=0 F S PSOIJ=$O(^PSRX(PSORXNUM,"A",PSOIJ)) Q:'PSOIJ S PSOREAS=$P($G(^(PSOIJ,0)),"^",2) I PSOREAS="C"!(PSOREAS="L") S PSOJJ=PSOIJ
37 ..I PSOJJ S PSOACRL=$G(^PSRX(PSORXNUM,"A",PSOJJ,0)) D
38 ...S PSOPHR=$P(PSOACRL,"^",3),PSOALC=$P(PSOACRL,"^",5),PSOADT=$P(PSOACRL,"^"),(PSONAT,PSOCOMM)=""
39 ...I PSOALC["Renewed" S PSOCOMM="Renewed by Pharmacy"
40 ...I PSOALC["Auto Discontinued" S PSOPHR="",PSONAT="A",PSOCOMM=$E($P(PSOALC,".",2),2,99) S:PSOCOMM="" PSOCOMM=PSOALC
41 ...I PSOALC["Discontinued During" S PSOCOMM="Discontinued by Pharmacy"
42 ..I 'PSOJJ S PSOCOMM="Discontinued by Pharmacy",PSONAT=""
43 ..S PSOZDUZ=$G(DUZ) S:$G(PSOPHR) DUZ=PSOPHR D EN^PSOHLSN1(PSORXNUM,"OD",$S(PSOCSTAT=15:"RP",1:""),PSOCOMM,PSONAT) S PSOECT=PSOECT+1 S DUZ=PSOZDUZ
44 ..I '$G(PSOADT) S PSOADT=DT_".2200"
45 ..I $D(^OR(100,PSOCPRS,6)) S $P(^(6),"^",3)=$E(PSOADT,1,12)
46 ..I $D(^OR(100,PSOCPRS,3)) S $P(^(3),"^")=$E(PSOADT,1,12)
47MAIL ;Send mail message upon job completion
48 K PSOPACRF
49 I $G(DUZ) D
50 .S XMDUZ="Patch PSO*7*86 Patch Install",XMSUB="Outpatient/CPRS Status clean-up",XMY(DUZ)=""
51 .D NOW^%DTC S PSOELSTP=%
52 .S PSOETEXT(1)="The tasked job for patch PSO*7*86 is complete."
53 .S PSOETEXT(2)="The total number of mismatched statuses found were "_+$G(PSOECT)_"."
54 .S Y=$G(PSOELSTA) D DD^%DT S PSOELSTA=$G(Y)
55 .S Y=$G(PSOELSTP) D DD^%DT S PSOELSTP=$G(Y)
56 .S PSOETEXT(3)="The job started on "_$G(PSOELSTA)_"."
57 .S PSOETEXT(4)="The job ended on "_$G(PSOELSTP)_"."
58 .S XMTEXT="PSOETEXT(" N DIFROM D ^XMD K Y,XMDUZ,XMTEXT,XMSUB
59 S:$D(ZTQUEUED) ZTREQ="@"
60 Q
Note: See TracBrowser for help on using the repository browser.