source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCCVLOG.m@ 846

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

initial load of WorldVistAEHR

File size: 5.6 KB
Line 
1SCCVLOG ;ALB/RMO,TMP - CST/AST Log Utilities - Log Event; [ 04/05/95 8:39 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4UPDREC(SCLOG,SCIEN,SCCVT) ;Update CST/AST last entry and number of records
5 ; Input -- SCLOG CST/AST log IEN
6 ; SCIEN Last entry IEN
7 ; SCCVT 'AST' or 'CST' for type of template
8 ; Output -- None
9 N SCDATA,SCCVFL
10 S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
11 S SCDATA(1.01)=SCIEN ;last entry converted
12 S SCDATA(1.02)=$G(SCTOT(1.02)) ;number of records converted
13 S SCDATA(2.06)=$G(SCTOT(2.06)) ;number of records not converted
14 I $D(^SD(SCCVFL,+SCLOG,0)) D UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
15 Q
16 ;
17UPD(SCCVT,SCLOG,SCSTDT,SCENDT,SCOMBUL,SCTSK,SCVOL,SCACT) ;Update CST or AST log entry
18 ; Input -- SCCVT 'AST' or 'CST' for type of template
19 ; SCLOG CST or AST log IEN
20 ; SCSTDT Start date [optional]
21 ; SCENDT End date [optional]
22 ; SCOMBUL Bulletin upon completion [optional]
23 ; SCTSK Task # [optional]
24 ; SCVOL Volume set [optional]
25 ; SCACT Action [optional]
26 ; Output -- None
27 N SCDATA,SCCVFL
28 S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
29 I $G(SCACT) D HIS($$NOW^XLFDT,SCLOG,SCACT,"",SCCVFL,$G(SCTSK))
30 S:$G(SCSTDT) SCDATA(.03)=SCSTDT ;start date
31 S:$G(SCENDT) SCDATA(.04)=SCENDT ;end date
32 S:$G(SCOMBUL)'="" SCDATA(.06)=SCOMBUL ;bulletin upon completion
33 I $G(SCACT)=2,$P($G(^SD(SCCVFL,SCLOG,0)),U,8)'=3 D ;initialize fields when starting, but not on a restart
34 . S SCDATA(1.01)="@" ;last entry
35 . S SCDATA(1.02)=0 ;number of records
36 . S SCDATA(2.06)=0 ;number of records
37 S:$G(SCTSK)'="" SCDATA(1.03)=SCTSK ;task #
38 S:$G(SCVOL)'="" SCDATA(1.04)=SCVOL ;volume set
39 I $D(SCDATA) D UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
40 Q
41 ;
42HIS(SCEVDTM,SCLOG,SCACT,SCCVEVT,SCCVFL,SCTSK) ; CST/AST Log history
43 ; Input -- SCEVDTM Event date/time
44 ; SCLOG CST/AST log IEN
45 ; SCACT Action
46 ; SCCVEVT Last log status
47 ; SCCVFL 'AST' or 'CST' file # (404.98 or 404.99)
48 ; SCTSK task # [optional]
49 ; Output -- None
50 N C,SCACTD,SCCVEVTD,SCDATA,SCHIS,SCIENS,SCLOG0,Y
51 S SCHIS=+$O(^SD(SCCVFL,SCLOG,"E","AEV",SCEVDTM,SCACT,0))
52 G HISQ:SCHIS
53 S SCIENS="+1,"_SCLOG
54 S SCDATA(.01)=SCEVDTM ;event date/time
55 S SCDATA(.02)=$S(SCCVEVT'=3:SCACT,1:7) ;action
56 S SCLOG0=$G(^SD(SCCVFL,SCLOG,0))
57 S:$G(SCCVEVT)="" SCCVEVT=$S('$P(SCLOG0,U,9):$P(SCLOG0,U,5),1:3)
58 S:$G(SCCVEVT)'="" SCDATA(.03)=SCCVEVT ;event
59 IF '$G(SCTSK) N SCTSK S SCTSK=$P($G(^SD(SCCVFL,SCLOG,1)),U,3) ;task number
60 I SCTSK D ;task comment
61 . S SCACTD=$$LOW^XLFSTR($$EXPAND^SCCVDSP2(SCCVFL_"75",.02,SCACT))
62 . I $G(SCCVEVT)'="",SCCVEVT<3 D
63 . . S Y=$$EXPAND^SCCVDSP2(SCCVFL_"75",.03,SCCVEVT)
64 . . S SCCVEVTD=$E(Y,1)_$$LOW^XLFSTR($E(Y,2,$L(Y)))
65 . S:$G(SCCVEVT)<3 SCDATA(50,"WP",1)=SCCVEVTD_" "_SCACTD_" as task #"_SCTSK
66 . S:$G(SCCVEVT)=3 SCDATA(50,"WP",1)="Template canceled by user #: "_$G(DUZ)
67 . S SCDATA(50)=$NA(SCDATA(50,"WP"))
68 D ADD^SCCVDBU(SCCVFL_"75",SCIENS,.SCDATA)
69 I SCCVFL=404.98,"^3^5^"[(U_SCACT_U) D
70 . ;Update file with estimate totals
71 . I 'SCCVEVT,SCACT=5,$O(SCTOT(0)) D UPDTOTL^SCCVEGU1(SCLOG,.SCTOT)
72 . ;
73 . I $P($G(^SD(404.98,SCLOG,0)),U,6) D ;send bulletin
74 . . I SCCVEVT D ;convert if complete or stopped
75 . . . D SEND^SCCVLOG2(SCLOG,SCACT)
76 . . ELSE I SCACT=5 D ;estimate only when complete
77 . . . D MAILSUM^SCCVEGD0(SCLOG)
78HISQ Q
79 ;
80CHKACT(SCLOG,SCCVEVT,SCACT,SCCVT) ;Check log entry action for a specific log event
81 ; Input -- SCLOG CST/AST log IEN
82 ; SCCVEVT CST/AST event
83 ; SCACT Action
84 ; SCCVT 'AST' or 'CST' for type of template
85 ; Output -- 1=Found and 0=Not Found
86 N A,D,E,Y,SCCVFL
87 S (D,Y)=0
88 S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
89 F S D=$O(^SD(SCCVFL,SCLOG,"E","AEV",D)) Q:'D!(Y) D
90 . S E=""
91 . F E=$O(^SD(SCCVFL,SCLOG,"E","AEV",D,E)) Q:E=""!(Y) I E=SCCVEVT D
92 . . S A=0
93 . . F S A=$O(^SD(SCCVFL,SCLOG,"E","AEV",D,E,A)) Q:'A!(Y) I A=SCACT S Y=1
94 Q +$G(Y)
95 ;
96STOP(SCLOG,SCREQ,SCSTOPF) ;Stop conversion/estimate
97 ; Input -- SCLOG CST log IEN
98 ; SCREQ CST request IEN
99 ; SCSTOPF Force exit [optional]
100 ; Output -- SCSTOPF 1=Stopped and 0=Not stopped
101 N SCREQ0,SCLOG1,SCFORCEX
102 ;
103 ; -- force exit if calling routine says to
104 S SCFORCEX=+$G(SCSTOPF)
105 ;
106 ; -- force exit if too many errors have occurred
107 IF 'SCFORCEX,$G(SCCVMAXE),$G(SCCVERRH)>SCCVMAXE S SCFORCEX=1
108 ;
109 S SCSTOPF=0
110 ;
111 I +$$LSTACT(SCLOG)=5 G STOPQ ;already completed
112 S SCREQ0=$G(^SD(404.98,SCLOG,"R",SCREQ,0))
113 S SCLOG1=$G(^SD(404.98,SCLOG,1))
114 I $S(SCFORCEX:1,$$S^%ZTLOAD:1,$P(SCREQ0,U,2)=2:1,$P(SCREQ0,U,5):$P(SCREQ0,U,5)<$$NOW^XLFDT,1:0) D
115 . D UPD("CST",SCLOG,"","","","@","@",3)
116 . ;
117 I +$$LSTACT(SCLOG)=3 D
118 . S SCSTOPF=1
119 . ;
120 . ; stopping a running task
121 . I $D(ZTQUEUED) S ZTSTOP=1 Q
122 . ;
123 . ; -- kill/stop a pending task
124 . N ZTSK
125 . S ZTSK=$P(SCLOG1,U,3)
126 . ; -- get status
127 . IF ZTSK]"" D ISQED^%ZTLOAD
128 . ; -- kill task if task is pending
129 . IF $G(ZTSK(0)) D KILL^%ZTLOAD
130 . ;
131STOPQ Q
132 ;
133LSTACT(SCLOG) ;Last action taken on CST log entry
134 ; Input -- SCLOG CST log IEN
135 ; Output -- Action^Description
136 N SCACT,Y
137 S SCACT=$P($G(^SD(404.98,SCLOG,0)),U,7)
138 I $G(SCACT) S Y=SCACT_U_$$EXPAND^SCCVDSP2(404.9875,.02,SCACT)
139 Q $G(Y)
140 ;
141LSTEVT(SCLOG) ;Last event performed on CST log entry
142 ; Input -- SCLOG CST log IEN
143 ; Output -- event
144 N SCEVT
145 S SCEVT=$P($G(^SD(404.98,SCLOG,0)),U,5)
146 Q SCEVT
147 ;
148LSTREQ(SCLOG) ;Returns the # of the last request for a CST
149 ; Input -- SCLOG CST log IEN
150 ; Output -- Last request ien
151 ;
152 Q +$O(^SD(404.98,SCLOG,"R","A"),-1)
153 ;
Note: See TracBrowser for help on using the repository browser.