From ef2bef3bad31da3b19ac9ee2c36fee879c4760db Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 3 Feb 2009 23:14:05 +0000 Subject: [PATCH] New SRH form for IPPF --- contrib/forms/ippf_srh/info.txt | 1 + contrib/forms/ippf_srh/new.php | 238 ++++++++++++++++++++++++++++++++++++++ contrib/forms/ippf_srh/report.php | 79 +++++++++++++ contrib/forms/ippf_srh/table.sql | 22 ++++ contrib/forms/ippf_srh/view.php | 3 + 5 files changed, 343 insertions(+) create mode 100644 contrib/forms/ippf_srh/info.txt create mode 100644 contrib/forms/ippf_srh/new.php create mode 100644 contrib/forms/ippf_srh/report.php create mode 100644 contrib/forms/ippf_srh/table.sql create mode 100644 contrib/forms/ippf_srh/view.php diff --git a/contrib/forms/ippf_srh/info.txt b/contrib/forms/ippf_srh/info.txt new file mode 100644 index 000000000..95b5af839 --- /dev/null +++ b/contrib/forms/ippf_srh/info.txt @@ -0,0 +1 @@ +IPPF SRH Data diff --git a/contrib/forms/ippf_srh/new.php b/contrib/forms/ippf_srh/new.php new file mode 100644 index 000000000..1ec7cee28 --- /dev/null +++ b/contrib/forms/ippf_srh/new.php @@ -0,0 +1,238 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +require_once("../../globals.php"); +require_once("$srcdir/api.inc"); +require_once("$srcdir/forms.inc"); +require_once("$srcdir/options.inc.php"); +require_once("$srcdir/patient.inc"); + +$CPR = 4; // cells per row + +$pprow = array(); + +if (! $encounter) { // comes from globals.php + die("Internal error: we do not seem to be in an encounter!"); +} + +function end_cell() { + global $item_count, $cell_count; + if ($item_count > 0) { + echo ""; + $item_count = 0; + } +} + +function end_row() { + global $cell_count, $CPR; + end_cell(); + if ($cell_count > 0) { + for (; $cell_count < $CPR; ++$cell_count) echo ""; + echo "\n"; + $cell_count = 0; + } +} + +function end_group() { + global $last_group; + if (strlen($last_group) > 0) { + end_row(); + echo " \n"; + echo "\n"; + } +} + +$formid = $_GET['id']; + +// If Save was clicked, save the info. +// +if ($_POST['bn_save']) { + $sets = ""; + $fres = sqlStatement("SELECT * FROM layout_options " . + "WHERE form_id = 'SRH' AND uor > 0 AND field_id != '' AND " . + "edit_options != 'H' " . + "ORDER BY group_name, seq"); + while ($frow = sqlFetchArray($fres)) { + $field_id = $frow['field_id']; + $value = get_layout_form_value($frow); + if ($sets) $sets .= ", "; + $sets .= "$field_id = '$value'"; + } + + if ($formid) { + // Updating an existing form. + $query = "UPDATE form_ippf_srh SET $sets WHERE id = '$formid'"; + sqlStatement($query); + } + else { + // Adding a new form. + $query = "INSERT INTO form_ippf_srh SET $sets"; + $newid = sqlInsert($query); + addForm($encounter, "IPPF SRH Data", $newid, "ippf_srh", $pid, $userauthorized); + } + + formHeader("Redirecting...."); + formJump(); + formFooter(); + exit; +} + +if ($formid) { + $pprow = sqlQuery ("SELECT * FROM form_ippf_srh WHERE " . + "id = '$formid' AND activity = '1'") ; +} +?> + + + + + + + + + + + + topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0"> +
+ +

IPPF SRH Data

+ +\n"; + + $fres = sqlStatement("SELECT * FROM layout_options " . + "WHERE form_id = 'SRH' AND uor > 0 " . + "ORDER BY group_name, seq"); + $last_group = ''; + $cell_count = 0; + $item_count = 0; + $display_style = 'block'; + + while ($frow = sqlFetchArray($fres)) { + $this_group = $frow['group_name']; + $titlecols = $frow['titlecols']; + $datacols = $frow['datacols']; + $data_type = $frow['data_type']; + $field_id = $frow['field_id']; + $list_id = $frow['list_id']; + + $currvalue = ''; + + if ($frow['edit_options'] == 'H') { + // This data comes from static history + if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id]; + } else { + if (isset($pprow[$field_id])) $currvalue = $pprow[$field_id]; + } + + // Handle a data category (group) change. + if (strcmp($this_group, $last_group) != 0) { + end_group(); + $group_seq = 'srh' . substr($this_group, 0, 1); + $group_name = substr($this_group, 1); + $last_group = $this_group; + echo "
$group_name\n"; + echo "
\n"; + echo " \n"; + $display_style = 'none'; + } + + // Handle starting of a new row. + if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) { + end_row(); + echo " "; + } + + if ($item_count == 0 && $titlecols == 0) $titlecols = 1; + + // Handle starting of a new label cell. + if ($titlecols > 0) { + end_cell(); + echo "\n \n"; + } + echo " \n"; +} + +// This function is invoked from printPatientForms in report.inc +// when viewing a "comprehensive patient report". Also from +// interface/patient_file/encounter/forms.php. +// +function ippf_srh_report($pid, $encounter, $cols, $id) { + global $fi_report_cols; + + /******************************************************************** + + include('fia.inc.php'); + + $row = sqlQuery ("SELECT form_encounter.onset_date AS occdate, fi.* " . + "FROM forms, form_encounter, form_ippf_srh AS fi WHERE " . + "forms.formdir = 'ippf_srh' AND " . + "forms.form_id = '$id' AND " . + "fi.id = '$id' AND fi.activity = '1' AND " . + "form_encounter.encounter = forms.encounter AND " . + "form_encounter.pid = forms.pid"); + + if (!$row) return; + + $fi_report_cols = $cols; + + echo "
"; + $cell_count += $titlecols; + } + ++$item_count; + + echo ""; + if ($frow['title']) echo $frow['title'] . ":"; else echo " "; + echo ""; + + // Handle starting of a new data cell. + if ($datacols > 0) { + end_cell(); + echo " 0) echo " style='padding-left:5pt'"; + echo ">"; + $cell_count += $datacols; + } + + ++$item_count; + + if ($frow['edit_options'] == 'H') + echo generate_display_field($frow, $currvalue); + else + generate_form_field($frow, $currvalue); + } + + end_group(); + // echo "\n"; +?> + +

+ +  + +  +

+ + + + + diff --git a/contrib/forms/ippf_srh/report.php b/contrib/forms/ippf_srh/report.php new file mode 100644 index 000000000..ac98843bb --- /dev/null +++ b/contrib/forms/ippf_srh/report.php @@ -0,0 +1,79 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +include_once("../../globals.php"); +include_once($GLOBALS["srcdir"] . "/api.inc"); + +$fi_report_cols = 2; +$fi_report_colno = 0; + +// Helper function used by ippf_srh_report(). +// Writes a title/value pair to a table cell. +// +function fi_report_item($title, $value) { + global $fi_report_cols, $fi_report_colno; + if (!$value) return; + if (++$fi_report_colno > $fi_report_cols) { + $fi_report_colno = 1; + echo "
$title: " . + "$value  
\n"; + echo " \n"; + + if ($row['fiinjmin'] ) fi_report_item("Min of Injury", $row['fiinjmin']); + if ($row['fiinjtime']) fi_report_item("During", $arr_injtime[$row['fiinjtime']]); + if ($row['fimatchtype']) fi_report_item("Match Type", $arr_match_type[$row['fimatchtype']]); + foreach ($arr_activity as $key => $value) { + if ($row["fimech_$key"]) fi_report_item("Mechanism", $value); + } + foreach ($arr_sanction as $key => $value) { + if ($row["fimech_$key"]) fi_report_item("Sanction", $value); + } + if ($row["fimech_othercon"]) fi_report_item("Other Contact", $row["fimech_othercon"]); + if ($row["fimech_othernon"]) fi_report_item("Other Noncontact", $row["fimech_othernon"]); + fi_report_item("Surface" , $arr_surface[$row['fisurface']]); + fi_report_item("Position" , $arr_position[$row['fiposition']]); + fi_report_item("Footwear" , $arr_footwear[$row['fifootwear']]); + fi_report_item("Side" , $arr_side[$row['fiside']]); + fi_report_item("Removed" , $arr_removed[$row['firemoved']]); + + echo " \n"; + echo "
\n"; + + ********************************************************************/ + +} +?> diff --git a/contrib/forms/ippf_srh/table.sql b/contrib/forms/ippf_srh/table.sql new file mode 100644 index 000000000..bd34a40e9 --- /dev/null +++ b/contrib/forms/ippf_srh/table.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS form_ippf_srh ( + id bigint(20) NOT NULL auto_increment, + activity tinyint(1) NOT NULL DEFAULT 1, + men_hist varchar(255) NOT NULL DEFAULT '', + men_compl varchar(255) NOT NULL DEFAULT '', + pap_hist varchar(255) NOT NULL DEFAULT '', + gyn_exams varchar(255) NOT NULL DEFAULT '', + pr_status varchar(255) NOT NULL DEFAULT '', + gest_age_by varchar(255) NOT NULL DEFAULT '', + obs_exams varchar(255) NOT NULL DEFAULT '', + pr_outcome varchar(255) NOT NULL DEFAULT '', + pr_compl varchar(255) NOT NULL DEFAULT '', + abo_exams varchar(255) NOT NULL DEFAULT '', + hiv_exams varchar(255) NOT NULL DEFAULT '', + its_exams varchar(255) NOT NULL DEFAULT '', + fer_exams varchar(255) NOT NULL DEFAULT '', + fer_causes varchar(255) NOT NULL DEFAULT '', + fer_treat varchar(255) NOT NULL DEFAULT '', + uro_exams varchar(255) NOT NULL DEFAULT '', + uro_disease varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (id) +) ENGINE=MyISAM; diff --git a/contrib/forms/ippf_srh/view.php b/contrib/forms/ippf_srh/view.php new file mode 100644 index 000000000..0bbc122b9 --- /dev/null +++ b/contrib/forms/ippf_srh/view.php @@ -0,0 +1,3 @@ + \ No newline at end of file -- 2.11.4.GIT