It was brought to my attention that when the set POS from the encounter is enabled and a new encounter is created. It does not default to the facility POS.
This was because the code was only looking to match the POS to the saved POS from the billing form. But is the form was not previously saved there would be no POS code so the default is the first code in the list Pharmacy.
Added :
line 226
if($iter['billing_location'] == 1){
$posCode = $iter['pos_code'];
}
changed line 259
if($pos["code"] == $result['pos_code'] || $pos["code"] == $posCode) echo "selected";