September 14, 2016 : Blood Volume Estimation
© 安岡喜晴 (JoyShine)
I added blood volume estimation (Nadler formula) to the
Medical Calculator.
static const CalcInput BVOL_CM_KG_INPUTS[] = {
{ L"Enter Height (centimeters)", INPUT_NUMBER, NULL },
{ L"Enter Weight (kilograms)", INPUT_NUMBER, NULL },
{ L"Select Sex", INPUT_CHOICE, L"- Select -|Male|Female" },
};
static const CalcInput BVOL_FT_IN_LBS_INPUTS[] = {
{ L"Enter Height (feet)", INPUT_NUMBER, NULL },
{ L"Enter Height (inches)", INPUT_NUMBER, NULL },
{ L"Enter Weight (pounds)", INPUT_NUMBER, NULL },
{ L"Select Sex", INPUT_CHOICE, L"- Select -|Male|Female" },
};
static inline void bvol_compute(double h_in, double w_lbs, bool male,
wchar_t* disp, size_t dsz,
wchar_t* pri, size_t psz,
wchar_t* det, size_t esz) {
double bv = male
? (0.006012 * pow(h_in, 3) + 14.6 * w_lbs) + 604.0
: (0.005835 * pow(h_in, 3) + 15.0 * w_lbs) + 183.0;
wchar_t b[32]; fmt_g(b, 32, bv);
swprintf(disp, dsz, L"%ls", b);
swprintf(pri, psz,
L"Estimated Blood Volume (Nadler) : %ls mL\r\n"
L"Sex : %ls",
b, male ? L"Male" : L"Female");
(void)esz; det[0] = 0;
}
inline void calc_bvol_cm_kg(const double* in,
wchar_t* disp, size_t dsz,
wchar_t* pri, size_t psz,
wchar_t* det, size_t esz) {
bool female;
if (!val_pos(in[0]) || !val_pos(in[1]) || !val_sex_code(in[2], &female)) {
calc_err(disp, dsz, pri, psz, det, esz,
L"Height and weight must be > 0; sex must be 1 (Male) or 2 (Female).");
return;
}
double h_in = in[0] / 2.54;
double w_lbs = in[1] * 2.20462;
bvol_compute(h_in, w_lbs, !female, disp, dsz, pri, psz, det, esz);
}
inline void calc_bvol_ft_in_lbs(const double* in,
wchar_t* disp, size_t dsz,
wchar_t* pri, size_t psz,
wchar_t* det, size_t esz) {
bool female;
if (!val_nonneg(in[0]) || !val_nonneg(in[1]) || !val_pos(in[2]) ||
!val_sex_code(in[3], &female)) {
calc_err(disp, dsz, pri, psz, det, esz,
L"Height components must be >= 0, weight must be > 0; sex must be 1 (Male) or 2 (Female).");
return;
}
double h_in = in[0] * 12.0 + in[1];
double w_lbs = in[2];
bvol_compute(h_in, w_lbs, !female, disp, dsz, pri, psz, det, esz);
}