Skip to content

Commit ce26ece

Browse files
authored
Merge pull request #190 from b123400/fix-189
Fix description, issueDate, and posology
2 parents 273efc8 + dadeac5 commit ce26ece

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

AmiKoDesitin/EPrescription/EPrescription.m

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,9 @@ + (NSDate *)parseDateString:(NSString *)str {
165165

166166
NSError *error = nil;
167167
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"([\\+|\\-])([0-9]{1,2}):?([0-9]{1,2})$"
168-
options:nil
168+
options:0
169169
error:&error];
170-
NSTextCheckingResult *result = [regex firstMatchInString:str options:nil range:NSMakeRange(0, str.length)];
171-
NSString *overall = [str substringWithRange:[result range]];
170+
NSTextCheckingResult *result = [regex firstMatchInString:str options:0 range:NSMakeRange(0, str.length)];
172171
NSString *timeZoneOffsetMark = [str substringWithRange:[result rangeAtIndex:1]];
173172
NSString *timeZoneOffsetHour = [str substringWithRange:[result rangeAtIndex:2]];
174173
NSString *timeZoneOffsetMinutes = [str substringWithRange:[result rangeAtIndex:3]];
@@ -185,6 +184,8 @@ + (NSDate *)parseDateString:(NSString *)str {
185184
}
186185

187186
- (ZurRosePrescription *)toZurRosePrescription {
187+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
188+
dateFormatter.dateFormat = @"yyyy-MM-dd";
188189
ZurRosePrescription *prescription = [[ZurRosePrescription alloc] init];
189190

190191
prescription.issueDate = self.date;
@@ -257,20 +258,24 @@ - (ZurRosePrescription *)toZurRosePrescription {
257258
product.insuranceEanId = insuranceEan;
258259

259260
BOOL repetition = NO;
261+
NSDate *validityRepetition = nil;
260262
NSMutableArray<ZurRosePosology *> *poses = [NSMutableArray array];
263+
ZurRosePosology *pos = [[ZurRosePosology alloc] init];
264+
[poses addObject:pos];
261265
for (EPrescriptionPosology *mediPos in medi.pos) {
262-
ZurRosePosology *pos = [[ZurRosePosology alloc] init];
263-
[poses addObject:pos];
264266
if (mediPos.d.count) {
265267
pos.qtyMorning = mediPos.d[0].intValue;
266268
pos.qtyMidday = mediPos.d[1].intValue;
267269
pos.qtyEvening = mediPos.d[2].intValue;
268270
pos.qtyNight = mediPos.d[3].intValue;
271+
pos.posologyText = medi.appInstr;
269272
}
270273
if (mediPos.dtTo) {
271274
repetition = YES;
275+
validityRepetition = mediPos.dtTo;
272276
}
273277
}
278+
product.validityRepetition = [dateFormatter stringFromDate:validityRepetition];
274279
product.repetition = repetition;
275280
product.posology = poses;
276281
}
@@ -332,8 +337,8 @@ - (NSDictionary *)amkDict {
332337
},
333338
@"patient": @{
334339
@"patient_id": [self generatePatientUniqueID],
335-
@"given_name": self.patientLastName ?: @"",
336-
@"family_name": self.patientFirstName ?: @"",
340+
@"given_name": self.patientFirstName ?: @"",
341+
@"family_name": self.patientLastName ?: @"",
337342
@"birth_date": self.patientBirthdate ? [birthDateDateFormatter stringFromDate:self.patientBirthdate] : @"",
338343
@"gender": self.patientGender.intValue == 1 ? KEY_AMK_PAT_GENDER_M : KEY_AMK_PAT_GENDER_F,
339344
@"email_address": self.patientEmail ?: @"",

AmiKoDesitin/EPrescription/ZurRoseProduct.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ - (DDXMLElement *)toXML {
3535
[e addAttribute:[DDXMLNode attributeWithName:@"eanId" stringValue:self.eanId]];
3636
}
3737
if (self.description_) {
38-
[e addAttribute:[DDXMLNode attributeWithName:@"description" stringValue:self.description_]];
38+
[e addAttribute:[DDXMLNode attributeWithName:@"description" stringValue:self.description_.length <= 50 ? self.description_ : [self.description_ substringToIndex:50]]];
3939
}
4040
[e addAttribute:[DDXMLNode attributeWithName:@"repetition" stringValue:self.repetition ? @"true" : @"false"]];
4141
if (self.nrOfRepetitions >= 0) {

AmiKoDesitin/Prescription.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ - (ZurRosePrescription *)toZurRosePrescription {
190190
NSDateFormatter *dateFormatter = [NSDateFormatter new];
191191
dateFormatter.dateFormat = @"dd.MM.yyyy (HH:mm:ss)";
192192
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
193-
NSDate *date = [dateFormatter dateFromString:self.placeDate];
193+
NSDate *date = [dateFormatter dateFromString:dateString];
194194
prescription.issueDate = date;
195-
} else {
195+
}
196+
if (!prescription.issueDate) {
196197
prescription.issueDate = [NSDate date];
197198
}
198199

0 commit comments

Comments
 (0)