source: WorldVistAEHR/trunk/r/HEALTHEVET_DESKTOP-XHD/XHDPTREE.m@ 1604

Last change on this file since 1604 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.8 KB
RevLine 
[613]1XHDPTREE ; SLC/JER - Configurator Server Calls ; 08 Oct 2003 11:00
2 ;;1.0;HEALTHEVET DESKTOP;;Jul 15, 2003
3GETTREE(XHDCY,XHDMOD) ; Control Branching
4 N XHDCI,XHDCDA,X S X="ONERROR^XHDPTREE",@^%ZOSF("TRAP")
5 S XHDCI=0,XHDCDA=+$O(^XHD(8935.91,"AMROOT",XHDMOD,0))
6 S XHDCY=$NA(^TMP("XHDPTREE",$J)) K @XHDCY
7 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<?xml version=""1.0"" encoding=""UTF-8""?>"
8 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<getConfigurationCallResult"
9 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
10 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="xsi:noNamespaceSchemaLocation=""C:\reeng\main\modules\config\src\gov\va\med\hds\cd\config\xml\getConfigurationCallResult.xsd"">"
11 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<configTree>"
12 D GETCAT(XHDCY,XHDCDA,.XHDCI)
13 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</configTree>"
14 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</getConfigurationCallResult>"
15 S XHDCY=$NA(^TMP("XHDPTREE",$J,"XMLDOC"))
16 Q
17FLDS() ; Get field string
18 Q ".01:1"
19GETCAT(XHDCY,XHDCDA,XHDCI) ; Loads Top-level Fields
20 N XHDCF,XHDKI,PCATAG S XHDCF=0
21 S PCATAG=$S($$ISROOT(XHDCDA):"pluginParameterCategory",1:"parameterCategory")
22 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<"_PCATAG_">"
23 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<id>"_XHDCDA_"</id>"
24 D GETS^DIQ(8935.91,XHDCDA_",",$$FLDS,"IE",XHDCY)
25 F S XHDCF=$O(@XHDCY@(8935.91,XHDCDA_",",XHDCF)) Q:XHDCF'>0 D
26 . N TAG,VAL
27 . S TAG=$TR($$FLDNAME(XHDCF,8935.91)," /","")
28 . S VAL=$G(@XHDCY@(8935.91,XHDCDA_",",XHDCF,$S(XHDCF=.04:"I",1:"E")))
29 . I XHDCF=.04 S VAL=+VAL
30 . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<"_TAG_">"_VAL_"</"_TAG_">"
31 K @XHDCY@(8935.91)
32 ;** get parameters **
33 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<parameters>"
34 D GETPARAM(XHDCY,XHDCDA,.XHDCI)
35 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</parameters>"
36 S XHDKI=0
37 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<children>"
38 F S XHDKI=$O(^XHD(8935.91,XHDCDA,3,XHDKI)) Q:+XHDKI'>0 D
39 . N XHDKID S XHDKID=$P($G(^XHD(8935.91,XHDCDA,3,XHDKI,0)),U,2)
40 . D GETCAT(XHDCY,XHDKID,.XHDCI)
41 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</children>"
42 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</"_PCATAG_">"
43 Q
44ISROOT(XHDCDA) ; Boolean - is record plugin root?
45 Q +$P($G(^XHD(8935.91,XHDCDA,0)),U,5)
46FLDNAME(XHDCFN,FILENUM) ; Resolve field names
47 Q $$MIXED($P($G(^DD(FILENUM,XHDCFN,0)),U))
48MIXED(X) ; Return Mixed Case X
49 N XHDI,WORD,TMP
50 S TMP="" F XHDI=1:1:$L(X," ") S WORD=$$LOW^XLFSTR($P(X," ",XHDI)),$E(WORD)=$S(XHDI=1:$E(WORD),1:$$UP^XLFSTR($E(WORD))),TMP=$S(TMP="":WORD,1:TMP_WORD)
51 Q TMP
52GETPARAM(XHDCY,XHDCDA,XHDCI) ; Loads Parameters
53 N XHDI S XHDI=0
54 F S XHDI=$O(^XHD(8935.91,XHDCDA,2,XHDI)) Q:+XHDI'>0 D
55 . N PNODE,FULLNAME,MULTIVAL,WORDPROC,PAR,PARDEF0,PARDEF1,DNAME,VDTYPE,READONLY
56 . S PNODE=$G(^XHD(8935.91,XHDCDA,2,XHDI,0))
57 . Q:PNODE']""
58 . S PAR=$P(PNODE,U,2),PARDEF0=$G(^XTV(8989.51,PAR,0)),PARDEF1=$G(^(1))
59 . S FULLNAME=$P(PARDEF0,U),DNAME=$P(PARDEF0,U,2),VDTYPE=$P(PARDEF1,U)
60 . S READONLY=$S(+$P(PARDEF0,U,6):"true",1:"false")
61 . S MULTIVAL=$S(+$P(PARDEF0,U,3):"true",1:"false")
62 . S WORDPROC=$S(VDTYPE="W":"true",1:"false")
63 . N PLIST,ERR
64 . D GETLST^XPAR(.PLIST,"ALL^"_DUZ_";VA(200,^"_$$GETSRV_";DIC(49,",PAR,$S(VDTYPE="D":"Q",1:"E"),.ERR)
65 . I ERR Q
66 . I PLIST=0 D Q
67 . . N KEY,ENT,INST,NAME,VAL,EXTENT
68 . . S NAME=$$ESCAPE^XHDLXM(DNAME)
69 . . S INST=$S(FULLNAME="ORWOR TIMEOUT CHART":1,1:"")
70 . . S VAL=$S(FULLNAME="ORWOR TIMEOUT CHART":DTIME,1:"")
71 . . S:(MULTIVAL="true") NAME=NAME_" "_INST
72 . . S ENT=DUZ_";VA(200,",EXTENT=$$ENTNAME^XPARLIST(ENT)
73 . . S KEY=NAME_U_ENT_U_PAR_U_INST
74 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<parameter>"
75 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<id>"_PAR_"</id>"
76 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<name>"_NAME_"</name>"
77 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<fullName>"_$$ESCAPE^XHDLXM(FULLNAME)_"</fullName>"
78 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<key>"_KEY_"</key>"
79 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<readOnly>"_READONLY_"</readOnly>"
80 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<extEntity>"_EXTENT_"</extEntity>"
81 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<multiValued>"_MULTIVAL_"</multiValued>"
82 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<wordProcessing>"_WORDPROC_"</wordProcessing>"
83 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)=$S(VAL="":"<value/>",1:"<value>"_VAL_"</value>")
84 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<defaultValue/>"
85 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</parameter>"
86 . N XHDJ S XHDJ=0
87 . F S XHDJ=$O(PLIST(XHDJ)) Q:+XHDJ'>0 D
88 . . N KEY,ENT,INST,VAL,NAME,EXTENT
89 . . S NAME=$$ESCAPE^XHDLXM(DNAME)
90 . . S INST=$P(PLIST(XHDJ),U),VAL=$P(PLIST(XHDJ),U,2)
91 . . S:(MULTIVAL="true") NAME=NAME_" "_INST
92 . . S ENT=$$GETENT(PAR,INST,VAL),EXTENT=$$ENTNAME^XPARLIST(ENT)
93 . . S KEY=NAME_U_ENT_U_PAR_U_INST
94 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<parameter>"
95 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<id>"_PAR_"</id>"
96 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<name>"_NAME_"</name>"
97 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<fullName>"_$$ESCAPE^XHDLXM(FULLNAME)_"</fullName>"
98 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<key>"_KEY_"</key>"
99 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<readOnly>"_READONLY_"</readOnly>"
100 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<extEntity>"_EXTENT_"</extEntity>"
101 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<multiValued>"_MULTIVAL_"</multiValued>"
102 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<wordProcessing>"_WORDPROC_"</wordProcessing>"
103 . . ; If wp, call for wp result
104 . . I (WORDPROC="true") D
105 . . . N VALIST,ERR
106 . . . D GETWP^XPAR(.VALIST,"ALL^"_$P(KEY,U,2),PAR,INST,.ERR)
107 . . . I 'ERR D
108 . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<value>"
109 . . . . N XHDK S XHDK=0
110 . . . . F S XHDK=$O(VALIST(XHDK)) Q:+XHDK'>0 D
111 . . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)=$$ESCAPE^XHDLXM($G(VALIST(XHDK,0)))
112 . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</value>"
113 . . . N DFLIST,ERR
114 . . . D GETWP^XPAR(.DFLIST,"PKG",PAR,INST,.ERR)
115 . . . I 'ERR D
116 . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<defaultValue>"
117 . . . . N XHDK S XHDK=0
118 . . . . F S XHDK=$O(VALIST(XHDK)) Q:+XHDK'>0 D
119 . . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)=$$ESCAPE^XHDLXM($G(VALIST(XHDK,0)))
120 . . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</defaultValue>"
121 . . E D
122 . . . N DVAL S DVAL=$$GET^XPAR("PKG",PAR,INST,$S(VDTYPE="D":"Q",1:"E"))
123 . . . S VAL=$$XFORM(VAL,VDTYPE)
124 . . . S DVAL=$$XFORM(DVAL,VDTYPE)
125 . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<value>"_$$ESCAPE^XHDLXM(VAL)_"</value>"
126 . . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<defaultValue>"_$$ESCAPE^XHDLXM(DVAL)_"</defaultValue>"
127 . . S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</parameter>"
128 Q
129GETSRV() ; Get user's Service/Section
130 Q $P($G(^VA(200,DUZ,5)),U)
131XFORM(VAL,VDTYPE) ; Transform values for select data types
132 N XHDY S XHDY=VAL
133 I VDTYPE="D" S XHDY=$$FMTHL7^XLFDT(VAL) G XFORMX
134 I VDTYPE="Y" S XHDY=$S(VAL="YES":"true",VAL="NO":"false",1:VAL)
135XFORMX Q XHDY
136GETENT(PAR,INST,VAL) ; Find entity, given parameter, instance, and value
137 N VLIST,ERR,ENTITY S ENTITY=0
138 D ENVAL^XPAR(.VLIST,PAR,INST,.ERR)
139 I 'ERR D
140 . N XHDENT S XHDENT=0
141 . F S XHDENT=$O(VLIST(XHDENT)) Q:+XHDENT'>0!+ENTITY D
142 . . I $P(XHDENT,";",2)="VA(200,",(+XHDENT'=DUZ) Q
143 . . I ($G(VLIST(XHDENT,INST))=VAL) S ENTITY=XHDENT
144 S:'+ENTITY ENTITY=DUZ_";VA(200,"
145 Q ENTITY
146ONERROR ; Trap errors
147 N XHDCI S XHDCI=4
148 ; remove remnant of DIQ1 call result
149 K @XHDCY@(8935.91)
150 ; remove partial configTree node
151 F S XHDCI=$O(@XHDCY@("XMLDOC",XHDCI)) Q:+XHDCI'>0 K @XHDCY@("XMLDOC",XHDCI)
152 ; append error node to call result
153 S XHDCI=4
154 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<error>"
155 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="<![CDATA["_$$EC^%ZOSV_"]]>"
156 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</error>"
157 S XHDCI=XHDCI+1,@XHDCY@("XMLDOC",XHDCI)="</getConfigurationCallResult>"
158 S XHDCY=$NA(^TMP("XHDPTREE",$J,"XMLDOC"))
159 D ^%ZTER
160 Q
Note: See TracBrowser for help on using the repository browser.