source: FOIAVistA/trunk/r/CLINICAL_PROCEDURES-MD/MDRPCOG.m@ 1352

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

initial load of FOIAVistA 6/30/08 version

File size: 5.8 KB
Line 
1MDRPCOG ; HOIFO/DP - CP Gateway ; [01-09-2003 15:20]
2 ;;1.0;CLINICAL PROCEDURES;**6**;Apr 01, 2004;Build 102
3 ; Description:
4 ; This is the main routine that manages the CLINICAL PROCEDURES Gateway functions.
5 ; Access to these functions is controlled via the MD GATEWAY RPC.
6 ;
7 ; Integration Agreements:
8 ; IA# 10097 [Supported] %ZOSV calls
9 ; IA# 10103 [Supported] Calls to XLFDT
10 ; IA# 2263 [Supported] Calls to XPAR
11 ;
12CLEANUP ; [Procedure] Cleanup a past results report
13 F X=0:0 S X=$O(^MDD(703.1,DATA,.1,X)) Q:'X D
14 .S:$G(^MDD(703.1,DATA,.1,X,.1))]"" MDFDA(703.11,X_","_DATA_",",.1)="@"
15 .S:$O(^MDD(703.1,DATA,.1,X,.2,0)) MDFDA(703.11,X_","_DATA_",",.2)="@"
16 D:$D(MDFDA) FILE^DIE("K","MDFDA","MDERR")
17 I $D(MDERR) D ERROR^MDRPCU(RESULTS,.MDERR) Q
18 ; Manual cleanup of the empty UNC nodes and WP root
19 F X=0:0 S X=$O(^MDD(703.1,DATA,.1,X)) Q:'X D
20 .K ^MDD(703.1,DATA,.1,X,.1)
21 .K ^MDD(703.1,DATA,.1,X,.2)
22 S @RESULTS@(0)="1^Item purged"
23 Q
24 ;
25DONE ; [Procedure] Done processing, Mark study status
26 S MDFDA(703.1,+DATA_",",.09)=$G(P1,"U")
27 D FILE^DIE("","MDFDA")
28 Q
29 ;
30GETATT ; [Procedure] Get attachments for study
31 F X=0:0 S X=$O(^MDD(703.1,+DATA,.1,X)) Q:'X D
32 .S Y=+$O(@RESULTS@(""),-1)+1
33 .S @RESULTS@(Y)="703.11;"_X_U_^MDD(703.1,+DATA,.1,X,0)
34 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
35 Q
36 ;
37GETOLD ; [Procedure] Returns old results by date
38 ; Variables:
39 ; LOGDATE: [Private] Loop variable
40 ; STOPDATE: [Private] Date to stop retrieving entries
41 ;
42 ; New private variables
43 NEW LOGDATE,STOPDATE,MDX
44 S LOGDATE=+DATA,STOPDATE=+$P(DATA,U,2)+.2359
45 F S LOGDATE=$O(^MDD(703.1,"ADTP",LOGDATE)) W !,"-->",LOGDATE Q:'LOGDATE!(LOGDATE>STOPDATE) D Q:Y>50
46 .F MDX=0:0 S MDX=$O(^MDD(703.1,"ADTP",LOGDATE,MDX)) Q:'MDX D
47 ..I '$$CHECK(MDX) Q
48 ..S Y=$O(@RESULTS@(""),-1)+1
49 ..S @RESULTS@(Y)="703.1;"_MDX_U_$G(^MDD(703.1,MDX,0))
50 S:'LOGDATE!(LOGDATE>STOPDATE) LOGDATE=STOPDATE
51 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)_U_LOGDATE_U_$$FMTE^XLFDT(LOGDATE)
52 Q
53 ;
54GETPAR ; [Procedure] Get a parameter value for an RPC Call
55 S @RESULTS@(0)=$$PARVAL(DATA)
56 Q
57 ;
58GETTXT ; [Procedure] Get attachment text for processing
59 N X,STUDY,ATT
60 S X=0,STUDY=$P(DATA,",",2),ATT=+DATA
61 I '$O(^MDD(703.1,STUDY,.1,ATT,.2,0)) S @RESULTS@(0)="-1^No Data" Q
62 F S X=$O(^MDD(703.1,STUDY,.1,ATT,.2,X)) Q:'X S @RESULTS@(X)=^(X,0)
63 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
64 Q
65 ;
66NEXT ; [Procedure] Get the next study to process
67 S Y=+$O(^MDD(703.1,"ASTATUS","P",$G(DATA)))
68 S @RESULTS@(0)=$S($D(^MDD(703.1,Y,0)):"703.1;"_Y_U_^MDD(703.1,Y,0),1:0)
69 Q
70 ;
71PARVAL(INSTANCE) ; [Procedure] Extrinsic get of parameter values
72 ; Input parameters
73 ; 1. INSTANCE [Literal/Required] XPAR instance
74 ;
75 Q $$GET^XPAR("SYS","MD GATEWAY",INSTANCE)
76 ;
77POLL ; [Procedure] Returns server time and flag for studies to process
78 I $$PARVAL("Shutdown Flag")]"" D Q
79 .S @RESULTS@(0)="-1^SHUTDOWN"
80 .D SETPAR("Shutdown Flag","")
81 S @RESULTS@(0)=$$FMTE^XLFDT($$NOW^XLFDT)
82 S @RESULTS@(1)=$D(^MDD(703.1,"ASTATUS","P"))
83 Q
84 ;
85POLLER(RESULTS) ; [Procedure] Non-Disk activity poller
86 ; With the exception of a shutdown request pending, this stand alone RPC will operate
87 ; without creating any disk activity and not crash during backup operations on the main
88 ; VistA server.
89 ;
90 ; Input parameters
91 ; 1. RESULTS [Reference/Required]
92 ;
93 I $$PARVAL("Shutdown Flag")]"" D Q
94 .S RESULTS(0)="-1^SHUTDOWN"
95 .D SETPAR("Shutdown Flag","")
96 S RESULTS(0)=$$FMTE^XLFDT($$NOW^XLFDT)
97 S RESULTS(1)=$D(^MDD(703.1,"ASTATUS","P"))
98 Q
99 ;
100RPC(RESULTS,OPTION,DATA,P1) ; [Procedure]
101 ; Input parameters
102 ; 1. RESULTS [Literal/Required] RPC Return Array
103 ; 2. OPTION [Literal/Required] Gateway Option to execute
104 ; 3. DATA [Literal/Required] Other information
105 ; 4. P1 [Literal/Required] Overflow variable
106 ;
107 ; Variables:
108 ; MDENV: [Private] Server environment variable
109 ; MDERR: [Private] Fileman return array
110 ; MDFDA: [Private] Fileman FDA
111 ;
112 ; New private variables
113 NEW MDENV,MDERR,MDFDA
114 S RESULTS=$NA(^TMP("MDRPCOB",$J)) K @RESULTS
115 D @OPTION
116 Q
117 ;
118RUNNING ; [Procedure] Returns 0/1 and message on running status
119 ; Note: If lock CAN be obtained, then gateway is NOT running
120 L +^MDD("CPGATEWAY"):1 E S @RESULTS@(0)="1^RUNNING" Q
121 L -(^MDD("CPGATEWAY")) S @RESULTS@(0)="0^NOT RUNNING"
122 Q
123 ;
124SETFILE ; [Procedure] Set filename of new attachment
125 S MDFDA(703.11,$P(DATA,U,1),.02)=$P(DATA,U,2)
126 D FILE^DIE("","MDFDA")
127 Q
128 ;
129SETPAR(INSTANCE,VALUE) ; [Procedure] Set value into XPAR parameter
130 ; Input parameters
131 ; 1. INSTANCE [Literal/Required] Parameter Instance
132 ; 2. VALUE [Literal/Required] Parameter Value
133 ;
134 D EN^XPAR("SYS","MD GATEWAY",INSTANCE,VALUE)
135 Q
136 ;
137START ; [Procedure] Can we begin?
138 ; Ensure only one Gateway per system by locking the phantom global node
139 L +^MDD("CPGATEWAY"):1
140 I '$T D STATUS S @RESULTS@(0)="-1^FAIL" Q
141 ; Clear all process settings
142 D NDEL^XPAR("SYS","MD GATEWAY")
143 S DATA=$G(DATA,"30^1000") ; Default poll interval and log entries
144 D SETPAR("Polling Interval",+$P(DATA,U,1))
145 D SETPAR("Maximum Log Entries",+$P(DATA,U,2))
146 D SETPAR("Job ID",$J)
147 D SETPAR("Started At",$$FMTE^XLFDT($$NOW^XLFDT))
148 D SETPAR("Started By",$$GET1^DIQ(200,DUZ_",",.01))
149 D GETENV^%ZOSV S MDENV=Y
150 D SETPAR("UCI",$P(MDENV,U,1))
151 D SETPAR("Volume",$P(MDENV,U,2))
152 D SETPAR("Node",$P(MDENV,U,3))
153 D SETNM^%ZOSV("CP Gateway")
154 S @RESULTS@(0)="1^OK"
155 Q
156 ;
157STATUS ; [Procedure] Return status of BP
158 D GETLST^XPAR(.MDRET,"SYS","MD GATEWAY","Q")
159 F X=0:0 S X=$O(MDRET(X)) Q:'X S @RESULTS@(X)=MDRET(X)
160 Q
161 ;
162STOP ; [Procedure] Flag client to stop via cal to POLL
163 D SETPAR("Shutdown Flag","Yes")
164 Q
165 ;
166XFERDIR ; [Procedure] Return Imaging xfer directory
167 S @RESULTS@(0)=$$GET^XPAR("SYS","MD IMAGING XFER")
168 Q
169 ;
170CHECK(MDRI) ; Check if Upload Value and Upload Text has already been purged.
171 N MDFLG S MDFLG=0
172 F X=0:0 S X=$O(^MDD(703.1,MDRI,.1,X)) Q:'X D Q:MDFLG
173 .S:$G(^MDD(703.1,MDRI,.1,X,.1))]"" MDFLG=1
174 .S:$O(^MDD(703.1,MDRI,.1,X,.2,0)) MDFLG=1
175 Q MDFLG
Note: See TracBrowser for help on using the repository browser.