Display FirstName and then Last Name, sort by id

image

Display FirstName and then Last Name, sort by id
Eg in patient finder view the last name is displayed first, and the patients are sorted last name wise.

Better would be pts be sorted id wise by default , and if the first name is displayed first…
How can i achieve this pl. The most recent pt should be on top, n the rest in descending order.

you can change below code in interface\main\finder\dynamic_finder_ajax.php file.

1]
if ($aColumns[$iSortCol] == ‘name’) {
//$orderby .= “lname $sSortDir, fname $sSortDir, mname $sSortDir”;
$orderby .= “id Desc”;
} else {
$orderby .= "" . escape_sql_column_name($aColumns[$iSortCol], array('patient_data')) . " $sSortDir";
}

2]
foreach ($aColumns as $colname) {
if ($colname == ‘name’) {
$name = $row[‘fname’];
if ($name && $row[‘lname’]) {
$name .= ', ';
}
if ($row[‘lname’]) {
$name .= $row[‘lname’];
}
if ($row[‘mname’]) {
$name .= ’ ’ . $row[‘mname’];
}
$arow[] = attr($name);
} else {
$arow[] = isset($fieldsInfo[$colname]) ? attr(generate_plaintext_field($fieldsInfo[$colname], $row[$colname])) : attr($row[$colname]);
}
}

I attached dynamic_finder_ajax.php file and screenshot for your reference.



dynamic_finder_ajax.php (11.7 KB)

Thanks,
Param,
help@capminds.com

got this error…
tried after ctrl+F5
still

Can you share your dynamic_finder_ajax.php.

The file which you attached i had downloaded and used it. will upload the same file.
dynamic_finder_ajax.php (11.7 KB)

i didnt edit any file. just used your.

ok. don’t use my file…just change below code in your interface\main\finder\dynamic_finder_ajax.php file.
1] if ($aColumns[$iSortCol] == ‘name’) {
$orderby .= “id Desc”;
} else {
$orderby .= "" . escape_sql_column_name($aColumns[$iSortCol], array('patient_data')) . " $sSortDir";
}

2]

if ($colname == ‘name’) {
$name = $row[‘fname’];
if ($name && $row[‘lname’]) {
$name .= ', ';
}
if ($row[‘lname’]) {
$name .= $row[‘lname’];
}
if ($row[‘mname’]) {
$name .= ’ ’ . $row[‘mname’];
}

little unclear for me pl, can u tell me which line text to remove and replace with?

can you share your old dynamic_finder_ajax.php file. i will correct you.

dynamic_finder_ajax.php (11.5 KB)
Thank you so much. Here it is.

dynamic_finder_ajax.php (11.8 KB)
Its worked me.I hope its work for you

1 Like

wow :slight_smile: awesome… it worked.
The last most pt as per id and first name first.