Going back and actually reading earlier in the thread, looks like you’re talking about /interface/reports/patient_list_creation.php
Accessible via the GUI by going to Reports → clients → Patient List creation.
Gave it a quick read, check out line ~500.
We may be able to grab the list of patient ids to query on in one of the below.
while ($row = sqlFetchArray($result)) {
$patArr[] = $row[‘patient_id’];
$patInfoArr = array();
$patInfoArr[‘patient_id’] = $row[‘patient_id’];
Scroll to the bottom of while loop. line ~546
We’ll probably want to append our new column here.
$patFinalDataArr[] = $patInfoArr;
Since I’m too lazy to spend the time to actually figure out what is in each of these arrays by reading the code I just put a bunch of echo and print_r statements inside and after the end of the while loop but before the ?> indicating the end of this chunk of php code.
Then going back to the patients list creation screen, filling out some junk data and hitting submit
The highlighted comes from the below line of code.
print_r($patArr) . nl2br(“\n \n”);
Looks like the $patArr array grows with every iteration of the while loop. So in theory if we grab this variable just after the end of the while loop it should give us an array of all the PIDs, highlighted below, we need.
So to get from a php array to a list compatible with the IN operator, looks like we’ll want to use the php .implode functionality.
Might want to note that the pid field is a bigint(20), not sure if this will matter later on.
Let’s try:
$sql = “SELECT MAX(date
) FROM form_encounter
WHERE pid
IN (”.implode(‘,’,$patArr).“)”;
It failed with the below error.
When I run:
SELECT MAX(date
) FROM form_encounter
WHERE pid
IN (3,4,6)
it in the SQL tab in phpmyadmin it returns null.
Seems like this should work based on what I read on stackoverflow. Might this be a SQL versioning issue? Can someone a bit more knowledgeable about MariaDB chime in here? @brady.miller