gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] ID issuers, types, and validation


From: Busser, Jim
Subject: Re: [Gnumed-devel] ID issuers, types, and validation
Date: Fri, 29 Nov 2013 15:19:29 +0000

On 2013-07-29, at 3:20 AM, Karsten Hilbert <address@hidden> wrote:

>>>> One sane approach would be to define a (number of) regular
>>>> expression(s) with each external ID type:
>>>> 
>>>>    dem.enum_ext_id_types.regexen text[] default NULL
>>>> 
>>>> and have INSERT/UPDATE triggers on dem.lnk_identity2ext_id
>>>> check that.
>> 
>> just wondering how a trigger would "check" that the external_id value 
>> conforms to whatever is in the column 'regexen' …
>> 
>> would it require some kind of casting of what is in the regexen and 
>> converting it into a function wherein the value of the external_id must 
>> compute as TRUE?
> 
> It would check the column value against the regular expression and see 
> whether there's a match.
> 
> Karsten

If it is acceptable to resurrect threads … one of my ID types, to be valid, 
requires

        - 10 digit number, beginning with 9
        - it must also satisfy a modulus(9) requirement

Setting aside the complexity of the second requirement, the first could be 
guarded-against (in terms of keyboard mis-entry) by use of a regex.

Locally, users often either input a string of pure digits

        9123456789

or else break them up

        9123 456 789 (4 digits, space, 3 digits, space, 3 digits)

and the following regex would achieve this pattern-match requirement:

                ^9[0-9]\{3\} \{0,1\}[0-9]\{3\} \{0,1\}[0-9]\{3\}$

        9123456789
        echo '9123456789' | grep "^9[0-9]\{3\} \{0,1\}[0-9]\{3\} 
\{0,1\}[0-9]\{3\}$"
        9123456789

        9123 456 789
        echo '9123 456 789' | grep "^9[0-9]\{3\} \{0,1\}[0-9]\{3\} 
\{0,1\}[0-9]\{3\}$"
        9123 456 789

        912345678 
        echo '912345678' | grep "^9[0-9]\{3\} \{0,1\}[0-9]\{3\} 
\{0,1\}[0-9]\{3\}$"
        (fails)

        9123 456 7800
        echo '9123 456 7800' | grep "^9[0-9]\{3\} \{0,1\}[0-9]\{3\} 
\{0,1\}[0-9]\{3\}$"
        (fails)

So … can 1.5 (gnumed_v20) acquire

        dem.enum_ext_id_types.regexen text[] default NULL

and have INSERT/UPDATE triggers on dem.lnk_identity2ext_id check that?

-- Jim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]