Currently my app needs to calculate the plasma concentration (multiple doses). I'm expecting it to be cyclical like depicted in this case:
However, when I try to calculate and plot it out, it comes out like
The equation that I was told that it should be is
and my function looks like the one below
function calculatePlasmaConcentration(x, bioavailability, vd, ka, ke, dosing, dose) {
var firstPart, secondPart, c;
firstPart = ((bioavailability * dose * ka) / (vd * ka - vd * ke));
secondPart = (Math.exp(-ke * x) / (1 - Math.exp(-ke * dosing))) - (Math.exp(-ka * x) / (1 - Math.exp(-ka * dosing)));
c = firstPart * secondPart;
return c;
}
I can't seem to see that I wrote the equation wrong, what am I doing wrong? the parameter x should be time in hours.
adding the default values here:
defaultDrugInfo = {
dose: 500,
dosing: 24,
bioavailability: .89,
ka: .883,
ke: .0578,
vd: 6,
optimalTopRange: 10,
optimalBottomRange: 5
}
Thanks in advance!