From fb71c5cce02385b04adeb448bc5825d593197729 Mon Sep 17 00:00:00 2001 From: b123400 Date: Sun, 25 Jan 2026 00:13:06 +0900 Subject: [PATCH 1/2] remove temp.zip after download --- scripts/download.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/download.sh b/scripts/download.sh index 48a2667..eae0764 100755 --- a/scripts/download.sh +++ b/scripts/download.sh @@ -127,7 +127,7 @@ sed -i -e 's/xmlns.*="[^"]*"//' $TARGET sed -i -e 's/xsi:.*="[^"]*"//' $TARGET rm Refdata.Articles.xml -rm $TARGET-e +rm temp.zip rm -rf Refdata-AllHtml From b0135511ecf97db23b02f69bf15e5c3424e1523a Mon Sep 17 00:00:00 2001 From: b123400 Date: Sun, 25 Jan 2026 00:13:49 +0900 Subject: [PATCH 2/2] Add type column to database to show if it's fachinfo or patinfo --- src/c2s/aips.cpp | 8 ++++++-- src/c2s/cpp2sqlite.cpp | 5 +++-- src/c2s/medicine.h | 1 + src/sqlDatabase.cpp | 1 + src/sqlDatabase.hpp | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/c2s/aips.cpp b/src/c2s/aips.cpp index 3674d25..578ba8c 100644 --- a/src/c2s/aips.cpp +++ b/src/c2s/aips.cpp @@ -166,8 +166,9 @@ MedicineList & parseXML(const std::string &filename, // Mapping: https://github.com/zdavatz/cpp2sqlite/issues/252 // For --pinfo, Add both fi and pi: https://github.com/zdavatz/cpp2sqlite/issues/271 - if (!(type == "fi" && v.second.get("Type", "") == "SmPC") && - !(type == "pi" && (v.second.get("Type", "") == "SmPC" || v.second.get("Type", "") == "PIL")) + std::string medType = v.second.get("Type", ""); + if (!(type == "fi" && medType == "SmPC") && + !(type == "pi" && (medType == "SmPC" || medType == "PIL")) ) { continue; } @@ -183,6 +184,9 @@ MedicineList & parseXML(const std::string &filename, } Medicine Med; + Med.type = medType == "SmPC" ? "FI" + : medType == "PIL" ? "PI" + : ""; Med.title = attachedDocument.second.get("Description", ""); boost::replace_all(Med.title, "&", "&"); // Issue #49 diff --git a/src/c2s/cpp2sqlite.cpp b/src/c2s/cpp2sqlite.cpp index c1d448c..8e34cfa 100644 --- a/src/c2s/cpp2sqlite.cpp +++ b/src/c2s/cpp2sqlite.cpp @@ -740,10 +740,10 @@ void openDB(const std::string &filename) sqlDb.openDB(filename); - sqlDb.createTable(TABLE_NAME_AMIKO, "_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, auth TEXT, atc TEXT, substances TEXT, regnrs TEXT, atc_class TEXT, tindex_str TEXT, application_str TEXT, indications_str TEXT, customer_id INTEGER, pack_info_str TEXT, add_info_str TEXT, ids_str TEXT, titles_str TEXT, content TEXT, style_str TEXT, packages TEXT"); + sqlDb.createTable(TABLE_NAME_AMIKO, "_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, auth TEXT, atc TEXT, substances TEXT, regnrs TEXT, atc_class TEXT, tindex_str TEXT, application_str TEXT, indications_str TEXT, customer_id INTEGER, pack_info_str TEXT, add_info_str TEXT, ids_str TEXT, titles_str TEXT, content TEXT, style_str TEXT, packages TEXT, type TEXT"); sqlDb.createIndex(TABLE_NAME_AMIKO, "idx_", {"title", "auth", "atc", "substances", "regnrs", "atc_class"}); sqlDb.prepareStatement(TABLE_NAME_AMIKO, - "null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"); + "null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"); sqlDb.createTable(TABLE_NAME_PRODUCT, "_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, eancodes TEXT, pack_info_str TEXT, packages TEXT"); sqlDb.createIndex(TABLE_NAME_PRODUCT, "idx_prod_", {"title", "author", "eancodes"}); @@ -1176,6 +1176,7 @@ int main(int argc, char **argv) rowToInsert.atc = m.atc; rowToInsert.substances = m.subst; rowToInsert.regnrs = m.regnrs; + rowToInsert.type = m.type; // atc_class std::string atcClass = ATC::getClassByAtcColumn(m.atc); diff --git a/src/c2s/medicine.h b/src/c2s/medicine.h index 79e2d4c..54d3f49 100644 --- a/src/c2s/medicine.h +++ b/src/c2s/medicine.h @@ -26,6 +26,7 @@ struct Medicine { std::string style; std::string contentHTMLPath; // Path to the XHTML file std::string sections; + std::string type; // "FI" for type=SmPC, "PI" for type=PIL }; typedef std::vector MedicineList; diff --git a/src/sqlDatabase.cpp b/src/sqlDatabase.cpp index e0cfcb3..482463f 100644 --- a/src/sqlDatabase.cpp +++ b/src/sqlDatabase.cpp @@ -158,6 +158,7 @@ void Sql::insertRow(const std::string_view &tableName, DB::RowToInsert row) { // TODO: bindText(16, row.style_str); bindText(17, row.packages); + bindText(18, row.type); runStatement(tableName); } diff --git a/src/sqlDatabase.hpp b/src/sqlDatabase.hpp index 64158e7..9ff8fa5 100644 --- a/src/sqlDatabase.hpp +++ b/src/sqlDatabase.hpp @@ -35,6 +35,7 @@ struct RowToInsert { std::string content; std::string style_str; std::string packages; + std::string type; // "FI" for Fachinfo or "PI" for Patinfo }; struct Sql