• N&PD Moderators: Skorpio

I need a validation for the following APAP program

Ksa

Ex-Bluelighter
Joined
Aug 13, 2010
Messages
2,093
Location
TRUMP...TRUTH.
I made a program that evaluates dissolved acetaminophen quantities and the resulting toxicity upon ingestion. The program also suggests the lowest water amount that can be used for a certain amount of pills that will result in a liquid mixture. The program can tell if the pills dissolve completely or if filtration is needed and many other features.

Can a scientist or engineer confirm that the program is safe for the use, in any circumstances, and that the output information is 100% accurate for any possible user input?

http://www.megaupload.com/?d=O0Q00REF

The code is too long to fit on one page I'm afraid so I'll use 2 pages.

Code:
import java.io.*;
import java.util.*;
import java.text.*;
public class Tylenol
{
  public static void main(String[] args)
  {
    DecimalFormat a = new DecimalFormat(".00");
    Date date = new Date();
    double n = 1;
    do{
      try{
        System.out.println("    _/    _/    _/_/_/    _/_/    ");
        System.out.println("   _/  _/    _/        _/    _/   ");
        System.out.println("  _/_/        _/_/    _/_/_/_/    ");
        System.out.println(" _/  _/          _/  _/    _/     ");
        System.out.println("_/    _/  _/_/_/    _/    _/      ");
        System.out.println(date.toString()+"\n");
        System.out.println("Welcome to Ksa's disolved acetaminophen calculator!\n");
        System.out.println("WARNING: This program outputs toxicity information for acetaminophen only.");
        System.out.println("         Daily use of acetaminophen can be hazardous regardless of output.");
        System.out.println("         This helps users who have trouble swallowing the pills make safe ");
        System.out.println("         acetaminophen solutions. Program intended for proper use only. ");
        System.out.println("");
        System.out.println("Select a topic and press enter:");
        System.out.println("");
        System.out.println("1. Check if a solution has safe amounts of disolved acetaminophen.");
        System.out.println("2. Give me the acetaminophen water solubility value for a certain temperature.");
        System.out.println("3. Exit");
        Scanner input = new Scanner(System.in);
        double entry = input.nextDouble();
        n = 2;
        if(entry==1)
        {
          Scanner input3 = new Scanner(System.in);
          System.out.println("");
          System.out.println("Enter solution temperature in degrees Celsius before filtration:");
          double temperature = input3.nextDouble();
          if(temperature < 0)
          {
            System.out.println("");
            System.out.println("Water freezes at zero degrees celsius.(Invalid value)");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          System.out.println("");
          System.out.println("Enter amount of pills:");
          double pills = input.nextDouble();
          if(pills < 0)
          {
            System.out.println("");
            System.out.println("Invalid entry.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          System.out.println("");
          System.out.println("Enter acetaminophen content of one pill, in miligrams (mg):");
          double apap = input.nextDouble();
          if(apap < 0)
          {
            System.out.println("");
            System.out.println("Invalid entry.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          System.out.println("");
          System.out.println("Enter the total water volume, in millilitres (mL):");
          double water = input.nextDouble();
          if(water < 0)
          {
            System.out.println("");
            System.out.println("Invalid entry.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          double solubility = (0.0006*Math.pow(temperature,2) + 0.0165*temperature + 0.7221)*10;
          double intake = pills*apap;
          double intake2 = water*solubility;
          if(temperature > 35)
          {
            System.out.println("");
            System.out.println("The temperature is unsafe, resulting in high amounts of disolved acetaminophen.\nPlease lower the temperature below 35 degrees Celsius.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          if(pills > 50)
          {
            System.out.println("");
            System.out.println("You have entered "+ pills+" pills. That may be unsafe for other reasons.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input5 = new Scanner(System.in);
            String entrya = input5.nextLine();
            System.exit(0);
          }
           if(apap > 2000)
          {
            System.out.println("");
            System.out.println("You have entered "+ apap+" mg acetaminophen per pill. \nThat amount is non FDA approved and is considered dangerous.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input23 = new Scanner(System.in);
            String entrya = input23.nextLine();
            System.exit(0);
          }
           if(water > 500)
          {
            System.out.println("");
            System.out.println(water + " ml of water is unsafe.(above 500ml treshold).");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input41 = new Scanner(System.in);
            String entrya = input41.nextLine();
            System.exit(0);
          }
 
Code:
 if(pills*apap < water*solubility && pills*apap>8000)
          {
            System.out.println("");
            System.out.println("The solution contains "+ a.format(intake/1000)+ " g of disolved acetaminophen.");
            System.out.println("Ingestion can result in fatal acetaminophen overdose.");
            System.out.println("Death occurs aproximatly 8 hours after ingestion if no antidote is provided.");
            System.out.println("Reason of death: Liver failure.");
            System.out.println("Using "+ a.format(2*pills)+" mL of water instead of "+a.format(water)+" mL should render the");
            System.out.println("filtered solution safe. Note that using water amounts below ");
            System.out.println(a.format(2*pills)+" mL will result in a slurry and not a liquid mixture.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input6 = new Scanner(System.in);
            String entrya = input6.nextLine();
            System.exit(0);
          }
          else if(pills*apap >= water*solubility && water*solubility>8000)
          {
            System.out.println("");
            System.out.println("The solution contains "+ a.format(intake2/1000)+ " g of disolved acetaminophen.");
            System.out.println("Ingestion can result in fatal acetaminophen overdose.");
            System.out.println("Death occurs aproximatly 8 hours after ingestion if no antidote is provided.");
            System.out.println("Reason of death: Liver failure.");
            System.out.println("Using "+ a.format(2*pills)+" mL of water instead of "+a.format(water)+" mL should render the");
            System.out.println("filtered solution safe. Note that using water amounts below ");
            System.out.println(a.format(2*pills)+" mL will result in a slurry and not a liquid mixture.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input7 = new Scanner(System.in);
            String entrya = input7.nextLine();
            System.exit(0);
          }
          else if(pills*apap < water*solubility && pills*apap>2000)
          {
            System.out.println("");
            System.out.println("The solution contains "+ a.format(intake/1000)+ " g of disolved acetaminophen.");
            System.out.println("Ingestion is hazardous and can result in permanent liver damage.");
            System.out.println("Using "+ a.format(2*pills)+" mL of water instead of "+a.format(water)+" mL should render the");
            System.out.println("filtered solution safe. Note that using water amounts below ");
            System.out.println(a.format(2*pills)+" mL will result in a slurry and not a liquid mixture.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input8 = new Scanner(System.in);
            String entrya = input8.nextLine();
            System.exit(0);
          }
          else if(pills*apap >= water*solubility && water*solubility>2000)
          {
            System.out.println("");
            System.out.println("The filtered solution contains "+ a.format(intake2/1000)+ " g of disolved acetaminophen.");
            System.out.println("Ingestion is hazardous and can result in permanent liver damage.");
            System.out.println("Using "+ a.format(2*pills)+" mL of water instead of "+a.format(water)+" mL should render the");
            System.out.println("filtered solution safe. Note that using water amounts below ");
            System.out.println(a.format(2*pills)+" mL will result in a slurry and not a liquid mixture.");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input9 = new Scanner(System.in);
            String entrya = input9.nextLine();
            System.exit(0);
          }
          else{
            System.out.println("");
            System.out.println(pills*apap < water*solubility ? "The solution contains "+a.format(intake/1000)+ " g of disolved acetaminophen." : "The solution contains "+a.format(intake2/1000)+ " g of disolved acetaminophen.");
            System.out.println("Ingesting the solution is safe occasionally.\n(given it only contains water and acetaminophen) ");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input9 = new Scanner(System.in);
            String entrya = input9.nextLine();
            System.exit(0);
          }
        }
        else if(entry==2)
        {
          System.out.println("");
          System.out.println("Enter water temperature in degrees Celsius from 0 to 100 degrees Celsius:");
          Scanner input2 = new Scanner(System.in);
          double temperature = input2.nextDouble();
          if(temperature < 0)
          {
            System.out.println("");
            System.out.println("Water freezes at zero degrees Celsius(Invalid value)");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          else if(temperature > 100)
          {
            System.out.println("");
            System.out.println("Water boils at 100 degrees Celsius. (Invalid value)");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input4 = new Scanner(System.in);
            String entrya = input4.nextLine();
            System.exit(0);
          }
          else{
            System.out.println("");
            double solubility = 0.0006*Math.pow(temperature,2) + 0.0165*temperature + 0.7221;
            System.out.println("The solubility of acetaminophen in water at "+temperature+" degrees Celsius is "+a.format(solubility)+"g/100mL");
            System.out.println("");
            System.out.println("Press Enter to abord.");
            Scanner input9 = new Scanner(System.in);
            String entrya = input9.nextLine();
            System.exit(0);
          }
        }
        else{System.exit(0);}
      }
      catch(Exception e){
        System.out.println("");
        System.out.println("Invalid entry. Please try again.\n");
      }
    }while(n==1);
  }
}
 
When I say accurate you can consider a 95% level of significance in the ki square analysis of the results if such analysis is ever performed by anyone.

thanks!
 
I am not proficient in code, and am too frightened to download the executable file to this device; thus I cannot make comments as to any mechanical flaws, etc....

A few thoughts:

- the end user will as we know be 'extracting' some drug (codeine, hydrocodone, tramadol, butalbital etc, etc) from APAP-containing formulations, many of which contain other actives such as caffeine, aspirin

- the formulation and target drugs may call for different protocols

- the 50 pill maximum may be prudent for those with low tolerances if the target is a 8-10mg codeine tablet, but impractical for those with moderate tolerances

- conversely, 8 5mg oxycodone tablets could prove fatal in some cases (even assuming a mediocre %yld)

- the calculator may convey a artificial sense of safety, and again the interested parties are drug-abusers who are trying to separate various poisons from other poisons, and are in theory 'naive enough' to rely on a calculator to determine how to use water to "possibly not poison oneself with APAP while still getting high on the desired toxin"

- potential mechanical defects in the software resulting in incorrect data (which again, is something i cannot assess)

Still, not a bad idea, and retrospectively I realize everything i just said you have likely already considered................
 
I am not proficient in code, and am too frightened to download the executable file to this device; thus I cannot make comments as to any mechanical flaws, etc....

A few thoughts:

- the end user will as we know be 'extracting' some drug (codeine, hydrocodone, tramadol, butalbital etc, etc) from APAP-containing formulations, many of which contain other actives such as caffeine, aspirin

- the formulation and target drugs may call for different protocols

- the 50 pill maximum may be prudent for those with low tolerances if the target is a 8-10mg codeine tablet, but impractical for those with moderate tolerances

- conversely, 8 5mg oxycodone tablets could prove fatal in some cases (even assuming a mediocre %yld)

- the calculator may convey a artificial sense of safety, and again the interested parties are drug-abusers who are trying to separate various poisons from other poisons, and are in theory 'naive enough' to rely on a calculator to determine how to use water to "possibly not poison oneself with APAP while still getting high on the desired toxin"

- potential mechanical defects in the software resulting in incorrect data (which again, is something i cannot assess)

Still, not a bad idea, and retrospectively I realize everything i just said you have likely already considered................

Thanks! The program is defined in the description to evaluate toxicity of acetaminophen only. It doesn`t account for anything else for safety reasons. Opioid toxicity varies a lot from person to person, I have no clue how to include it safely.

Only for people concerned with acetaminophen intake only.

I'll get back to you on this one day.

thanks!
 
Just a little explanation. The key line in this program that requires chemistry knowledge is:

double solubility = (0.0006*Math.pow(temperature,2) + 0.0165*temperature + 0.7221)*10;
double intake = pills*apap;
double intake2 = water*solubility;


The first line contains the solubility calculation. This was done by applying a square mean fit to the solubility data in this paper and multiplying by 10 to fix units:

fitzz.jpg


http://pubs.acs.org/doi/abs/10.1021/je990124v

R(square) is 0.993 so the fitted model explains 99.3% of the variation. Anova table that I built states there is no significant lack of fit on a confidence level of 99%. This is assuming the paper has the values right, but the values contained in that paper agree in terms of precision with what I already seen so far.

The next 2 lines describe 2 types of intake. The first intake is when there is way too much water compared to the pills, so the pills completely disolve in the water, because the water volume multiplied by the solubility at that temperature is greater than the total acetaminophen contained in the pills. This physically means that the solution is not saturated in acetaminophen and that further acetaminophen can be dissolved. So the total amount of dissolved acetaminophen will be the acetaminophen contained in the pills, meaning pills*amount of apap in a pill.

The second case is when there's too few water and you cannot dissolve all your pills. It means that the total dissolved acetaminophen is the water volume multiplied by it's solubility at that particular temperature because the water is saturated so even if you keep adding acetaminophen, it will dissolve no more.

else if(pills*apap >= water*solubility && water*solubility>2000)

Then theres a series of if and else if statements which separate the different program responses for different parameters. If you enter 35 degrees Celsius, 20 pills, 500mg and 500mL, the program output is different as if you enter 2 degrees Celsius, 20 pills, 500mg and 50mL.

I have tested the program so far in many places, it never failed to predict the acetaminophen quantity dissolved in pure water. Note that the values the program yields are always the maximum values as in reality, the presence of more soluble substances in the pills such as binders and sugars will disolve first and lower the solubility of apap for that particular temperature so so far it appears safe, from my point of view and the point of view of people who tried the program.
 
Last edited:
The program also suggests the lowest water amount that can be used for a certain amount of pills that will result in a liquid mixture. The program can tell if the pills dissolve completely or if filtration is needed and many other features.

Hello Ksa. Given your fascination with solubility, you should have named yourself Ksp.

This is all really interesting. You mention "pills", but how can you account for all the other possible substances found in pharmaceutical products containing APAP?

Can you write or link to your principal equation in normal language (not code)?
 
Hello Ksa. Given your fascination with solubility, you should have named yourself Ksp.

This is all really interesting. You mention "pills", but how can you account for all the other possible substances found in pharmaceutical products containing APAP?

Can you write or link to your principal equation in normal language (not code)?

Hah. In fact, the truth is I'm tired to look in that damn table every time I want to know stuff lol. You are right about the other compounds, especially the polymer. Those substances will dissolve first so in reality there's a little less APAP then what the program calculates, but that's good right? Safety speaking. I have yet not encountered substances that, when combined with APAP increase its solubility. Not saying there aren't but I haven't seen any of em around. How do you remember your account name lol? :)

solubility = 0.0006T^2 + 0.0165T + 0.7221

cheers,

Dan
 
Last edited:
Rofl...my link was shut down for copyright violation. Nice fail FBI. So now I can't upload my content anymore because some shit entertainment companies want Kim's cars and women.
 
Top