Fórum AJUDA COM FORMULA #608752
22/03/2020
0
Boa noite preciso de uma ajuda urgente para desenvolver essa formula desse site https://www.msdmanuals.com/medical-calculators/GFR_CKD_EPI-pt.htm
no Delphi...por favor se alguem puder me ajudar
no Delphi...por favor se alguem puder me ajudar
Alexandre
Curtir tópico
+ 0
Responder
Posts
23/03/2020
Emerson Nascimento
a fórmula é:
TFG = 141 * mín(Sorocreatinina/kappa, 1)^alfa * máx(Sorocreatinina/kappa, 1)^-1,209 * 0,993^Idade * Sexo * Raça
função:
para testes chamei a função no onclick dos componentes RadioGroupSex e RadioGroupRace, e no onchange dos componentes MaskEditAge, MaskEditSerumCreatinine, ComboBoxSerumCreatinine e ComboBoxDP.
TFG = 141 * mín(Sorocreatinina/kappa, 1)^alfa * máx(Sorocreatinina/kappa, 1)^-1,209 * 0,993^Idade * Sexo * Raça
função:
procedure TForm1.GFR_CKD_EPI_fx;
type
TCreatinine_unit = record
Coefficient: double;
Fit: double;
Name: string;
end;
const
Serum_creatinine_unit: array[0..3] of TCreatinine_unit = (
(Coefficient: 0.0113122171945701; Fit: 0;Name: 'mcmol/L_Cr'),
(Coefficient: 1; Fit: 0;Name: 'mg%_Cr'),
(Coefficient: 1; Fit: 0;Name: 'mg/dL_Cr'),
(Coefficient: 11.3122171945701; Fit: 0;Name: 'mmol/L_Cr')
);
var
doCalc: boolean;
rbchk: boolean;
Sex, Race, alpha, kappa: double;
Age: integer;
unit_parts: TCreatinine_unit;
ParamSerum_creatinine, Serum_creatinine: double;
dp: integer;
GFR: double;
function fixDP(r: double; dps: integer): string;
var
msign: string;
x: double;
m: string;
begin
msign := '';
if (r < 0) then msign := '-';
x := abs(r);
if (x > power(10, 21)) then
begin
result := msign + FloatToStr(x);
exit;
end;
m := FloatToStr(round(x * power(10, dps)));
if (dps = 0) then
begin
result := msign + m;
exit;
end;
while (length(m) <= dps) do m := '0' + m;
result := msign + copy(m, 0, length(m) - dps) + '.' + copy(m, length(m) + 1 - dps);
end;
begin
doCalc := true;
Sex := 0;
alpha := 0;
kappa := 0;
Race := 0;
rbchk := (RadioGroupSex.ItemIndex > -1);
{RadioGroupSex.Items = [Mulher, Homem]}
if RadioGroupSex.ItemIndex = 0 then
begin
Sex := 1.018;
alpha := -0.329;
kappa := 0.7;
end
else
if RadioGroupSex.ItemIndex = 1 then
begin
Sex := 1;
alpha := -0.411;
kappa := 0.9;;
end;
if (not rbchk) then doCalc := false;
rbchk := (RadioGroupRace.ItemIndex > -1);
{RadioGroupRaca.Items = [Branco ou outro (1); Negro (1.159)]}
if RadioGroupRace.ItemIndex = 0 then
Race := 1
else
if RadioGroupRace.ItemIndex = 1 then
Race := 1.159;
if (not rbchk) then doCalc := false;
Age := StrToIntDef(MaskEditAge.Text,0);
ParamSerum_creatinine := StrToFloatDef(MaskEditSerumCreatinine.Text,0);
{ComboBoxSerumCreatinine.Items = [mcmol/L, mg%, mg/dL, mmol/L]}
unit_parts := Serum_creatinine_unit[ComboBoxSerumCreatinine.ItemIndex];
Serum_creatinine := ParamSerum_creatinine * unit_parts.Coefficient + unit_parts.Fit;
{ComboBoxDP.Items = [0,1,2,3]}
dp := StrToIntDef(ComboBoxDP.Items[ComboBoxDP.ItemIndex],0);
GFR := 141
* math.power(math.min(Serum_creatinine/kappa, 1), alpha)
* math.power(math.max(Serum_creatinine/kappa, 1), -1.209)
* math.power(0.993,Age)
* Sex
* Race;
if (doCalc) then MaskEditGRF.Text := fixDP(GFR, dp);
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)