-
Notifications
You must be signed in to change notification settings - Fork 0
/
RAIcalculateviewcontroller.m
154 lines (93 loc) · 3.39 KB
/
RAIcalculateviewcontroller.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// RAIcalculateviewcontroller.m
// endotools
//
// Created by Johnson Thomas on 11/23/12.
// Copyright (c) 2012 Johnson Thomas. All rights reserved.
//
#import "RAIcalculateviewcontroller.h"
@interface RAIcalculateviewcontroller ()
@end
@implementation RAIcalculateviewcontroller
// connection variables to text fields
@synthesize grams;
@synthesize RAI;
@synthesize calc;
@synthesize dose;
//@synthesize textField;
// declaring variables
float gramvalue = 1;
float raivalue = 1;
float result;
NSString *dosetext;
float uCiretained;
// Action to hide the keypad when return key is pressed
-(IBAction)hidekeyboard:(id)sender;{
[sender resignFirstResponder];
}
- (IBAction)keyboardisappear:(id)sender {
[grams resignFirstResponder];
[RAI resignFirstResponder];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255/255 green:102/255 blue:102/255 alpha:1];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// When calculate button is pressed, following method gets activated
- (IBAction)calculateRAIdose:(id)sender
{
gramvalue =[grams.text intValue]; // extracts the intiger value from the string stored in the textfiled.
raivalue=[RAI.text intValue]; // extracts the intiger value from the string stored in the textfiled.
/// picking the amout of radiation retained s per moderate dosage schedule for I131 therapy : adopted from thyroid manager .org
if (gramvalue <21 && gramvalue>9)
uCiretained = 80;
else if (gramvalue <31 && gramvalue >20)
uCiretained =90;
else if (gramvalue <41 && gramvalue >30)
uCiretained = 100;
else if (gramvalue <51 && gramvalue >40)
uCiretained = 120;
else if (gramvalue <61 && gramvalue >50)
uCiretained = 140;
else if (gramvalue <71 && gramvalue >60)
uCiretained = 150;
else if (gramvalue <81 && gramvalue >70)
uCiretained = 160;
else if (gramvalue <91 && gramvalue >80)
uCiretained = 170;
else if (gramvalue <101 && gramvalue >90)
uCiretained = 180;
else if (gramvalue > 100)
uCiretained = 200;
else
uCiretained = 100;
// debug subroutine - if user didn't enter any value in the textfileds and hit enter we will have 0/0. This routine is to prevent that from happening
if (gramvalue > 0 || raivalue >0) {
result= (((gramvalue * uCiretained * 100)/raivalue) / 1000);
} else {
result=0;
}
///result = 6.6666;
//NSLog(@ "ramvalue = %f", gramvalue);
// NSLog(@"uCiretained = %f", uCiretained);
// NSLog(@" raivalue = %f", raivalue);
// NSLog(@"result %.2f", result);
// writing result to the textfield
dosetext = [NSString stringWithFormat:@"%.2f", result];
dose.text= dosetext;
}
@end