views:

136

answers:

4

Im building an admin interface for a medical records management app. My client has asked me for a way to easily select the patient the user wants to work with without having to select the patient everytime he wants to perform an action. So, say for instance he wants to store a record for the patient's current status (weight, size, etc) and then assign the same patient to a different doctor or change the company the patient currently works for.. he doesnt want to select the same patient all three times... he wants a select dropdown for patients and perform the different actions for that patient.

Im thinking this should be somehow stored in a session variable.. I have a table of patients and Im using LinqtoSql classes.... what do you reccommend?? help please.

A: 

You could use the session to keep a list of recently active patient records for a given users session. Every time the user selects a new patient simply add that patient's name to the "Recent" list. Since you can control the length of the session you could just allow the list to expire when the user's session does. As far as not making the user select a customer again, just have it auto-select the most recent (last entry) on the list of recent customers.

Nathan Taylor
A: 

Personally I would consider caching as an option here. By the sounds of it you want to load ALL data for ALL patients which is fine for a small amount of data but will not scale gracefully.

Consider going to the database the FIRST time you need the patient's data, and getting your data from the cache for subsequent queries...

Jason Irwin
+1  A: 

Sounds like you want to put something into Session--perhaps some of the basic "recent patient" information, such as a patient ID, patient name, etc.

Definitely take a look at this post on how to do it in a very graceful way.

TheObjectGuy
Dude: If you're gonna try to push traffic to your blog, you should at least put a summary of the post here so I can decided whether I want to follow the link or not.
Esteban Araya
Lol, didnt notice it was your blog.. still looks interesting.. but cant figure out how to use it... Like I said, I would like to store the "selected patient object" in the session....please give me a more detailed explanation of how to do it....Im supposed to save SessionInfo class in my models?? where should I put the MysessionInfo class?? is "MyClass" supposed to be Patient??.. this is really confusing\
NachoF
The first class in the post can be copied/pasted into your application. Then, create your own sublclass like... public class MyPatientStuff : SessionInfo<MyPatientStuff> { public Guid Id { get; set; } public string Name { get; set; } }
TheObjectGuy
Ok, it seems to be working.. but Im still not sure whats a good way of getting the data onto my View now.. before I could just do <%=Session["patient_name"]%> in my view but this<%=MySessionInfo.Current.Patient.Name%>; gives me that the class doesnt belong in the current context
NachoF
Sounds like you either have to import the namespace on your page (i.e. <%@ import namespace="...." %> ) or you need to to specify it like <%= MyNamespace.MySessionInfo.Current.Patient.Name %>
TheObjectGuy
A: 

The best way is to have the id in the route.

Use something like this when registering routes:

   routes.MapRoute(
        "Standard",                                             
        "{controller}/{action}/{PatientId}",           
        new
          {
            controller = "home", 
            action = "index", 
            PatientId = ""
          }
      );

When you select a Patient you post to an action that sets the PatientID in the RouteParameterCollection and redirect to the the action that displays the form for changing the patient. this way you always have the patientID in the URL.

Using session has some drawbacks:

  • If you have 2 windows open both use the same session. This might confuse users.
  • You can not bookmark a page
  • Session is usually stored in memory on the appserver. This might lead to performance problems if extensively used.
Malcolm Frexner