1 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
2 <!-- Generated by Hand -->
4 Copyright (C) 2011 Julia Longtin <julia.longtin@gmail.com>
6 This program is free software; you can redistribute it and/or
7 Modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 <xsl:stylesheet version=
"1.0"
12 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform">
13 <!-- this file contains code written in php, used before the <html> tag -->
14 <!-- this code is generated for each date field in the form, to split the time of day from the date in question, for display purposes -->
15 <xsl:template match=
"field[@type='date']" mode=
"split_timeofday">
16 <xsl:text disable-output-escaping=
"yes"><![CDATA[if ($]]
></xsl:text>
17 <xsl:value-of select=
"$fetchrow"/>
18 <xsl:text disable-output-escaping=
"yes"><![CDATA[[']]
></xsl:text>
19 <xsl:value-of select=
"@name"/>
20 <xsl:text disable-output-escaping=
"yes"><![CDATA['] != '') {
21 $dateparts = split(' ', $]]
></xsl:text>
22 <xsl:value-of select=
"$fetchrow"/>
23 <xsl:text disable-output-escaping=
"yes"><![CDATA[[']]
></xsl:text>
24 <xsl:value-of select=
"@name"/>
25 <xsl:text disable-output-escaping=
"yes"><![CDATA[']);
27 <xsl:value-of select=
"$fetchrow"/>
28 <xsl:text disable-output-escaping=
"yes"><![CDATA[[']]
></xsl:text>
29 <xsl:value-of select=
"@name"/>
30 <xsl:text disable-output-escaping=
"yes"><![CDATA['] = $dateparts[
0];
34 <!-- generate php code for fetching form contents, regardless of table format. -->
35 <xsl:template match=
"table[@type='form']" mode=
"fetch">
36 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* Use the formFetch function from api.inc to load the saved record */
38 <xsl:value-of select=
"$fetchrow"/>
39 <xsl:text disable-output-escaping=
"yes"><![CDATA[ = formFetch($table_name, $_GET['id']);
43 <xsl:template match=
"table[@type='extended']" mode=
"fetch">
44 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* use the sqlQuery function from sql.inc to load the saved record. */
45 /* if we were passed an ID, pull it in specifically. otherwise, pull in the newest. */
47 /* use the pid from the session to find the newest version of this form. */
50 $sql = 'select * from '.$table_name.
" where pid='".$pid.
"'";
53 <xsl:when test=
"//signature">
54 <xsl:text disable-output-escaping=
"yes"><![CDATA[ /* use sqlStatement to get multiple rows */
55 $signature_fields = sqlStatement(
"select * from signatures where formname=']]></xsl:text>
56 <xsl:value-of select="/form/safename
"/>
57 <xsl:text disable-output-escaping="yes
"><![CDATA[' order by level ASC");
61 while ($signature_field = sqlFetchArray($signature_fields)) {
62 $current_signature_field=$signature_field['fieldname'];
63 $current_signature_comparison_operator=$signature_field['relationship'];
64 $current_signature_comparison_value=$signature_field['constant'];
65 $last_level=$current_level;
66 $current_level=$signature_field['level'];
67 $current_level_subordinate_relationship=$signature_field['subordinaterelationship'];
68 $current_level_peer_relationship=$signature_field['peerrelationship'];
69 if (strcmp($current_level, $last_level) !=
0) {
70 /* we changed levels */
71 if (strcmp($last_level, '') ==
0) {
72 /* current is our first level */
77 /* current is not our first level */
79 if (strcmp($current_level_subordinate_relationship, 'AND') ==
0) {
87 $sql .= $current_signature_field.' ';
88 if (strcmp($current_signature_comparison_operator,'not-equal') ==
0) {
95 $sql .= '''.$current_signature_comparison_value.'' ';
100 $sql .= $current_level_peer_relationship.' ';
101 $sql .= $current_signature_field.' ';
102 if (strcmp($current_signature_comparison_operator,'not-equal') ==
0) {
109 $sql .=
"'".$current_signature_comparison_value.
"' ";
112 $sql .= ') ) order by effective_date DESC limit
0,
1';
117 <xsl:text disable-output-escaping=
"yes"><![CDATA[
118 $sql .= ' order by date DESC limit
0,
1';
122 <xsl:text disable-output-escaping=
"yes"><![CDATA[$]]
></xsl:text>
123 <xsl:value-of select=
"$fetchrow"/>
124 <xsl:text disable-output-escaping=
"yes"><![CDATA[ = sqlQuery($sql);
129 <xsl:value-of select=
"$fetchrow"/>
130 <xsl:text disable-output-escaping=
"yes"><![CDATA[= sqlQuery('select * from '.$table_name.
" where pid='".$pid.
"' and id='".$_GET['id'].
"' order by date DESC limit 0,1");
134 <xsl:template match=
"table">
135 <xsl:if test=
"$fetchrow!=''">
136 <xsl:text disable-output-escaping=
"yes"><![CDATA[/** CHANGE THIS - name of the database table associated with this form **/
137 $table_name = ']]
></xsl:text>
138 <xsl:value-of select=
"./text()" />
139 <xsl:text disable-output-escaping=
"yes"><![CDATA[';
144 <xsl:template match=
"acl">
145 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* Check the access control lists to ensure permissions to this page */
146 $thisauth = acl_check(']]
></xsl:text>
147 <xsl:value-of select=
"@table" />
148 <xsl:text disable-output-escaping=
"yes"><![CDATA[', ']]
></xsl:text>
149 <xsl:value-of select=
"./text()" />
150 <xsl:text disable-output-escaping=
"yes"><![CDATA[');]]
></xsl:text>
151 <xsl:if test=
"@table='patients'">
152 <xsl:text disable-output-escaping=
"yes"><![CDATA[
154 die($form_name.': Access Denied.');
156 /* perform a squad check for pages touching patients, if we're in 'athletic team' mode */
157 if ($GLOBALS['athletic_team']!='false') {
158 $tmp = getPatientData($pid, 'squad');
159 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
164 <xsl:if test=
"$page='new' or $page='view'">
165 <xsl:text disable-output-escaping=
"yes"><![CDATA[
166 if ($thisauth != 'write' && $thisauth != 'addonly')
167 die($form_name.': Adding is not authorized.');
171 <!-- default layout object -->
172 <xsl:template match=
"layout">
173 <xsl:if test=
"$page='show'">
174 <xsl:text disable-output-escaping=
"yes"><![CDATA[
<!-- display the form's layouts based fields -->
175 <table border='
0' cellpadding='
0' width='
100%'
>
177 display_layout_rows(']]
></xsl:text>
178 <xsl:value-of select=
"@name"/>
179 <xsl:text disable-output-escaping=
"yes"><![CDATA[', $]]
></xsl:text>
180 <xsl:value-of select=
"$fetchrow"/>
181 <xsl:text disable-output-escaping=
"yes"><![CDATA[);
186 <xsl:if test=
"$page='new' or $page='view'">
187 <xsl:text disable-output-escaping=
"yes"><![CDATA[
<!-- display the form's layouts based fields -->
189 while ($frow = sqlFetchArray($fres)) {
190 $this_group = $frow['group_name'];
191 $titlecols = $frow['titlecols'];
192 $datacols = $frow['datacols'];
193 $data_type = $frow['data_type'];
194 $field_id = $frow['field_id'];
195 $list_id = $frow['list_id'];
196 $currvalue = isset($result[$field_id]) ? $result[$field_id] : '';
198 // Handle a data category (group) change.
199 if (strcmp($this_group, $last_group) !=
0) {
201 $group_seq = substr($this_group,
0,
1);
202 $group_name = substr($this_group,
1);
203 $last_group = $this_group;
204 echo
"<div><span class='sectionlabel'><input type='checkbox' id='form_cb_$group_seq' value='1' " .
205 "onclick='return divclick(this,\"$field_id\
");'";
206 if (strcmp($check_first_section, 'true')) echo
" checked='checked'";
208 // Modified
6-
09 by BM - Translate if applicable
209 echo '
/>' . xl_layout_label($group_name) . '
</span>' . PHP_EOL;
211 echo
"<div id='".$field_id.
"' class='section'>" . PHP_EOL;
212 echo
" <table border='0' cellpadding='0'>" . PHP_EOL;
213 /* setting this to false here turns it off for the rest of the sections. */
214 $check_first_section = 'false';
217 // Handle starting of a new row.
218 if (($titlecols
> 0 && $cell_count
>= $cells_per_row) || $cell_count ==
0) {
223 if ($item_count ==
0 && $titlecols ==
0) $titlecols =
1;
225 // Handle starting of a new label cell.
226 if ($titlecols
> 0) {
228 echo
"<td colspan='$titlecols' valign='top'";
229 echo ($frow['uor'] ==
2) ?
" class='required'" :
" class='label'";
230 if ($cell_count ==
2) echo
" style='padding-left:10pt'";
232 $cell_count += $titlecols;
237 /* Modified
6-
09 by BM - Translate if applicable */
238 if ($frow['title']) echo (xl_layout_label($frow['title']));
240 // Handle starting of a new data cell.
243 echo
"<td colspan='$datacols' class='text'";
244 if ($cell_count
> 0) echo
" style='padding-left:5pt'";
246 $cell_count += $datacols;
250 generate_form_field($frow, $currvalue);
259 <!-- default style object -->
260 <xsl:template match=
"style">
261 <xsl:if test=
"//layout">
262 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* set some style related variables for the layouts code */
263 /* if this is true, check the check box on the first section, and none of the others. */
264 $check_first_sections='true';
266 /* how many cells to draw on each row. */
267 $cells_per_row=]]
></xsl:text>
268 <xsl:value-of select=
"@cells_per_row" />
269 <xsl:text disable-output-escaping=
"yes"><![CDATA[;
273 <xsl:template match=
"manual" mode=
"head">
274 <xsl:if test=
"$page='show' or $page='view' or $page='new'">
275 <xsl:if test=
"//manual//field[@type='checkbox_list' or @type='exams' or @type='textbox' or @type='textarea' or @type='provider' or @type='date' or @type='textfield' or @type='dropdown_list']">
276 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* in order to use the layout engine's draw functions, we need a fake table of layout data. */
277 $manual_layouts = array(
279 <xsl:for-each select=
"//manual//field[@type='checkbox_list' or @type='exams' or @type='textbox' or @type='textarea' or @type='provider' or @type='date' or @type='textfield' or @type='dropdown_list']">
280 <xsl:text disable-output-escaping=
"yes"><![CDATA[ ']]
></xsl:text>
281 <xsl:value-of select=
"@name" />
282 <xsl:text disable-output-escaping=
"yes"><![CDATA[' =
>
283 array( 'field_id' =
> ']]
></xsl:text>
284 <xsl:value-of select=
"@name" />
285 <xsl:if test=
"@type='checkbox_list'">
286 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
289 'description' =
> ']]
></xsl:text>
291 <xsl:if test=
"@type='exams'">
292 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
295 'description' =
> ']]
></xsl:text>
297 <xsl:if test=
"@type='textbox'">
298 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
301 'description' =
> ']]
></xsl:text>
303 <xsl:if test=
"@type='textarea'">
304 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
306 'fld_length' =
> ']]
></xsl:text>
308 <xsl:when test=
"@columns">
309 <xsl:value-of select=
"@columns"/>
312 <xsl:text disable-output-escaping=
"yes"><![CDATA[
40]]
></xsl:text>
315 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
316 'max_length' =
> ']]
></xsl:text>
318 <xsl:when test=
"@rows">
319 <xsl:value-of select=
"@rows"/>
322 <xsl:text disable-output-escaping=
"yes"><![CDATA[
4]]
></xsl:text>
325 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
326 'description' =
> ']]
></xsl:text>
328 <xsl:if test=
"@type='provider'">
329 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
332 'description' =
> ']]
></xsl:text>
334 <xsl:if test=
"@type='date' and @name!='effective_date'">
335 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
338 'description' =
> ']]
></xsl:text>
340 <xsl:if test=
"@type='textfield'">
341 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
343 'fld_length' =
> ']]
></xsl:text>
345 <xsl:when test=
"@size">
346 <xsl:value-of select=
"@size"/>
349 <xsl:text disable-output-escaping=
"yes"><![CDATA[
10]]
></xsl:text>
352 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
353 'max_length' =
> ']]
></xsl:text>
354 <xsl:value-of select=
"@maxlength" />
355 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
356 'description' =
> ']]
></xsl:text>
358 <xsl:if test=
"@type='dropdown_list'">
359 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
362 'description' =
> ']]
></xsl:text>
364 <xsl:value-of select=
"@hoverover" />
365 <xsl:text disable-output-escaping=
"yes"><![CDATA[',
366 'list_id' =
> ']]
></xsl:text>
367 <xsl:variable name=
"i" select=
"@list"/>
368 <xsl:value-of select=
"//list[@name=$i]/@id" />
369 <xsl:text disable-output-escaping=
"yes"><![CDATA[' )]]
></xsl:text>
370 <xsl:if test=
"following-sibling::field or ../following-sibling::section/field">
371 <xsl:text disable-output-escaping=
"yes"><![CDATA[,]]
></xsl:text>
373 <xsl:text disable-output-escaping=
"yes"><![CDATA[
376 <xsl:text disable-output-escaping=
"yes"><![CDATA[ );
381 <xsl:template match=
"layout" mode=
"head">
382 <xsl:if test=
"$page!='show'">
383 <xsl:text disable-output-escaping=
"yes"><![CDATA[/* Functions for generating the layout based form fields */
384 function end_cell() {
385 global $item_count, $cell_count;
386 if ($item_count
> 0) {
393 global $cell_count, $cells_per_row;
395 if ($cell_count
> 0) {
396 for (; $cell_count < $cells_per_row; ++$cell_count) echo '
<td></td>';
397 echo '
</tr>' . PHP_EOL;
402 function end_group() {
404 if (strlen($last_group)
> 0) {
406 echo '
</table>' . PHP_EOL;
407 echo '
</div>' . PHP_EOL;
411 /* global variables used by the previous functions */
416 /* Retreive the layout engine based form information. */
417 $fres = sqlStatement('SELECT * FROM layout_options ' .
418 "WHERE form_id = ']]></xsl:text>
419 <xsl:value-of select="@name
" />
420 <xsl:text disable-output-escaping="yes
"><![CDATA[' AND uor > 0 " .
421 'ORDER BY group_name, seq');
425 <xsl:template match=
"safename">
426 <xsl:text disable-output-escaping=
"yes"><![CDATA[/** CHANGE THIS to match the folder you created for this form. **/
427 $form_folder = ']]
></xsl:text>
428 <xsl:value-of select=
"./text()" />
429 <xsl:text disable-output-escaping=
"yes"><![CDATA[';
433 <xsl:template match=
"RealName">
434 <xsl:text disable-output-escaping=
"yes"><![CDATA[/** CHANGE THIS name to the name of your form. **/
435 $form_name = ']]
></xsl:text>
436 <xsl:value-of select=
"./text()" />
437 <xsl:text disable-output-escaping=
"yes"><![CDATA[';
441 <xsl:template name=
"generate_chkdata">
442 <xsl:text disable-output-escaping=
"yes"><![CDATA[
443 /* define check field functions. used for translating from fields to html viewable strings */
445 <xsl:if test=
"//field[@type='date']">
446 <xsl:text disable-output-escaping=
"yes"><![CDATA[
447 function chkdata_Date(&$record, $var) {
448 return htmlspecialchars($record{
"$var"},ENT_QUOTES);
452 <xsl:if test=
"//field[@type='textarea' or @type='textfield']">
453 <xsl:text disable-output-escaping=
"yes"><![CDATA[
454 function chkdata_Txt(&$record, $var) {
455 return htmlspecialchars($record{
"$var"},ENT_QUOTES);
459 <xsl:if test=
"//checkbox">
460 <xsl:text disable-output-escaping=
"yes"><![CDATA[
461 function chkdata_CB(&$record, $nam, $var) {
462 if (preg_match(
"/Negative.*$var/",$record{$nam})) {return;} else {return '
checked=
"checked"';}
466 <xsl:if test=
"//button">
467 <xsl:text disable-output-escaping=
"yes"><![CDATA[
468 function chkdata_Radio(&$record, $nam, $var) {
469 if (strpos($record{$nam},$var) !== false) {return '
checked=
"checked"';}
473 <xsl:if test=
"//option">
474 <xsl:text disable-output-escaping=
"yes"><![CDATA[
475 function chkdata_PopOrScroll(&$record, $nam, $var) {
476 if (preg_match(
"/Negative.*$var/",$record{$nam})) {return;} else {return 'selected';}