ONCWEB1 ;ALBANY OIFO/RVD - VACCR WEB SERVICE ;Nov 4, 2022@14:22:22
;;2.2;ONCOLOGY;**16,19**;Aug 1,2022;Build 4
;
; SAC EXEMPTION 202302071746-02 : non-ANSI standard M code
;
Q
;
; EDITS CLOUD SERVER CALLS
;
T3 ;Edits call to HWSC
N RESPONSE,ONCHR,ONCSYS,ONCTMP S (ONCTMP,RESPONSE)=""
S ONCSYS=$$PROD^XUPROD() ;1=PROD, 0=PRE=PROD
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"
I $G(ONCEXEC)="P" W !," Calling Web Service..."
;globalName must be cleaned before a case set-up & deleted after done posting
N globalName S globalName=$NA(^TMP("ONC",$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"
S ONC("Ocp-Apim-Subscription-Key")="d27e1428f71e47239327d7e77e1439c6"
; 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=""
N XMLQUIT S XMLQUIT="^TMP(""ONC"","_$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")="/ppd/api/RunEdit/GetVersion"
.S:ONCSYS=1 ONC("path")="/prd/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
.S:ONCSYS=0 ONC("path")="/ppd/api/RunEdit/VaccrProcessCaseFile"
.S:ONCSYS=1 ONC("path")="/prd/api/RunEdit/VaccrProcessCaseFile"
.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
. S ^TMP("ONCSED01R",$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
;
TCS ;Collaborative Stage call to HWSC
N RESPONSE,ONCHR,ONCSYS,ONCTMP S (ONCTMP,RESPONSE)=""
S ONCSYS=$$PROD^XUPROD() ;1=PROD, 0=PRE=PROD
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 Calculate Collaborative Stage Cloud Server"
W !," Call Web Service to calculate CS..."
;globalName must be cleaned before a case set-up & deleted after done posting
N globalName S globalName=$NA(^TMP("ONCINPUT",$J))
S RESPONSE=$$PPOSTCS(ONCHAND,$G(ONCHR),globalName)
I RESPONSE=0 S ONCTMP=^TMP($JOB,"OUT","EXCEPTION")
;RESPONSE = server message back
Q
PPOSTCS(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=""
N XMLQUIT S XMLQUIT="^TMP(""ONCINPUT"","_$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")="/ppd/api/RunEdit/GetVersion"
.S:ONCSYS=1 ONC("path")="/prd/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
.S:ONCSYS=0 ONC("path")="/ppd/api/RunEdit/VaccrProcessCStageCalculate"
.S:ONCSYS=1 ONC("path")="/prd/api/RunEdit/VaccrProcessCStageCalculate"
.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
. S ^TMP("ONCCSRSP",$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[HONCWEB1 7378 printed Oct 16, 2024@18:29:52 Page 2
ONCWEB1 ;ALBANY OIFO/RVD - VACCR WEB SERVICE ;Nov 4, 2022@14:22:22
+1 ;;2.2;ONCOLOGY;**16,19**;Aug 1,2022;Build 4
+2 ;
+3 ; SAC EXEMPTION 202302071746-02 : non-ANSI standard M code
+4 ;
+5 QUIT
+6 ;
+7 ; EDITS CLOUD SERVER CALLS
+8 ;
T3 ;Edits call to HWSC
+1 NEW RESPONSE,ONCHR,ONCSYS,ONCTMP
SET (ONCTMP,RESPONSE)=""
+2 ;1=PROD, 0=PRE=PROD
SET ONCSYS=$$PROD^XUPROD()
+3 SET ONCHR=$NAME(^TMP($JOB,"ONCXML"))
+4 if '$DATA(ONCWEB)
SET ONCWEB="ONCO WEB SERVER"
+5 if '$DATA(ONCSERV)
SET ONCSERV="ONCO VACCR WEB SERVICE"
+6 SET TIME=$$HTE^XLFDT($HOROLOG,7)
+7 SET TIME=$TRANSLATE(TIME,"@","T")
+8 SET SITE=+$PIECE($$SITE^VASITE(),"^",3)
+9 SET ONCHAND="OncoTrax Cloud XML Encryption"
+10 IF $GET(ONCEXEC)="P"
WRITE !," Calling Web Service..."
+11 ;globalName must be cleaned before a case set-up & deleted after done posting
+12 NEW globalName
SET globalName=$NAME(^TMP("ONC",$JOB))
+13 SET RESPONSE=$$PPOST3(ONCHAND,$GET(ONCHR),globalName)
+14 IF RESPONSE=0
SET ONCTMP=^TMP($JOB,"OUT","EXCEPTION")
+15 ;RESPONSE = server message back
+16 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 ONC("Ocp-Apim-Subscription-Key")="d27e1428f71e47239327d7e77e1439c6"
+11 ; Set error trap
+12 SET $ETRAP="D ERROR^ONCWEB1"
+13 SET ONC("server")=ONCWEB
+14 SET ONC("webserviceName")=ONCSERV
+15 ;
+16 KILL ^TMP($JOB,"OUT","EXCEPTION")
+17 ; Get instance of client REST request object
+18 ;
+19 SET ONC("restObject")=$$GETREST^XOBWLIB(ONC("webserviceName"),ONC("server"))
+20 ;W !,"REST OBJECT= ",ONC("restObject")
+21 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+22 ;
+23 NEW xmlString
SET xmlString=""
+24 NEW XMLQUIT
SET XMLQUIT="^TMP(""ONC"","_$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 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/GetVersion"
+34 if ONCSYS=1
SET ONC("path")="/prd/api/RunEdit/GetVersion"
+35 SET ONC("Content-Type")="application/json"
+36 SET ONC("restObject").ContentType="application/json"
+37 SET ONC("postResult")=$$GET^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+38 IF $GET(ONCEXEC)="P"
Begin DoDot:1
+39 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/VaccrProcessCaseFile"
+40 if ONCSYS=1
SET ONC("path")="/prd/api/RunEdit/VaccrProcessCaseFile"
+41 SET ONC("Content-Type")="application/xml"
+42 SET ONC("restObject").ContentType="application/xml"
+43 SET ONC("postResult")=$$POST^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+44 KILL ONCEXEC
+45 ;W !,"Post method...",!,"ERROR...= ",$G(ONCERR, "NONE")
+46 ;
+47 NEW stream
SET stream=##class(%Stream.TmpCharacter).%New()
+48 DO stream.CopyFrom(ONC("restObject").HttpResponse.Data)
+49 ;
+50 NEW result
SET result=""
+51 NEW ONC1
SET ONC1=1
+52 FOR
if stream.AtEnd=1
QUIT
Begin DoDot:1
+53 SET ^TMP("ONCSED01R",$JOB,ONC1)=stream.ReadLine()
+54 SET ONC1=ONC1+1
End DoDot:1
+55 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+56 if 'ONC("postResult")
Begin DoDot:1
+57 SET ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
+58 SET ONC("result")=0
+59 QUIT
End DoDot:1
+60 QUIT result
+61 ;
TCS ;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 SET ONCHR=$NAME(^TMP($JOB,"ONCXML"))
+4 if '$DATA(ONCWEB)
SET ONCWEB="ONCO WEB SERVER"
+5 if '$DATA(ONCSERV)
SET ONCSERV="ONCO VACCR WEB SERVICE"
+6 SET TIME=$$HTE^XLFDT($HOROLOG,7)
+7 SET TIME=$TRANSLATE(TIME,"@","T")
+8 SET SITE=+$PIECE($$SITE^VASITE(),"^",3)
+9 SET ONCHAND="OncoTrax Calculate Collaborative Stage Cloud Server"
+10 WRITE !," Call Web Service to calculate CS..."
+11 ;globalName must be cleaned before a case set-up & deleted after done posting
+12 NEW globalName
SET globalName=$NAME(^TMP("ONCINPUT",$JOB))
+13 SET RESPONSE=$$PPOSTCS(ONCHAND,$GET(ONCHR),globalName)
+14 IF RESPONSE=0
SET ONCTMP=^TMP($JOB,"OUT","EXCEPTION")
+15 ;RESPONSE = server message back
+16 QUIT
PPOSTCS(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 NEW XMLQUIT
SET XMLQUIT="^TMP(""ONCINPUT"","_$JOB
+24 FOR
Begin DoDot:1
+25 SET xmlString=xmlString_$GET(@globalName,"")
+26 SET globalName=$QUERY(@globalName)
End DoDot:1
if globalName'[XMLQUIT
QUIT
+27 DO ONC("restObject").EntityBody.Write(xmlString)
+28 ;
+29 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+30 ; Execute HTTP Post method ($$POST^XOBWLIB) or Get method ($$GET^XOBWLIB)
+31 IF $GET(ONCEXEC)="G"
Begin DoDot:1
+32 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/GetVersion"
+33 if ONCSYS=1
SET ONC("path")="/prd/api/RunEdit/GetVersion"
+34 SET ONC("Content-Type")="application/json"
+35 SET ONC("restObject").ContentType="application/json"
+36 SET ONC("postResult")=$$GET^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+37 IF $GET(ONCEXEC)="P"
Begin DoDot:1
+38 if ONCSYS=0
SET ONC("path")="/ppd/api/RunEdit/VaccrProcessCStageCalculate"
+39 if ONCSYS=1
SET ONC("path")="/prd/api/RunEdit/VaccrProcessCStageCalculate"
+40 SET ONC("Content-Type")="application/xml"
+41 SET ONC("restObject").ContentType="application/xml"
+42 SET ONC("postResult")=$$POST^XOBWLIB(ONC("restObject"),ONC("path"),.ONCERR)
End DoDot:1
+43 KILL ONCEXEC
+44 ;W !,"Post method...",!,"ERROR...= ",$G(ONCERR, "NONE")
+45 ;
+46 NEW stream
SET stream=##class(%Stream.TmpCharacter).%New()
+47 DO stream.CopyFrom(ONC("restObject").HttpResponse.Data)
+48 ;
+49 NEW result
SET result=""
+50 NEW ONC1
SET ONC1=1
+51 FOR
if stream.AtEnd=1
QUIT
Begin DoDot:1
+52 SET ^TMP("ONCCSRSP",$JOB,ONC1)=stream.ReadLine()
+53 SET ONC1=ONC1+1
End DoDot:1
+54 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+55 if 'ONC("postResult")
Begin DoDot:1
+56 SET ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
+57 SET ONC("result")=0
+58 QUIT
End DoDot:1
+59 QUIT result
+60 ;
+61 ;
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")