Adding description (category?) to an encounter

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.

hi @lumbee, it’s openemr_postcalendar_categories table

1 Like

Great, thank you Stephen. Also for posterity, these can be be added through the UI in Administration > Clinic > Calendar, then choose the “Categories” menu item.