How to define Kt/V, an indicator of the efficiency of dialysis, as scalar function of SQL Server?

In Japan, Shinzato’s fomula for calculating Kt/V, an indicator of efficiency of dialysis, is recommended by JSDT. Since integral equation is used to solve Shinzato’s method, you couldn’t solve algebraically. In K/DOQQI, it is usual to solve Kt/V with Daugirdas’ method. Shinzato has described that Daugirdas’ Kt/V is similar to Shinzato’s Kt/V.

\displaystyle \mathrm{Kt/V} = - LN( R - 0.08 \times t ) + \left[ 4 - \left( 3.5 \times R \right) \right] \times\frac{\mathrm{UF}}{\mathrm{W}}\\  = - LN \left( \frac{\mathrm{postBUN}}{\mathrm{preBUN}} - 0.008 \times t \right) + \left[ 4 - \left( 3.5 \times \frac{\mathrm{postBUN}}{\mathrm{preBUN}} \right) \right] \times \frac{\mathrm{preWeight} - \mathrm{postWeight}}{\mathrm{postWeight}} \cdots(1)
\displaystyle \mathrm{Gw} = \mathrm{G}\cdot\mathrm{Tw} = \mathrm{Kd}\int_{0}^{Td}C_1dt + \mathrm{Kd}\int_{0}^{Td}C_2dt + \mathrm{Kd}\int_{0}^{Td}C_3dt \cdots(2)
\displaystyle \mathrm{Ce} = \mathrm{Cs} Exp\left( - \frac{\mathrm{Kt}}{\mathrm{V}} \right) + \frac{\mathrm{G}}{\mathrm{K}}\left[ 1 - Exp\left( - \frac{\mathrm{Kt}}{\mathrm{V}} \right) \right] \cdots(3)

Execute the procedure as following;

CREATE FUNCTION Function_KtV 
(		@preBUN DEC(4, 1)
	,	@postBUN DEC(4, 1)
	,	@preWeight	DEC(4, 1)
	,	@postWeight DEC(4, 1)
	,	@DialysisDuration	int
)
RETURNS DEC(3,2)
AS
BEGIN
	DECLARE	@KtV DEC(3, 2)
	SELECT	@KtV = - LOG(@postBUN / @preBUN - 0.008 * @DialysisDuration / 60) 
					+ (4 - (3.5 * @postBUN / @preBUN))
					* ((@preWeight - @postWeight) / @postWeight)
	RETURN	@KtV
END
GO

References: JSDT 29 (12): 1511-1516, 1996

Second Generation Logarithmic Estimates of Single-Pool Variable Volume

SQL Serverのスカラー値関数としてKt/Vを定義するには

 透析患者の透析効率を計算するには日本透析医学会の推奨する新里式があります.原著論文を見ると積分方程式を解く必要があり,一般的な数学の知識では歯が立ちません.ここでは Daugirdas による Kt/V をデータベース内で計算する方法を述べます.新里自身も Daugirdas による Kt/V と新里式による Kt/V とはかなり一致していると述べており,ほぼ代用可能ではないかと思われます.(1) が Daugirdas の方法で (2) と (3) を解くと新里式になります.

\displaystyle \mathrm{Kt/V} = - LN( R - 0.008 \times t ) + \left[ 4 - \left( 3.5 \times R \right) \right] \times\frac{\mathrm{UF}}{\mathrm{W}}\\  = - LN \left( \frac{\mathrm{postBUN}}{\mathrm{preBUN}} - 0.008 \times t \right) + \left[ 4 - \left( 3.5 \times \frac{\mathrm{postBUN}}{\mathrm{preBUN}} \right) \right] \times \frac{\mathrm{preWeight} - \mathrm{postWeight}}{\mathrm{postWeight}} \cdots(1)
\displaystyle \mathrm{Gw} = \mathrm{G}\cdot\mathrm{Tw} = \mathrm{Kd}\int_{0}^{Td}C_1dt + \mathrm{Kd}\int_{0}^{Td}C_2dt + \mathrm{Kd}\int_{0}^{Td}C_3dt \cdots(2)
\displaystyle \mathrm{Ce} = \mathrm{Cs} Exp\left( - \frac{\mathrm{Kt}}{\mathrm{V}} \right) + \frac{\mathrm{G}}{\mathrm{K}}\left[ 1 - Exp\left( - \frac{\mathrm{Kt}}{\mathrm{V}} \right) \right] \cdots(3)

 下記プロシージャを実行して関数を作成します.

CREATE FUNCTION Function_KtV 
(		@preBUN DEC(4, 1)
	,	@postBUN DEC(4, 1)
	,	@preWeight	DEC(4, 1)
	,	@postWeight DEC(4, 1)
	,	@DialysisDuration	int
)
RETURNS DEC(3,2)
AS
BEGIN
	DECLARE	@KtV DEC(3, 2)
	SELECT	@KtV = - LOG(@postBUN / @preBUN - 0.008 * @DialysisDuration / 60) 
					+ (4 - (3.5 * @postBUN / @preBUN))
					* ((@preWeight - @postWeight) / @postWeight)
	RETURN	@KtV
END
GO

参照:透析会誌 29 (12): 1511-1516, 1996

Second Generation Logarithmic Estimates of Single-Pool Variable Volume