-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMLMedication.m
128 lines (107 loc) · 4.21 KB
/
MLMedication.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
/*
Copyright (c) 2013 Max Lungarella <[email protected]>
Created on 24/08/2013.
This file is part of AmiKo for OSX.
AmiKo for OSX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------ */
#import "MLMedication.h"
#import "MLUtilities.h"
static NSString* SectionTitle_DE[] = {@"Zusammensetzung", @"Galenische Form", @"Kontraindikationen", @"Indikationen", @"Dosierung/Anwendung",
@"Vorsichtsmassnahmen", @"Interaktionen", @"Schwangerschaft", @"Fahrtüchtigkeit", @"Unerwünschte Wirk.", @"Überdosierung", @"Eig./Wirkung",
@"Kinetik", @"Präklinik", @"Sonstige Hinweise", @"Zulassungsnummer", @"Packungen", @"Inhaberin", @"Stand der Information"};
static NSString* SectionTitle_FR[] = {@"Composition", @"Forme galénique", @"Contre-indications", @"Indications", @"Posologie", @"Précautions",
@"Interactions", @"Grossesse/All.", @"Conduite", @"Effets indésir.", @"Surdosage", @"Propriétés/Effets", @"Cinétique", @"Préclinique", @"Remarques",
@"Numéro d'autorisation", @"Présentation", @"Titulaire", @"Mise à jour"};
@implementation MLMedication
@synthesize medId;
@synthesize customerId;
@synthesize title;
@synthesize auth;
@synthesize atccode;
@synthesize substances;
@synthesize regnrs;
@synthesize atcClass;
@synthesize therapy;
@synthesize application;
@synthesize indications;
@synthesize packInfo;
@synthesize addInfo;
@synthesize sectionIds;
@synthesize sectionTitles;
@synthesize styleStr;
@synthesize contentStr;
@synthesize packages;
- (NSArray *) listOfSectionIds
{
return [sectionIds componentsSeparatedByString:@","];
}
- (NSArray *) listOfSectionTitles
{
NSMutableArray *titles = [[sectionTitles componentsSeparatedByString:@";"] mutableCopy];
NSUInteger n = [titles count];
for (int i=0; i<n; ++i) {
titles[i] = [self shortTitle:titles[i]];
}
return titles;
}
- (NSDictionary *) indexToTitlesDict
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSArray *ids = [self listOfSectionIds];
NSArray *titles = [self listOfSectionTitles];
NSUInteger n1 = [ids count];
NSUInteger n2 = [titles count];
NSUInteger n = n1 < n2 ? n1 : n2;
for (NSUInteger i=0; i<n; ++i) {
NSString *id = ids[i];
id = [id stringByReplacingOccurrencesOfString:@"section" withString:@""];
id = [id stringByReplacingOccurrencesOfString:@"Section" withString:@""];
if ([id length]>0) {
dict[id] = [self shortTitle:titles[i]];
}
}
return dict;
}
- (NSString *) shortTitle:(NSString *)longTitle
{
NSString *t = [longTitle lowercaseString];
if ([MLUtilities isGermanApp]) {
for (int i=0; i<19; i++) {
NSString *compareString = [SectionTitle_DE[i] lowercaseString];
if (compareString!=nil) {
if ([t rangeOfString:compareString].location != NSNotFound) {
t = SectionTitle_DE[i];
return t;
}
}
}
} else if ([MLUtilities isFrenchApp]) {
for (int i=0; i<19; i++) {
NSString *compareString = [SectionTitle_FR[i] lowercaseString];
if (compareString!=nil) {
if ([t rangeOfString:compareString].location != NSNotFound) {
t = SectionTitle_FR[i];
return t;
}
}
}
}
return longTitle;
}
- (void)importFromDict:(NSDictionary *)dict
{
title = [dict objectForKey:KEY_AMK_MED_TITLE];
auth = [dict objectForKey:KEY_AMK_MED_OWNER];
regnrs = [dict objectForKey:KEY_AMK_MED_REG_N];
atccode = [dict objectForKey:KEY_AMK_MED_ATC];
}
@end