Yes, sessions are not saved until the end of a request. You may want to 
consider putting the 'patient id' in a cookie, or using it as part of the 
URL, so you can use request.vars to retrieve it.

On Tuesday, April 23, 2013 5:42:39 AM UTC-7, AnnG wrote:
>
> Hi,
> I have a main patient input page with 3 components on... 
>
> <div id="content">   
>     <div id="patient_info" class="layout_block">
>         {{=LOAD('patient', 'patient_details.load', ajax=True, 
> target='patient_info')}}
>     </div>    
>     <div id="phenotype_form" class="layout_block"> 
>         {{=LOAD('phenotype_form', 'phenotype_form.load', ajax=True, 
> target='phenotype_form')}}  
>     </div>    
>     <div id="patient_scan_history" class="layout_block"> 
>         {{=LOAD('patient_scan_history', 'patient_scan_history.load', 
> ajax=True, target='patient_scan_history')}}  
>     </div>    
> </div>.
>
> ...and to work properly, 2 of those components (the first and third above) 
> need a patient id, which is held in an input box (id="patient_id") on a 
> form, in patient_details.load (first component above) ...
>
> <form id="patient_form">
>   <fieldset>
>     <table>
>         <tr>
>             <td> Patient ID  (or leave empty for new patient): <input name
> ="patient_id" id="patient_id" value={{=(patient_id or '')}}></td>
>             <td><input type="submit" value="Search Patient"></td>
>             <div id="clearcanvas_target">{{=study_response}}</div>
>         </tr>
>         <tr>
>             <td>    Source: <input type='text' name='source' id='source' 
> value={{=patient_source}}> 
>                     Diagnosis: <input type='text' name='diagnosis' id=
> 'diagnosis' value={{=patient_diagnosis}}>  
>             </td>
>             
>         </tr>
>      </table>             
>   </fieldset>
> </form>
>
> ... and here is the part of patient_load.py, where I can get the 
> patient_id from request.vars.patient_id, and set a global variable 
> session.patient_id to have the same value.
>
> if(request.vars.patient_id):
>         session.patient_id = int(request.vars.patient_id)    
>         
>         study_response = open_patient_images_clearcanvas(session.
> patient_id)
>
>         db = get_db()
>     
>         rows = db((db.patient.patient_pk == db.patient_diagnosis.
> patient_fk) & (db.patient_diagnosis.diagnosis_fk == db.diagnosis.
> diagnosis_pk) & (db.patient.patient_pk == session.patient_id)).select(db.
> patient.source, db.diagnosis.diagnosis_name)
>
> ...
>
>
> The above patient_load component works OK.  
> BUT  the third component, where I wish to load patient history, and which 
> also requires a patient_id, wont work properly, as the session.patient_id 
> above is not updated until i press refresh.
> Here is my main patient_scan_history.py function
>
> def patient_scan_history(): 
>     patient_id = 1
>     if(session.patient_id):
>         patient_id = session.patient_id
>         db = get_db()
>         patient_scans = Patient_scan_history(db, patient_id)
>         patient_scan_history = patient_scans.get_patient_scan_history()
>     else:
>         return dict(html_table = None)
>     
>     html_table = TABLE(  TR(*[TH(*headers) for headers inpatient_scan_history
> ['headers']]), *[TR(*rows) for rows in patient_scan_history['table']]) 
>     
>     return dict(html_table=html_table)
>
> ... and my patient_scan_history.load
>
> <form>
>   <fieldset>
>      {{=html_table}}
>   </fieldset>
> </form>
>
> So from the users point of view, the top component information loads as 
> soon as there is a valid patient id and the submit ('search patient') 
> button is pressed. But the third component is not updated at this point, 
> and only shows the correct patient history table when the refresh button is 
> clicked.
>
> As the 3rd component is reliant on a patient ID from the 1st component, 
> I'm guessing maybe it should not be a component ??
> Can anyone help???
>
> Regards
> A
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to