Automatically updating tablea

A place for users and developers of the Xataface to discuss and receive support.

Automatically updating tablea

Postby milos » Mon Jan 26, 2009 3:35 am

Hello,

I suppose this is simple but I can not make it. I have a table (Visits) consisting of the following fields: PatientID, VisitID, Diagnosis, ICD10, and I have a lookup table (DgList) consisting of two fields: Diagnosis (Primary key) and ICD10. What I would like is that after selecting Diagnosis ICD10 field in the Visits table is automatically updated.
Thanks
milos
 
Posts: 3
Joined: Mon Jan 26, 2009 3:25 am

Postby shannah » Mon Jan 26, 2009 12:27 pm

I'm not sure I fully understand the question. Can you elaborate a little bit or try to rephrase it?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Automatically updating table

Postby milos » Tue Jan 27, 2009 2:55 am

Thank you for the prompt answer. In a rush I made an error in explaining. I will try to explain what I need. The DgList table consist of two fields Diagnosis (primary key) and ICD10 code for diagnosis. Some slightly different diagnoses can have the same ICD10 code. Diagnosis table has three fields: VisitID, Diagnosis and ICD10. This table keeps a list of all diagnosis during particular visit for a patient. During each visit the patient can have one or more diagnosis. Physicians usually know the diagnosis, but not ICD10 code. Therefore, physician chooses the diagnosis from the valuelist. So far everything was simple. The diagnosis is added to Diagnosis table. Now, I would like to add ICD10 code for that particular diagnosis from the DgList table to the Diagnosis table, based on the previously chosen diagnosis, and I don’t know how to do it.
Milos
milos
 
Posts: 3
Joined: Mon Jan 26, 2009 3:25 am

Postby shannah » Tue Jan 27, 2009 11:26 am

I see. Probably best to use the beforeSave() trigger in the diagnosis table delegate class to set the value of the ICD10 field:

Code: Select all
function beforeSave(&$record){
    if ( $record->valueChanged('Diagnosis') ){
        $icd10Rec = df_get_record('DgList', array('Diagnosis'=>'='.$record->val('Diagnosis')));
        $record->setValue('ICD10', $icd10Rec->val('ICD10'));
   }
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby milos » Sat Jan 31, 2009 2:56 pm

Thank you. It works perfectly now.
milos
 
Posts: 3
Joined: Mon Jan 26, 2009 3:25 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 17 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved