forked from pixmeo/osirix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvancedQuerySubview.m
187 lines (163 loc) · 7.83 KB
/
AdvancedQuerySubview.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
/*=========================================================================
Program: OsiriX
Copyright (c) OsiriX Team
All rights reserved.
Distributed under GNU - LGPL
See http://www.osirix-viewer.com/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#import "AdvancedQuerySubview.h"
@implementation AdvancedQuerySubview
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
filterKeyPopup = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(9,18,135,26) pullsDown:NO];
[filterKeyPopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"Patient Name", nil), NSLocalizedString(@"Patient ID", nil), NSLocalizedString(@"Modality", nil), NSLocalizedString(@"Study Date", nil), nil]];
searchTypePopup = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(146,18,135,26) pullsDown:NO];
[searchTypePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"contains", nil), NSLocalizedString(@"starts with", nil), NSLocalizedString(@"ends with", nil), NSLocalizedString(@"is", nil), nil]];
[searchTypePopup setHidden:YES];
valueField = [[NSTextField alloc] initWithFrame:NSMakeRect(287,20,140,22)];
[valueField setHidden:YES];
datePicker = [[NSDatePicker alloc] initWithFrame:NSMakeRect(287,20,140,22)];
[datePicker setDatePickerElements: NSYearMonthDayDatePickerElementFlag];
[datePicker setDatePickerStyle: NSTextFieldAndStepperDatePickerStyle];
[datePicker setDateValue: [NSCalendarDate dateWithYear:[[NSCalendarDate date] yearOfCommonEra] month:[[NSCalendarDate date] monthOfYear] day:[[NSCalendarDate date] dayOfMonth] hour:0 minute:0 second:0 timeZone: nil]];
[datePicker setBackgroundColor: [NSColor whiteColor]];
[datePicker setDrawsBackground: YES];
[datePicker setHidden:YES];
//addButton = [[NSButton alloc] initWithFrame:NSMakeRect(436,14,39,38)];
addButton = [[NSButton alloc] initWithFrame:NSMakeRect(440,18,26,26)];
//[addButton setImage:[NSImage imageNamed:@"add.tif"]];
[addButton setImage:[NSImage imageNamed:NSImageNameAddTemplate]];
[addButton setImagePosition:NSImageOnly];
//[addButton setBezelStyle:NSCircularBezelStyle];
[addButton setBezelStyle:NSRegularSquareBezelStyle];
removeButton = [[NSButton alloc] initWithFrame:NSMakeRect(469,18,26,26)];
//[removeButton setImage:[NSImage imageNamed:@"minus.tif"]];
[removeButton setImage:[NSImage imageNamed:NSImageNameRemoveTemplate]];
[removeButton setImagePosition:NSImageOnly];
[removeButton setBezelStyle:NSRegularSquareBezelStyle];
[removeButton setEnabled:NO];
NSArray *views = [NSArray arrayWithObjects:filterKeyPopup, searchTypePopup, valueField, addButton, removeButton, datePicker, nil];
id view;
NSView *lastView = nil;
for (view in views) {
[lastView setNextKeyView:view];
[self addSubview:view];
lastView = view;
}
dateRangePopup = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(287,18,135,26) pullsDown:NO];
[dateRangePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"the last day", nil), NSLocalizedString(@"the last 2 days", nil), NSLocalizedString(@"the last 7 days", nil), NSLocalizedString(@"the last 31 days", nil), NSLocalizedString(@"the last 2 months", nil), NSLocalizedString(@"the last 3 month", nil), NSLocalizedString(@"the last year", nil), nil]];
[self addSubview:dateRangePopup];
[dateRangePopup setHidden:YES];
[dateRangePopup release];
}
return self;
}
- (void)drawRect:(NSRect)rect {
// Drawing code here.
//NSLog(@"rect %@ %f %f %f %f", [self description], rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
// NSLog (@"box
[super drawRect:rect];
}
- (id) filterKeyPopup{
return filterKeyPopup;
}
- (id) searchTypePopup{
return searchTypePopup;
}
- (id) valueField{
return valueField;
}
- (id) addButton{
return addButton;
}
- (id) removeButton{
return removeButton;
}
- (id) datePicker{
return datePicker;
}
- (id) dateRangePopup{
return dateRangePopup;
}
- (id) modalityPopup{
return modalityPopup;
}
- (IBAction) showSearchTypePopup: (id) sender
{
[searchTypePopup setHidden:YES];
[dateRangePopup setHidden:YES];
[valueField setHidden:YES];
[datePicker setHidden:YES];
[searchTypePopup setHidden:NO];
//Study date selected. Need to adjust searchType parameters and add Date formtter.
[searchTypePopup removeAllItems];
if ([sender indexOfSelectedItem] == 3 || [sender indexOfSelectedItem] == 11 || [sender indexOfSelectedItem] == 12) { //dates
[searchTypePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"is Today", nil), NSLocalizedString(@"is Yesterday", nil),
NSLocalizedString(@"is before", nil), NSLocalizedString(@"is after", nil),NSLocalizedString(@"is within", nil), NSLocalizedString(@"is exactly", nil), nil]];
}
else if ([sender indexOfSelectedItem] == 2) { //Modality
[searchTypePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"is CR", nil), NSLocalizedString(@"is CT", nil),
NSLocalizedString(@"is DX", nil), NSLocalizedString(@"is ES", nil), NSLocalizedString(@"is MG", nil), NSLocalizedString(@"is MR", nil),
NSLocalizedString(@"is NM", nil), NSLocalizedString(@"is OT", nil),NSLocalizedString(@"is PT", nil),NSLocalizedString(@"is RF", nil),
NSLocalizedString(@"is SC", nil),NSLocalizedString(@"is US", nil),NSLocalizedString(@"is XA", nil),NSLocalizedString(@"is Other", nil), nil]];
}
else if ([sender indexOfSelectedItem] == 10) { //Status
[searchTypePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"is empty", nil), NSLocalizedString(@"is unread", nil),
NSLocalizedString(@"is reviewed", nil), NSLocalizedString(@"is dictated", nil), NSLocalizedString(@"is validated", nil),nil]];
}
else //not dates
[searchTypePopup addItemsWithTitles:[NSArray arrayWithObjects:NSLocalizedString(@"contains", nil), NSLocalizedString(@"starts with", nil),
NSLocalizedString(@"ends with", nil), NSLocalizedString(@"is", nil), nil]];
[self showValueField: searchTypePopup];
}
- (IBAction) showValueField: (id) sender
{
[datePicker setHidden:YES];
// need date range Popup
if ( ([filterKeyPopup indexOfSelectedItem] == 3 || [filterKeyPopup indexOfSelectedItem] == 11 || [filterKeyPopup indexOfSelectedItem] == 12) && [searchTypePopup indexOfSelectedItem] == 4) {
[dateRangePopup setHidden:NO];
[valueField setHidden:YES];
[searchTypePopup setNextKeyView:dateRangePopup];
}
// Modalities
else if ([filterKeyPopup indexOfSelectedItem] == 2 && [searchTypePopup indexOfSelectedItem] < 13) {
[dateRangePopup setHidden:YES];
[valueField setHidden:YES];
}
// Study status
else if ([filterKeyPopup indexOfSelectedItem] == 10) {
[dateRangePopup setHidden:YES];
[valueField setHidden:YES];
}
//add date formatter
else if (([filterKeyPopup indexOfSelectedItem] == 3 || [filterKeyPopup indexOfSelectedItem] == 11 || [filterKeyPopup indexOfSelectedItem] == 12)) {
if (([searchTypePopup indexOfSelectedItem] == 2) || ([searchTypePopup indexOfSelectedItem] == 3) || ([searchTypePopup indexOfSelectedItem] == 5)) {
[dateRangePopup setHidden:YES];
[valueField setHidden:YES];
[datePicker setHidden:NO];
// NSDateFormatter *formatter = [[[NSDateFormatter alloc] initWithDateFormat:@"%m/%d/%Y" allowNaturalLanguage:NO] autorelease];
// [[valueField cell] setFormatter:formatter];
// [valueField setObjectValue:[NSDate date]];
}
else {
// no other fields to view Selection is today or Yesterday exact match
[dateRangePopup setHidden:YES];
[valueField setHidden:YES];
[searchTypePopup setNextKeyView:valueField];
}
}
// just standard text
else {
[dateRangePopup setHidden:YES];
[valueField setHidden:NO];
}
}
- (IBAction)showModalityPopup:(id)sender
{
[modalityPopup setHidden:NO];
}
@end