APSKAMN6 ;IHS/ANMC/SFB/MRS - CONTAINS ALL MATH FUNCTIONS[ 09/28/94 10:51 AM ]
;;1.0;Aminoglycoside Kinetics;;OCT 31,1994
I APSKPTIN'=1 D NOINFO^APSKAMN
G START^APSKAMN0
TIME ;EP - CHANGES TIME INPUTS TO DECIMAL HOURS
S (APSKP,APSKQ1,APSKQ2)=0
S APSKQ1=$P(APSKZ(APSKX1),":",1)
S APSKQ2=$P(APSKZ(APSKX1),":",2)
S APSKP=APSKQ1_"."_APSKQ2
S APSKT(APSKX1)=APSKQ1+(100*(APSKP-APSKQ1)/60)
Q
LN ;EP - APSKLNN=LN(APSKXX) (LOG BASE E)
S APSKTT=APSKXX,(APSKLNN,APSKDD)=0 Q:APSKXX'>0
LN2 I APSKTT'<1 S APSKTT=.5*APSKTT,APSKDD=APSKDD+1 G LN2
LN3 I APSKTT<.5 S APSKTT=2*APSKTT,APSKDD=(APSKDD-1) G LN3
S APSKTT=(APSKTT-.707107)/(APSKTT+.707107),APSKLNN=APSKTT*APSKTT
S APSKLNN=+$J((((.598979*APSKLNN+.961471)*APSKLNN+2.88539)*APSKTT+APSKDD-.5)*.693147,1,6)
K APSKDD,APSKTT
Q
EXP ;EP - APSKEE=EXP(X) (E TO THE X POWER)
S APSKEE=0,APSKBB=1.4427*APSKXX\1+1 Q:APSKBB>90
S APSKEE=.693147*APSKBB-APSKXX,APSKAA=.00132988-(.000141316*APSKEE),APSKAA=((APSKAA*APSKEE-.00830136)*APSKEE+.0416574)*APSKEE,APSKEE=(((APSKAA-.166665)*APSKEE+.5)*APSKEE-1)*APSKEE+1,APSKAA=2
I APSKBB'>0 S APSKAA=.5,APSKBB=-APSKBB
F APSKII=1:1:APSKBB S APSKEE=APSKAA*APSKEE
S APSKEE=+$J(APSKEE,1,6)
K APSKAA,APSKBB,APSKII
Q
;
PWR ;EP - APSKPP=APSKXX^APSKYY
S APSKPP=1 Q:APSKYY=0
S APSKEE=0,APSKGG=APSKXX,APSKHHH=APSKYY
I APSKXX<0,APSKYY\1=APSKYY S APSKPP=1-(2*APSKYY)+(4*(APSKYY/2)\1),APSKXX=-APSKXX
I APSKXX D LN S APSKXX=APSKYY*APSKLNN D EXP
S APSKPP=APSKPP*APSKEE,APSKXX=APSKGG,APSKYY=APSKHHH
I APSKYY>1,APSKXX#1+(APSKYY#1)=0 S APSKPP=$J(APSKPP,1,0)
K APSKGG,APSKHHH,APSKEE,APSKLNN
Q
APSKAMN6 ;IHS/ANMC/SFB/MRS - CONTAINS ALL MATH FUNCTIONS[ 09/28/94 10:51 AM ]
+1 ;;1.0;Aminoglycoside Kinetics;;OCT 31,1994
+2 IF APSKPTIN'=1
DO NOINFO^APSKAMN
+3 GOTO START^APSKAMN0
TIME ;EP - CHANGES TIME INPUTS TO DECIMAL HOURS
+1 SET (APSKP,APSKQ1,APSKQ2)=0
+2 SET APSKQ1=$PIECE(APSKZ(APSKX1),":",1)
+3 SET APSKQ2=$PIECE(APSKZ(APSKX1),":",2)
+4 SET APSKP=APSKQ1_"."_APSKQ2
+5 SET APSKT(APSKX1)=APSKQ1+(100*(APSKP-APSKQ1)/60)
+6 QUIT
LN ;EP - APSKLNN=LN(APSKXX) (LOG BASE E)
+1 SET APSKTT=APSKXX
SET (APSKLNN,APSKDD)=0
IF APSKXX'>0
QUIT
LN2 IF APSKTT'<1
SET APSKTT=.5*APSKTT
SET APSKDD=APSKDD+1
GOTO LN2
LN3 IF APSKTT<.5
SET APSKTT=2*APSKTT
SET APSKDD=(APSKDD-1)
GOTO LN3
+1 SET APSKTT=(APSKTT-.707107)/(APSKTT+.707107)
SET APSKLNN=APSKTT*APSKTT
+2 SET APSKLNN=+$JUSTIFY((((.598979*APSKLNN+.961471)*APSKLNN+2.88539)*APSKTT+APSKDD-.5)*.693147,1,6)
+3 KILL APSKDD,APSKTT
+4 QUIT
EXP ;EP - APSKEE=EXP(X) (E TO THE X POWER)
+1 SET APSKEE=0
SET APSKBB=1.4427*APSKXX\1+1
IF APSKBB>90
QUIT
+2 SET APSKEE=.693147*APSKBB-APSKXX
SET APSKAA=.00132988-(.000141316*APSKEE)
SET APSKAA=((APSKAA*APSKEE-.00830136)*APSKEE+.0416574)*APSKEE
SET APSKEE=(((APSKAA-.166665)*APSKEE+.5)*APSKEE-1)*APSKEE+1
SET APSKAA=2
+3 IF APSKBB'>0
SET APSKAA=.5
SET APSKBB=-APSKBB
+4 FOR APSKII=1:1:APSKBB
SET APSKEE=APSKAA*APSKEE
+5 SET APSKEE=+$JUSTIFY(APSKEE,1,6)
+6 KILL APSKAA,APSKBB,APSKII
+7 QUIT
+8 ;
PWR ;EP - APSKPP=APSKXX^APSKYY
+1 SET APSKPP=1
IF APSKYY=0
QUIT
+2 SET APSKEE=0
SET APSKGG=APSKXX
SET APSKHHH=APSKYY
+3 IF APSKXX<0
IF APSKYY\1=APSKYY
SET APSKPP=1-(2*APSKYY)+(4*(APSKYY/2)\1)
SET APSKXX=-APSKXX
+4 IF APSKXX
DO LN
SET APSKXX=APSKYY*APSKLNN
DO EXP
+5 SET APSKPP=APSKPP*APSKEE
SET APSKXX=APSKGG
SET APSKYY=APSKHHH
+6 IF APSKYY>1
IF APSKXX#1+(APSKYY#1)=0
SET APSKPP=$JUSTIFY(APSKPP,1,0)
+7 KILL APSKGG,APSKHHH,APSKEE,APSKLNN
+8 QUIT