// // 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"; } } ?> OpenEMR IPPF Upgrade

OpenEMR IPPF Upgrade

Converting database to UTF-8 encoding..."; $tres = sqlStatement("SHOW TABLES"); while ($trow = sqlFetchArray($tres)) { $value = array_shift($trow); $query = "ALTER TABLE $value CONVERT TO CHARACTER SET utf8"; if ($verbose) { echo "
$query\n"; } sqlStatement($query); } $query = "ALTER DATABASE $dbase CHARACTER SET utf8"; if ($verbose) { echo "
$query\n"; } sqlStatement($query); echo "
 \n"; } $ires = sqlStatement("SELECT " . "l.pid, l.id, l.type, l.begdate, l.title, " . "g.client_status, g.in_ab_proc, g.ab_location, " . "g.rec_compl, g.contrameth, g.fol_compl " . "FROM lists AS l " . "JOIN lists_ippf_gcac AS g ON l.type = 'ippf_gcac' AND g.id = l.id " . "ORDER BY l.pid, l.begdate"); while ($irow = sqlFetchArray($ires)) { $patient_id = $irow['pid']; $list_id = $irow['id']; $first = true; $ieres = sqlStatement("SELECT encounter " . "FROM issue_encounter " . "WHERE pid = '$patient_id' AND list_id = '$list_id' " . "ORDER BY encounter"); if (sqlNumRows($ieres)) { while ($ierow = sqlFetchArray($ieres)) { do_visit_form($irow, $ierow['encounter'], $first); $first = false; } } else { echo "
*** Issue $list_id for pid $patient_id has no linked visits, skipped ***\n"; } } echo "

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.