Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...it was ingeniously designed and all those clicks were for my own good... and that was even before I got my speedy and useful answer to my tekkie question that I eventually posted..."

Geography

Where in the world do Tek-Tips members come from?
bgode (Programmer)
18 Apr 12 10:43
I currently maintain an Excel spreadsheet that contains fairly static information about some of the drugs used at our clinic.  I save this spreadsheet as a csv file and read it into an array.  I use the name of the drug as the key, and access the array to pull off manufacturer name, unit price, etc.  My users now want to make this table date sensitive.  For instance, unit price may change from time to time.  The users are envisioning adding two more columns to the table to create an effective date range.  Then based on the date that the drug was administered, the unit price, etc would be pulled for that date range.  The name of the drug will no longer be unique to the table.  Is there a way to make my array date sensitive and still keep the structure and programming fairly intact?  Or would a rewrite using lists actually be simpler?  My apologies for being so long-winded.
feherke (Programmer)
18 Apr 12 11:27
Hi

I would just dump the CSV & Excel idea and put the data where they should be : in a database.

This means some work to done, but adding new features in the further will be easier.

The data structure would be something like :

drug              price
id | name         id | drugid | price | begin      | end
---+-----         ---+--------+-------+------------+-----------
 1 | Foo           1 |      1 |  1.01 | 2012-01-01 | 2012-01-31
 2 | Bar           2 |      2 |  2.01 | 2012-01-01 |
                   3 |      1 |  1.02 | 2012-02-01 |

Then you could query the prices like this :

CODE --> PostgreSQL

-- get current prices
select
d.name,p.price
from drug d
inner join price p on p.drugid=d.id
where p."end" is null;

-- get prices valid on 2012-01-15
select
d.name,p.price
from drug d
inner join price p on p.drugid=d.id
where '2012-01-15' between p.begin and coalesce(p."end",now());
 

Feherke.
http://feherke.github.com/

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close