gnumed-devel
[Top][All Lists]
Advanced

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

Re: [Gnumed-devel] Inadvertent deletion of Procedure when Deleting episo


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] Inadvertent deletion of Procedure when Deleting episode
Date: Fri, 2 Aug 2013 11:33:30 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Aug 02, 2013 at 09:12:17AM +0000, Jim Busser wrote:

> about which child tables I could not discern anything from
> 
>       \d+ clin.clin_root_item


See way down (Kindtabellen):

                                                                                
                            Tabelle »clin.clin_root_item«
    Spalte     |           Typ            |                                 
Attribute                                 | Speicherung | Statistikziel |       
                                   Beschreibung                                 
          
---------------+--------------------------+---------------------------------------------------------------------------+-------------+---------------+-------------------------------------------------------------------------------------------------
 pk_audit      | integer                  | not null Vorgabewert 
nextval('audit.audit_fields_pk_audit_seq'::regclass) | plain       |            
   | 
 row_version   | integer                  | not null Vorgabewert 0              
                                      | plain       |               | 
 modified_when | timestamp with time zone | not null Vorgabewert now()          
                                      | plain       |               | 
 modified_by   | name                     | not null Vorgabewert 
"current_user"()                                     | plain       |            
   | 
 pk_item       | integer                  | not null Vorgabewert 
nextval('clin.clin_root_item_pk_item_seq'::regclass) | plain       |            
   | the primary key, not named "id" or "pk" as usual since child               
                    +
               |                          |                                     
                                      |             |               |          
tables will have "id"/"pk"-named primary keys already and                       
      +
               |                          |                                     
                                      |             |               |          
we would get duplicate columns while inheriting from this                       
      +
               |                          |                                     
                                      |             |               |          
table
 clin_when     | timestamp with time zone | not null Vorgabewert now()          
                                      | plain       |               | when this 
clinical item became known, can be different from                               
     +
               |                          |                                     
                                      |             |               |          
when it was entered into the system (= audit.audit_fields.modified_when)
 fk_encounter  | integer                  | not null                            
                                      | plain       |               | the 
encounter this item belongs to
 fk_episode    | integer                  | not null                            
                                      | plain       |               | the 
episode this item belongs to
 narrative     | text                     |                                     
                                      | extended    |               | each 
clinical item by default inherits a free text field for clinical narrative
 soap_cat      | text                     |                                     
                                      | extended    |               | each 
clinical item must be either one of the S, O, A, P, U                           
          +
               |                          |                                     
                                      |             |               |          
categories or NULL to indicate a non-clinical item, U meaning 
Unspecified-but-clinical
Indexe:
    "clin_root_item_pkey" PRIMARY KEY, btree (pk_item)
    "idx_cri_encounter" btree (fk_encounter)
    "idx_cri_episode" btree (fk_episode)
Check-Constraints:
    "clin_root_item_sane_soap_cat" CHECK (soap_cat IS NULL OR (lower(soap_cat) 
= ANY (ARRAY['s'::text, 'o'::text, 'a'::text, 'p'::text, 'u'::text])))
Fremdschlüssel-Constraints:
    "clin_root_item_fk_encounter_fkey" FOREIGN KEY (fk_encounter) REFERENCES 
clin.encounter(pk) ON UPDATE CASCADE ON DELETE RESTRICT
    "clin_root_item_fk_episode_fkey" FOREIGN KEY (fk_episode) REFERENCES 
clin.episode(pk) ON UPDATE CASCADE ON DELETE RESTRICT
Regeln:
    clin_ritem_no_del AS
    ON DELETE TO clin.clin_root_item DO INSTEAD  SELECT 
clin.f_protect_clin_root_item() AS f_protect_clin_root_item
    clin_ritem_no_ins AS
    ON INSERT TO clin.clin_root_item DO INSTEAD  SELECT 
clin.f_protect_clin_root_item() AS f_protect_clin_root_item
Trigger:
    tr_announce_clin_clin_root_item_del AFTER DELETE ON clin.clin_root_item 
DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE 
gm.trf_announce_table_del('operation=DELETE::table=clin.clin_root_item::PK 
name=pk_item', 'select $1.pk_item', 'select fk_patient from clin.encounter 
where pk = $1.fk_encounter limit 1')
    tr_announce_clin_clin_root_item_ins_upd AFTER INSERT OR UPDATE ON 
clin.clin_root_item DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE 
PROCEDURE gm.trf_announce_table_ins_upd('table=clin.clin_root_item::PK 
name=pk_item', 'select $1.pk_item', 'select fk_patient from clin.encounter 
where pk = $1.fk_encounter limit 1')
    tr_sanity_check_enc_epi_insert BEFORE INSERT ON clin.clin_root_item FOR 
EACH ROW EXECUTE PROCEDURE clin.trf_sanity_check_enc_epi_insert()
Erbt von: audit.audit_fields
Kindtabellen: au.referral,
              clin.allergy,
              clin.clin_aux_note,
              clin.clin_narrative,
              clin.family_history,
              clin.form_instances,
              clin.hospital_stay,
              clin.lab_request,
              clin.procedure,
              clin.substance_intake,
              clin.test_result,
              clin.vaccination
Hat OIDs: nein


Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

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