Fixed bug where template patient is returned when nothing in database rather than NULL patient pointer.