| 1 | MDRPCOG ; HOIFO/DP - CP Gateway ; [01-09-2003 15:20]
|
---|
| 2 | ;;1.0;CLINICAL PROCEDURES;;Apr 01, 2004
|
---|
| 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 | ;
|
---|
| 12 | CLEANUP ; [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 | ;
|
---|
| 25 | DONE ; [Procedure] Done processing, Mark study status
|
---|
| 26 | S MDFDA(703.1,+DATA_",",.09)=$G(P1,"U")
|
---|
| 27 | D FILE^DIE("","MDFDA")
|
---|
| 28 | Q
|
---|
| 29 | ;
|
---|
| 30 | GETATT ; [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 | ;
|
---|
| 37 | GETOLD ; [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 | ;
|
---|
| 54 | GETPAR ; [Procedure] Get a parameter value for an RPC Call
|
---|
| 55 | S @RESULTS@(0)=$$PARVAL(DATA)
|
---|
| 56 | Q
|
---|
| 57 | ;
|
---|
| 58 | GETTXT ; [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 | ;
|
---|
| 66 | NEXT ; [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 | ;
|
---|
| 71 | PARVAL(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 | ;
|
---|
| 77 | POLL ; [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 | ;
|
---|
| 85 | POLLER(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 | ;
|
---|
| 100 | RPC(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 | ;
|
---|
| 118 | SETFILE ; [Procedure] Set filename of new attachment
|
---|
| 119 | S MDFDA(703.11,$P(DATA,U,1),.02)=$P(DATA,U,2)
|
---|
| 120 | D FILE^DIE("","MDFDA")
|
---|
| 121 | Q
|
---|
| 122 | ;
|
---|
| 123 | SETPAR(INSTANCE,VALUE) ; [Procedure] Set value into XPAR parameter
|
---|
| 124 | ; Input parameters
|
---|
| 125 | ; 1. INSTANCE [Literal/Required] Parameter Instance
|
---|
| 126 | ; 2. VALUE [Literal/Required] Parameter Value
|
---|
| 127 | ;
|
---|
| 128 | D EN^XPAR("SYS","MD GATEWAY",INSTANCE,VALUE)
|
---|
| 129 | Q
|
---|
| 130 | ;
|
---|
| 131 | START ; [Procedure] Can we begin?
|
---|
| 132 | ; Ensure only one Gateway per system by locking the phantom global node
|
---|
| 133 | L +^MDD("CPGATEWAY"):1
|
---|
| 134 | I '$T D STATUS S @RESULTS@(0)="-1^FAIL" Q
|
---|
| 135 | ; Clear all process settings
|
---|
| 136 | D NDEL^XPAR("SYS","MD GATEWAY")
|
---|
| 137 | S DATA=$G(DATA,"30^1000") ; Default poll interval and log entries
|
---|
| 138 | D SETPAR("Polling Interval",+$P(DATA,U,1))
|
---|
| 139 | D SETPAR("Maximum Log Entries",+$P(DATA,U,2))
|
---|
| 140 | D SETPAR("Job ID",$J)
|
---|
| 141 | D SETPAR("Started At",$$FMTE^XLFDT($$NOW^XLFDT))
|
---|
| 142 | D SETPAR("Started By",$$GET1^DIQ(200,DUZ_",",.01))
|
---|
| 143 | D GETENV^%ZOSV S MDENV=Y
|
---|
| 144 | D SETPAR("UCI",$P(MDENV,U,1))
|
---|
| 145 | D SETPAR("Volume",$P(MDENV,U,2))
|
---|
| 146 | D SETPAR("Node",$P(MDENV,U,3))
|
---|
| 147 | D SETNM^%ZOSV("CP Gateway")
|
---|
| 148 | S @RESULTS@(0)="1^OK"
|
---|
| 149 | Q
|
---|
| 150 | ;
|
---|
| 151 | STATUS ; [Procedure] Return status of BP
|
---|
| 152 | D GETLST^XPAR(.MDRET,"SYS","MD GATEWAY","Q")
|
---|
| 153 | F X=0:0 S X=$O(MDRET(X)) Q:'X S @RESULTS@(X)=MDRET(X)
|
---|
| 154 | Q
|
---|
| 155 | ;
|
---|
| 156 | STOP ; [Procedure] Flag client to stop via cal to POLL
|
---|
| 157 | D SETPAR("Shutdown Flag","Yes")
|
---|
| 158 | Q
|
---|
| 159 | ;
|
---|
| 160 | XFERDIR ; [Procedure] Return Imaging xfer directory
|
---|
| 161 | S @RESULTS@(0)=$$GET^XPAR("SYS","MD IMAGING XFER")
|
---|
| 162 | Q
|
---|
| 163 | ;
|
---|
| 164 | CHECK(MDRI) ; Check if Upload Value and Upload Text has already been purged.
|
---|
| 165 | N MDFLG S MDFLG=0
|
---|
| 166 | F X=0:0 S X=$O(^MDD(703.1,MDRI,.1,X)) Q:'X D Q:MDFLG
|
---|
| 167 | .S:$G(^MDD(703.1,MDRI,.1,X,.1))]"" MDFLG=1
|
---|
| 168 | .S:$O(^MDD(703.1,MDRI,.1,X,.2,0)) MDFLG=1
|
---|
| 169 | Q MDFLG
|
---|