source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/OR3CONV1.m

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

initial load of FOIAVistA 6/30/08 version

File size: 6.0 KB
Line 
1OR3CONV1 ;SLC/MLI-Conversion utilities and cleanup ;8/2/97 [5/25/99 9:33am]
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**14,40**;Dec 17, 1997
3 ;
4 ; Continuation calls from OR3CONV - used by OE/RR version 3 conversion
5 ;
6 ; Utilities for site to call:
7 ; RESTART - if process stopped for any reason, this can be used
8 ; to restart the background portion of the conversion.
9 ;
10 ; STATUS - display the status of the conversion via TaskMan and
11 ; via OE/RR.
12 ;
13STOP ; entry point to stop conversion cleanly
14 N X
15 S X=$G(^ORD(100.99,1,"CONV"))
16 I +X W !,"The conversion has already run to completion." Q
17 I '$P(X,"^",6) W !,"The background job conversion has not yet started." Q
18 D STATUS
19 I $$RUSURE("stop") D SET^OR3CONV(11,1)
20 Q
21 ;
22RESTART ; entry point to restart conversion
23 N X
24 S X=$$CHECK()
25 I X]"" D Q
26 . W !,"You can not use the RESTART call at this time."
27 . W !,X
28 . W !!,"Call STATUS^OR3CONV1 to get current status of conversion."
29 D STATUS
30 I $$RUSURE("restart") D
31 . S ZTSAVE("ORESTART")=$P(^ORD(100.99,1,"CONV"),"^",9)
32 . D QUEUE^OR3CONV
33 Q
34 ;
35CHECK() ; check status to see if restart should be allowed
36 N X
37 S X=$G(^ORD(100.99,1,"CONV"))
38 I +X Q "The conversion has already run to completion."
39 I '$P(X,"^",6) Q "The background job conversion has not yet started."
40 S X=+$P(X,"^",10) I X S X=$$ZTSKCHK(X) I '$P(X,"^",2) Q $P(X,"^",1)
41 Q ""
42 ;
43RUSURE(TEXT) ; return 1 if yes, 0 otherwise
44 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
45 S DIR(0)="YA",DIR("B")="No"
46 S DIR("A")="Are you sure you want to "_TEXT_" the conversion? "
47 D ^DIR
48 Q +Y
49 ;
50STATUS ; get status of conversion
51 N STAGE,X
52 S X=$G(^ORD(100.99,1,"CONV"))
53 I +X W !,"The conversion has already completed!" Q
54 I $P(X,"^",1)="" W !,"The conversion has not yet started." Q
55 I $P(X,"^",11) W !,"The background job was requested to stop." Q
56 I '$P(X,"^",6),'$P(X,"^",10) D Q
57 . W !,"The background conversion of patient orders has not"
58 . W !,"started yet. This process is queued to run by the post-"
59 . W !,"installation process of CPRS. It has not yet been queued."
60 I $P(X,"^",10) D Q
61 . W !,"The background conversion of patient orders is running."
62 . W !,"The task number assigned to the conversion was ",$P(X,"^",10),"."
63 . W !,"The following is the status of the process according to TaskMan:"
64 . W !?5,$P($$ZTSKCHK($P(X,"^",10)),"^",1)
65 . W !
66 . S STAGE=$$STAGE($P(X,"^",8))
67 . I +STAGE=0 D Q
68 . . W !,"The background job is currently populating the list of"
69 . . W !,"patients that will need to be processed by the conversion."
70 . . W !,"Last DFN populated: ",$O(^ORD(100.99,1,"PTCONV","A"),-1)
71 . W !,"The background conversion is currently on stage ",+STAGE,"."
72 . W !,"This stage converts ",$S(STAGE<7:"patients who ",1:""),$P(STAGE,"^",2),"."
73 . I $P(X,"^",9) D
74 . . W !,"It last completed processing "
75 . . W $P(STAGE,"^",3)," ",$P(X,"^",9),"."
76 . W !!,"So far, orders for ",+$P(X,"^",12)," patients have converted."
77 . W !,"There are currently ",+$P(^ORD(100.99,1,"PTCONV",0),"^",4)," patients left to process."
78 . I +STAGE'=1 Q ; show more info for inpatients
79 . W !!,"Patients on ward ",$P(X,"^",4)," are currently being processed."
80 . W !,"The last patient to be converted was DFN #",$P(X,"^",5),"."
81 Q
82 ;
83ZTSKCHK(ZTSK) ; check status of task via TaskMan utilities
84 ; return message^flag where flag is 1 to allow requeue...0 otherwise
85 D STAT^%ZTLOAD
86 Q $P($T(ZTSKMSG+ZTSK(1)),";;",2)
87 ;
88ZTSKMSG ;;Unable to find task on current volume set^1
89 ;;Task is scheduled and waiting to run^0
90 ;;The task is running^0
91 ;;The task completed^1
92 ;;The task was created without being scheduled^0
93 ;;The process stopped for some reason^1
94 ;;Unable to obtain status from TaskMan^1
95 ;
96STAGE(STAGE) ; return text of what stage does
97 Q $P($T(STAGETXT+STAGE),";;",2)
98 ;
99 ; stages - number^text^up to text
100STAGETXT ;;0^populating list of patients to convert
101 ;;1^are current inpatients^ward
102 ;;2^have future scheduled admissions on file^scheduled admission date
103 ;;3^have waiting list file entries^DFN
104 ;;4^have discharges within last 4 weeks^discharge date
105 ;;5^have appointments in last 4 or next 4 weeks^hospital location
106 ;;6^have not already been converted^DFN
107 ;;7^orders not associated with PATIENT file entries^variable pointer
108 ;
109CLEANUP ; conversion is completed
110 N X
111 I '$$FINALCHK() D ERROR Q
112 D KILL^OR3C101,REQUEUE^ORMTIME(1)
113 D BADNAMES^PSJIPST3
114 D MAIL
115 Q
116 ;
117FINALCHK() ; check to see if every patient converted
118 N DFN,ERROR
119 S ERROR=1
120 F DFN=0:0 S DFN=$O(^ORD(100.99,1,"PTCONV",DFN)) Q:'DFN D Q:ERROR
121 . S ERROR=$$CONVERT^OR3CONV(DFN,1) ; try again to convert
122 . I '$$PTDONE^OR3CONV(DFN) S ERROR=0
123 Q ERROR
124 ;
125MAIL ; send e-mail that the conversion completed
126 N COUNT,X
127 S COUNT=0,X=$G(^ORD(100.99,1,"CONV"))
128 D LINE("The orders conversion has completed")
129 D LINE(" ")
130 D LINE("The conversion was first started: "_$$FMTE^XLFDT($P(X,"^",6)))
131 D LINE("It ran to completion: "_$$FMTE^XLFDT($P(X,"^",7)))
132 D SEND("OE/RR version 3.0 conversion complete")
133 Q
134 ;
135ERROR ; create mail message if unconverted patients found
136 N COUNT
137 S COUNT=0
138 D LINE("A problem was encountered in the OE/RR conversion. After")
139 D LINE("going through all patients, it was still unable to convert")
140 D LINE("orders for some patients. Please contact the national")
141 D LINE("customer support help desk for further assistance.")
142 D SEND("OE/RR version 3.0 conversion encountered problem")
143 Q
144 ;
145LINE(TEXT) ; store data in array for mail message
146 S COUNT=COUNT+1
147 S ORTEXT(COUNT)=TEXT
148 Q
149 ;
150SEND(SUBJECT) ; define rest of XM variables and fire message off
151 N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
152 S XMSUB=SUBJECT,XMTEXT="ORTEXT("
153 S XMDUZ="OE/RR CONVERSION"
154 F I="G.CPRS INSTALLATION@ISC-SLC.VA.GOV",DUZ S XMY(I)=""
155 D ^XMD
156 Q
157 ;
158PTCONV ; populate OR3 PATIENTS TO CONVERT multiple...hard set for speed
159 N COUNT,DFN,LAST
160 S COUNT=0,LAST=""
161 F DFN=0:0 S DFN=$O(^DPT(DFN)) Q:'DFN!(DFN'=+DFN) I $D(^(DFN,0)) D
162 . S LAST=DFN,COUNT=COUNT+1
163 . I $D(^ORD(100.99,1,"PTCONV",DFN,0)) Q
164 . S ^ORD(100.99,1,"PTCONV",DFN,0)=DFN,^ORD(100.99,1,"PTCONV","B",DFN,DFN)=""
165 S ^ORD(100.99,1,"PTCONV",0)="^100.9903PA^"_LAST_"^"_COUNT
166 Q
Note: See TracBrowser for help on using the repository browser.