source: ePrescribing/trunk/p/C0PWS1.m@ 1603

Last change on this file since 1603 was 1595, checked in by George Lilly, 12 years ago

initial release of ePrescribing

File size: 17.9 KB
RevLine 
[1595]1C0PWS1 ; ERX/GPL - Web Service utilities; 8/31/09 ; 5/9/12 12:14am
2 ;;1.0;C0P;;Apr 25, 2012;Build 103
3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22 ; TEST Lines below not intended for End Users. Programmers only.
23 ; BEWARE ZWRITE SYNTAX. It may not work in other M Implementations.
24TEST(C0PDUZ,C0PDFN) ; TEST RETRIEVAL OF PATIENT1 MEDS
25 ;S DEBUG=1 ;
26 D SOAP("C0POUT",6,C0PDUZ,C0PDFN)
27 ZWRITE C0POUT
28 Q
29 ;
30ACCOUNTF() Q 113059002 ; file number for account file
31XMLFN() Q 113059001 ; XML TEMPLATE FILE NUMBER
32BINDFN() Q 113059001.04 ; FILE NUMBER FOR BINDING SUBFILE
33 ;
34GETTID(C0PWS,C0PTNAME) ; EXTRINSIC WHICH RETURNS THE TEMPLATE ID FOR
35 ; TEMPLATE NAMED C0PTNAME BELONGING TO WEB SERVICE NAMED C0PWS
36 ; ALSO WORKS IF THE ACCOUNT NUMBER IS PASSED IN C0PWS
37 S C0PXF=113059001 ; FILE NUMBER FOR THE C0P XML TEMPLATE FILE
38 S C0PAF=113059002 ; FILE NUMBER FOR THE C0P WS ACCT FILE
39 N C0PA,C0PT ; C0P ACCOUNT AND C0P TEMPLATE
40 I C0PWS>0 S C0PA=C0PWS
41 E D ; NAME NOT RECORD NUMBER IS PASSED FOR ACCOUNT
42 . S C0PA=$O(^C0PS("B",C0PWS,"")) ; RECORD NUMBER OF ACCOUNT
43 . I C0PA="" D Q ; OOPS ACCOUNT NOT FOUND
44 . . W "ACCOUNT "_C0PWS_" NOT FOUND",!
45 S C0PT=$O(^C0PX("C",C0PA,C0PTNAME,"")) ; RECORD NUMBER OF TEMPLATE
46 ; WE USE THE C INDEX TO INSURE THAT THE TEMPLATE BELONGS TO THE WEB SERVICE
47 Q C0PT
48 ;
49RESTID(C0PDUZ,C0PTID) ; RESOLVE TEMPLATE ID FROM SUBSCRIPTION
50 ;
51 N C0PAIEN S C0PAIEN=$$SUBINIT^C0PSUB(C0PDUZ) ;IEN OF SUBSCRIPTION
52 N C0PACCT S C0PACCT=$$GET1^DIQ(C0PSUBF,C0PAIEN_","_C0PDUZ_",",1,"I") ;ACCT
53 N C0PWBS S C0PWBS=$$GET1^DIQ(C0PAF,C0PACCT_",",4,"I") ;WEB SERVICE IEN
54 N C0PUTID S C0PUTID=$$GETTID(C0PWBS,C0PTID) ;TEMPLATE ID
55 Q C0PUTID
56 ;
57SOAP(C0PRTN,C0PTID,C0PDUZ,C0PDFN,C0PVOR) ; MAKES A SOAP CALL FOR
58 ; TEMPLATE ID C0PTID
59 ; RETURNS THE XML RESULT IN C0PRTN, PASSED BY NAME
60 ; C0PVOR IS THE NAME OF A VARIABLE OVERRIDE ARRAY, WHICH IS APPLIED
61 ; BEFORE MAPPING
62 ;
63 ; ARTIFACTS SECTION
64 ; THE FOLLOWING WILL SET UP DEBUGGING ARTIFACTS FOR A POSSIBLE FUTURE
65 ; ONLINE DEBUGGER. IF DEBUG=1, VARIABLES CONTAINING INTERMEDIATE RESULTS
66 ; WILL NOT BE NEWED.
67 I $G(DEBUG)="" N C0PV ; CATALOG OF ARTIFACT VARIABLES AND ARRAYS
68 S C0PV(100,"C0PXF","XML TEMPLATE FILE NUMBER")=""
69 S C0PV(200,"C0PHEAD","SOAP HEADER VARIABLE NAME")=""
70 S C0PV(300,"header","SOAP HEADER")=""
71 S C0PV(400,"C0PMIME","MIME TYPE")=""
72 S C0PV(500,"C0PURL","WS URL")=""
73 S C0PV(550,"C0PPURL","PROXY URL")=""
74 S C0PV(600,"C0PXML","XML VARIABLE NAME")=""
75 S C0PV(700,"xml","OUTBOUND XML")=""
76 S C0PV(800,"C0PRSLT","RAW XML RESULT RETURNED FROM WEB SERVICE")=""
77 S C0PV(900,"C0PRHDR","RETURNED HEADER")=""
78 S C0PV(1000,"C0PRXML","XML RESULT NORMALIZED")=""
79 S C0PV(1100,"C0PR","REPLY TEMPLATE")=""
80 S C0PV(1200,"C0PREDUX","REDUX STRING")=""
81 S C0PV(1300,"C0PIDX","RESULT XPATH INDEX")=""
82 S C0PV(1400,"C0PARY","RESULT XPATH ARRAY")=""
83 S C0PV(1500,"C0PNOM","RESULT DOM DOCUMENT NAME")=""
84 S C0PV(1600,"C0PID","RESULT DOM ID")=""
85 I $G(DEBUG)'="" G NOTNEW ; SKIP NEWING THE VARIABLES IF IN DEBUG
86 N ZI,ZJ S ZI=""
87NEW ; new the variables
88 S ZI=$O(C0PV(ZI))
89 S ZJ=$O(C0PV(ZI,"")) ; SET UP NEW COMMAND
90 ;W ZJ,!
91 N @ZJ ; NEW THE VARIABLE
92 I $O(C0PV(ZI))'="" G NEW ;LOOP TO GET NEW IN CONTEXT
93NOTNEW ; (goto label) don't new the variables... skip that
94 ; END ARTIFACTS
95 ;
96 D INITXPF("C0PF") ; SET FILE NUMBER AND PARAMATERS
97 S C0PXF=C0PF("XML FILE NUMBER") ; FILE NUMBER FOR THE C0P XML TEMPLATE FILE
98 I +C0PTID=0 D ; A STRING WAS PASSED FOR THE TEMPLATE NAME
99 . S C0PUTID=$$RESTID(C0PDUZ,C0PTID) ;RESOLVE TEMPLATE IEN FROM NAME
100 E S C0PUTID=C0PTID ; AN IEN WAS PASSED
101 N xml,template,header
102 S C0PHEAD=$$GET1^DIQ(C0PXF,C0PUTID_",",2.2,,"header")
103 S C0PMIME=$$GET1^DIQ(C0PXF,C0PUTID_",","MIME TYPE")
104 S C0PPURL=$$GET1^DIQ(C0PXF,C0PUTID_",","PROXY SERVER")
105 ;S C0PURL=$$GET1^DIQ(C0PXF,C0PUTID_",","URL") ;GPL CHANGE TO USE PROD FLAG
106 D SETUP^C0PMAIN() ; INITIALIZE C0PACCT IEN OF WS ACCOUNT
107 S C0PURL=$$WSURL^C0PMAIN(C0PACCT) ; RESOLVES PRODUCTION VS TEST
108 S C0PXML=$$GET1^DIQ(C0PXF,C0PUTID_",",2.1,,"xml")
109 S C0PTMPL=$$GET1^DIQ(C0PXF,C0PUTID_",",3,,"template")
110 I C0PTMPL="template" D ; there is a template to process
111 . K xml ; going to replace the xml array
112 . D EN^C0PMAIN("xml","url",C0PDUZ,C0PDFN,C0PUTID,$G(C0PVOR))
113 . ;N ZZG M ZZG(1)=xml
114 . ;S ZDIR=^TMP("C0CCCR","ODIR")
115 . ;ZWR ZZG(1)
116 . ;W $$OUTPUT^C0CXPATH("xml(1)","GPLTEST-"_ZDFN_".xml",ZDIR)
117 I $G(C0PPROXY) S C0PURL=C0PPURL
118 I '$D(C0PERROR) S C0PERROR="0^NO ERRORS" ; to do: start using this gpl
119 K C0PRSLT,C0PRHDR
120 ;
121 ; token to catch runaway linux jobs - gpl 4/12/2012
122 ; But not ready for release b/c depends on code that is not available --smh 5/9/12
123 ; D LOG^C0PTRAK($J,"PULLBACK")
124 ;
125 S ok=$$httpPOST^%zewdGTM(C0PURL,.xml,C0PMIME,.C0PRSLT,.header,"",.gpl5,.C0PRHDR)
126 ;
127 ; kill token after return from EWD
128 ;
129 ;D UNLOG^C0PTRAK($J) ; success, remove the token ; smh commented out 5/9/12
130 ;K ^TMP("C0PERX",$J)
131 K C0PRXML
132 ;I DUZ=135 B ; patch so others can use the pullback while i debug - gpl
133 ;. ;I $D(C0PRSLT(1)) D NORMAL("C0PRXML","C0PRSLT(1)") ;RETURN XML IN AN ARRAY
134 ;. I $D(C0PRSLT(1)) D CHUNK("C0PRXML","C0PRSLT",2000) ;RETURN IN AN ARRAY
135 ;. ; SWITCHED TO CHUNK TO HANDLE ARRAYS OF XML
136 ;E I $D(C0PRSLT(1)) D NORMAL("C0PRXML","C0PRSLT(1)") ;RETURN XML IN AN ARRAY
137 ; The following is a temporary fix to keep eRx working while a better
138 ; solution is developed. Template ID 6 is GETMEDS for eRx and it needs
139 ; to handle xml files that are too big for NORMAL to handle. So, I wrote
140 ; CHUNK which will allow us to handle any size xml file bound for the
141 ; EWD parser.
142 ; However, all the other templates in eRx need NORMAL to find the
143 ; embedded XML file in their web service responses. So, we will use
144 ; CHUNK for template 6 and continue to use NORMAL for all other templates
145 ; we can handle big med lists, but not big web service calls.
146 ; What is needed is a better NORMAL (see NORMAL2) or another routine
147 ; to detect, extract, and decode embeded XML files of any size. gpl 10/8/10
148 I C0PUTID=6 D ;
149 . I $D(C0PRSLT(1)) D CHUNK("C0PRXML","C0PRSLT",2000) ;RETURN IN AN ARRAY
150 E I $D(C0PRSLT(1)) D NORMAL("C0PRXML","C0PRSLT(1)") ;RETURN XML IN AN ARRAY
151 S C0PR=$$GET1^DIQ(C0PXF,C0PUTID_",",.03,"I") ; REPLY TEMPLATE
152 ; reply templates are optional and are specified by populating a
153 ; template pointer in field 2.5 of the request template
154 ; if specified, the reply template is the source of the REDUX string
155 ; used for XPath on the reply, and for UNBIND processing
156 ; if no reply template is specified, REDUX is obtained from the request
157 ; template and no UNBIND processing is performed. The XPath array is
158 ; returned without variable bindings
159 I C0PR'="" D ; REPLY TEMPLATE EXISTS
160 . I +$G(DEBUG)'=0 W "REPLY TEMPLATE:",C0PR,!
161 . S C0PTID=C0PR ;
162 S C0PREDUX=$$GET1^DIQ(C0PXF,C0PUTID_",",2.5) ;XPATH REDUCTION STRING
163 K C0PIDX,C0PARY ; XPATH INDEX AND ARRAY VARS
164 S C0PNOM="C0PMEDS"_$J ; DOCUMENT NAME FOR THE DOM
165 N ZBIG S ZBIG=0
166 I C0PUTID'=6 D ;
167 . S ZBIG=$$TOOBIG("C0PRXML") ; PATCH BY GPL WHICH ASSUMES ONLY
168 . ; TEMPLATE 1 IS A REGULAR XML FILE.. EVERYTHING ELSE HAS EMBEDDED XML
169 I ZBIG>0 D ; PROBABLY AN EMBEDDED XML DOCUMENT
170 . S C0PID=$$UNWRAP("C0PRXML",ZBIG,C0PNOM) ; DECODE AND PARSE THE EMBEDED XML
171 E S C0PID=$$PARSE^C0PXEWD("C0PRXML",C0PNOM) ;CALL THE PARSER
172 ;S C0PID=$$PARSE^C0PXEWD("C0PRXML",C0PNOM) ;CALL THE PARSER
173 S C0PID=$$FIRST^C0PXEWD($$ID^C0PXEWD(C0PNOM)) ;ID OF FIRST NODE
174 D XPATH^C0PXEWD(C0PID,"/","C0PIDX","C0PARY","",C0PREDUX) ;XPATH GENERATOR
175 S OK=$$DELETE^C0PXEWD(C0PNOM) ; REMOVE PARSED XML FROM THE EWD DOM
176 ; Next, call UNBIND to map the reply XPath array to variables
177 ; This is only done if a Reply Template is provided
178 D DEMUXARY(C0PRTN,"C0PARY")
179 ; M @C0PRTN=C0PARY
180 Q
181 ;
182TOOBIG(ZXML) ; EXTRINSIC WHICH RETURNS TRUE IF ANY NODE IS OVER 2000 CHARS
183 ; RETURNS THE INDEX OF THE LARGE NODE . IF NO LARGE NODE, RETURNS ZERO
184 N ZI,ZR
185 S ZI=""
186 S ZR=0 ; DEFAULT FALSE
187 F S ZI=$O(@ZXML@(ZI)) Q:ZI="" D ;
188 . I $L(@ZXML@(ZI))>1000 S ZR=ZI
189 Q ZR
190 ;
191NORMAL(OUTXML,INXML) ;NORMALIZES AN XML STRING PASSED BY NAME IN INXML
192 ; INTO AN XML ARRAY RETURNED IN OUTXML, ALSO PASSED BY NAME
193 ;
194 N ZI,ZN,ZTMP
195 S ZN=1
196 S @OUTXML@(ZN)=$P(@INXML,"><",ZN)_">"
197 S ZN=ZN+1
198 F S @OUTXML@(ZN)="<"_$P(@INXML,"><",ZN) Q:$P(@INXML,"><",ZN+1)="" D ;
199 . S @OUTXML@(ZN)=@OUTXML@(ZN)_">"
200 . S ZN=ZN+1
201 Q
202 ;
203CHUNK(OUTXML,INXML,ZSIZE) ; BREAKS INXML INTO ZSIZE BLOCKS
204 ; INXML IS AN ARRAY PASSED BY NAME OF STRINGS
205 ; OUTXML IS ALSO PASSED BY NAME
206 ; IF ZSIZE IS NOT PASSED, 1000 IS USED
207 I '$D(ZSIZE) S ZSIZE=1000 ; DEFAULT BLOCK SIZE
208 N ZB,ZI,ZJ,ZK,ZL,ZN
209 S ZB=ZSIZE-1
210 S ZN=1
211 S ZI=0 ; BEGINNING OF INDEX TO INXML
212 F S ZI=$O(@INXML@(ZI)) Q:+ZI=0 D ; FOR EACH STRING IN INXML
213 . S ZL=$L(@INXML@(ZI)) ; LENGTH OF THE STRING
214 . F ZJ=1:ZSIZE:ZL D ;
215 . . S ZK=$S(ZJ+ZB<ZL:ZJ+ZB,1:ZL) ; END FOR EXTRACT
216 . . S @OUTXML@(ZN)=$E(@INXML@(ZI),ZJ,ZK) ; PULL OUT THE PIECE
217 . . S ZN=ZN+1 ; INCREMENT OUT ARRAY INDEX
218 Q
219 ;
220NORMAL2(OUTXML,INXML) ;NORMALIZES AN ARRAY OF XML STRINGS PASSED BY NAME INXML
221 ; AS @INXML@(1) TO @INXML@(x) ALL NUMERIC
222 ; INTO AN XML ARRAY RETURNED IN OUTXML, ALSO PASSED BY NAME
223 ; this routine doesn't work unless the blocks are on xml tag boundaries - gpl
224 ; which is hard to do... this routine is left here awaiting future development
225 N ZI,ZN,ZJ
226 S ZJ=0
227 S ZN=1
228 F S ZJ=$O(@INXML@(ZJ)) Q:+ZJ=0 D ; FOR EACH XML STRING IN ARRAY
229 . S @OUTXML@(ZN)=$P(@INXML@(ZJ),"><",ZN)_">"
230 . S ZN=ZN+1
231 . F S @OUTXML@(ZN)="<"_$P(@INXML@(ZJ),"><",ZN) Q:$P(@INXML@(ZJ),"><",ZN+1)="" D ;
232 . . S @OUTXML@(ZN)=@OUTXML@(ZN)_">"
233 . . S ZN=ZN+1
234 Q
235 ;
236UNWRAP(ZXML,ZI,ZNOM) ; EXTRINSIC TO LOCATE, DECODE AND PARSE AN EMBEDED XML DOC
237 ; RETURNS THE DOCID OF THE DOM
238 N ZS,ZX
239 S ZS=$P($P(@ZXML@(ZI),">",2),"<",1) ; PULL OUT THE ENCODED STRING
240 S ZX=$$DECODE^RGUTUU(ZS)
241 N ZZ
242 N ZY S ZY="<?xml version=""1.0"" encoding=""utf-8""?>"
243 I $E(ZX,1,5)'="<?xml" S ZZ(1)=ZY_ZX
244 E S ZZ(1)=ZX
245 N ZI
246 ;F ZI=1:1 Q:$$REDUCE(.ZZ,ZI) ; CHOP THE STRING INTO 4000 CHAR ARRAY
247 S ZI=$$REDUCRCR(.ZZ,1) ; RECURSIVE VERSION OF REDUCE
248 S G=$$PARSE^C0PXEWD("ZZ",C0PNOM)
249 I G=0 D ERROR^C0PMAIN(",U113059005,",$ST($ST,"PLACE"),"ERX-XML-PRS","XML Parsing Error") QUIT ;ZWR ^TMP("MXMLERR",$J,*) B
250 Q G
251 ;
252REDUCE(ZARY,ZN) ; WILL REDUCE ZARY(ZN) BY CHOPPING IT TO 4000 CHARS
253 ; AND PUTTING THE REST IN ZARY(ZN+1)
254 ; ZARY IS PASSED BY REFERENCE
255 ; EXTRINSIC WHICH RETURNS FALSE IF THERE IS NOTHING TO REDUCE
256 I $L(ZARY(ZN))<4001 Q 0 ;NOTHING TO REDUCE
257 S ZARY(ZN+1)=$E(ZARY(ZN),4001,$L(ZZ(ZN))) ;BREAK IT UP
258 S ZARY(ZN)=$E(ZARY(ZN),1,4000) ;
259 Q 1 ;ACTUALLY REDUCED
260 ;
261REDUCRCR(ZARY,ZN) ; RECURSIVE VERSION OF REDUCE ABOVE
262 ; WILL REDUCE ZARY(ZN) BY CHOPPING IT TO 4000 CHARS
263 ; AND PUTTING THE REST IN ZARY(ZN+1)
264 ; ZARY IS PASSED BY REFERENCE
265 ; EXTRINSIC WHICH RETURNS FALSE IF THERE IS NOTHING TO REDUCE
266 I $L(ZARY(ZN))<4001 Q 0 ;NOTHING TO REDUCE
267 S ZARY(ZN+1)=$E(ZARY(ZN),4001,$L(ZZ(ZN))) ;BREAK IT UP
268 S ZARY(ZN)=$E(ZARY(ZN),1,4000) ;
269 I '$$REDUCRCR(.ZARY,ZN+1) Q 1 ; CALL RECURSIVELY
270 Q 1 ;ACTUALLY REDUCED
271 ;
272DEMUXARY(OARY,IARY) ;CONVERT AN XPATH ARRAY PASSED AS IARY TO
273 ; FORMAT @OARY@(x,xpath) where x is the first multiple
274 N ZI,ZJ,ZK,ZL S ZI=""
275 F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ;
276 . D DEMUX^C0CMXP("ZJ",ZI)
277 . S ZK=$P(ZJ,"^",3)
278 . S ZK=$RE($P($RE(ZK),"/",1))
279 . S ZL=$P(ZJ,"^",1)
280 . I ZL="" S ZL=1
281 . S @OARY@(ZL,ZK)=@IARY@(ZI)
282 Q
283 ;
284 ; BEGIN OLD CODE - REMOVE AFTER A WHILE WHEN "SOAP" SETTLES DOWN - GPL
285 ;s URL="http://preproduction.newcropaccounts.com/InterfaceV7/Doctor.xml"
286 ;D GETPOST1(URL) ;
287 ;N I,J
288 ;S J=$O(gpl(""),-1) ; count of things in gpl
289 ;F I=1:1:J S gpl(I)=$$CLEAN^C0PEWDU(gpl(I))
290 ;I $$GET1^DIQ(113059001,"3,",2.1,,"gpl")'="gpl" D Q ; ERR GETTING TEMPLATE
291 ;. W "ERROR RETRIEVING TEMPLATE",!
292 ;S gpl(1)="RxInput="_gpl(1)
293 S url="https://preproduction.newcropaccounts.com/InterfaceV7/RxEntry.aspx"
294 S url="https://secure.newcropaccounts.com/V7/WebServices/Doctor.asmx"
295 S url="http://76.110.202.22/v7/WebServices/Doctor.asmx" ;RICHARD'S SOAP PROXY SERVER
296 ;S url="http://76.110.202.22/" ;RICHARD'S SOAP PROXY SERVER
297 N header
298 S ZH=$$GET1^DIQ(113059001,"3,",2.2,,"header")
299 ;W $$OUTPUT^C0CXPATH("gpl(1)","NewCropV7-DOCTOR2.xml","/home/dev/CCR/"),!
300 S ok=$$httpPOST^%zewdGTM(url,.gpl,"text/xml; charset=utf-8",.gpl6,.header,"",.gpl5,.gpl7)
301 ;S ok=$$httpPOST2(.RTN,url,.gpl,"text/xml; charset=utf-8",.gpl6,.header,"",.gpl5,.gpl7)
302 ;S ok=$$httpPOST2(.RTN,"https://preproduction.newcropaccounts.com/InterfaceV7/RxEntry.aspx",.gpl,"application/x-www-form-urlencoded",.gpl6,"","",.gpl5,.gpl7)
303 ZWRITE gpl6 ; smh: this zwrite is never reached.
304 Q
305PARSE(INXML,INDOC) ;CALL THE EWD PARSER ON INXML, PASSED BY NAME
306 ; INDOC IS PASSED AS THE DOCUMENT NAME TO EWD
307 ; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY EWD
308 N ZR
309 M ^CacheTempEWD($j)=@INXML ;
310 S ZR=$$parseDocument^%zewdHTMLParser(INDOC)
311 K ^CacheTempEWD($j) ;clean up after
312 Q ZR
313 ;
314ADDWS(WSNAME,WSTNAM,WSURL) ; ADD A WEB SERVICE TEMPLATE GIVEN A WSDL URL
315 ; WSNAME IS THE NAME OF THE WEB SERVICE.. WILL BE LAYGO
316 ; WSTNAM IS THE TEMPLATE NAME TO BE ADDED TO BE CREATED AND IMPORTED
317 ; WSURL IS THE URL TO THE WSDL DEFINITION OF THE TEMPLATE
318 ; WILL FIRST TRY AND FETCH THE XML FROM THE INTERNET USING THE URL
319 ; IF SUCCESSFUL, AND THE RETURN XML IS VALID, AN ENTRY IN THE XML TEMPLATE
320 ; FILE WILL BE CREATED, WITH THE RAW XML AND DERIVED TEMPLATE XML.
321 ; THEN ENTRIES IN THE BINDING SUBFILE WILL BE CREATED FOR EACH XPATH
322 ; FINALLY, THE TEMPLATE WILL BE POINTED TO IN THE WEB SERVICE FILE TEMPLATE
323 ; MULTIPLE
324 N C0PWSF S C0PWSF=113059003 ; WEB SERVICE FILE
325 N C0PXTF S C0PXTF=113059001 ; XML TEMPLATE FILE
326 ; NEVER MIND... WRONG APPROACH
327 Q
328 ;
329TBLD(INT) ; TEMPLATE BUILD OF TEMPLATE INT
330 ; want to break this up into pieces - gpl
331 ; THE TEMPLATE NEEDS TO EXIST AND THE DEFINING XML URL MUST BE POPULATED
332 ; THEN THE DEFINING XML WILL BE RETRIVED AND STORED INTO THE RAW XML FIELD
333 ; IT WILL BE TRANSFORMED INTO A TEMPLATE AND STORED IN THE TEMPLATE FIELD
334 ; ALL THE XPATHs WILL BE EXTRACTED AND A BINDING MULTIPLE CREATED FOR EACH
335 ; ALL IN ONE SIMPLE ROUTINE
336 ; WHAT REMAINS IS FOR MANUAL ENTRY OF THE OTHER FIELDS IN THE BINDINGS
337 N C0PXTF S C0PXTF=113059001 ; XML TEMPLATE FILE
338 N C0PURL ; URL TO RETRIEVE THE DEFINING XML FOR THE TEMPLATE
339 S C0PURL=$$GET1^DIQ(C0PXTF,INT,2)
340 D GET1URL^C0PEWD2(C0PURL)
341 D CLEAN^DILF
342 ; D WP^DIE(ZF,ZIEN_",",1,,$NA(@ZOR@(ZD,ZI,"TX"))) ; WP OF ORDER TXT
343 D WP^DIE(C0PXTF,INT_",",2.1,,$NA(gpl))
344 D WP^DIE(C0PXTF,INT_",",3,,$NA(gplTEMP))
345 ;N C0PFDA ; DON'T NEW FOR TESTING
346 D ADDXP("gpl2",INT)
347 Q
348 ;
349COMPILE(INTID) ;COMPILE A XML TEMPLATE IN RECORD INTID
350 ;
351 D INITXPF("C0PF") ;FILE ARRAY TO POINT TO C0P FILES
352 D COMPILE^C0CMXP(INTID,"C0PF") ;COMPILE THE TEMPLATE
353 Q
354 ;
355CPBIND(INID,OUTID,FORCE) ; COPIES XPATH BINDINGS FROM TEMPLATE INID
356 ; TO TEMPLATE OUTID - ONLY BINDINGS FOR MATCHING XPATHS ARE COPIED
357 ; NOTE - REDO THIS TO USE FILEMAN CALLS GPL
358 ; WILL NOT OVERWRITE UNLESS FORCE=1
359 N FARY S FARY="C0PF"
360 D INITXPF("C0PF")
361 I +OUTID=0 S OUTID=$$RESTID^C0CSOAP(OUTID,FARY) ;RESOLVE TEMPLATE NAME
362 I +INID=0 S INID=$$RESTID^C0CSOAP(INID,FARY) ;RESOLVE TEMPLATE NAME
363 N ZI
364 S ZI=0
365 F S ZI=$O(^C0PX(OUTID,5,ZI)) Q:+ZI=0 D ; FOR EACH XPATH IN OUTID
366 . W !,ZI," ",^C0PX(OUTID,5,ZI,0)
367 . S ZN=^C0PX(OUTID,5,ZI,0)
368 . I $D(^C0PX(OUTID,5,ZI,1)) D ;Q ;
369 . . W !,"ERROR XPATH BINDING EXISTS ",ZI
370 . D ; LOOK FOR MATCHING XPATH IN SOURCE
371 . . S ZJ=$O(^C0PX(INID,5,"B",ZN,""))
372 . . ;W " FOUND:",ZJ
373 . . I ZJ'="" D ;
374 . . . ;W !,"SETTING ",$G(^C0PX(INID,5,ZJ,1))
375 . . . S ^C0PX(OUTID,5,ZI,0)=^C0PX(INID,5,ZJ,0) ;GET BOTH FIELDS
376 . . . S ^C0PX(OUTID,5,ZI,1)=$G(^C0PX(INID,5,ZJ,1))
377 Q
378 ;
379INITXPF(ARY) ;INITIAL XML/XPATH FILE ARRAY
380 ;
381 S @ARY@("XML FILE NUMBER")=113059001
382 S @ARY@("BINDING SUBFILE NUMBER")=113059001.04
383 S @ARY@("MIME TYPE")="2.3"
384 S @ARY@("PROXY SERVER")="2.4"
385 S @ARY@("REPLY TEMPLATE")=".03"
386 S @ARY@("TEMPLATE NAME")=".01"
387 S @ARY@("TEMPLATE XML")="3"
388 S @ARY@("URL")="1"
389 S @ARY@("WSDL URL")="2"
390 S @ARY@("XML")="2.1"
391 S @ARY@("XML HEADER")="2.2"
392 S @ARY@("XPATH REDUCTION STRING")="2.5"
393 S @ARY@("CCR VARIABLE")="4"
394 S @ARY@("FILEMAN FIELD NAME")="1"
395 S @ARY@("FILEMAN FIELD NUMBER")="1.2"
396 S @ARY@("FILEMAN FILE POINTER")="1.1"
397 S @ARY@("INDEXED BY")=".05"
398 S @ARY@("SQLI FIELD NAME")="3"
399 S @ARY@("VARIABLE NAME")="2"
400 Q
401 ;
402ADDXP(INARY,TID) ;ADD XPATH .01 FIELD TO BINDING SUBFILE OF TEMPLATE TID
403 N FARY S FARY="C0PFILES"
404 D INITXPF(FARY)
405 D ADDXP^C0CMXP(INARY,TID,FARY) ;
406 Q
407 ;
408ADDXML(INXML,TEMPID) ;ADD XML TO A TEMPLATE ID TEMPID
409 ; INXML IS PASSED BY NAME
410 N FARY S FARY="C0PFILES"
411 D INITXPF(FARY)
412 D ADDXML^C0CMXP(INXML,TEMPID,FARY) ;CALL C0C ROUTINE TO ADD TO THE FILE
413 Q
414 ;
415ADDTEMP(INXML,TEMPID,FARY) ;ADD XML TEMPLATE TO TEMPLATE RECORD TEMPID FIELD 3
416 ;
417 N FARY S FARY="C0PFILES"
418 D INITXPF(FARY)
419 D ADDTEMP^C0CMXP(INXML,TEMPID,FARY)
420 Q
421 ;
422GETXML(OUTXML,TEMPID,FARY) ;GET THE XML FROM TEMPLATE TEMPID
423 ;
424 N FARY S FARY="C0PFILES"
425 D INITXPF(FARY)
426 N C0PUTID ; TEMPLATE IEN TO USE
427 D GETXML^C0CMXP(OUTXML,TEMPID,FARY)
428 Q
429 ;
430GETTEMP(OUTXML,TEMPID,FARY) ;GET THE TEMPLATE XML FROM TEMPLATE TEMPID
431 ;
432 N FARY S FARY="C0PFILES"
433 D INITXPF(FARY)
434 N C0PUTID ; TEMPLATE IEN TO USE
435 D GETTEMP^C0CMXP(OUTXML,TEMPID,FARY)
436 Q
437 ;
438COPYHDR(ZS,ZD) ; COPY XML HEADER FROM RECORD ZS TO ZD
439 ; ASSUMES C0P XML TEMPLATE FILE
440 N FARY
441 D INITXPF("FARY")
442 D COPYWP^C0CMXP("XML HEADER",ZS,ZD,"FARY")
443 Q
444 ;
445UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
446 K ZERR
447 D CLEAN^DILF
448 D UPDATE^DIE("","C0PFDA","","ZERR")
449 I $D(ZERR) D ERROR^C0PMAIN(",U113059008,",$ST($ST,"PLACE"),"ERX-UPDIE-FAIL","Fileman Data Update Failure") QUIT
450 K C0PFDA
451 Q
452 ;
Note: See TracBrowser for help on using the repository browser.