Archive for August 11th, 2011

For the bililite webservices, I kept all the data in what I would call "standard" American medical units, centimeters for height, kilograms for weight, mmHg for blood pressure, mg/dl for bilirubin. But lots of doctors use pounds and inches, and it would be nice to allow those as well. I could have separate data entry forms for different units, but I decided it would be easier and more useful to allow units on the numbers. I could allow fractions as well (which some of my medical assistants still insist on recording; 21 5/8 instead of 21.625. My EMR blows a gasket with that, but my program would do better). And then, I could allow mixed units, like a weight of "6 pounds 5 1/2 ounces".

I didn't find anything exactly right on the web, but symcbean on stackoverflow had a clever idea for evaluating fractions: turn "2 1/2" into "2+1/2" then use eval.

Continue reading ‘Fractions and Units in PHP’ »