[613] | 1 | XWBRPCC ;OIFO-Oakland/REM - M2M Broker Client Utilities ;06/05/2002 17:25
|
---|
| 2 | ;;1.1;RPC BROKER;**28,34**;Mar 28, 1997
|
---|
| 3 | ;
|
---|
| 4 | QUIT
|
---|
| 5 | ;
|
---|
| 6 | ;p34 - added line to set "MODE" like in PRE^XWBM2MC. No longer will it
|
---|
| 7 | ; be set in PRE^XWBM2MC - REQUEST.
|
---|
| 8 | ;
|
---|
| 9 | ; -------------------------------------------------------------------
|
---|
| 10 | ; RPC Client: Methods Calls
|
---|
| 11 | ; -------------------------------------------------------------------
|
---|
| 12 | ;
|
---|
| 13 | ; [Public/Supported Method]
|
---|
| 14 | EXECUTE(XWBPARMS) ; -- execute rpc call
|
---|
| 15 | ;
|
---|
| 16 | ; -- validate parameters passed
|
---|
| 17 | IF '$$VALIDATE(.XWBPARMS) QUIT 0
|
---|
| 18 | ;
|
---|
| 19 | ; -- call method to build request from parameters array
|
---|
| 20 | DO REQUEST(.XWBPARMS)
|
---|
| 21 | IF $G(XWBPARMS("RESULTS"))="" SET XWBPARMS("RESULTS")=$NA(^TMP("XWBRPC",$J,"XML"))
|
---|
| 22 | QUIT $$EXECUTE^XWBVLC(.XWBPARMS)
|
---|
| 23 | ;
|
---|
| 24 | VALIDATE(XWBPARMS) ; -- validate parameters sent in
|
---|
| 25 | ; // TODO: Do checks and build validate error message
|
---|
| 26 | QUIT 1
|
---|
| 27 | ;
|
---|
| 28 | REQUEST(XWBPARMS) ; -- build XML request
|
---|
| 29 | ;
|
---|
| 30 | NEW XWBLINE,XWBPI,PTYPE
|
---|
| 31 | SET XWBLINE=0
|
---|
| 32 | SET XWBPARMS("MESSAGE TYPE")="Gov.VA.Med.RPC.Request"
|
---|
| 33 | ;
|
---|
| 34 | S XWBPARMS("MODE")="RPCBroker" ;*p34-added line to set "MODE" instead of in PRE^XWBM2MC.
|
---|
| 35 | ;SET XWBPARMS("MODE")="single call" ;Comment out for **M2M
|
---|
| 36 | ;
|
---|
| 37 | IF $G(XWBPARMS("REQUEST"))="" SET XWBPARMS("REQUEST")=$NA(XWBPARMS("REQUEST","XML"))
|
---|
| 38 | SET XWBREQ=XWBPARMS("REQUEST")
|
---|
| 39 | KILL @XWBREQ
|
---|
| 40 | ;
|
---|
| 41 | DO ADD($$XMLHDR^XWBUTL())
|
---|
| 42 | ;p34-added 'broker m2m' in XML message
|
---|
| 43 | DO ADD("<vistalink type="""_$G(XWBPARMS("MESSAGE TYPE"))_""" mode="""_$G(XWBPARMS("MODE"))_""" >")
|
---|
| 44 | ;
|
---|
| 45 | I $G(XWBPARMS("MODE"))'="RPCBroker" D
|
---|
| 46 | . DO ADD("<session>")
|
---|
| 47 | . ;
|
---|
| 48 | . ;**M2M - don't send DUZ
|
---|
| 49 | . DO ADD("<duz value="""_$G(XWBPARMS("DUZ"))_""" />")
|
---|
| 50 | . DO ADD("<security>")
|
---|
| 51 | . ;
|
---|
| 52 | . DO ADD("<token value="""_$G(XWBPARMS("TOKEN"))_""" />")
|
---|
| 53 | . DO ADD("</security>")
|
---|
| 54 | . DO ADD("</session>")
|
---|
| 55 | . Q
|
---|
| 56 | DO ADD("<rpc uri="""_$G(XWBPARMS("URI"))_""" method="""_$G(XWBPARMS("METHOD"))_""" >")
|
---|
| 57 | IF $D(XWBPARMS("PARAMS"))>9 DO
|
---|
| 58 | . DO ADD("<params>")
|
---|
| 59 | . SET XWBPI=0
|
---|
| 60 | . FOR SET XWBPI=$O(XWBPARMS("PARAMS",XWBPI)) Q:'XWBPI!(XWBCRLFL) DO
|
---|
| 61 | . . SET PTYPE=$G(XWBPARMS("PARAMS",XWBPI,"TYPE"))
|
---|
| 62 | . . IF PTYPE="STRING" DO STRING QUIT
|
---|
| 63 | . . IF PTYPE="ARRAY" DO ARRAY QUIT
|
---|
| 64 | . . IF PTYPE="REF" DO REF QUIT
|
---|
| 65 | . DO ADD("</params>")
|
---|
| 66 | DO ADD("</rpc>")
|
---|
| 67 | DO ADD("</vistalink>")
|
---|
| 68 | QUIT
|
---|
| 69 | ;
|
---|
| 70 | STRING ;
|
---|
| 71 | ;;DO ADD("<param type=""string"" position="""_XWBPI_""" >"_$G(XWBPARMS("PARAMS",XWBPI,"VALUE"))_"</param>")
|
---|
| 72 | I $$CTLCHK($G(XWBPARMS("PARAMS",XWBPI,"VALUE"))) S XWBCRLFL=1 D ERROR^XWBM2MC(8) Q
|
---|
| 73 | DO ADD("<param type=""string"" position="""_XWBPI_""" >"_$$CHARCHK^XWBUTL($G(XWBPARMS("PARAMS",XWBPI,"VALUE")))_"</param>")
|
---|
| 74 | QUIT
|
---|
| 75 | ;
|
---|
| 76 | ARRAY ;
|
---|
| 77 | NEW XWBNAME
|
---|
| 78 | DO ADD("<param type=""array"" position="""_XWBPI_""" >")
|
---|
| 79 | DO ADD("<indices>")
|
---|
| 80 | ;
|
---|
| 81 | SET XWBNAME="" FOR SET XWBNAME=$O(XWBPARMS("PARAMS",XWBPI,"VALUE",XWBNAME)) Q:XWBNAME="" DO
|
---|
| 82 | . ;;DO ADD("<index name="""_XWBNAME_""" value="""_$G(XWBPARMS("PARAMS",XWBPI,"VALUE",XWBNAME))_""" />")
|
---|
| 83 | . I $$CTLCHK($G(XWBPARMS("PARAMS",XWBPI,"VALUE",XWBNAME))) S XWBCRLFL=1 D ERROR^XWBM2MC(8) Q
|
---|
| 84 | . DO ADD("<index name="""_XWBNAME_""" >"_$$CHARCHK^XWBUTL($G(XWBPARMS("PARAMS",XWBPI,"VALUE",XWBNAME)))_"</index>")
|
---|
| 85 | DO ADD("</indices>")
|
---|
| 86 | DO ADD("</param>")
|
---|
| 87 | QUIT
|
---|
| 88 | ;
|
---|
| 89 | REF ;
|
---|
| 90 | I $$CTLCHK($G(XWBPARMS("PARAMS",XWBPI,"VALUE"))) S XWBCRLFL=1 D ERROR^XWBM2MC(8) Q
|
---|
| 91 | DO ADD("<param type=""ref"" position="""_XWBPI_""" >"_$$CHARCHK^XWBUTL($G(XWBPARMS("PARAMS",XWBPI,"VALUE")))_"</param>")
|
---|
| 92 | QUIT
|
---|
| 93 | ;
|
---|
| 94 | ADD(STR) ; -- add string to array
|
---|
| 95 | SET XWBLINE=XWBLINE+1
|
---|
| 96 | ;
|
---|
| 97 | I $G(XWBDBUG) S ^REM("M2MCL","REQUEST",XWBLINE)=STR
|
---|
| 98 | ;
|
---|
| 99 | SET @XWBREQ@(XWBLINE)=STR
|
---|
| 100 | QUIT
|
---|
| 101 | ;
|
---|
| 102 | CTLCHK(STR) ;Check for control character in string.
|
---|
| 103 | ; Exception are $C(10)-LF, $C(13)-CR
|
---|
| 104 | N I,Q,X
|
---|
| 105 | S X=0
|
---|
| 106 | I '(STR?.E1C.E) Q X
|
---|
| 107 | S I="" F I=1:1:$L(STR) D
|
---|
| 108 | .S Q="" F Q=1:1:31 D Q:X
|
---|
| 109 | ..;I Q=10!(Q=13) Q
|
---|
| 110 | ..;W !,"I= ",I," Q= ",Q
|
---|
| 111 | ..I $E(STR,I)[$C(Q) S X=1 Q
|
---|
| 112 | Q X
|
---|
| 113 | ;
|
---|
| 114 | ; -------------------------------------------------------------------
|
---|
| 115 | ; Request Format Documentation
|
---|
| 116 | ; -------------------------------------------------------------------
|
---|
| 117 | ;
|
---|
| 118 | ; [ Parameter Array Format -->> passed to REQUEST^XWBRPCC(.XWBPARMS) ]
|
---|
| 119 | ;
|
---|
| 120 | ; -- general information
|
---|
| 121 | ; XWBPARMS("ADDRESS")="127.0.0.1"
|
---|
| 122 | ; XWBPARMS("ADDRESS")="152.127.1.35"
|
---|
| 123 | ; XWBPARMS("PORT")=9800
|
---|
| 124 | ; XWBPARMS("DUZ")=990
|
---|
| 125 | ; XWBPARMS("TOKEN")="SOMETHING"
|
---|
| 126 | ; XWBPARMS("RPC NAME")="SDOE LIST ENCOUNTERS FOR PAT"
|
---|
| 127 | ;
|
---|
| 128 | ; -- string parameter type
|
---|
| 129 | ; XWBPARMS("PARAMS",1,"TYPE")="STRING"
|
---|
| 130 | ; XWBPARMS("PARAMS",1,"VALUE")=2
|
---|
| 131 | ; XWBPARMS("PARAMS",2,"TYPE")="STRING"
|
---|
| 132 | ; XWBPARMS("PARAMS",2,"VALUE")=2961001
|
---|
| 133 | ; XWBPARMS("PARAMS",3,"TYPE")="STRING"
|
---|
| 134 | ; XWBPARMS("PARAMS",3,"VALUE")=3030101
|
---|
| 135 | ;
|
---|
| 136 | ; -- sample array parameter type
|
---|
| 137 | ; XWBPARMS("PARAMS",4,"TYPE")="ARRAY"
|
---|
| 138 | ; XWBPARMS("PARAMS",4,"VALUE","FNAME")="JOE"
|
---|
| 139 | ; XWBPARMS("PARAMS",4,"VALUE","LNAME")="GOODMAN"
|
---|
| 140 | ;
|
---|
| 141 | ; -------------------------------------------------------------------
|
---|
| 142 | ;
|
---|
| 143 | ; [ Sample XML produced by calling REQUEST^XWBRPCC(.XWBPARMS) ]
|
---|
| 144 | ;
|
---|
| 145 | ; <?xml version="1.0" encoding="utf-8" ?>
|
---|
| 146 | ; <vistalink type="Gov.VA.Med.RPC.Request" mode="single call" >
|
---|
| 147 | ; <rpc uri="XWB TEST CALL" >
|
---|
| 148 | ; <session>
|
---|
| 149 | ; <duz value="990" />
|
---|
| 150 | ; <security>
|
---|
| 151 | ; <token value="something" />
|
---|
| 152 | ; </security>
|
---|
| 153 | ; </session>
|
---|
| 154 | ; <params>
|
---|
| 155 | ; <param type="string" position="1" >2</param>
|
---|
| 156 | ; <param type="string" position="2" >2961001</param>
|
---|
| 157 | ; <param type="string" position="3" >3030101</param>
|
---|
| 158 | ; <param type="array" position="4" >
|
---|
| 159 | ; <indices>
|
---|
| 160 | ; <index name="status" value="veteran" />
|
---|
| 161 | ; <index name="gender" value="male" />
|
---|
| 162 | ; </indices>
|
---|
| 163 | ; </param>
|
---|
| 164 | ; </params>
|
---|
| 165 | ; </rpc>
|
---|
| 166 | ; </vistalink>
|
---|
| 167 | ;
|
---|
| 168 | ; -------------------------------------------------------------------
|
---|
| 169 | ;
|
---|