Skip to content

Commit

Permalink
Merge pull request #190 from b123400/fix-189
Browse files Browse the repository at this point in the history
Fix description, issueDate, and posology
  • Loading branch information
zdavatz authored Jan 16, 2025
2 parents 273efc8 + dadeac5 commit ce26ece
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
19 changes: 12 additions & 7 deletions AmiKoDesitin/EPrescription/EPrescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ + (NSDate *)parseDateString:(NSString *)str {

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

- (ZurRosePrescription *)toZurRosePrescription {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd";
ZurRosePrescription *prescription = [[ZurRosePrescription alloc] init];

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

BOOL repetition = NO;
NSDate *validityRepetition = nil;
NSMutableArray<ZurRosePosology *> *poses = [NSMutableArray array];
ZurRosePosology *pos = [[ZurRosePosology alloc] init];
[poses addObject:pos];
for (EPrescriptionPosology *mediPos in medi.pos) {
ZurRosePosology *pos = [[ZurRosePosology alloc] init];
[poses addObject:pos];
if (mediPos.d.count) {
pos.qtyMorning = mediPos.d[0].intValue;
pos.qtyMidday = mediPos.d[1].intValue;
pos.qtyEvening = mediPos.d[2].intValue;
pos.qtyNight = mediPos.d[3].intValue;
pos.posologyText = medi.appInstr;
}
if (mediPos.dtTo) {
repetition = YES;
validityRepetition = mediPos.dtTo;
}
}
product.validityRepetition = [dateFormatter stringFromDate:validityRepetition];
product.repetition = repetition;
product.posology = poses;
}
Expand Down Expand Up @@ -332,8 +337,8 @@ - (NSDictionary *)amkDict {
},
@"patient": @{
@"patient_id": [self generatePatientUniqueID],
@"given_name": self.patientLastName ?: @"",
@"family_name": self.patientFirstName ?: @"",
@"given_name": self.patientFirstName ?: @"",
@"family_name": self.patientLastName ?: @"",
@"birth_date": self.patientBirthdate ? [birthDateDateFormatter stringFromDate:self.patientBirthdate] : @"",
@"gender": self.patientGender.intValue == 1 ? KEY_AMK_PAT_GENDER_M : KEY_AMK_PAT_GENDER_F,
@"email_address": self.patientEmail ?: @"",
Expand Down
2 changes: 1 addition & 1 deletion AmiKoDesitin/EPrescription/ZurRoseProduct.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (DDXMLElement *)toXML {
[e addAttribute:[DDXMLNode attributeWithName:@"eanId" stringValue:self.eanId]];
}
if (self.description_) {
[e addAttribute:[DDXMLNode attributeWithName:@"description" stringValue:self.description_]];
[e addAttribute:[DDXMLNode attributeWithName:@"description" stringValue:self.description_.length <= 50 ? self.description_ : [self.description_ substringToIndex:50]]];
}
[e addAttribute:[DDXMLNode attributeWithName:@"repetition" stringValue:self.repetition ? @"true" : @"false"]];
if (self.nrOfRepetitions >= 0) {
Expand Down
5 changes: 3 additions & 2 deletions AmiKoDesitin/Prescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ - (ZurRosePrescription *)toZurRosePrescription {
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateFormat = @"dd.MM.yyyy (HH:mm:ss)";
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
NSDate *date = [dateFormatter dateFromString:self.placeDate];
NSDate *date = [dateFormatter dateFromString:dateString];
prescription.issueDate = date;
} else {
}
if (!prescription.issueDate) {
prescription.issueDate = [NSDate date];
}

Expand Down

0 comments on commit ce26ece

Please sign in to comment.