PSSPGX2 ;BIR/MV - PHARMACOGENOMICS API CONTINUE ;09/20/07
;;1.0;PHARMACY DATA MANAGEMENT;**262**;9/30/97;Build 66
;
; Reference to ^MXMLDOM is supported by DBIA #3561
;
;POST is cloned from PEPSPOST^PSSHTTP
POST(DOCHAND,PSSXML,PSSWS) ; post the XML request to PEPS server and return the routes
; PSSXML: XML request (header and input data...)
; PSSWS : An array
; PSSWS("SERVICE_NAME") - Webservice name. Ex: "PGX_ORDER_CHECKS"
; PSSWS("PATH") - Ex: "pgxwarning"
; PSSWS("SERVER") - the server name. Ex: "PEPS"
; output: PSSOUT - array containing the list of route names for the given drug.
;
; @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
;
I ($G(PSSWS("SERVER"))="")!($G(PSSWS("SERVICE_NAME"))="")!($G(PSSWS("PATH"))="") S PSSOUT(0)="-1^Either the Server name or Path is missing" Q 0
; Set error trap
SET $ETRAP="DO ERROR^PSSHTTP"
;
SET PSS("server")=PSSWS("SERVER")
SET PSS("webserviceName")=PSSWS("SERVICE_NAME")
SET PSS("path")=PSSWS("PATH")
SET PSS("parameterName")="xmlRequest"
SET PSS("parameterValue")=PSSXML
; 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")
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSSPGX2 2088 printed Mar 25, 2026@15:58:11 Page 2
PSSPGX2 ;BIR/MV - PHARMACOGENOMICS API CONTINUE ;09/20/07
+1 ;;1.0;PHARMACY DATA MANAGEMENT;**262**;9/30/97;Build 66
+2 ;
+3 ; Reference to ^MXMLDOM is supported by DBIA #3561
+4 ;
+5 ;POST is cloned from PEPSPOST^PSSHTTP
POST(DOCHAND,PSSXML,PSSWS) ; post the XML request to PEPS server and return the routes
+1 ; PSSXML: XML request (header and input data...)
+2 ; PSSWS : An array
+3 ; PSSWS("SERVICE_NAME") - Webservice name. Ex: "PGX_ORDER_CHECKS"
+4 ; PSSWS("PATH") - Ex: "pgxwarning"
+5 ; PSSWS("SERVER") - the server name. Ex: "PEPS"
+6 ; output: PSSOUT - array containing the list of route names for the given drug.
+7 ;
+8 ; @DESC Sends an HTTP request to PEPS as a POST
+9 ;
+10 ; @DOCHAND Handle to XML document
+11 ; @XML XML request as string
+12 ;
+13 ; @RETURNS A handle to response XML document
+14 ; 1 for success, 0 for failure
+15 ;
+16 NEW PSS,PSSERR,$ETRAP,$ESTACK
+17 ;
+18 IF ($GET(PSSWS("SERVER"))="")!($GET(PSSWS("SERVICE_NAME"))="")!($GET(PSSWS("PATH"))="")
SET PSSOUT(0)="-1^Either the Server name or Path is missing"
QUIT 0
+19 ; Set error trap
+20 SET $ETRAP="DO ERROR^PSSHTTP"
+21 ;
+22 SET PSS("server")=PSSWS("SERVER")
+23 SET PSS("webserviceName")=PSSWS("SERVICE_NAME")
+24 SET PSS("path")=PSSWS("PATH")
+25 SET PSS("parameterName")="xmlRequest"
+26 SET PSS("parameterValue")=PSSXML
+27 ; Get instance of client REST request object
+28 SET PSS("restObject")=$$GETREST^XOBWLIB(PSS("webserviceName"),PSS("server"))
+29 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+30 ;
+31 ; Insert XML as parameter
+32 DO PSS("restObject").InsertFormData(PSS("parameterName"),PSS("parameterValue"))
+33 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+34 ;
+35 ; Execute HTTP Post method
+36 SET PSS("postResult")=$$POST^XOBWLIB(PSS("restObject"),PSS("path"),.PSSERR)
+37 IF $DATA(^TMP($JOB,"OUT","EXCEPTION"))>0
QUIT 0
+38 ;
+39 if PSS("postResult")
Begin DoDot:1
+40 SET PSS("result")=##class(gov.va.med.pre.ws.XMLHandler).getHandleToXmlDoc(PSS("restObject").HttpResponse.Data,.DOCHAND)
+41 QUIT
End DoDot:1
+42 ;
+43 if 'PSS("postResult")
Begin DoDot:1
+44 SET ^TMP($JOB,"OUT","EXCEPTION")="Unable to make http request."
+45 SET PSS("result")=0
+46 QUIT
End DoDot:1
+47 ;
+48 QUIT PSS("result")