Best method for converting several sets of numbers with several different ratios

Posted by C Patton on Stack Overflow See other posts from Stack Overflow or by C Patton
Published on 2010-03-29T08:21:02Z Indexed on 2010/03/29 8:23 UTC
Read the original article Hit count: 291

Filed under:
|
|

I'm working on an open-source harm reduction application for opioid addicts.

One of the features in this application is the conversion (in mg/mcg) between common opioids, so people don't overdose by accident.

If you're morally against opioid addiction and wouldn't respond because of your morals, please consider that this application is for HARM REDUCTION.. So people don't end up dead.

I have this data..

3mg morphine IV = 10mcg fentanyl IV 2mg morphine oral = 1mg oxycodone oral 3mg oral morphine = 1mg oxymorphone oral 7.0mg morphine oral = 1mg hydromorphone oral 1mg morphine iv = .10mg oxymorphone iv 1mg morphine oral = 1mg hydrocodone oral 1mg morphine oral = 6.67mg codeine oral 1mg morphine oral = .10mg methadone oral

And I have a textbox that is the source dosage in mg (a double) that the user can enter in. Underneath this, I have radio boxes for the source substance (ie: morphine) and the destination substance (ie oxycodone) for conversion..

I've been trying to think of the most efficient way to do this, but nearly every seems sloppy. If I were to do something like

public static double MorphinetoOxycodone(string morphineValue)
{
double morphine = Double.Parse(morphineValue);
return (morphine / 2 ); 
}

I would also have to make a function for OxycodonetoMorphine, OxycodonetoCodeine, etc.. and then would end up with dozens functions..

There must be an easier way than this that I'm missing.

If you'll notice, all of my conversions use morphine as the base value.. what might be the easiest way to use the morphine value to convert one opioid to another? For example, if 1mg morphine oral is equal to 1mg hydrocodone and 1mg morphine oral is equal to .10mg methadone, wouldn't I just multiply 1*.10 to get the hydrocodone->methadone value? Implementing this idea is what I'm having the most trouble with.

Any help would be GREATLY appreciated.. and if you'd like, I would add your name/nickname to the credits in this program. It's possible that many, many people around the world will use this (I'm translating it into several languages as well) and to know that your work could've helped an addict from dying.. I think that's a great thing :)

-cory

© Stack Overflow or respective owner

Related posts about number

Related posts about conversion