Skip to content

Commit

Permalink
Merge pull request #252 from b123400/fix-251
Browse files Browse the repository at this point in the history
Handle missing medicine in CSV
  • Loading branch information
zdavatz authored Jul 7, 2023
2 parents 7d68820 + 4682d21 commit 229d907
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion AmiKoOSX/MLMainWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3779,7 +3779,20 @@ - (void) csvProcessKeywords:(NSArray *)keywords
#endif

csvMedication = [mDb getMediWithRegnr:rn];
[self searchKeyword:kw inMedication:csvMedication chapters:chapterSet regnr:rn];
if (csvMedication) {
[self searchKeyword:kw inMedication:csvMedication chapters:chapterSet regnr:rn];
} else {
// https://github.com/zdavatz/amiko-osx/issues/251
// When the medicine isn't found in DB, we put the Regnr in link.
[csv appendFormat:@"\n%@%@%@%@\"%@\"%@\"%@\"%@%@%@\"%@\"%@%@",
@"", CSV_SEPARATOR,
@"", CSV_SEPARATOR,
@"", CSV_SEPARATOR,
@"", CSV_SEPARATOR,
@"", CSV_SEPARATOR,
@"", CSV_SEPARATOR,
rn];
}
}
} // for

Expand Down
1 change: 1 addition & 0 deletions MLDBAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ - (MLMedication *) cursorToShortMedInfo:(NSArray *)cursor

- (MLMedication *) cursorToFullMedInfo:(NSArray *)cursor
{
if (!cursor) return nil;
MLMedication *medi = [[MLMedication alloc] init];

[medi setMedId:[(NSString *)[cursor objectAtIndex:kMedId] longLongValue]];
Expand Down

0 comments on commit 229d907

Please sign in to comment.