-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsaAnesthesiaTypeViewController.m
333 lines (281 loc) · 13.7 KB
/
AsaAnesthesiaTypeViewController.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/*This file is generated by perlxml.pl. DO NOT MODIFY */
#import "AsaAnesthesiaTypeViewController.h"
#import "BBUtil.h"
#import "FormSection.h"
#import "FormElement.h"
#import "BBCheckBox.h"
#import "BooleanFormElement.h"
#import "StringListElement.h"
#import "TextElement.h"
#import "StringArrayTableAdapter.h"
#import "ElementListFormElement.h"
#import "FormElementTableAdapter.h"
#import "FormElementTableCellFactory.h"
#import "AntibioticFormElement.h"
#import "MedicationFormElement.h"
#import "BBData.h"
#import "BBAutoCompleteTextField.h"
@interface AsaAnesthesiaTypeViewController () <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet BBCheckBox *asa1BBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *asa2BBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *asa3BBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *asa4BBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *asa5BBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *asaEBBCheckBox;
@property (weak, nonatomic) IBOutlet UITextField *preopEvalByUITextField;
@property (weak, nonatomic) IBOutlet BBCheckBox *generalGetaBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *macMedNecessityBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *spinalBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *generalLmaBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *nerveBlockBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *generalMaskBBCheckBox;
@property (weak, nonatomic) IBOutlet BBCheckBox *epiduralBBCheckBox;
@end
@implementation AsaAnesthesiaTypeViewController
NSString *const ASA_ANESTHESIA_TYPE_SECTION_TITLE = @"AsaAnesthesiaTypeSectionKey";
static NSString *const ASA1_KEY = @"Asa1Key";
static NSString *const ASA2_KEY = @"Asa2Key";
static NSString *const ASA3_KEY = @"Asa3Key";
static NSString *const ASA4_KEY = @"Asa4Key";
static NSString *const ASA5_KEY = @"Asa5Key";
static NSString *const ASAE_KEY = @"AsaEKey";
static NSString *const PREOP_EVAL_BY_KEY = @"PreopEvalByKey";
static NSString *const GENERAL_GETA_KEY = @"GeneralGetaKey";
static NSString *const MAC_MED_NECESSITY_KEY = @"MacMedNecessityKey";
static NSString *const SPINAL_KEY = @"SpinalKey";
static NSString *const GENERAL_LMA_KEY = @"GeneralLmaKey";
static NSString *const NERVE_BLOCK_KEY = @"NerveBlockKey";
static NSString *const GENERAL_MASK_KEY = @"GeneralMaskKey";
static NSString *const EPIDURAL_KEY = @"EpiduralKey";
- (void)viewDidLoad
{
[super viewDidLoad];
[self.asa1BBCheckBox addTarget:self action:@selector(radioGroup1:) forControlEvents:UIControlEventTouchUpInside];
[self.asa2BBCheckBox addTarget:self action:@selector(radioGroup1:) forControlEvents:UIControlEventTouchUpInside];
[self.asa3BBCheckBox addTarget:self action:@selector(radioGroup1:) forControlEvents:UIControlEventTouchUpInside];
[self.asa4BBCheckBox addTarget:self action:@selector(radioGroup1:) forControlEvents:UIControlEventTouchUpInside];
[self.asa5BBCheckBox addTarget:self action:@selector(radioGroup1:) forControlEvents:UIControlEventTouchUpInside];
if (_section) {
[self validateSection:_section];
NSArray *elements = [_section.elements array];
for (FormElement *element in elements) {
if ([element.key isEqualToString:ASA1_KEY]){
[self.asa1BBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:ASA2_KEY]){
[self.asa2BBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:ASA3_KEY]){
[self.asa3BBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:ASA4_KEY]){
[self.asa4BBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:ASA5_KEY]){
[self.asa5BBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:ASAE_KEY]){
[self.asaEBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:PREOP_EVAL_BY_KEY]){
[self.preopEvalByUITextField setText:((TextElement*)element).value];
}
if ([element.key isEqualToString:GENERAL_GETA_KEY]){
[self.generalGetaBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:MAC_MED_NECESSITY_KEY]){
[self.macMedNecessityBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:SPINAL_KEY]){
[self.spinalBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:GENERAL_LMA_KEY]){
[self.generalLmaBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:NERVE_BLOCK_KEY]){
[self.nerveBlockBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:GENERAL_MASK_KEY]){
[self.generalMaskBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
if ([element.key isEqualToString:EPIDURAL_KEY]){
[self.epiduralBBCheckBox setSelected:[((BooleanFormElement*)element).value boolValue]];
}
}
}
}
-(void)addDatePicker: (UITextField*)textField withSelector: (SEL)selector {
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[textField setInputView:datePicker];
UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame: CGRectMake(0,0,340,44)];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:selector];
[myToolbar setItems:[NSArray arrayWithObject: doneButton] animated:NO];
textField.inputAccessoryView = myToolbar;
}
-(void)validateSection:(FormSection*)section
{
NSAssert([section getElementForKey:ASA1_KEY]!= nil, @"Asa1 is nil");
NSAssert([section getElementForKey:ASA2_KEY]!= nil, @"Asa2 is nil");
NSAssert([section getElementForKey:ASA3_KEY]!= nil, @"Asa3 is nil");
NSAssert([section getElementForKey:ASA4_KEY]!= nil, @"Asa4 is nil");
NSAssert([section getElementForKey:ASA5_KEY]!= nil, @"Asa5 is nil");
NSAssert([section getElementForKey:ASAE_KEY]!= nil, @"AsaE is nil");
NSAssert([section getElementForKey:PREOP_EVAL_BY_KEY]!= nil, @"PreopEvalBy is nil");
NSAssert([section getElementForKey:GENERAL_GETA_KEY]!= nil, @"GeneralGeta is nil");
NSAssert([section getElementForKey:MAC_MED_NECESSITY_KEY]!= nil, @"MacMedNecessity is nil");
NSAssert([section getElementForKey:SPINAL_KEY]!= nil, @"Spinal is nil");
NSAssert([section getElementForKey:GENERAL_LMA_KEY]!= nil, @"GeneralLma is nil");
NSAssert([section getElementForKey:NERVE_BLOCK_KEY]!= nil, @"NerveBlock is nil");
NSAssert([section getElementForKey:GENERAL_MASK_KEY]!= nil, @"GeneralMask is nil");
NSAssert([section getElementForKey:EPIDURAL_KEY]!= nil, @"Epidural is nil");
}
-(BOOL)validateData:(NSString**)errMsg
{
return true;
}
- (IBAction)accept:(id)sender {
NSString* errMsg;
if ( ! [self validateData: &errMsg] ){
[BBUtil showAlertWithMessage:errMsg];
return;
}
if ( !self.section ){
self.section = (FormSection*)[BBUtil newCoreDataObjectForEntityName:@"FormSection"];
self.section.title = ASA_ANESTHESIA_TYPE_SECTION_TITLE;
}
BooleanFormElement *asa1 = (BooleanFormElement*)[_section getElementForKey:ASA1_KEY];
if (!asa1) {
asa1 = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asa1.key = ASA1_KEY;
[_section addElementsObject:asa1];
}
asa1.value = [NSNumber numberWithBool:self.asa1BBCheckBox.isSelected];
BooleanFormElement *asa2 = (BooleanFormElement*)[_section getElementForKey:ASA2_KEY];
if (!asa2) {
asa2 = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asa2.key = ASA2_KEY;
[_section addElementsObject:asa2];
}
asa2.value = [NSNumber numberWithBool:self.asa2BBCheckBox.isSelected];
BooleanFormElement *asa3 = (BooleanFormElement*)[_section getElementForKey:ASA3_KEY];
if (!asa3) {
asa3 = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asa3.key = ASA3_KEY;
[_section addElementsObject:asa3];
}
asa3.value = [NSNumber numberWithBool:self.asa3BBCheckBox.isSelected];
BooleanFormElement *asa4 = (BooleanFormElement*)[_section getElementForKey:ASA4_KEY];
if (!asa4) {
asa4 = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asa4.key = ASA4_KEY;
[_section addElementsObject:asa4];
}
asa4.value = [NSNumber numberWithBool:self.asa4BBCheckBox.isSelected];
BooleanFormElement *asa5 = (BooleanFormElement*)[_section getElementForKey:ASA5_KEY];
if (!asa5) {
asa5 = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asa5.key = ASA5_KEY;
[_section addElementsObject:asa5];
}
asa5.value = [NSNumber numberWithBool:self.asa5BBCheckBox.isSelected];
BooleanFormElement *asaE = (BooleanFormElement*)[_section getElementForKey:ASAE_KEY];
if (!asaE) {
asaE = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
asaE.key = ASAE_KEY;
[_section addElementsObject:asaE];
}
asaE.value = [NSNumber numberWithBool:self.asaEBBCheckBox.isSelected];
TextElement *preopEvalBy = (TextElement*)[_section getElementForKey:PREOP_EVAL_BY_KEY];
if (!preopEvalBy) {
preopEvalBy = (TextElement*)[BBUtil newCoreDataObjectForEntityName:@"TextElement"];
preopEvalBy.key = PREOP_EVAL_BY_KEY;
[_section addElementsObject:preopEvalBy];
}
preopEvalBy.value = self.preopEvalByUITextField.text;
BooleanFormElement *generalGeta = (BooleanFormElement*)[_section getElementForKey:GENERAL_GETA_KEY];
if (!generalGeta) {
generalGeta = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
generalGeta.key = GENERAL_GETA_KEY;
[_section addElementsObject:generalGeta];
}
generalGeta.value = [NSNumber numberWithBool:self.generalGetaBBCheckBox.isSelected];
BooleanFormElement *macMedNecessity = (BooleanFormElement*)[_section getElementForKey:MAC_MED_NECESSITY_KEY];
if (!macMedNecessity) {
macMedNecessity = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
macMedNecessity.key = MAC_MED_NECESSITY_KEY;
[_section addElementsObject:macMedNecessity];
}
macMedNecessity.value = [NSNumber numberWithBool:self.macMedNecessityBBCheckBox.isSelected];
BooleanFormElement *spinal = (BooleanFormElement*)[_section getElementForKey:SPINAL_KEY];
if (!spinal) {
spinal = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
spinal.key = SPINAL_KEY;
[_section addElementsObject:spinal];
}
spinal.value = [NSNumber numberWithBool:self.spinalBBCheckBox.isSelected];
BooleanFormElement *generalLma = (BooleanFormElement*)[_section getElementForKey:GENERAL_LMA_KEY];
if (!generalLma) {
generalLma = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
generalLma.key = GENERAL_LMA_KEY;
[_section addElementsObject:generalLma];
}
generalLma.value = [NSNumber numberWithBool:self.generalLmaBBCheckBox.isSelected];
BooleanFormElement *nerveBlock = (BooleanFormElement*)[_section getElementForKey:NERVE_BLOCK_KEY];
if (!nerveBlock) {
nerveBlock = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
nerveBlock.key = NERVE_BLOCK_KEY;
[_section addElementsObject:nerveBlock];
}
nerveBlock.value = [NSNumber numberWithBool:self.nerveBlockBBCheckBox.isSelected];
BooleanFormElement *generalMask = (BooleanFormElement*)[_section getElementForKey:GENERAL_MASK_KEY];
if (!generalMask) {
generalMask = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
generalMask.key = GENERAL_MASK_KEY;
[_section addElementsObject:generalMask];
}
generalMask.value = [NSNumber numberWithBool:self.generalMaskBBCheckBox.isSelected];
BooleanFormElement *epidural = (BooleanFormElement*)[_section getElementForKey:EPIDURAL_KEY];
if (!epidural) {
epidural = (BooleanFormElement*)[BBUtil newCoreDataObjectForEntityName:@"BooleanFormElement"];
epidural.key = EPIDURAL_KEY;
[_section addElementsObject:epidural];
}
epidural.value = [NSNumber numberWithBool:self.epiduralBBCheckBox.isSelected];
[self.delegate sectionCreated:self.section];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)changeMedUnit:(UIButton*)sender {
if ([sender.titleLabel.text isEqualToString: @"cc"]) {
[sender setTitle:@"mcg" forState:UIControlStateNormal];
} else if ([sender.titleLabel.text isEqualToString: @"mcg"]) {
[sender setTitle:@"mg" forState:UIControlStateNormal];
} else if ([sender.titleLabel.text isEqualToString: @"mg"]) {
[sender setTitle:@"G" forState:UIControlStateNormal];
} else if ([sender.titleLabel.text isEqualToString: @"G"]) {
[sender setTitle:@"none" forState:UIControlStateNormal];
} else if ([sender.titleLabel.text isEqualToString: @"none"]) {
[sender setTitle:@"cc" forState:UIControlStateNormal];
}
}
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
- (IBAction)dismiss:(id)sender {
[BBUtil refreshManagedObject:_section];
[self dismissViewControllerAnimated:YES completion:nil];
}
+(NSString*)sectionTitle
{
return ASA_ANESTHESIA_TYPE_SECTION_TITLE;
}
-(void)radioGroup1:(BBCheckBox*)sender {
BOOL selected = sender.selected;
self.asa1BBCheckBox.selected = NO;
self.asa2BBCheckBox.selected = NO;
self.asa3BBCheckBox.selected = NO;
self.asa4BBCheckBox.selected = NO;
self.asa5BBCheckBox.selected = NO;
sender.selected = selected;
}
@end