From 4682d2131b811378ede18cfb26d2fe2f7ebb07e3 Mon Sep 17 00:00:00 2001 From: b123400 Date: Fri, 7 Jul 2023 22:37:13 +0900 Subject: [PATCH] Insert empty line and put Regnr in link when the medicine is not found #251 --- AmiKoOSX/MLMainWindowController.m | 15 ++++++++++++++- MLDBAdapter.m | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/AmiKoOSX/MLMainWindowController.m b/AmiKoOSX/MLMainWindowController.m index d175a35..6f0f7f9 100644 --- a/AmiKoOSX/MLMainWindowController.m +++ b/AmiKoOSX/MLMainWindowController.m @@ -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 diff --git a/MLDBAdapter.m b/MLDBAdapter.m index 7b8cf15..d84a6ae 100644 --- a/MLDBAdapter.m +++ b/MLDBAdapter.m @@ -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]];