ONCWEB2 ;ALBANY OIFO/RTK - VACCR WEB SERVICE ;Feb 14, 2024@14:22:22
;;2.2;ONCOLOGY;**19,20**;Aug 1,2022;Build 5
;
; SAC EXEMPTION 202408071458-03 : non-ANSI standard M code
;
Q
;
; COLLABORATIVE STAGE CLOUD SERVER CALLS
; MODIFIED FROM ONCWEB1
;
;
T3 ;Collaborative Stage call to HWSC
N RESPONSE,ONCHR,ONCSYS,ONCTMP S (ONCTMP,RESPONSE)=""
S ONCSYS=$$PROD^XUPROD() ;1=PROD, 0=PRE=PROD
K ^TMP("ONCSCRSP",$J),^TMP("ONCTBRSP",$J)
S ONCHR=$NA(^TMP($J,"ONCXML"))
S:'$D(ONCWEB) ONCWEB="ONCO WEB SERVER"
S:'$D(ONCSERV) ONCSERV="ONCO VACCR WEB SERVICE"
S TIME=$$HTE^XLFDT($H,7)
S TIME=$TR(TIME,"@","T")
S SITE=+$P($$SITE^VASITE(),"^",3)
S ONCHAND="OncoTrax Cloud xml Encryption"
;W !," Calling Web Service..."
;globalName must be cleaned before a case set-up & deleted after done posting
I $G(ONCCSRQT)="SCHEMA" N globalName S globalName=$NA(^TMP("ONCCSCMA",$J))
I $G(ONCCSRQT)="TABLE" N globalName S globalName=$NA(^TMP("ONCCSTBL",$J))
S RESPONSE=$$PPOST3(ONCHAND,$G(ONCHR),globalName)
I RESPONSE=0 S ONCTMP=^TMP($JOB,"OUT","EXCEPTION")
;RESPONSE = server message back
Q
PPOST3(ONCHAND,XML,globalName) ;POST request
; @DESC Sends an HTTP request to SERVER as a POST or GET
; @ONCHAND Handle to XML document
; @XML XML request as string
; @globalName the name of global to use
; @RESPONSE A handle to response XML document
; 1 for success, 0 for failure
N ONC,ONCERR,$ETRAP,$ESTACK,ONCFERR
S:'$D(ONCWEB) ONCWEB="ONCO WEB SERVER"
S:'$D(ONCSERV) ONCSERV="ONCO VACCR WEB SERVICE"
; Set error trap
S $ETRAP="D ERROR^ONCWEB1"
S ONC("server")=ONCWEB
S ONC("webserviceName")=ONCSERV
;
K ^TMP($JOB,"OUT","EXCEPTION")
; Get instance of client REST request object
;
S ONC("restObject")=$$GETREST^XOBWLIB(ONC("webserviceName"),ONC("server"))
;W !,"REST OBJECT= ",ONC("restObject")
I $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 Q 0
;
N xmlString S xmlString=""
I $G(ONCCSRQT)="SCHEMA" N XMLQUIT S XMLQUIT="^TMP(""ONCCSCMA"","_$J
I $G(ONCCSRQT)="TABLE" N XMLQUIT S XMLQUIT="^TMP(""ONCCSTBL"","_$J
F D Q:globalName'[XMLQUIT
. S xmlString=xmlString_$G(@globalName,"")
. S globalName=$Q(@globalName)
D ONC("restObject").EntityBody.Write(xmlString)
;
I $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 Q 0
; Execute HTTP Post method ($$POST^XOBWLIB) or Get method ($$GET^XOBWLIB)
I $G(ONCEXEC)="G" D
.;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/GetVersion"
.S:ONCSYS=0 ONC("path")="/ppd/api/RunEdit/GetVersion"
.;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/GetVersion"
.S:ONCSYS=1 ONC("path")="/prda/api/RunEdit/GetVersion"
.S ONC("Content-Type")="application/json"
.S ONC("restObject").ContentType="application/json"
.S ONC("postResult")=$$GET^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
I $G(ONCEXEC)="P" D
.I $G(ONCCSRQT)="SCHEMA" D
..;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
..S:ONCSYS=0 ONC("path")="/ppd/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
..;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
..S:ONCSYS=1 ONC("path")="/prda/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
.I $G(ONCCSRQT)="TABLE" D
..;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/VaccrProcessIsTableRecordComplete"
..S:ONCSYS=0 ONC("path")="/ppd/api/RunEdit/VaccrProcessIsTableRecordComplete"
..;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/VaccrProcessIsTableRecordComplete"
..S:ONCSYS=1 ONC("path")="/prda/api/RunEdit/VaccrProcessIsTableRecordComplete"
.S ONC("Content-Type")="application/xml"
.S ONC("restObject").ContentType="application/xml"
.S ONC("postResult")=$$POST^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
K ONCEXEC
;W !,"Post method...",!,"ERROR...= ",$G(ONCERR, "NONE")
;
N stream s stream=##class(%Stream.TmpCharacter).%New()
d stream.CopyFrom(ONC("restObject").HttpResponse.Data)
;
n result s result=""
N ONC1 S ONC1=1
f q:stream.AtEnd=1 d
. I $G(ONCCSRQT)="SCHEMA" S ^TMP("ONCSCRSP",$J,ONC1)=stream.ReadLine()
. I $G(ONCCSRQT)="TABLE" S ^TMP("ONCTBRSP",$J,ONC1)=stream.ReadLine()
. S ONC1=ONC1+1
I $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 Q 0
D:'ONC("postResult")
. S ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
. S ONC("result")=0
. Q
Q result
;
ERROR ;
; @DESC Handles error during request to DC SERVER via webservice.
; Depends on GLOBAL variable ONCERR to be set in previous call.
; @RETURNS Nothing. Value store in global.
N ERRARRAY
; Get error object from Error Object Factory
I $GET(ONCERR)="" SET ONCERR=$$EOFAC^XOBWLIB()
; Store the error object in the error array
D ERR2ARR^XOBWLIB(ONCERR,.ERRARRAY)
; Parse out the error text and store in global
S ^TMP($JOB,"OUT","EXCEPTION")=$$GETTEXT(.ERRARRAY)
; Set ecode to empty to return to calling function
S $ECODE=""
Q
;
GETTEXT(ERRARRAY) ;
; @DESC Gets the error text from the array
; @ERRARRAY Error array stores error in format defined by web service product.
; @RETURNS Error info as a single string
N ONC
; Loop through the text subscript of error array and concatenate
S ONC("errorText")=""
S ONC("I")=""
F S ONC("I")=$ORDER(ERRARRAY("text",ONC("I"))) QUIT:ONC("I")="" D
. SET ONC("errorText")=ONC("errorText")_ERRARRAY("text",ONC("I"))
. Q
Q ONC("errorText")
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCWEB2 5377 printed Nov 22, 2024@17:39:15 Page 2
ONCWEB2 ;ALBANY OIFO/RTK - VACCR WEB SERVICE ;Feb 14, 2024@14:22:22
+1 ;;2.2;ONCOLOGY;**19,20**;Aug 1,2022;Build 5
+2 ;
+3 ; SAC EXEMPTION 202408071458-03 : non-ANSI standard M code
+4 ;
+5 QUIT
+6 ;
+7 ; COLLABORATIVE STAGE CLOUD SERVER CALLS
+8 ; MODIFIED FROM ONCWEB1
+9 ;
+10 ;
T3 ;Collaborative Stage call to HWSC
+1 NEW RESPONSE,ONCHR,ONCSYS,ONCTMP
SET (ONCTMP,RESPONSE)=""
+2 ;1=PROD, 0=PRE=PROD
SET ONCSYS=$$PROD^XUPROD()
+3 KILL ^TMP("ONCSCRSP",$JOB),^TMP("ONCTBRSP",$JOB)
+4 SET ONCHR=$NAME(^TMP($JOB,"ONCXML"))
+5 if '$DATA(ONCWEB)
SET ONCWEB="ONCO WEB SERVER"
+6 if '$DATA(ONCSERV)
SET ONCSERV="ONCO VACCR WEB SERVICE"
+7 SET TIME=$$HTE^XLFDT($HOROLOG,7)
+8 SET TIME=$TRANSLATE(TIME,"@","T")
+9 SET SITE=+$PIECE($$SITE^VASITE(),"^",3)
+10 SET ONCHAND="OncoTrax Cloud xml Encryption"
+11 ;W !," Calling Web Service..."
+12 ;globalName must be cleaned before a case set-up & deleted after done posting
+13 IF $GET(ONCCSRQT)="SCHEMA"
NEW globalName
SET globalName=$NAME(^TMP("ONCCSCMA",$JOB))
+14 IF $GET(ONCCSRQT)="TABLE"
NEW globalName
SET globalName=$NAME(^TMP("ONCCSTBL",$JOB))
+15 SET RESPONSE=$$PPOST3(ONCHAND,$GET(ONCHR),globalName)
+16 IF RESPONSE=0
SET ONCTMP=^TMP($JOB,"OUT","EXCEPTION")
+17 ;RESPONSE = server message back
+18 QUIT
PPOST3(ONCHAND,XML,globalName) ;POST request
+1 ; @DESC Sends an HTTP request to SERVER as a POST or GET
+2 ; @ONCHAND Handle to XML document
+3 ; @XML XML request as string
+4 ; @globalName the name of global to use
+5 ; @RESPONSE A handle to response XML document
+6 ; 1 for success, 0 for failure
+7 NEW ONC,ONCERR,$ETRAP,$ESTACK,ONCFERR
+8 if '$DATA(ONCWEB)
SET ONCWEB="ONCO WEB SERVER"
+9 if '$DATA(ONCSERV)
SET ONCSERV="ONCO VACCR WEB SERVICE"
+10 ; Set error trap
+11 SET $ETRAP="D ERROR^ONCWEB1"
+12 SET ONC("server")=ONCWEB
+13 SET ONC("webserviceName")=ONCSERV
+14 ;
+15 KILL ^TMP($JOB,"OUT","EXCEPTION")
+16 ; Get instance of client REST request object
+17 ;
+18 SET ONC("restObject")=$$GETREST^XOBWLIB(ONC("webserviceName"),ONC("server"))
+19 ;W !,"REST OBJECT= ",ONC("restObject")
+20 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+21 ;
+22 NEW xmlString
SET xmlString=""
+23 IF $GET(ONCCSRQT)="SCHEMA"
NEW XMLQUIT
SET XMLQUIT="^TMP(""ONCCSCMA"","_$JOB
+24 IF $GET(ONCCSRQT)="TABLE"
NEW XMLQUIT
SET XMLQUIT="^TMP(""ONCCSTBL"","_$JOB
+25 FOR
Begin DoDot:1
+26 SET xmlString=xmlString_$GET(@globalName,"")
+27 SET globalName=$QUERY(@globalName)
End DoDot:1
if globalName'[XMLQUIT
QUIT
+28 DO ONC("restObject").EntityBody.Write(xmlString)
+29 ;
+30 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+31 ; Execute HTTP Post method ($$POST^XOBWLIB) or Get method ($$GET^XOBWLIB)
+32 IF $GET(ONCEXEC)="G"
Begin DoDot:1
+33 ;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/GetVersion"
+34 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/GetVersion"
+35 ;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/GetVersion"
+36 if ONCSYS=1
SET ONC("path")="/prda/api/RunEdit/GetVersion"
+37 SET ONC("Content-Type")="application/json"
+38 SET ONC("restObject").ContentType="application/json"
+39 SET ONC("postResult")=$$GET^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+40 IF $GET(ONCEXEC)="P"
Begin DoDot:1
+41 IF $GET(ONCCSRQT)="SCHEMA"
Begin DoDot:2
+42 ;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
+43 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
+44 ;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
+45 if ONCSYS=1
SET ONC("path")="/prda/api/RunEdit/VaccrProcessIsSchemaRecordComplete"
End DoDot:2
+46 IF $GET(ONCCSRQT)="TABLE"
Begin DoDot:2
+47 ;S:ONCSYS=0 ONC("path")="/development1/api/RunEdit/VaccrProcessIsTableRecordComplete"
+48 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/VaccrProcessIsTableRecordComplete"
+49 ;S:ONCSYS=1 ONC("path")="/development1/api/RunEdit/VaccrProcessIsTableRecordComplete"
+50 if ONCSYS=1
SET ONC("path")="/prda/api/RunEdit/VaccrProcessIsTableRecordComplete"
End DoDot:2
+51 SET ONC("Content-Type")="application/xml"
+52 SET ONC("restObject").ContentType="application/xml"
+53 SET ONC("postResult")=$$POST^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+54 KILL ONCEXEC
+55 ;W !,"Post method...",!,"ERROR...= ",$G(ONCERR, "NONE")
+56 ;
+57 NEW stream
SET stream=##class(%Stream.TmpCharacter).%New()
+58 DO stream.CopyFrom(ONC("restObject").HttpResponse.Data)
+59 ;
+60 NEW result
SET result=""
+61 NEW ONC1
SET ONC1=1
+62 FOR
if stream.AtEnd=1
QUIT
Begin DoDot:1
+63 IF $GET(ONCCSRQT)="SCHEMA"
SET ^TMP("ONCSCRSP",$JOB,ONC1)=stream.ReadLine()
+64 IF $GET(ONCCSRQT)="TABLE"
SET ^TMP("ONCTBRSP",$JOB,ONC1)=stream.ReadLine()
+65 SET ONC1=ONC1+1
End DoDot:1
+66 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+67 if 'ONC("postResult")
Begin DoDot:1
+68 SET ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
+69 SET ONC("result")=0
+70 QUIT
End DoDot:1
+71 QUIT result
+72 ;
ERROR ;
+1 ; @DESC Handles error during request to DC SERVER via webservice.
+2 ; Depends on GLOBAL variable ONCERR to be set in previous call.
+3 ; @RETURNS Nothing. Value store in global.
+4 NEW ERRARRAY
+5 ; Get error object from Error Object Factory
+6 IF $GET(ONCERR)=""
SET ONCERR=$$EOFAC^XOBWLIB()
+7 ; Store the error object in the error array
+8 DO ERR2ARR^XOBWLIB(ONCERR,.ERRARRAY)
+9 ; Parse out the error text and store in global
+10 SET ^TMP($JOB,"OUT","EXCEPTION")=$$GETTEXT(.ERRARRAY)
+11 ; Set ecode to empty to return to calling function
+12 SET $ECODE=""
+13 QUIT
+14 ;
GETTEXT(ERRARRAY) ;
+1 ; @DESC Gets the error text from the array
+2 ; @ERRARRAY Error array stores error in format defined by web service product.
+3 ; @RETURNS Error info as a single string
+4 NEW ONC
+5 ; Loop through the text subscript of error array and concatenate
+6 SET ONC("errorText")=""
+7 SET ONC("I")=""
+8 FOR
SET ONC("I")=$ORDER(ERRARRAY("text",ONC("I")))
if ONC("I")=""
QUIT
Begin DoDot:1
+9 SET ONC("errorText")=ONC("errorText")_ERRARRAY("text",ONC("I"))
+10 QUIT
End DoDot:1
+11 QUIT ONC("errorText")