@@ -27,7 +27,7 @@ void class_bdd::createEmpty(const wxString& path) | |||
rc += sqlite3_open_v2(_C(path), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Consult(id INTEGER PRIMARY KEY ASC, n_dossier INTEGER, nom VARCHAR(50), prenom VARCHAR(50), responsable VARCHAR(100), consultant VARCHAR(50), theme TEXT, etablissement VARCHAR(100), travail VARCHAR(50), date_cs DATE, publi_prevue BOOLEAN, service VARCHAR(100));", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Result(id INTEGER PRIMARY KEY ASC, publi BOOLEAN DEFAULT 0, publi_CHU BOOLEAN DEFAULT 0, cs_associe BOOLEAN DEFAULT 0, nb_result INTEGER DEFAULT 0, id_result TEXT DEFAULT \"\");", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Publi(id INTEGER PRIMARY KEY, titre TEXT, auteurs TEXT, lien VARCHAR(50), date_publi DATE);", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Publi(id INTEGER PRIMARY KEY, titre TEXT, auteurs TEXT, abstract TEXT, revue TEXT, lien VARCHAR(50), date_publi DATE);", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Correc(orig TEXT PRIMARY KEY, dest TEXT);", NULL, NULL, NULL); | |||
if (rc) | |||
{ | |||
@@ -71,7 +71,7 @@ void class_bdd::importer(const wxString& filename) | |||
if (c != '"') | |||
item[i] << c; | |||
}while (((c != ';') && (!inquote)) || inquote); //boucle pour un item, se finit par un ';' sauf entre guillemets | |||
item[i] = item[i].BeforeLast(wxUniChar(';')); | |||
item[i] = item[i].BeforeLast(';'); | |||
} | |||
item[22]=""; | |||
do | |||
@@ -307,4 +307,29 @@ void class_bdd::modcorrection(const wxString& orig, const wxString& dest) | |||
void class_bdd::delcorrection(const wxString& orig) | |||
{ | |||
sqlite3_exec(db, "DELETE FROM Correc WHERE orig=\"" + orig + "\";", NULL, NULL, NULL); | |||
} | |||
} | |||
int class_bdd::nbresult(const wxString& id) | |||
{ | |||
sqlite3_prepare_v2(db, "SELECT nb_result FROM Result WHERE id=" + id + ";" , -1, &stmt, NULL); | |||
sqlite3_step(stmt); | |||
int out = sqlite3_column_int(stmt, 0); | |||
sqlite3_finalize(stmt); | |||
return out; | |||
} | |||
void class_bdd::modnbresult(const wxString& id, int nbresults) | |||
{ | |||
sqlite3_exec(db, "UPDATE Result SET nb_result=" + _itoW(nbresults) + " WHERE id=" + id + ";", NULL, NULL, NULL); | |||
} | |||
wxString class_bdd::getidresult(const wxString& id) | |||
{ | |||
sqlite3_prepare_v2(db, "SELECT id_result FROM Result WHERE id=" + id + ";", -1, &stmt, NULL); | |||
sqlite3_step(stmt); | |||
wxString out = _W(sqlite3_column_text(stmt, 0)); | |||
sqlite3_finalize(stmt); | |||
return out; | |||
} |
@@ -34,6 +34,12 @@ class class_bdd | |||
void addcorrection(const wxString& id, int col, const wxString& dest); | |||
void modcorrection(const wxString& orig, const wxString& dest); | |||
void delcorrection(const wxString& orig); | |||
int nbresult(const wxString& id); | |||
void modnbresult(const wxString& id, int nbresults); | |||
wxString getidresult(const wxString& id); | |||
}; | |||
#endif //__bdd__ |
@@ -12,6 +12,10 @@ dialog_optionsRche( parent ) | |||
if (configuration->getrule(i).inuse) | |||
checklist_ruleset->Check(i); | |||
} | |||
checklist_ruleset->SetSelection(0); | |||
wxCommandEvent ev; | |||
ev.SetInt(0); | |||
OnChecklistSelect(ev); | |||
} | |||
void optionsRche::OnChecklistSelect( wxCommandEvent& event ) | |||
@@ -87,6 +91,7 @@ void optionsRche::OnAdd( wxCommandEvent& event ) | |||
toadd.retmax = spinctrl_retmax->GetValue(); | |||
checklist_ruleset->Append(toadd.name); | |||
checklist_ruleset->SetSelection(checklist_ruleset->GetCount() - 1); | |||
configuration->addrule(toadd); | |||
} | |||
@@ -151,8 +156,11 @@ void optionsRche::OnUpdate( wxCommandEvent& event ) | |||
tomod.suppl = textctrl_suppl->GetValue(); | |||
tomod.retmax = spinctrl_retmax->GetValue(); | |||
checklist_ruleset->SetString(checklist_ruleset->GetSelection(), tomod.name); | |||
configuration->modrule(checklist_ruleset->GetSelection(), tomod); | |||
if (checklist_ruleset->GetSelection() != wxNOT_FOUND) | |||
{ | |||
checklist_ruleset->SetString(checklist_ruleset->GetSelection(), tomod.name); | |||
configuration->modrule(checklist_ruleset->GetSelection(), tomod); | |||
} | |||
} | |||
void optionsRche::OnOk( wxCommandEvent& event ) | |||
@@ -12,20 +12,114 @@ class_recherche::class_recherche(config* configuration, class_bdd* bdd, wxGrid* | |||
class_recherche::~class_recherche() | |||
{ | |||
if (curldata.content) | |||
free (curldata.content); | |||
curl_easy_cleanup (curlhandle); | |||
curl_global_cleanup (); | |||
} | |||
void class_recherche::start() | |||
{ | |||
//wxArrayInt selection = grid_Consults->GetSelectedRows(); | |||
//for (int i=0; i < (int)selection.GetCount(); i++) | |||
bool firstpass = true; | |||
wxArrayInt selection = grid->GetSelectedRows(); | |||
if (selection.GetCount() == 0) | |||
for (int s=0; s < grid->GetNumberRows(); s++) | |||
selection.Add(s); | |||
for (int j=0; j < configuration->getnbrule(); j++) | |||
{ | |||
if (configuration->getrule(j).inuse) | |||
{ | |||
wxProgressDialog progress_dialog("Recherche", _T("Recherche avec la règle «") + configuration->getrule(j).name + "»", selection.GetCount(), NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME | wxPD_CAN_ABORT); | |||
for (int i=0; i < (int)selection.GetCount(); i++) | |||
{ | |||
if (firstpass || (grid->GetCellValue(selection[i], 0) == "0")) | |||
{ | |||
go (selection[i], configuration->getrule(j)); | |||
} | |||
if (!progress_dialog.Update(i)) | |||
break; | |||
} | |||
} | |||
firstpass = false; | |||
} | |||
} | |||
void class_recherche::go(int row, rule regle) | |||
{ | |||
wxString requete = build(row, regle); | |||
esearch(requete); | |||
parsesearch(); | |||
wxString temp = bdd->getidresult(grid->GetCellValue(row, 13)); | |||
wxArrayString idresultbdd, tofetch; | |||
while (temp.Length() > 0) | |||
{ | |||
idresultbdd.Add(temp.BeforeFirst(',').AfterLast('!')); | |||
temp = temp.AfterFirst(','); | |||
} | |||
for (int i=0; i < (int)idresult.GetCount(); i++) | |||
if (idresultbdd.Index(idresult[i]) != wxNOT_FOUND) | |||
tofetch.Add(idresult[i]); | |||
idresult = tofetch; | |||
efetch(); | |||
} | |||
void class_recherche::efetch() | |||
{ | |||
} | |||
void class_recherche::parsesearch() | |||
{ | |||
idresult.Clear(); | |||
XMLDocument* doc = new XMLDocument(); | |||
doc->Parse(curldata.content); | |||
XMLElement* parcours = doc->RootElement(); | |||
parcours = parcours->FirstChildElement("Count"); | |||
nbresult = atoi(parcours->GetText()); | |||
parcours = parcours->NextSiblingElement("RetMax"); | |||
int count = atoi(parcours->GetText()); | |||
parcours = parcours->NextSiblingElement("IdList"); | |||
if (count>0) | |||
{ | |||
parcours = parcours->FirstChildElement(); | |||
for (int i=0; i < count - 1 ; i++) | |||
{ | |||
idresult.Add(parcours->GetText()); | |||
parcours = parcours->NextSiblingElement(); | |||
} | |||
idresult.Add(parcours->GetText()); | |||
parcours = parcours->Parent()->ToElement(); | |||
} | |||
delete(doc); | |||
} | |||
void class_recherche::esearch(wxString requete) | |||
{ | |||
curl_easy_setopt (curlhandle, CURLOPT_URL, _C(requete)); | |||
if (configuration->IsUseproxy()) | |||
{ | |||
curl_easy_setopt (curlhandle, CURLOPT_PROXY, _C(configuration->GetProxyurl())); | |||
curl_easy_setopt (curlhandle, CURLOPT_PROXYPORT, configuration->GetProxyport()); | |||
} | |||
else | |||
curl_easy_setopt (curlhandle, CURLOPT_PROXY, ""); | |||
curldata.content = (char*) malloc(1); | |||
curldata.size = 0; | |||
if (curlhandle) | |||
curl_easy_perform(curlhandle); | |||
} | |||
wxString class_recherche::build(int row, rule regle) | |||
{ | |||
wxString requete="?db=pubmed&term="; | |||
wxString requete="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term="; | |||
bool both = false; | |||
if (grid->GetCellValue(row, 5) == "") | |||
regle.usedemandeur = false; | |||
@@ -130,7 +224,7 @@ wxString class_recherche::parseresponsable(wxString responsable, int op) | |||
{ | |||
wxString out; | |||
if (responsable.Find('/') == wxNOT_FOUND) | |||
out = responsable; | |||
out = responsable + "[Author]"; | |||
else | |||
{ | |||
out = "(" + responsable.BeforeFirst('/') + "[Author]"; | |||
@@ -8,6 +8,8 @@ | |||
#include "config.h" | |||
#include "tinyxml2.h" | |||
using namespace tinyxml2; | |||
typedef struct _CurlData { | |||
char *content; | |||
size_t size; | |||
@@ -20,9 +22,16 @@ private: | |||
class_bdd* bdd; | |||
wxGrid* grid; | |||
int nbresult; | |||
wxArrayString idresult; | |||
CURL* curlhandle; | |||
CurlData curldata; | |||
void go(int row, rule regle); | |||
void esearch(wxString requete); | |||
void parsesearch(); | |||
void efetch(); | |||
wxString build(int row, rule regle); | |||
wxString parsedemandeur(wxString nom, wxString prenom, int op); | |||
wxString parseresponsable(wxString responsable, int op); | |||
@@ -0,0 +1,64 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<Session Name="C:\Projets\Sante_Pub.workspace"> | |||
<int Value="8" Name="m_selectedTab"/> | |||
<wxString Value="C:\Projets\Sante_Pub.workspace" Name="m_workspaceName"/> | |||
<TabInfoArray Name="TabInfoArray"> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\misc.h" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\cosmos.h" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\cosmos.cpp" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\config.h" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\config.cpp" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\bdd.h" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\bdd.cpp" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\recherche.h" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="0" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
<TabInfo> | |||
<wxString Value="C:\Projets\CosMoS\recherche.cpp" Name="FileName"/> | |||
<int Value="0" Name="FirstVisibleLine"/> | |||
<int Value="18" Name="CurrentLine"/> | |||
<wxArrayString Name="Bookmarks"/> | |||
</TabInfo> | |||
</TabInfoArray> | |||
<SerializedObject Name="m_breakpoints"> | |||
<long Value="0" Name="Count"/> | |||
</SerializedObject> | |||
</Session> |