source: FOIAVistA/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJ0061.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 3.4 KB
Line 
1PSJ0061 ;BIR/LDT - Check for Trailing Zeros on dates; 02 MAY-01
2 ;;5.0; INPATIENT MEDICATIONS ;**61**;16 DEC 97
3 ;
4 ;Reference to ^PS(55 is supported by DBIA# 2191.
5 ;
6ENNV ; Begin check of existing orders
7 I $G(DUZ)="" W !,"Your user code is undefined. It must be defined to run this routine." Q
8 K ZTSAVE,ZTSK S ZTRTN="ENQN^PSJ0061",ZTDESC="Inpatient Orders Check (INPATIENT MEDS)",ZTIO="" D ^%ZTLOAD
9 W !!,"The check of existing Pharmacy orders is",$S($D(ZTSK):"",1:" NOT")," queued",!
10 I $D(ZTSK) W " (to start NOW).",!!,"YOU WILL RECEIVE TWO MAILMAN MESSAGES WHEN TASK #"_ZTSK_" HAS COMPLETED."
11 Q
12ENQN ; Check of existing Pharmacy orders.
13 N PSJBEG,PSJPDFN,PSJORD,PSJSTRT,PSJSTP,CREAT,EXPR,OCNT,PSJND2
14 D NOW^%DTC S PSJSTART=$E(%,1,12),CREAT=$E(%,1,7),EXPR=$$FMADD^XLFDT(CREAT,30,0,0,0),OCNT=0
15 K ^XTMP("PSJ")
16 S PSJBEG=0 F S PSJBEG=$O(^PS(55,"AUDS",PSJBEG)) Q:'PSJBEG S PSJPDFN=0 F S PSJPDFN=$O(^PS(55,"AUDS",PSJBEG,PSJPDFN)) Q:'PSJPDFN D
17 . S PSJORD=0 F S PSJORD=$O(^PS(55,"AUDS",PSJBEG,PSJPDFN,PSJORD)) Q:'PSJORD D
18 .. S PSJND=$G(^PS(55,PSJPDFN,5,PSJORD,0)),PSJLOG=$P(PSJND,"^",16)
19 .. S PSJND2=$G(^PS(55,PSJPDFN,5,PSJORD,2)),PSJSTRT=$P(PSJND2,"^",2),PSJSTP=$P(PSJND2,"^",4) D
20 ... I (PSJLOG'=+PSJLOG)!(PSJSTRT'=+PSJSTRT)!(PSJSTP'=+PSJSTP) S ^XTMP("PSJ",PSJPDFN,PSJORD)=PSJSTRT_"^"_PSJSTP_"^"_PSJLOG,OCNT=OCNT+1
21 S:$D(^XTMP("PSJ")) ^XTMP("PSJ",0)=EXPR_"^"_CREAT
22 D SENDMSG
23 I $D(^XTMP("PSJ")) D CLEAN
24DONE ;
25 K DAYS,MINS,HOURS,PSG,PSJSTART,X,XMDUZ,XMSUB,XMTEXT,XMY,Y,ZTDESC,ZTDTH,ZTIO,ZTREQ,ZTRTN,ZTSAVE,ZTSK S ZTREQ="@"
26 Q
27 Q
28SENDMSG ;Send mail message when check is complete.
29 K PSG,XMY S XMDUZ="MEDICATIONS,INPATIENT",XMSUB="INPATIENT MEDS ORDER CHECK COMPLETED",XMTEXT="PSG(",XMY(DUZ)="" D NOW^%DTC S Y=% X ^DD("DD")
30 S PSG(1,0)=" The check of existing Pharmacy orders for use with Inpatient",PSG(2,0)="Medications 5.0 completed as of "_Y_"."
31 S X=$$FMDIFF^XLFDT(%,PSJSTART,3) S:$L(X," ")>1 DAYS=+$P(X," "),X=$P(X," ",2) S HOURS=+$P(X,":"),MINS=+$P(X,":",2)
32 S PSG(3,0)=" ",PSG(4,0)="This process checked orders for patients in "_$S($G(DAYS):DAYS_" day"_$E("s",DAYS'=1)_", ",1:"")_HOURS_" hour"_$E("s",HOURS'=1),PSG(5,0)="and "_MINS_" minute"_$E("s",MINS'=1)_"."
33 S PSG(6,0)=OCNT_" pharmacy orders were found with trailing zeroes in the start,",PSG(7,0)="stop, or log-in date."
34 D ^XMD
35 Q
36 ;
37CLEAN ;
38 N PSJPDFN,PSJORD,PSJND,PSJND2,PSJST,PSJSTRT,PSJSTP,PSJLOG
39 S PSJPDFN=0 F S PSJPDFN=$O(^XTMP("PSJ",PSJPDFN)) Q:'PSJPDFN S PSJORD=0 F S PSJORD=$O(^XTMP("PSJ",PSJPDFN,PSJORD)) Q:'PSJORD D
40 . I '$D(^PS(55,PSJPDFN,5,PSJORD)) Q
41 . S PSJND=$G(^PS(55,PSJPDFN,5,PSJORD,0)),PSJST=$P(PSJND,"^",7),PSJLOG=$P(PSJND,"^",16)
42 . S PSJND2=$G(^PS(55,PSJPDFN,5,PSJORD,2)),PSJSTRT=$P(PSJND2,"^",2),PSJSTP=$P(PSJND2,"^",4) D
43 .. I PSJLOG'=+PSJLOG S $P(^PS(55,PSJPDFN,5,PSJORD,0),"^",16)=+PSJLOG
44 .. I PSJSTRT]"",PSJSTRT'=+PSJSTRT S $P(^PS(55,PSJPDFN,5,PSJORD,2),"^",2)=+PSJSTRT D
45 ... I $D(^PS(55,"AUDS",PSJSTRT,PSJPDFN,PSJORD)) K ^PS(55,"AUDS",PSJSTRT,PSJPDFN,PSJORD) S ^PS(55,"AUDS",+PSJSTRT,PSJPDFN,PSJORD)=""
46 .. I PSJSTP]"",PSJSTP'=+PSJSTP S $P(^PS(55,PSJPDFN,5,PSJORD,2),"^",4)=+PSJSTP D
47 ... I $D(^PS(55,PSJPDFN,5,"AU",PSJST,PSJSTP,PSJORD)) K ^PS(55,PSJPDFN,5,"AU",PSJST,PSJSTP,PSJORD) S ^PS(55,PSJPDFN,5,"AU",PSJST,+PSJSTP,PSJORD)=""
48 K PSG,XMY S XMDUZ="MEDICATIONS,INPATIENT",XMSUB="INPATIENT MEDS ORDER CLEANUP COMPLETED",XMTEXT="PSG(",XMY(DUZ)="" D NOW^%DTC S Y=% X ^DD("DD")
49 S PSG(1,0)=" The cleanup of Inpatient Medication orders with invalid dates ",PSG(2,0)="completed as of "_Y_"."
50 D ^XMD
51 Q
Note: See TracBrowser for help on using the repository browser.