Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 18th, 2009, 10:12 AM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Confused about how to Store a List of Data

I'm making an EMR (electronic medicals records) software for my dad, who's a doctor, as a school project. I'm using VB 2008, and MS SQL server 2005. In my database, one of the tables is VisitHistory, which stores the records of all patient visits. The fields in this are PatientID, VisitDate, Complaints & Diagnosis. There is also a table called Meds, which is an inventory of the number of tablets of each medicine available in the clinic.
Now I also need to store the medicines supplied to the patient in the first table (visitHistory). In one vb form, where the doctor adds a new visit, he has to fill in the medications he wants, and the quantity of each. For example, 20 tablets of Ibuprofen, 10 tablets of Paracetamol, etc. This is done through a combobox listing all the medicines available from the Meds table, and a text box to enter the quantity of thet medicine. The i wan the form to list the medicine and its quantity, and subtract that quantity from the Medicine Inventory table called Meds. Also, if the doctor changes his mind, he should be able to remove a medicine from the list, and have that quantity added back to the Meds table. How do i go about this? So basically, I want a way to store and display a list of unspecified length (the number of medicines prescribed could vary). For display, i was thinking of either using a listbox showing each medicine and its quantity; or showing a textbox with each medicine separated with commas. This means i would have to parse the data to get each individual medicine, while retrieving the data.
For storage, I have no clue what to do. It would be great if i could put a field in the VisitHistory table that attached another table, and this table could have all the medicines and their quantities listed as individual rows. Since i dont think this is possible, I'm thinking of adding fields like 'Med1', 'MedQuantity1', 'Med2', 'MedQuantity2', etc to the table, and limiting the max number of medicines the doctor can add to 10 or something. Alternatively, I could make one table of the medicines prescribed, and each record will have a visitID, medicine ID, and quantity. Then when you want to see the medicines for each visit, the program will have to search the database and display all the the medicines for that visit. But this method seems very convoluted. Is there a simpler way to store a table for each record in a table?
My question is very confusing, I hope you can understand what i'm trying to ask. If you can't, please post, and i'll try to clarify...
Reply With Quote
  #2 (permalink)  
Old January 18th, 2009, 01:47 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

You are thinking it the right way.

You should add a table that holds the medicineID, the quantity and an Id that connect that to the patient VisitHistory (VisitID).

This is the correct way. You will have to do some querys to get the data, but you could add this way all the medicine you need. If you have problems building the querys you could ask again. There is no problem with this method, in fact is the correct way to handle the database.

For the display part, maybe a grid will be a better solution???

Adding item to it could be the same way you are doing it now (the combo with the med, and the textbox with the quantity).

You could also have a delete there. Take in mind, that for security reason, there should be no way to retrieve old medicine from the patients(if you give a patient something a month ago, you shouldn't get it back from him, but that could be different)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #3 (permalink)  
Old January 18th, 2009, 02:23 PM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok good that i'm on the right track. However, this poses one more problem. I have another tab in the form where it lists all past visits from the patient, along with all the details, in a DataGridView. That is, the GridView has columns VisitDate, Complaints, Diagnosis etc. I would like for there to be one column with the medicines given. If it had been a simple field in the table, it would have been easy to get it into the datagridview. I'm not quite sure how i would be able to populate a certain cell of each record in the datagridview with the results from a SQL statement. Can you help out with that? Basically, it'll have to be some sub called on the event of a new row loading in the DataGridView, and within that, there would have to be code to fill in the cell with the Select statement. So when the form is loaded and the DataGridView is being called, the procedure should be called every time a new row is loaded. Any clues on how to do this?

And yes, you are right, there is no reason for the doctor to be able to delete the medicine records from previous visits. That is only for the current visit. And yes, a grid or listbox will be the best option. good idea. Why didn't i think of a grid!!!

Last edited by skorned; January 18th, 2009 at 02:26 PM..
Reply With Quote
  #4 (permalink)  
Old January 18th, 2009, 03:22 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

You will have to google about this, but this easily can be done using some datasource added to the grid, so you don't show medicines, but instead a button that change the grid when pressed and show the medicines according to the pressed row.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #5 (permalink)  
Old January 18th, 2009, 03:28 PM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh yes...i could put 2 datagridviews, one showing all the visits and the other one below acting as a lookup table, showing all the relevant medicines for that visit....
wow i'm having a lot of 'why-didnt-i-think-of-that' moments today!!!
Reply With Quote
  #6 (permalink)  
Old January 18th, 2009, 07:21 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You should also look into "Master-Detail" style of display. That is, a master row and then, below it and *possibly* hidden until requested, one or more details rows.

For your code, each visit could be a master row and then all the meds for that visit could fall under the appropriate master row as zero or more detail rows. Again, a click on a button or checkbox could display the detail rows. (It would be better to use JavaScript in the browser to show/hide the detail rows rather than doing it all in ASP.NET code, but it would be okay to get started doing it all server side.)
Reply With Quote
  #7 (permalink)  
Old January 19th, 2009, 09:23 AM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK i think i fixed it. VB makes the display really easy to do. For the tab with aalll the past visits, i have one datagridview that is bound to the VisitHistory table for that particular patient, and another datagridview which is bound to the MedicineHistory for that particular VisitHistory record for that particular table. It works brilliantly. As for the form for adding new medicines, an unbound DataGridView will do the job nicely i think.
Now I have another problem. In the first tab which shows the entire medical history, the 2nd grid which shows the medicines for that particular visit binds to a table called MedicineHist. Now in this table, amonst other things, i have created relation from the DrugID field in this table to the DrugID field in the Medicines Inventory table. So, when a medicine is selected, the DrugID for that medicine will be stored. However, in the grid, I want it to display the medicine name, not the drug id. For this, i'll have to somehow pass the drug id as a parameter to a SQL query to the medicine inventory table, and populate the field in the grid with the resulting name, not the ID. How do I do this? Can the grid be bound to 2 tables? Or I remember seeing something about DisplayMember and ValueMember. I used it in a combobox. It basically shows one set of values to the user, but when one of them is selected, a corresponding ID or value is saved to the database or variable. Any clue how to do this for a particular column of a DataGridView? I'm so lost.
Reply With Quote
  #8 (permalink)  
Old January 19th, 2009, 12:06 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

No.. you don't need to look for every id. You need a query that join the two tables..
something like (you will have to fit this to your needs)
SELECT medname FROM meds inner join medshistory on meds.id = medshistory.medid.

Use any of the build in querys builder to build it. you don't have to know how to build the exact SQL, the builder has visual help to make it work.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way 2 store data in a Word Doc? BrianWren VB Databases Basics 0 April 14th, 2008 06:07 PM
create a custom list to store the category code kiwibey SharePoint Development 0 April 3rd, 2008 02:04 AM
How to store data in a session using javascript? chayan Classic ASP Professional 0 March 10th, 2007 10:14 AM
Using SQLMembershipProvider how to store data relaytest49 ASP.NET 2.0 Professional 0 September 12th, 2006 08:56 PM
How I store & retrieve List/Menu Mysql/PHP gsedrak1 PHP Databases 3 September 15th, 2005 08:49 PM



All times are GMT -4. The time now is 10:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.