//
// 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.
// Disable PHP timeout. This will not work in safe mode.
ini_set('max_execution_time', '0');
$ignoreAuth = true; // no login required
require_once('interface/globals.php');
require_once('library/forms.inc');
use OpenEMR\Core\Header;
$verbose = 0;
$debug = 0;
$insert_count = 0;
// Create a visit form from an abortion issue. This may be called
// multiple times for a given issue.
//
function do_visit_form($irow, $encounter, $first)
{
global $insert_count, $debug, $verbose;
$pid = $irow['pid'];
// If a gcac form already exists for this visit, get out.
$row = sqlQuery("SELECT COUNT(*) AS count FROM forms WHERE " .
"pid = '$pid' AND encounter = '$encounter' AND " .
"formdir = 'LBFgcac' AND deleted = 0");
if ($row['count']) {
echo "
*** Visit $pid.$encounter skipped, already has a GCAC visit form ***\n";
return;
}
$a = array(
'client_status' => $irow['client_status'],
'in_ab_proc' => $irow['in_ab_proc'],
'ab_location' => $irow['ab_location'],
'complications' => $irow['fol_compl'],
'contrameth' => $irow['contrameth'],
);
// logic that applies only to the first related visit
if ($first) {
if ($a['ab_location'] == 'ma') {
$a['ab_location'] = 'proc';
}
$a['complications'] = $irow['rec_compl'];
$a['contrameth'] = '';
}
$newid = 0;
$didone = false;
foreach ($a as $field_id => $value) {
if ($value !== '') {
if ($newid) {
$query = "INSERT INTO lbf_data " .
"( form_id, field_id, field_value ) " .
" VALUES ( '$newid', '$field_id', '$value' )";
if ($verbose) {
echo "
$query\n";
}
if (!$debug) {
sqlStatement($query);
}
} else {
$query = "INSERT INTO lbf_data " .
"( field_id, field_value ) " .
" VALUES ( '$field_id', '$value' )";
if ($verbose) {
echo "
$query\n";
}
if (!$debug) {
$newid = sqlInsert($query);
}
}
$didone = true;
}
}
if ($newid && !$debug) {
addForm($encounter, 'IPPF GCAC', $newid, 'LBFgcac', $pid, 1);
++$insert_count;
}
if (!$didone) {
echo "
*** Empty issue skipped for visit $pid.$encounter ***\n";
}
}
?>
Done. Inserted $insert_count visit forms.
\n"; echo "\n"; exit(); } ?>This converts your OpenEMR database to UTF-8 encoding if it is not already, and also converts GCAC issues to the corresponding visit forms. Both of these steps are needed for IPPF sites upgrading from releases prior to 2009-08-27.