source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOPOST7.m@ 812

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

initial load of FOIAVistA 6/30/08 version

File size: 6.4 KB
Line 
1PSOPOST7 ;BIR/EJW,JLC-Post install routine ;10/04/02
2 ;;7.0;OUTPATIENT PHARMACY;**115,268**;DEC 1997;Build 9
3 ;External reference to ^DPT supported by DBIA 10035
4 ;External reference to ^PS(55 supported by DBIA 2228
5 ; POST-INSTALL ROUTINE FOR PATCH PSO*7*115 - TO RESET MISSING ENTRIES INTO THE PHARMACY PATIENT FILE (#55)
6 S ZTDTH=""
7 I $D(ZTQUEUED) S ZTDTH=$H
8 L +^XTMP("PSOPOST7"):$S(+$G(^DD("DILOCKTM"))>0:+^DD("DILOCKTM"),1:3) I '$T D Q
9 . I ZTDTH="" W !,"Clean up job is already running. Halting..."
10 L -^XTMP("PSOPOST7")
11 I ZTDTH="" D
12 .W !,"The background job to search for missing ^PS(55 entries must be queued."
13 .W !,"If no start date/time is entered when prompted, the background job will be"
14 .W !,"queued to run NOW."
15 .W !
16 .D BMES^XPDUTL("Queuing background job to search for missing ^PS(55 entries")
17 S ZTRTN="RES^PSOPOST7",ZTIO="",ZTDESC="Background job to search for missing ^PS(55 entries" D ^%ZTLOAD K ZTDTH,ZTRTN,ZTIO,ZTDESC
18 W:$D(ZTSK)&('$D(ZTQUEUED)) !!,"Task Queued !",!
19 Q
20RES ;
21 L +^XTMP("PSOPOST7"):$S(+$G(^DD("DILOCKTM"))>0:+^DD("DILOCKTM"),1:3) I '$T S:$D(ZTQUEUED) ZTREQ="@" Q
22 I '$G(DT) S DT=$$DT^XLFDT
23 I '$D(^XTMP("PSOPOST7")) S X1=DT,X2=+30 D C^%DTC S ^XTMP("PSOPOST7",0)=$G(X)_"^"_DT
24 S PSODT2=DT-20000
25 D NOW^%DTC S ^XTMP("PSOTIMEX","START")=%
26 D BMES^XPDUTL("Searching for missing ^PS(55 entries...")
27SRCH ; SEARCH THROUGH PRESCRIPTIONS
28 N RXP,RX0,PSODFN,PSODT,PSOCTP,PSOCTPA
29 S (PSOCTP,PSOCTPA)=0
30 S RXP=0 F S RXP=$O(^PSRX(RXP)) Q:'RXP S RX0=$G(^PSRX(RXP,0)),PSODT=$P(RX0,"^",13) I PSODT>PSODT2 S PSODFN=$P(RX0,"^",2) I PSODFN D
31 .I '$D(^DPT(PSODFN,0)) Q
32 .D PS55P
33 .D PS55PA
34 I $O(^XTMP("PSOPOST7",$J,""))'="" D RESET
35 N DFN,PSJORD,PSSTART,PSSTOP,PSSTATUS,A
36 S DFN=0
37 F S DFN=$O(^PS(55,DFN)) Q:'DFN D
38 . S PSJORD=0 F S PSJORD=$O(^PS(55,DFN,5,PSJORD)) Q:'PSJORD D
39 .. S PSSTATUS=$P($G(^PS(55,DFN,5,PSJORD,0)),U,9),PSSTART=$P($G(^PS(55,DFN,5,PSJORD,2)),U,2),PSSTOP=$P($G(^(2)),U,4) I PSSTOP]"",$D(^PS(55,"AUD",PSSTOP,DFN,PSJORD)) Q
40 .. K DR S DIE="^PS(55,"_DFN_",5,",DA=PSJORD,DA(1)=DFN,DR="10////^S X=PSSTART;28////^S X=PSSTATUS;34////^S X=PSSTOP"
41 .. D ^DIE
42 .. S ^XTMP("PSOPOST7",$J,"UD",DFN,PSJORD)="" K DIE,DR,DA
43 . S PSJORD=0 F S PSJORD=$O(^PS(55,DFN,"IV",PSJORD)) Q:'PSJORD D
44 .. S A=$G(^PS(55,DFN,"IV",PSJORD,0)) Q:A=""
45 .. S PSSTART=$P(A,"^",2),PSSTOP=$P(A,"^",3),PSSTATUS=$P(A,"^",17)
46 .. I PSSTOP]"",$D(^PS(55,"AIV",PSSTOP,DFN,PSJORD)) Q
47 .. K DR S DIE="^PS(55,"_DFN_",""IV"",",DA=PSJORD,DA(1)=DFN,DR=".02////^S X=PSSTART;.03////^S X=PSSTOP;100////S X=PSSTATUS"
48 .. D ^DIE
49 .. S ^XTMP("PSOPOST7",$J,"IV",DFN,PSJORD)="" K DIE,DR,DA
50MAIL ;
51 N CNT
52 D NOW^%DTC S PSOTIMEB=%
53 S Y=$G(^XTMP("PSOTIMEX","START")) D DD^%DT S PSOTIMEA=Y
54 S Y=$G(PSOTIMEB) D DD^%DT S PSOTIMEB=Y
55 S XMDUZ="Patch PSO*7*115",XMY(DUZ)="",XMSUB="PHARMACY PATIENT File (#55) search for missing entries"
56 K PSOTEXT S PSOTEXT(1)="Patch PSO*7*115 PHARMACY PATIENT File (#55) search and clean-up is complete.",PSOTEXT(2)="It started on "_$G(PSOTIMEA)_".",PSOTEXT(3)="It ended on "_$G(PSOTIMEB)_"."
57 S PSOTEXT(4)=" "
58 S PSOTEXT(5)=PSOCTP_" patients had missing ""P"" cross-references"_$S(PSOCTP>0:" and have been reset.",1:".")
59 S PSOTEXT(6)=PSOCTPA_" ^PS(55,PSODFN,""P"",""A"" cross-references were missing"_$S(PSOCTPA>0:" and have been reset.",1:".")
60 S PSOTEXT(7)=" "
61 S CNT=7
62 I PSOCTP S CNT=CNT+1,PSOTEXT(CNT)="The global ^XTMP(""PSOPOST7"","_$J_",PSODFN,ISSUE DATE,RXIEN) contains" D
63 .S CNT=CNT+1,PSOTEXT(CNT)="the missing ""P"" cross-reference entries. "_"("_$J_" is the job number.)"
64 S CNT=CNT+1,PSOTEXT(CNT)=" "
65 I PSOCTPA S CNT=CNT+1,PSOTEXT(CNT)="The global ^XTMP(""PSOPOST7"","_$J_",PSODFN,""P,A"",EXP. DATE,RXIEN) contains" D
66 .S CNT=CNT+1,PSOTEXT(CNT)="the missing ""P"",""A"" cross-reference entries. "_"("_$J_" is the job number.)"
67 I $D(^XTMP("PSOPOST7",$J,"UD")) D
68 . S CNT=CNT+1,PSOTEXT(CNT)="The global ^XTMP(""PSOPOST7"","_$J_",""UD"",DFN,PSJORD) contains"
69 . S CNT=CNT+1,PSOTEXT(CNT)="the unit dose orders missing stop dates."
70 I $D(^XTMP("PSOPOST7",$J,"IV")) D
71 . S CNT=CNT+1,PSOTEXT(CNT)="The global ^XTMP(""PSOPOST7"","_$J_",""IV"",DFN,PSJORD) contains"
72 . S CNT=CNT+1,PSOTEXT(CNT)="the IV orders missing stop dates."
73 S XMTEXT="PSOTEXT(" N DIFROM D ^XMD
74 K PSOTIMEA,PSOTIMEB,XMDUZ,XMSUB,PSOTEXT,XMTEXT,PSODT2
75 L -^XTMP("PSOPOST7")
76 S:$D(ZTQUEUED) ZTREQ="@"
77 Q
78 ;
79PS55P ; CHECK FOR MISSING "P" CROSS=REFERENCES
80 N PSOSQ
81 S PSOSQ=0 F S PSOSQ=$O(^PS(55,PSODFN,"P",PSOSQ)) Q:'PSOSQ I $G(^PS(55,PSODFN,"P",PSOSQ,0))=RXP Q
82 I PSOSQ Q
83 S ^XTMP("PSOPOST7",$J,PSODFN,PSODT,RXP)=""
84 Q
85 ;
86PS55PA ; CHECK FOR MISSING "P","A" CROSS-REFERENCES
87 N PSODT
88 S PSODT="" F S PSODT=$O(^PS(55,PSODFN,"P","A",PSODT)) Q:'PSODT I $D(^PS(55,PSODFN,"P","A",PSODT,RXP)) Q
89 I 'PSODT D
90 . N PSOEXP
91 . S PSOEXP=$P($G(^PSRX(RXP,2)),"^",6) I PSOEXP="" S PSOEXP=$P($G(^PSRX(RXP,3)),"^",5)
92 .I PSOEXP="" Q
93 .S ^XTMP("PSOPOST7",$J,PSODFN,"P,A",PSOEXP,RXP)=""
94 .D CHKPS
95 .S ^PS(55,PSODFN,"P","A",PSOEXP,RXP)="",PSOCTPA=PSOCTPA+1
96 Q
97 ;
98CHKPS ; SEE IF ^PS(55,PSODFN EXISTS - IF NOT SET TOP LEVEL AT LEAST
99 I '$D(^PS(55,PSODFN,0)) S ^PS(55,PSODFN,0)=PSODFN_"^^^^^2"
100 Q
101 ;
102RESET ; RESET "P" CROSS-REFERENCE BY BUILDING ^TMP GLOBAL IN ISSUE DATE SEQUENCE FOR ALL ENTRIES, THEN RESETTING THE "P" SUBSCRIPT
103 N PSOIDT,PSOSQ,CNT
104 S PSODFN="" F S PSODFN=$O(^XTMP("PSOPOST7",$J,PSODFN)) Q:'PSODFN S PSOCTP=PSOCTP+1 D
105 .K ^TMP("PSOPOST7",$J)
106 .S CNT=0
107 .I '$O(^XTMP("PSOPOST7",$J,PSODFN,"")) Q ; quit if only "P,A" entries
108 .L +^PS(55,PSODFN):$S(+$G(^DD("DILOCKTM"))>0:+^DD("DILOCKTM"),1:3)
109 .S PSODT="" F S PSODT=$O(^XTMP("PSOPOST7",$J,PSODFN,PSODT)) Q:'PSODT S RXP="" F S RXP=$O(^XTMP("PSOPOST7",$J,PSODFN,PSODT,RXP)) Q:'RXP D
110 ..S PSOIDT=$P($G(^PSRX(RXP,0)),"^",13) I PSOIDT'="" I '$D(^TMP("PSOPOST7",$J,PSOIDT,RXP)) S ^TMP("PSOPOST7",$J,PSOIDT,RXP)="",CNT=CNT+1
111 .S PSOSQ=0 F S PSOSQ=$O(^PS(55,PSODFN,"P",PSOSQ)) Q:'PSOSQ D ; NOW ADD ALL EXISTING ENRIES TO ^TMP GLOBAL
112 ..S RXP=$G(^PS(55,PSODFN,"P",PSOSQ,0)) I RXP="" Q
113 ..S PSOIDT=$P($G(^PSRX(RXP,0)),"^",13) I PSOIDT'="" I '$D(^TMP("PSOPOST7",$J,PSOIDT,RXP)) S ^TMP("PSOPOST7",$J,PSOIDT,RXP)="",CNT=CNT+1
114 .I $O(^PS(55,PSODFN,"P",CNT)) D
115 ..S PSOSQ=CNT F S PSOSQ=$O(^PS(55,PSODFN,"P",PSOSQ)) Q:'PSOSQ K ^PS(55,PSODFN,"P",PSOSQ) ; REMOVE SEQUENCE NUMBERS THAT ARE GREATER THAN THE NUMBER OF "P" ENTRIES
116 .S CNT=0,PSOIDT="" F S PSOIDT=$O(^TMP("PSOPOST7",$J,PSOIDT)) Q:'PSOIDT S RXP="" F S RXP=$O(^TMP("PSOPOST7",$J,PSOIDT,RXP)) Q:'RXP S CNT=CNT+1,^PS(55,PSODFN,"P",CNT,0)=RXP
117 .I CNT>0 S ^PS(55,PSODFN,"P",0)="^55.03PA^"_CNT_"^"_CNT
118 .L -^PS(55,PSODFN)
119 K ^TMP("PSOPOST7",$J)
120 Q
121 ;
Note: See TracBrowser for help on using the repository browser.