source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORTSK11.m@ 1742

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

initial load of WorldVistAEHR

File size: 5.1 KB
Line 
1RORTSK11 ;HCIOFO/SG - REPORT CREATION UTILITIES ; 11/14/06 1:16pm
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 Q
5 ;
6 ;***** ADDS THE ATTRIBUTE TO THE ELEMENT
7 ;
8 ; TASK Task number
9 ;
10 ; ELMTIEN IEN of the element
11 ;
12 ; NAME Attribute name
13 ;
14 ; VALUE Value of the attribute
15 ;
16 ; Return Values:
17 ; <0 Error code
18 ; 0 Invalid attribute name
19 ; >0 Attribute IEN
20 ;
21ADDATTR(TASK,ELMTIEN,NAME,VALUE) ;
22 I $G(ELMTIEN)<0 Q:$QUIT 0 Q
23 N IENS,RC,RORFDA,RORIEN,RORMSG
24 I $D(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10 Q:$QUIT 0 Q
25 S IENS="?+1,"_(+ELMTIEN)_","_(+TASK)_","
26 S (RORIEN(1),RORFDA(798.872,IENS,.01))=$$XEC(NAME)
27 I RORIEN(1)'>0 Q:$QUIT 0 Q
28 S RORFDA(798.872,IENS,1)=VALUE
29 D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
30 I $G(DIERR) D Q:$QUIT RC Q
31 . S RC=$$DBS^RORERR("RORMSG",-9,,,798.872,IENS)
32 Q:$QUIT +$G(RORIEN(1)) Q
33 ;
34 ;***** ADDS THE TEXT ELEMENT TO THE REPORT
35 ;
36 ; TASK Task number
37 ;
38 ; NAME Element name
39 ;
40 ; [.]ROR8TXT Either a closed root or a reference to an array
41 ; that contains the text in word processing format.
42 ;
43 ; [PARENT] IEN of the parent element
44 ;
45 ; The text should be properly encoded beforehand (use the
46 ; $$XMLENC^RORUTL03 function).
47 ;
48 ; Return Values:
49 ; <0 Error code
50 ; 0 Invalid element name
51 ; >0 IEN of the report element
52 ;
53ADDTEXT(TASK,NAME,ROR8TXT,PARENT) ;
54 I $G(PARENT)<0 Q:$QUIT 0 Q
55 N IENS,RC,RORFDA,RORIEN,RORMSG,TMP
56 S IENS="+1,"_(+TASK)_","
57 S (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
58 I TMP'>0 Q:$QUIT 0 Q
59 S RORFDA(798.87,IENS,.02)=+$G(PARENT)
60 S RORFDA(798.87,IENS,3)=$S($D(ROR8TXT)>1:"ROR8TXT",1:ROR8TXT)
61 D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
62 I $G(DIERR) D Q:$QUIT RC Q
63 . S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
64 Q:$QUIT +$G(RORIEN(1)) Q
65 ;
66 ;***** ADDS THE SINGLE-LINE ELEMENT TO THE REPORT
67 ;
68 ; TASK Task number
69 ;
70 ; NAME Element name
71 ;
72 ; [VALUE] Value of the element
73 ;
74 ; [PARENT] IEN of the parent element
75 ;
76 ; [SORTBY] Parent element is sorted by the value of the element
77 ; that is being added:
78 ; 1 Sort "as is"
79 ; 2 Sort as strings
80 ; 3 Sort as numbers
81 ;
82 ; Return Values:
83 ; <0 Error code
84 ; 0 Invalid element name
85 ; >0 IEN of the report element
86 ;
87ADDVAL(TASK,NAME,VALUE,PARENT,SORTBY,ID) ;
88 I $G(PARENT)<0 Q:$QUIT 0 Q
89 N IENS,RC,RORFDA,RORIEN,RORMSG,TMP
90 S IENS="+1,"_(+TASK)_","
91 S (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
92 I TMP'>0 Q:$QUIT 0 Q
93 S RORFDA(798.87,IENS,.02)=+$G(PARENT)
94 S:$G(SORTBY) RORFDA(798.87,IENS,.03)=SORTBY
95 S:$G(VALUE)'="" RORFDA(798.87,IENS,1)=VALUE
96 D:$G(ID)'=""
97 . S TMP="+2,"_IENS
98 . S (RORIEN(2),RORFDA(798.872,TMP,.01))=$$XEC("ID")
99 . S RORFDA(798.872,TMP,1)=ID
100 D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
101 I $G(DIERR) D Q:$QUIT RC Q
102 . S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
103 Q:$QUIT +$G(RORIEN(1)) Q
104 ;
105 ;***** CHECKS IF THE ELEMENT HAS "CHILDREN"
106 ;
107 ; TASK Task number
108 ;
109 ; ELMTIEN IEN of the element
110 ;
111 ; Return Values:
112 ; 0 Leaf element
113 ; >0 Has children
114 ;
115HASCHLD(TASK,ELMTIEN) ;
116 Q:ELMTIEN<0 0
117 Q $D(^RORDATA(798.8,+TASK,"RI","APSV",+ELMTIEN))>1
118 ;
119 ;***** UPDATES VALUE OF THE ELEMENT
120 ;
121 ; TASK Task number
122 ;
123 ; ELMTIEN IEN of the element
124 ;
125 ; [VALUE] Value of the element
126 ;
127 ; [SORTBY] Parent element is sorted by the value of the element
128 ; that is being added:
129 ; 1 Sort "as is"
130 ; 2 Sort as strings
131 ; 3 Sort as numbers
132 ;
133 ; [IGNORE] Do not render this element into the resulting XML
134 ; document.
135 ;
136 ; Return Values:
137 ; <0 Error code
138 ; >0 IEN of the report element
139 ;
140UPDVAL(TASK,ELMTIEN,VALUE,SORTBY,IGNORE) ;
141 I $G(ELMTIEN)<0 Q:$QUIT 0 Q
142 N IENS,RORFDA,RORIEN,RORMSG,TMP
143 I $D(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10 Q:$QUIT 0 Q
144 S IENS=(+ELMTIEN)_","_(+TASK)_","
145 S:$G(SORTBY) RORFDA(798.87,IENS,.03)=SORTBY
146 S RORFDA(798.87,IENS,.04)=$S($G(IGNORE):1,1:"")
147 S RORFDA(798.87,IENS,1)=$G(VALUE)
148 D FILE^DIE(,"RORFDA","RORMSG")
149 I $G(DIERR) D Q:$QUIT RC Q
150 . S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
151 Q:$QUIT +$G(RORIEN(1)) Q
152 ;
153 ;***** DUMPS THE VARIABLE
154 ;
155 ; TASK Task number
156 ;
157 ; ROOT Closed root of the variable
158 ;
159 ; [PARENT] IEN of the parent element (0, by default)
160 ;
161 ; [NAME] Element name ("VARDUMP", by default)
162 ;
163 ; Return Values:
164 ; <0 Error code
165 ; >0 IEN of the element
166 ;
167VARDUMP(TASK,ROOT,PARENT,NAME) ;
168 N DUMP,FLT,LFLT,PI
169 S:$G(NAME)="" NAME="VARDUMP"
170 S:$G(PARENT)'>0 PARENT=0
171 ;---
172 S LFLT=$L(ROOT)
173 S:$E(ROOT,LFLT)=")" LFLT=LFLT-1
174 S FLT=$E(ROOT,1,LFLT)
175 ;---
176 S DUMP=$$ADDVAL^RORTSK11(TASK,NAME,,PARENT)
177 I DUMP<0 Q:$QUIT DUMP Q
178 S PI=ROOT
179 F S PI=$Q(@PI) Q:$E(PI,1,LFLT)'=FLT D
180 . D ADDVAL^RORTSK11(TASK,"ITEM",PI_"="_@PI,DUMP)
181 Q:$QUIT DUMP Q
182 ;
183 ;***** RETURNS TYPE (CODE) OF THE ELEMENT
184 ;
185 ; NAME Element name
186 ;
187XEC(NAME) ;
188 S:'$D(RORCACHE("XMLENT",NAME)) RORCACHE("XMLENT",NAME)=+$O(^ROR(799.31,"B",$E(NAME,1,30),0))
189 Q RORCACHE("XMLENT",NAME)
Note: See TracBrowser for help on using the repository browser.