[Koha-devel] Handling normalized phone number data

dcook at prosentient.com.au dcook at prosentient.com.au
Thu Sep 15 02:31:34 CEST 2022


Glad to hear other folk are interested to store numbers in E.164 too! Like you say, we’re already doing it for SMS numbers, so I think it makes sense to do it for all phone numbers. Kyle, what do you think about my Koha::Patron->phone() method for doing that?

 

I was thinking how it would be nice to format them for display, but it’s probably easier said than done.

 

For instance, in Australia, we have several different formats (https://www.stylemanual.gov.au/grammar-punctuation-and-conventions/numbers-and-measurements/telephone-numbers):

*	0412 345 678 (mobile)
*	02 1234 5678 (landline)
*	1300 123 456 (nation-wide local rate number)
*	13 00 00 (alternative nation-wide local rate number)

 

It looks like Number::Phone doesn’t support Australian numbers and Number::Phone::Normalize looks old/simple. 

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

From: Kyle Hall <kyle at bywatersolutions.com> 
Sent: Wednesday, 14 September 2022 8:26 PM
To: dcook at prosentient.com.au
Cc: koha-devel <koha-devel at lists.koha-community.org>; Tomas Cohen Arazi <tomascohen at theke.io>; Martin Renvoize <martin.renvoize at ptfs-europe.com>
Subject: Re: Handling normalized phone number data

 

Storing numbers in E.164 makes sense to me! We already enforce it for SMS numbers, so it would make sense to extend this to all other phone numbers. It would then be trivial to have a phone number format syspref in the same way we have a date format syspref. For searching it would be as simple as stripping all non-numerics from the search term and performing a substring search.

 

Perhaps Number::Phone or Number::Phone::Normalize would be of use.

 

Kyle

 

On Wed, Sep 14, 2022 at 2:43 AM <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> > wrote:

Hi all,

 

I’ve been working lately on https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23817 in an effort to let staff users easily search phone numbers in the Patrons module.

 

Currently, phone number searching doesn’t work if you have punctuation or other formatting inconsistent with your search query. 

 

So I’m proposing normalizing phone numbers. Normalizing the search query is easy, but normalizing the data in the database is harder. In older versions of Koha, I used SQL to normalize the phone column in the WHERE clause, but that’s seemingly impossible now that we’re using DataTables and the REST API.

 

So it seems to me the only way forward is to normalize the data in the database. I’ve attached a patch which provides a Koha::Patron->phone() set method which normalizes the phone number before it’s saved in the database, but I don’t know what other Koha folk think about that. 

 

Thoughts?

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 



-- 

Kyle M. Hall

Loose Cannon, ByWater Solutions

 <mailto:kyle at bywatersolutions.com> kyle at bywatersolutions.com
 <http://bywatersolutions.com/> https://bywatersolutions.com

 <http://bywatersolutions.com/what-is-koha/> What is Koha?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220915/eb5d25f2/attachment.htm>


More information about the Koha-devel mailing list