[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation
From: |
Karsten Hilbert |
Subject: |
Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation |
Date: |
Thu, 22 Jan 2015 00:23:38 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Wed, Jan 21, 2015 at 10:34:03PM +0000, Jim Busser wrote:
> > dto = gmPerson.cDTO_person()
> > dto.firstnames = pat_fname
> > dto.lastnames = pat_lname
> > dto.gender = HL7_GENDERS[PID[PID_gender][0]]
> > dob = time.strptime(PID[PID_dob][0], '%Y%m%d')
> > dto.dob = pyDT.datetime(dob.tm_year, dob.tm_mon, dob.tm_mday, tzinfo =
> > gmDateTime.gmCurrentLocalTimezone)
>
> Are the minimum match requirements reflected by ALL of the following dto.
>
> firstnames
> lastnames
> gender
> dob
>
> meaning that whatever values would exist for these in the GNUmed patient
> record will have to match what is is the HL7 PID ?
>
> IOW if the patient (in GNUmed) has a middle name, but did not supply it to
> the lab then based on the current code will there fail to be a match?
GNUmed does not support a middle name (which is nothing but a second
firstname...).
> And does the existing code somewhere else already take into account (forgive)
> variations in upper / lower case or has that yet to be added (which I think
> is both reasonable and arguably essential).
You left out the crucial last line of code:
dto = gmPerson.cDTO_person()
...
=> idents = dto.get_candidate_identities()
Let's see what that does:
#--------------------------------------------------------
def get_candidate_identities(self, can_create=False):
"""Generate generic queries.
- not locale dependant
- data -> firstnames, lastnames, dob, gender
shall we mogrify name parts ? probably not as external
sources should know what they do
finds by inactive name, too, but then shows
the corresponding active name ;-)
Returns list of matching identities (may be empty)
or None if it was told to create an identity but couldn't.
"""
where_snippets = []
args = {}
where_snippets.append(u'firstnames = %(first)s')
args['first'] = self.firstnames
where_snippets.append(u'lastnames = %(last)s')
args['last'] = self.lastnames
if self.dob is not None:
where_snippets.append(u"dem.date_trunc_utc('day'::text,
dob) = dem.date_trunc_utc('day'::text, %(dob)s)")
args['dob'] = self.dob.replace(hour = 23, minute = 59,
second = 59)
if self.gender is not None:
where_snippets.append('gender = %(sex)s')
args['sex'] = self.gender
cmd = u"""
SELECT *, '%s' AS match_type
FROM dem.v_basic_person
WHERE
pk_identity IN (
SELECT pk_identity FROM
dem.v_person_names WHERE %s
)
ORDER BY lastnames, firstnames, dob""" % (
_('external patient source (name, gender, date of birth)'),
' AND '.join(where_snippets)
)
try:
rows, idx = gmPG2.run_ro_queries(queries = [{'cmd':
cmd, 'args': args}], get_col_idx=True)
except:
_log.error(u'cannot get candidate identities for dto
"%s"' % self)
_log.exception('query %s' % cmd)
rows = []
if len(rows) == 0:
_log.debug('no candidate identity matches found')
if not can_create:
return []
ident = self.import_into_database()
if ident is None:
return None
identities = [ident]
else:
identities = [ cIdentity(row = {'pk_field':
'pk_identity', 'data': row, 'idx': idx}) for row in rows ]
return identities
#--------------------------------------------------------
Do you think the first- and lastname matching should be case-insensitive ?
Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, (continued)
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Karsten Hilbert, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Karsten Hilbert, 2015/01/22
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import, Karsten Hilbert, 2015/01/25
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Karsten Hilbert, 2015/01/25
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Karsten Hilbert, 2015/01/22
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation,
Karsten Hilbert <=
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Busser, Jim, 2015/01/21
- Re: [Gnumed-devel] GNUmed HL7 import - patient association or creation, Karsten Hilbert, 2015/01/22