[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] Gnumed Value Objects dev guide, draft 1
From: |
Karsten Hilbert |
Subject: |
Re: [Gnumed-devel] Gnumed Value Objects dev guide, draft 1 |
Date: |
Sat, 17 Apr 2004 17:55:50 +0200 |
User-agent: |
Mutt/1.3.22.1i |
> Clinical items contain a group of fields that are always
> accessed together, typically through specific database views
The scope of "item" is "clinically meaningful snippet of
data". They should also encapsulate validation code if that
needs to be done outside the database.
> - Each instance verifies its existence upon instantiation
We don't currently do this anymore. We rely on
refetch_payload() failing in __init__().
> - Lazy fetching of fields is NOT supported
It is either/or. If you can instantiate an instance all data
for that instance (typically one row each from a few tables
forming a particular view). Lazy fetching/caching is done at
the next level, say gmClinicalRecord. Eventually we may end up
interjecting fully generic cTable classes inbetween the
business objects and the tables. Those might then cache
individual rows *independant of* clinical context (but then
need an age-based? eviction mechanism).
> _payload: list containing the values of all item fields in an ORDERED
> way.
However, don't rely on the order ! It can change due to:
- changes in PostgreSQL code, eg select * returning another order of fields
- changes to _cmd_fetch_payload
- changes to the database schema, eg the underlying views/tables
Always use _idx to access fields - and even that is subject to
schema changes.
> Methods:
> __init__(self, aPKey = None, **kwargs): constructor. Takes primary key
> as argument. ### DOC PENDING **kwargs
**kwargs accepts any number of keyword arguments, the
corresponding keyword argument list is passed to _pre_init()
and _post_init()
Anyone know how to invoke the predecessors __init__ from a
descendants __init__ ? That'd do away with the need for
_pre_init(), _post_init() and **kwargs.
> _pre_init(self, **kwargs): ### DOC PENDING
invoked very early in cClinItem.__init__()
> _post_init(self, **kwargs): ### DOC PENDING
invoked very late in cClinItem.__init()
allow modifying __init__ behaviour, such as finding the
primary key from other arguments
> get_fields(self): retrieves a list containing all backend fetched field
> names (both updatable and not).
> get_updatable_fields(self): retrieves a list containing updatable field
> names
those facilitate introspection and self-documentation
> refetch_payload(self): fetchs all the attributes from
> backend. This can be used to force updates after a DB level
> notify.
this is used for higher-level caching work
> If the load goes right, True is returned. If the fetch
> operation couldn't be performed, False is returned. Tipically,
> False will be returned if refetch is invoked after the instance
> was programatically modified.
so as to not lose changes, check for changes via _is_modified
> attVal = vacc[att]: retrieves the value for attribute 'att' and asigns it to
> 'attVal' variable
> allg[att] = attVal: sets the attribute 'att' as 'attVal' value, if it's
> effectively updatable. If any non-updatable field is being modified, an
> exception is raised.
Unfortunately, one cannot return False from __setitem__. Also,
if a non-updatable field is being modified it's a programming
error and should be caught as soon as possible.
> 4. Development status:
We need
cDiagnosis
cDrug
cCurrentlyPrescribedDrug
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346