Provider NPI Sort Asending Order

juggernautsei wrote on Thursday, June 07, 2012:

Hi,

I have been trying to get the Provider NPI list to show up in alphabetical order. I added the ASC to the sql query and the list is still in random order.

  // provider list, including address book entries with an NPI number
  else if ($data_type == 11) {
    $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
      "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE ‘%Inactive%’ ) " .
      “AND ( authorized = 1 OR ( username = ‘’ AND npi != ‘’ ) ) " .
      “ORDER BY lname, fname ASC”);                                         //Added to sort the list aphabetically
    echo “<select name=‘form_$field_id_esc’ id=‘form_$field_id_esc’ title=’$description’>”;
    echo “<option value=’’>” . htmlspecialchars( xl(‘Unassigned’), ENT_NOQUOTES) . “</option>”;
    while ($urow = sqlFetchArray($ures)) {
      $uname = htmlspecialchars( $urow . ’ ’ . $urow, ENT_NOQUOTES);   //This is where the sort gets undone.
      $optionId = htmlspecialchars( $urow, ENT_QUOTES);
      echo “<option value=’$optionId’”;
      if ($urow == $currvalue) echo " selected”;
      echo “>$uname</option>”;
    }
    echo “</select>”;

How would I get this to show in alphabetical order?

Sherwin
OpenMedPractice.com

mcaloon wrote on Thursday, June 07, 2012:

pretty sure you’re ordering by first name, check your result set to see if that is the case

juggernautsei wrote on Thursday, June 07, 2012:

My apologies, I should have waited ten more minutes.
Here is the answser.

  // provider list, including address book entries with an NPI number
  else if ($data_type == 11) {
    $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
      "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE ‘%Inactive%’ ) " .
      “AND ( authorized = 1 OR ( username = ‘’ AND npi != ‘’ ) ) " .
      “ORDER BY lname ASC”);
    echo “<select name=‘form_$field_id_esc’ id=‘form_$field_id_esc’ title=’$description’>”;
    echo “<option value=’’>” . htmlspecialchars( xl(‘Unassigned’), ENT_NOQUOTES) . “</option>”;
    while ($urow = sqlFetchArray($ures)) {
      $uname = htmlspecialchars( $urow . ’ ’ . $urow, ENT_NOQUOTES);
      $optionId = htmlspecialchars( $urow, ENT_QUOTES);
      echo “<option value=’$optionId’”;
      if ($urow == $currvalue) echo " selected”;
      echo “>$uname</option>”;
    }
    echo “</select>”;

Sherwin

papin0 wrote on Thursday, August 21, 2014:

Which file need to be modify? im using 4.1.2 (7)
we would like to have this also.

TIA