PSSHTTP ;WOIFO/AV - REENGINERING Sends XML Request to PEPS via HWSC ;09/20/07
;;1.0;PHARMACY DATA MANAGEMENT;**136,160**;9/30/97;Build 76
;
; @author - Alex Vazquez, Chris Flegel, Timothy Sabat, S Gordon
; @date - September 19, 2007
; @version - 1.0
;
QUIT
;;
PEPSPOST(DOCHAND,XML) ;
; @DESC Sends an HTTP request to PEPS as a POST
;
; @DOCHAND Handle to XML document
; @XML XML request as string
;
; @RETURNS A handle to response XML document
; 1 for success, 0 for failure
;
NEW PSS,PSSERR,$ETRAP,$ESTACK
;
; Set error trap
SET $ETRAP="DO ERROR^PSSHTTP"
;
SET PSS("server")="PEPS"
SET PSS("webserviceName")="ORDER_CHECKS"
SET PSS("path")="ordercheck"
;
SET PSS("parameterName")="xmlRequest"
SET PSS("parameterValue")=XML
;
; Get instance of client REST request object
SET PSS("restObject")=$$GETREST^XOBWLIB(PSS("webserviceName"),PSS("server"))
IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 QUIT 0
;
; Insert XML as parameter
DO PSS("restObject").InsertFormData(PSS("parameterName"),PSS("parameterValue"))
IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 QUIT 0
;
; Execute HTTP Post method
SET PSS("postResult")=$$POST^XOBWLIB(PSS("restObject"),PSS("path"),.PSSERR)
IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0 QUIT 0
;
DO:PSS("postResult")
. SET PSS("result")=##class(gov.va.med.pre.ws.XMLHandler).getHandleToXmlDoc(PSS("restObject").HttpResponse.Data, .DOCHAND)
. QUIT
;
DO:'PSS("postResult")
. SET ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
. SET PSS("result")=0
. QUIT
;
QUIT PSS("result")
;;
ERROR ;
; @DESC Handles error during request to PEPS via webservice.
;
; Depends on GLOBAL variable PSSERR to be set in previous call.
;
; @RETURNS Nothing. Value store in global.
;
NEW ERRARRAY
;
; Get error object from Error Object Factory
IF $GET(PSSERR)="" SET PSSERR=$$EOFAC^XOBWLIB()
; Store the error object in the error array
DO ERR2ARR^XOBWLIB(PSSERR,.ERRARRAY)
;
; Parse out the error text and store in global
SET ^TMP($JOB,"OUT","EXCEPTION")=$$GETTEXT(.ERRARRAY)
I $G(PSSFDBRT),$D(^TMP($JOB,"OUT","EXCEPTION")) S PSSOUT(0)="-1^"_^TMP($JOB,"OUT","EXCEPTION") K ^TMP($JOB,"OUT","EXCEPTION")
;
; Set ecode to empty to return to calling function
SET $ECODE=""
;
QUIT
;;
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
;
NEW PSS
;
; Loop through the text subscript of error array and concatenate
SET PSS("errorText")=""
SET PSS("I")=""
FOR SET PSS("I")=$ORDER(ERRARRAY("text",PSS("I"))) QUIT:PSS("I")="" DO
. SET PSS("errorText")=PSS("errorText")_ERRARRAY("text",PSS("I"))
. QUIT
;
QUIT PSS("errorText")
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSSHTTP 2851 printed Dec 13, 2024@02:32:03 Page 2
PSSHTTP ;WOIFO/AV - REENGINERING Sends XML Request to PEPS via HWSC ;09/20/07
+1 ;;1.0;PHARMACY DATA MANAGEMENT;**136,160**;9/30/97;Build 76
+2 ;
+3 ; @author - Alex Vazquez, Chris Flegel, Timothy Sabat, S Gordon
+4 ; @date - September 19, 2007
+5 ; @version - 1.0
+6 ;
+7 QUIT
+8 ;;
PEPSPOST(DOCHAND,XML) ;
+1 ; @DESC Sends an HTTP request to PEPS as a POST
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @XML XML request as string
+5 ;
+6 ; @RETURNS A handle to response XML document
+7 ; 1 for success, 0 for failure
+8 ;
+9 NEW PSS,PSSERR,$ETRAP,$ESTACK
+10 ;
+11 ; Set error trap
+12 SET $ETRAP="DO ERROR^PSSHTTP"
+13 ;
+14 SET PSS("server")="PEPS"
+15 SET PSS("webserviceName")="ORDER_CHECKS"
+16 SET PSS("path")="ordercheck"
+17 ;
+18 SET PSS("parameterName")="xmlRequest"
+19 SET PSS("parameterValue")=XML
+20 ;
+21 ; Get instance of client REST request object
+22 SET PSS("restObject")=$$GETREST^XOBWLIB(PSS("webserviceName"),PSS("server"))
+23 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+24 ;
+25 ; Insert XML as parameter
+26 DO PSS("restObject").InsertFormData(PSS("parameterName"),PSS("parameterValue"))
+27 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+28 ;
+29 ; Execute HTTP Post method
+30 SET PSS("postResult")=$$POST^XOBWLIB(PSS("restObject"),PSS("path"),.PSSERR)
+31 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+32 ;
+33 if PSS("postResult")
Begin DoDot:1
+34 SET PSS("result")=##class(gov.va.med.pre.ws.XMLHandler).getHandleToXmlDoc(PSS("restObject").HttpResponse.Data,