I am working on a script to import patients, and also am parsing some associated text to also create encounters for the patients. Here is the code I am using for this:
$encounter_date = date("Y-m-d", strtotime($match[0]));
$enc_id = generate_id();
$new_encounter = sqlInsert("INSERT INTO form_encounter (date, reason, pid, encounter, pc_catid, provider_id)
VALUES(?,?,?,?,?,?)",
[$encounter_date, "foobarImport", $patient['pid'], $enc_id, 16, 1]);
//make insertion into forms_wintas_foobar table
$forms_wintas_foobar = sqlInsert("insert into forms_wintas_foobar (pid, date, activity, progress_notes) VALUES(?,?,?,?)",
[$patient['pid'], $encounter_date, 1, nl2br($note)]);
if ($forms_wintas_foobar > 0) {
// echo("successfuly completed forms_wintas_foobar db insert". "\n");
} else {
return false;
}
//make insertion into forms table
$result = sqlInsert("insert into forms (encounter, form_name, form_id, pid, formdir) VALUES(?,?,?,?,?)",
[$enc_id, "wintas foobar", $forms_wintas_foobar, $patient['pid'], "wintas_foobar2"]);
if ($result > 0) {
// echo("successfuly completed forms table insert");
} else {
return false;
}
This is all working except for the encounter description. It seems to be linked to the pc_catid
field in the form_encounter
table; this points to the categories
table (foreign key to the id)? That does not seem to be the case as I am inserting 16 for the pc_catid. There is an insertion for 16 in the categories table, but as you can see in the screenshot the field appears to be blank. Any help is appreciated.