summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Bisballe Jensen <larsbisballe@gmail.com>2011-10-14 10:42:27 +0200
committerLars Bisballe Jensen <larsbisballe@gmail.com>2011-10-14 10:42:27 +0200
commit2e574b6dfcb824239079a485527d420497b27b01 (patch)
treef49be56d98f0e952461b856d41eb54218b5f135b
parent2d5f72a787426b59658d1b66cfe0ea602ea66b61 (diff)
parentd602bdeb65d0e4007a8a02e5c6d4b9b271287aa9 (diff)
Merge branch 'master' of http://git.aasimon.org/public/pracro
-rw-r--r--client/client.pro16
-rw-r--r--client/luapraxisd.cc32
-rw-r--r--client/pcpviewer.cc50
-rw-r--r--client/pcpviewer.h45
-rw-r--r--client/pracro.cc20
-rw-r--r--client/praxisd.cc395
-rw-r--r--client/praxisd.h189
-rw-r--r--server/src/praxisd.cc120
-rw-r--r--server/src/praxisd.h22
-rw-r--r--server/src/saxparser.cc4
-rwxr-xr-x[-rw-r--r--]tools/add_file (renamed from tools/PracroAdd)0
11 files changed, 829 insertions, 64 deletions
diff --git a/client/client.pro b/client/client.pro
index 4ba5e79..dd926a9 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -31,18 +31,6 @@ win32 {
unix {
LIBS += -llua
- LIBS += -lcurl -lexpat
-
- HEADERS += \
- ../server/src/praxisd.h \
- ../server/src/saxparser.h \
- ../server/src/debug.h
-
- SOURCES += \
- ../server/src/praxisd.cc \
- ../server/src/saxparser.cc
-
- DEFINES += WITH_PRAXISD
}
HEADERS += \
@@ -61,6 +49,8 @@ HEADERS += \
macrodrawer.h \
messagebox.h \
netcom.h \
+ pcpviewer.h \
+ praxisd.h \
resumewidget.h \
template.h \
widgets.h \
@@ -102,6 +92,8 @@ SOURCES += \
macrodrawer.cc \
messagebox.cc \
netcom.cc \
+ pcpviewer.cc \
+ praxisd.cc \
resumewidget.cc \
template.cc \
expandbutton.cc \
diff --git a/client/luapraxisd.cc b/client/luapraxisd.cc
index 1d9da4c..0696674 100644
--- a/client/luapraxisd.cc
+++ b/client/luapraxisd.cc
@@ -27,9 +27,7 @@
*/
#include "luapraxisd.h"
-#ifdef WITH_PRAXISD
-
-#include "../server/src/praxisd.h"
+#include "praxisd.h"
#include <lauxlib.h>
#include <strings.h>
@@ -40,7 +38,7 @@
(lua_isboolean(L,i) ? lua_toboolean(L,i) : luaL_checkint(L,i))
typedef struct px_userdata {
- Praxisd *px;
+ PraxisdSync *px;
} px_userdata;
static int px_getcave(lua_State *L)
@@ -53,14 +51,14 @@ static int px_getcave(lua_State *L)
QVector<QString> cavelist;
- Praxisd::patient_t patient = pxu->px->patient_get_by_cpr(cpr);
- std::vector<Praxisd::sogeord_t>::iterator i = patient.sogeord.begin();
+ Patient patient = pxu->px->patient_get_by_cpr(cpr);
+ QVector<sogeord_t>::iterator i = patient.sogeord.begin();
while(i != patient.sogeord.end()) {
- std::string cavesogeord = i->sogenr.substr(1, i->sogenr.size() - 1);
- std::vector<Praxisd::cave_t> cave = pxu->px->diverse_get_cave(cavesogeord);
+ QString cavesogeord = i->sogenr;//.mid(1, i->sogenr.size() - 1);
+ QVector<cave_t> cave = pxu->px->diverse_get_cave(cavesogeord);
if(cave.size() == 1) {
- if(cave[0].cave != "ANDET") cavelist.push_back(cave[0].cave.c_str());
- else cavelist.push_back(i->sogetxt.c_str());
+ if(cave[0].cave != "ANDET") cavelist.push_back(cave[0].cave);
+ else cavelist.push_back(i->sogetxt);
}
i++;
}
@@ -82,13 +80,13 @@ static int px_cavelist(lua_State *L)
pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
luaL_argcheck(L, pxu, 1, "Praxisd expected");
- std::vector<Praxisd::cave_t> cavelist = pxu->px->diverse_get_cave("");
+ QVector<cave_t> cavelist = pxu->px->diverse_get_cave("");
lua_createtable(L, 0, cavelist.size());
int top = lua_gettop(L);
- for(size_t i = 0; i < cavelist.size(); i++) {
- lua_pushstring(L, QString::fromUtf8(cavelist[i].cave.c_str()).toStdString().c_str());
+ for(size_t i = 0; i < (size_t)cavelist.size(); i++) {
+ lua_pushstring(L, QString::fromUtf8(cavelist[i].cave.toStdString().c_str()).toStdString().c_str());
lua_rawseti(L, top, i);
}
@@ -106,7 +104,7 @@ static int px_new(lua_State *L)
luaL_getmetatable(L, "Praxisd");
lua_setmetatable(L, -2);
- pxu->px = new Praxisd(host, port);
+ pxu->px = new PraxisdSync(host, port);
return 1;
}
@@ -144,9 +142,3 @@ void register_praxisd(lua_State *L)
luaL_register(L, NULL, px_meths);
luaL_openlib (L, "Praxisd", px_funcs, 0);
}
-
-#else/*WITH_PRAXISD*/
-
-void register_praxisd(lua_State *L){}
-
-#endif/*WITH_PRAXISD*/
diff --git a/client/pcpviewer.cc b/client/pcpviewer.cc
new file mode 100644
index 0000000..f5347d6
--- /dev/null
+++ b/client/pcpviewer.cc
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * pcpviewer.cc
+ *
+ * Tue Oct 11 14:13:34 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "pcpviewer.h"
+
+#include <stdio.h>
+
+PCPViewer::PCPViewer(QString patientid) : praxisd("localhost", 10000)
+{
+ this->patientid = patientid;
+
+ // QString j = praxisd.journal_get_by_cpr(patientid);
+ // printf("%s\n", j.toStdString().c_str());
+
+ DokMenuVector d = praxisd.dokmenu_get_all_by_cpr(patientid);
+ DokMenuVector::iterator di = d.begin();
+ while(di != d.end()) {
+ printf("%s %s %s %d %s\n",
+ di->group.toStdString().c_str(),
+ di->subject.toStdString().c_str(),
+ di->filename.toStdString().c_str(),
+ di->filesize,
+ di->date.toStdString().c_str());
+ di++;
+ }
+}
diff --git a/client/pcpviewer.h b/client/pcpviewer.h
new file mode 100644
index 0000000..479b587
--- /dev/null
+++ b/client/pcpviewer.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * pcpviewer.h
+ *
+ * Tue Oct 11 14:13:34 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_PCPVIEWER_H__
+#define __PRACRO_PCPVIEWER_H__
+
+#include <QWidget>
+
+#include "praxisd.h"
+
+class PCPViewer : public QWidget {
+Q_OBJECT
+public:
+ PCPViewer(QString patientid);
+
+private:
+ PraxisdSync praxisd;
+ QString patientid;
+};
+
+#endif/*__PRACRO_PCPVIEWER_H__*/
diff --git a/client/pracro.cc b/client/pracro.cc
index 57a8da7..50ec007 100644
--- a/client/pracro.cc
+++ b/client/pracro.cc
@@ -38,6 +38,7 @@
#include "netcom.h"
#include "mainwindow.h"
#include "launcherwindow.h"
+#include "pcpviewer.h"
#include "debug.h"
@@ -67,6 +68,7 @@ static void print_usage()
printf(" -c, --config FILE The configfile to use. Default is \""CONFIG_DEFAULT"\"\n");
printf(" -u, -U, --user USER Defines the requesting user(not the patient),\n"
" defaults to \""USER_DEFAULT"\"\n");
+ printf(" -V, --viewer Show PCPraxis viewer.\n");
printf(" -v, --version Print version information and exit.\n");
printf(" -d, --debug Make debug console available.\n");
printf(" Show the viewer only (no pracro editor window) with TEMPLATES.\n");
@@ -95,6 +97,7 @@ int main(int argc, char *argv[])
QString templ;
QString course;
QString templs;
+ bool show_viewer = false;
QStringList args = app.arguments();
QStringList::iterator arg = args.begin();
@@ -111,6 +114,10 @@ int main(int argc, char *argv[])
print_version();
return 0;
}
+ else if(*arg == "--viewer" ||
+ *arg == "-V") {
+ show_viewer = true;
+ }
else if(*arg == "--user" ||
*arg == "-U" ||
*arg == "-u") {
@@ -175,10 +182,15 @@ int main(int argc, char *argv[])
}
*/
- MainWindow mainwindow(cpr, course, templ, host, port, user);
- mainwindow.show();
-
- return app.exec();
+ if(show_viewer) {
+ PCPViewer pcpviewer(cpr);
+ pcpviewer.show();
+ return app.exec();
+ } else {
+ MainWindow mainwindow(cpr, course, templ, host, port, user);
+ mainwindow.show();
+ return app.exec();
+ }
}
#endif/*TESTING*/
diff --git a/client/praxisd.cc b/client/praxisd.cc
new file mode 100644
index 0000000..740825e
--- /dev/null
+++ b/client/praxisd.cc
@@ -0,0 +1,395 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * praxisd.cc
+ *
+ * Tue Oct 11 15:20:18 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "praxisd.h"
+
+#include <stdio.h>
+
+#include <QDomDocument>
+
+#include <QNetworkReply>
+
+#define DOCAVE(x) if(element.tagName() == #x) cave.x = element.text()
+static CaveVector getCaveList(QByteArray data)
+{
+ QDomDocument doc;
+ doc.setContent(data);
+
+ CaveVector cavelist;
+
+ QDomNode praxisd = doc.documentElement();
+ QDomNodeList nodes = praxisd.childNodes();
+ for(int i = 0; i < nodes.count(); i++) {
+ QDomNode node = nodes.at(i);
+ QDomElement element = node.toElement();
+ if(element.tagName() == "div_cave") {
+
+ cave_t cave;
+ cave.sogenr = element.attribute("sogenr");
+
+ QDomNodeList nodes = element.childNodes();
+ for(int j = 0; j < nodes.count(); j++) {
+ QDomNode node = nodes.at(j);
+ QDomElement element = node.toElement();
+ DOCAVE(cave);
+ DOCAVE(bemaerkning1);
+ DOCAVE(bemaerkning2);
+ DOCAVE(bemaerkning3);
+ }
+
+ cavelist.push_back(cave);
+ }
+ }
+
+ return cavelist;
+}
+
+#define DOPATIENT(x) if(element.tagName() == #x) patient.x = element.text()
+static Patient getPatient(QByteArray data)
+{
+ QDomDocument doc;
+ doc.setContent(data);
+
+ Patient patient;
+
+ QDomNode praxisd = doc.documentElement();
+ QDomNode patnode = praxisd.firstChild();
+
+ QDomElement patelement = patnode.toElement();
+ patient.cpr = patelement.attribute("cpr");
+
+ QDomNodeList nodes = patnode.childNodes();
+ for(int i = 0; i < nodes.count(); i++) {
+ QDomNode node = nodes.at(i);
+ QDomElement element = node.toElement();
+
+ DOPATIENT(fornavne);
+ DOPATIENT(efternavn);
+ DOPATIENT(stilling);
+ DOPATIENT(gade);
+ DOPATIENT(by);
+ DOPATIENT(telefonnumre);
+ DOPATIENT(sikringsgr);
+ DOPATIENT(amtsnr);
+ DOPATIENT(sygekontor);
+ DOPATIENT(henvnr);
+ DOPATIENT(frilinie1);
+ DOPATIENT(frilinie2);
+ DOPATIENT(frilinie3);
+ DOPATIENT(frilinie4);
+ DOPATIENT(frilinie5);
+
+ if(element.tagName() == "sogeords") {
+ sogeord_t sogeord;
+
+ QDomNodeList nodes = element.childNodes();
+ for(int j = 0; j < nodes.count(); j++) {
+ QDomNode node = nodes.at(j);
+ QDomElement element = node.toElement();
+ sogeord.sogenr = element.attribute("sogenr");
+ sogeord.sogedato = element.attribute("sogedato");
+ sogeord.sogetxt = element.text();
+ }
+
+ patient.sogeord.push_back(sogeord);
+ }
+
+ DOPATIENT(ydernr);
+ DOPATIENT(created);
+ DOPATIENT(donottouch);
+ DOPATIENT(visus);
+ DOPATIENT(labkort);
+ DOPATIENT(medkort);
+ DOPATIENT(jlock);
+ DOPATIENT(unknown1);
+ DOPATIENT(henvdato);
+ DOPATIENT(aarhund);
+ DOPATIENT(fakturadato);
+ DOPATIENT(fakturabelob);
+ DOPATIENT(betaldato);
+ DOPATIENT(betalbelob);
+ DOPATIENT(jdato);
+ DOPATIENT(unknown250);
+ DOPATIENT(unknown251);
+ DOPATIENT(jtime);
+ }
+
+ return patient;
+}
+
+#define DODOKMENU(x) if(element.tagName() == #x) dokmenu.x = element.text()
+static DokMenuVector getDokMenu(QByteArray data)
+{
+ QDomDocument doc;
+ doc.setContent(data);
+
+ DokMenuVector dokmenus;
+
+ QDomNode praxisd = doc.documentElement();
+ QDomNodeList nodes = praxisd.childNodes();
+ for(int i = 0; i < nodes.count(); i++) {
+ QDomNode node = nodes.at(i);
+ QDomElement element = node.toElement();
+ if(element.tagName() == "dokmenu") {
+ dokmenu_t dokmenu;
+ dokmenu.cpr = element.attribute("cpr");
+
+ QDomNodeList nodes = element.childNodes();
+ for(int j = 0; j < nodes.count(); j++) {
+ QDomNode node = nodes.at(j);
+ QDomElement element = node.toElement();
+ DODOKMENU(group);
+ DODOKMENU(subject);
+ if(element.tagName() == "filename") {
+ dokmenu.filename = element.text();
+ dokmenu.filesize = element.attribute("filesize").toUInt();
+ dokmenu.date = element.attribute("date");
+ }
+ }
+
+ dokmenus.push_back(dokmenu);
+ }
+ }
+
+ return dokmenus;
+}
+
+Praxisd::Praxisd(QString host, unsigned short int port)
+{
+ qRegisterMetaType<CaveVector>("CaveVector");
+ qRegisterMetaType<Patient>("Patient");
+ qRegisterMetaType<DokMenuVector>("DokMenuVector");
+
+ QUrl url;
+ url.setHost(host);
+ url.setPort(port);
+ url.setScheme("http");
+
+ request.setUrl(url);
+
+ manager = new QNetworkAccessManager(this);
+ connect(manager, SIGNAL(finished(QNetworkReply*)),
+ this, SLOT(replyFinished(QNetworkReply*)));
+}
+
+void Praxisd::replyFinished(QNetworkReply *reply)
+{
+ if(reply->error() == QNetworkReply::NoError) {
+
+ reply_t type = replytypes[reply];
+ switch(type) {
+ case journal:
+ emit gotJournal(reply->readAll());
+ break;
+
+ case cavelist:
+ emit gotCaveList(getCaveList(reply->readAll()));
+ break;
+
+ case patient:
+ emit gotPatient(getPatient(reply->readAll()));
+ break;
+
+ case dokmenu:
+ emit gotDokMenu(getDokMenu(reply->readAll()));
+ break;
+
+ case dokmenufile:
+ emit gotDokMenuFile(reply->readAll());
+ break;
+ }
+ } else {
+ emit networkError(reply->errorString());
+ }
+ replytypes.erase(replytypes.find(reply));
+}
+
+void Praxisd::makeTransfer(reply_t t, QString uri,
+ QMap<QString, QString> params)
+{
+ request.setRawHeader("User-Agent", "Pracro Client v"VERSION);
+
+ QUrl url;
+ url.setHost(request.url().host());
+ url.setPort(request.url().port());
+ url.setScheme(request.url().scheme());
+
+ url.setPath(uri);
+
+ QMap<QString, QString>::iterator i = params.begin();
+ while(i != params.end()) {
+ url.addQueryItem(i.key(), i.value());
+ i++;
+ }
+
+ request.setUrl(url);
+
+ QNetworkReply* r = manager->get(request);
+ replytypes[r] = t;
+}
+
+void Praxisd::journal_get_by_cpr(QString cpr)
+{
+ QMap<QString, QString> params;
+ params["cpr"] = cpr;
+ makeTransfer(journal, "/praxisd/1.0/journal/get_by_cpr", params);
+}
+
+void Praxisd::diverse_get_cave(QString sogenr)
+{
+ QMap<QString, QString> params;
+ params["sogenr"] = sogenr;
+ makeTransfer(cavelist, "/praxisd/1.0/diverse/get_all_by_sogenr", params);
+}
+
+void Praxisd::patient_get_by_cpr(QString cpr)
+{
+ QMap<QString, QString> params;
+ params["cpr"] = cpr;
+ makeTransfer(patient, "/praxisd/1.0/patient/get_by_cpr", params);
+}
+
+void Praxisd::dokmenu_get_all_by_cpr(QString cpr)
+{
+ QMap<QString, QString> params;
+ params["cpr"] = cpr;
+ makeTransfer(dokmenu, "/praxisd/1.0/dokmenu/get_all_by_cpr", params);
+}
+
+void Praxisd::dokmenu_get_by_cpr_and_name(QString cpr, QString name)
+{
+ cpr = cpr;
+ name = name;
+ // uri = host + "/praxisd/1.0/dokmenu/get_by_cpr_and_name?cpr=" + cpr + "&name=" + name;
+ QMap<QString, QString> params;
+ params["cpr"] = cpr;
+ params["name"] = name;
+ makeTransfer(dokmenufile, "/praxisd/1.0/dokmenu/get_by_cpr_and_name", params);
+}
+
+PraxisdSync::PraxisdSync(QString host, unsigned short int port)
+{
+ this->host = host;
+ this->port = port;
+
+ start();
+}
+
+void PraxisdSync::run()
+{
+ Praxisd praxisd(host, port);
+
+ connect(&praxisd, SIGNAL(gotCaveList(CaveVector)),
+ this, SLOT(gotCaveList(CaveVector)), Qt::DirectConnection);
+
+ connect(&praxisd, SIGNAL(gotPatient(Patient)),
+ this, SLOT(gotPatient(Patient)), Qt::DirectConnection);
+
+ connect(&praxisd, SIGNAL(gotDokMenu(DokMenuVector)),
+ this, SLOT(gotDokMenu(DokMenuVector)), Qt::DirectConnection);
+
+ while(true) {
+ wsem.acquire();
+
+ switch(request_type) {
+ case Praxisd::journal:
+ break;
+ case Praxisd::cavelist:
+ praxisd.diverse_get_cave(request_sogenr);
+ break;
+ case Praxisd::patient:
+ praxisd.patient_get_by_cpr(request_cpr);
+ break;
+ case Praxisd::dokmenu:
+ praxisd.dokmenu_get_all_by_cpr(request_cpr);
+ break;
+ case Praxisd::dokmenufile:
+ break;
+ }
+
+ exec();
+ }
+}
+
+void PraxisdSync::gotCaveList(CaveVector cl)
+{
+ cavelist = cl;
+ rsem.release();
+ quit();
+}
+
+void PraxisdSync::gotPatient(Patient p)
+{
+ patient = p;
+ rsem.release();
+ quit();
+}
+
+void PraxisdSync::gotDokMenu(DokMenuVector d)
+{
+ dokmenu = d;
+ rsem.release();
+ quit();
+}
+
+QString PraxisdSync::journal_get_by_cpr(QString cpr)
+{
+ return cpr;
+}
+
+CaveVector PraxisdSync::diverse_get_cave(QString sogenr)
+{
+ request_type = Praxisd::cavelist;
+ request_sogenr = sogenr;
+
+ wsem.release();
+ rsem.acquire();
+
+ return cavelist;
+}
+
+Patient PraxisdSync::patient_get_by_cpr(QString cpr)
+{
+ cpr = "";
+ return Patient();
+}
+
+DokMenuVector PraxisdSync::dokmenu_get_all_by_cpr(QString cpr)
+{
+ request_type = Praxisd::dokmenu;
+ request_cpr = cpr;
+
+ wsem.release();
+ rsem.acquire();
+
+ return dokmenu;
+}
+
+QString PraxisdSync::dokmenu_get_by_cpr_and_name(QString cpr, QString name)
+{
+ return cpr + name;
+}
diff --git a/client/praxisd.h b/client/praxisd.h
new file mode 100644
index 0000000..1268be7
--- /dev/null
+++ b/client/praxisd.h
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * praxisd.h
+ *
+ * Tue Oct 11 15:20:18 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_PRAXISD_H__
+#define __PRACRO_PRAXISD_H__
+
+#include <QObject>
+#include <QString>
+#include <QVector>
+
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+
+#include <QByteArray>
+#include <QThread>
+#include <QSemaphore>
+
+typedef struct {
+ QString sogenr;
+ QString cave;
+ QString bemaerkning1;
+ QString bemaerkning2;
+ QString bemaerkning3;
+} cave_t;
+
+typedef struct {
+ QString sogenr;
+ QString sogedato;
+ QString sogetxt;
+} sogeord_t;
+
+typedef struct {
+ QString cpr;
+ QString fornavne;
+ QString efternavn;
+ QString stilling;
+ QString gade;
+ QString by;
+ QString telefonnumre;
+ QString sikringsgr;
+ QString amtsnr;
+ QString sygekontor;
+ QString henvnr;
+ QString frilinie1;
+ QString frilinie2;
+ QString frilinie3;
+ QString frilinie4;
+ QString frilinie5;
+ QVector<sogeord_t> sogeord;
+ QString ydernr;
+ QString created;
+ QString donottouch;
+ QString visus;
+ QString labkort;
+ QString medkort;
+ QString jlock;
+ QString unknown1;
+ QString henvdato;
+ QString aarhund;
+ QString fakturadato;
+ QString fakturabelob;
+ QString betaldato;
+ QString betalbelob;
+ QString jdato;
+ QString unknown250;
+ QString unknown251;
+ QString jtime;
+} patient_t;
+
+typedef struct {
+ QString cpr;
+ QString group;
+ QString subject;
+ QString filename;
+ size_t filesize;
+ QString date;
+} dokmenu_t;
+
+typedef QVector<cave_t> CaveVector;
+typedef patient_t Patient;
+typedef QVector<dokmenu_t> DokMenuVector;
+
+class Praxisd : public QObject {
+Q_OBJECT
+public:
+ typedef enum {
+ journal,
+ cavelist,
+ patient,
+ dokmenu,
+ dokmenufile
+ } reply_t;
+
+ Praxisd(QString host, quint16 port);
+
+ void journal_get_by_cpr(QString patientid);
+
+ void diverse_get_cave(QString sogenr);
+
+ void patient_get_by_cpr(QString cpr);
+
+ void dokmenu_get_all_by_cpr(QString cpr);
+
+ void dokmenu_get_by_cpr_and_name(QString cpr, QString name);
+
+signals:
+ void gotReply(QByteArray data);
+ void networkError(QString text);
+
+ void gotJournal(QString data);
+ void gotCaveList(CaveVector cave);
+ void gotPatient(Patient patient);
+ void gotDokMenu(DokMenuVector dokmenu);
+ void gotDokMenuFile(QString data);
+
+public slots:
+ void replyFinished(QNetworkReply*);
+
+private:
+ void makeTransfer(reply_t t, QString uri, QMap<QString, QString> params);
+
+ QNetworkAccessManager *manager;
+ QNetworkRequest request;
+
+ QString host;
+ unsigned short int port;
+
+ QMap<QNetworkReply*, reply_t> replytypes;
+};
+
+class PraxisdSync : public QThread {
+Q_OBJECT
+public:
+ PraxisdSync(QString host, unsigned short int port);
+
+ QString journal_get_by_cpr(QString patientid);
+ CaveVector diverse_get_cave(QString sogenr);
+ Patient patient_get_by_cpr(QString cpr);
+ DokMenuVector dokmenu_get_all_by_cpr(QString cpr);
+ QString dokmenu_get_by_cpr_and_name(QString cpr, QString name);
+
+ void run();
+
+public slots:
+ void gotCaveList(CaveVector);
+ void gotPatient(Patient);
+ void gotDokMenu(DokMenuVector);
+
+private:
+ QString host;
+ quint16 port;
+
+ QSemaphore rsem;
+ QSemaphore wsem;
+
+ Praxisd::reply_t request_type;
+ QString request_sogenr;
+ QString request_cpr;
+
+ CaveVector cavelist;
+ Patient patient;
+ DokMenuVector dokmenu;
+};
+
+#endif/*__PRACRO_PRAXISD_H__*/
diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc
index d814b54..a75ad9f 100644
--- a/server/src/praxisd.cc
+++ b/server/src/praxisd.cc
@@ -27,6 +27,8 @@
*/
#include "praxisd.h"
+#include "saxparser.h"
+
static std::string strtime(bool with_sec = true)
{
std::string ret;
@@ -190,7 +192,6 @@ void Praxisd::add_sogeord(std::string cpr, std::string sogeord,
}
#define DOTAG(x) if(name == #x) str = &p.x;
-#include "saxparser.h"
class PatientParser : public SAXParser {
public:
@@ -201,7 +202,7 @@ public:
if(str) *str += data;
}
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
DOTAG(fornavne);
DOTAG(efternavn);
@@ -236,11 +237,12 @@ public:
DOTAG(unknown250);
DOTAG(unknown251);
DOTAG(jtime);
+
if(name == "sogeords") {} // do nothing
if(name == "sogeord") {
Praxisd::sogeord_t s;
if(attr.find("sogenr") != attr.end()) s.sogenr = attr["sogenr"];
- if(attr.find("sogedatpo") != attr.end()) s.sogedato = attr["sogedato"];
+ if(attr.find("sogedato") != attr.end()) s.sogedato = attr["sogedato"];
p.sogeord.push_back(s);
str = &p.sogeord[p.sogeord.size() - 1].sogetxt;
}
@@ -273,6 +275,8 @@ Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr)
printf("Ouch %d\n", errornum);
}
+ // printf("Get Patient: %d %s\n", xml.length(), xml.c_str()); fflush(stdout);
+
PatientParser parser(p);
parser.parse(xml.data(), xml.length());
@@ -305,7 +309,7 @@ public:
AdresseParser(std::vector<Praxisd::adresse_t> &al) : div(al) { str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_adresse") {
Praxisd::adresse_t a;
@@ -341,7 +345,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_behandling") {
Praxisd::behandling_t a;
@@ -375,7 +379,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_cave") {
Praxisd::cave_t d;
@@ -408,7 +412,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_diagnose") {
Praxisd::diagnose_t d;
@@ -441,7 +445,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_frase") {
Praxisd::frase_t d;
@@ -474,7 +478,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_grafik") {
Praxisd::grafik_t d;
@@ -505,7 +509,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_indholdstof") {
Praxisd::indholdstof_t d;
@@ -540,7 +544,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_klage") {
Praxisd::klage_t d;
@@ -573,7 +577,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_oversigt") {
Praxisd::oversigt_t d;
@@ -605,7 +609,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_postnummer") {
Praxisd::postnummer_t d;
@@ -642,7 +646,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_type") {
Praxisd::type_t d;
@@ -676,7 +680,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_undersoegelse") {
Praxisd::undersoegelse_t d;
@@ -709,7 +713,7 @@ public:
{ str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "div_ydelse") {
Praxisd::ydelse_t d;
@@ -746,7 +750,7 @@ public:
AftaleParser(std::vector<Praxisd::aftale_t> &a) : div(a) { str = NULL; }
void characterData(std::string &data) { if(str) *str += data; }
void endTag(std::string) { str = NULL; }
- void startTag(std::string name, std::map<std::string, std::string> attr)
+ void startTag(std::string name, attributes_t &attr)
{
if(name == "aftale") {
Praxisd::aftale_t a;
@@ -842,6 +846,77 @@ bool Praxisd::authenticate(std::string user, std::string pass)
return false; // Don't interpret an error as successful login.
}
+class DokMenuParser : public SAXParser {
+public:
+ DokMenuParser(std::vector<Praxisd::dokmenu_t> &a) : div(a) { str = NULL; }
+ void characterData(std::string &data) { if(str) *str += data; }
+ void endTag(std::string) { str = NULL; }
+ void startTag(std::string name, attributes_t &attr)
+ {
+ if(name == "dokmenu") {
+ Praxisd::dokmenu_t a;
+ if(attr.find("date") != attr.end()) a.date = attr["date"];
+ if(attr.find("calendar") != attr.end()) a.date = attr["calendar"];
+ div.push_back(a);
+ }
+
+ DODIVTAG(group);
+ DODIVTAG(subject);
+
+ DODIVTAG(filename);
+ if(name == "filename") {
+ div[div.size() - 1].filesize = atoi(attr["filesize"].c_str());
+ div[div.size() - 1].date = attr["date"];
+ }
+ }
+
+private:
+ std::string *str;
+ std::vector<Praxisd::dokmenu_t> &div;
+};
+
+std::vector<Praxisd::dokmenu_t> Praxisd::dokmenu_get_all_by_cpr(std::string cpr)
+{
+ std::vector<Praxisd::dokmenu_t> dokmenu;
+ std::string xml;
+
+ std::string uri = host + "/praxisd/1.0/dokmenu/get_all_by_cpr?cpr=" + cpr;
+ curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
+
+ curl_easy_setopt(ch, CURLOPT_POST, 0L);
+ curl_easy_setopt(ch, CURLOPT_WRITEDATA, &xml);
+
+ CURLcode errornum = curl_easy_perform(ch);
+ if(errornum != CURLE_OK) {
+ printf("Ouch %d\n", errornum);
+ }
+
+ DokMenuParser parser(dokmenu);
+ parser.parse(xml.data(), xml.length());
+
+ return dokmenu;
+}
+
+// Get Dokmenu by Name and CPR
+std::string Praxisd::dokmenu_get_by_cpr_and_name(std::string cpr,
+ std::string name)
+{
+ std::string data;
+
+ std::string uri = host + "/praxisd/1.0/dokmenu/get_by_cpr_and_name?cpr=" +
+ cpr + "&name=" + name;
+ curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
+
+ curl_easy_setopt(ch, CURLOPT_POST, 0L);
+ curl_easy_setopt(ch, CURLOPT_WRITEDATA, &data);
+
+ CURLcode errornum = curl_easy_perform(ch);
+ if(errornum != CURLE_OK) {
+ printf("Ouch %d\n", errornum);
+ }
+
+ return data;
+}
#ifdef TEST_PRAXISD
//deps: saxparser.cc debug.cc log.cc
@@ -875,7 +950,8 @@ TEST_EQUAL_INT(exp.length(), j2.length(), "Compare lengths");
TEST_EQUAL_STR(exp, j2, "Did we correctly append to the journal?");
*/
-p.add_sogeord(CPR, "CA0003", "Nolder");
+
+//p.add_sogeord(CPR, "CA0003", "Nolder");
{
std::vector<Praxisd::cave_t> cave = p.diverse_get_cave("A0001");
@@ -888,6 +964,14 @@ p.add_sogeord(CPR, "CA0003", "Nolder");
TEST_EQUAL_INT(cave.size(), 25, "Get them all.");
}
+{
+ std::vector<Praxisd::dokmenu_t> dm = p.dokmenu_get_all_by_cpr(CPR);
+ TEST_NOTEQUAL_INT(dm.size(), 0, "Empty result?");
+
+ std::string file = p.dokmenu_get_by_cpr_and_name(CPR, dm[0].filename);
+ TEST_EQUAL_INT(file.size(), dm[0].filesize, "Size matters?");
+}
+
TEST_END;
#endif/*TEST_PRAXISD*/
diff --git a/server/src/praxisd.h b/server/src/praxisd.h
index 03029bb..84848b8 100644
--- a/server/src/praxisd.h
+++ b/server/src/praxisd.h
@@ -238,14 +238,20 @@ public:
#if 0
// Get Name by UserID
std::string user_get_name_by_id(std::string user);
+#endif
- // Get All Docmenu by CPR
- typedef struct {} docmenu_t;
- std::vector<docmenu_t> docmenu_get_all_by_cpr(std::string cpr);
+ // Get All Dokmenu by CPR
+ typedef struct {
+ std::string group;
+ std::string subject;
+ std::string filename;
+ size_t filesize;
+ std::string date;
+ } dokmenu_t;
+ std::vector<dokmenu_t> dokmenu_get_all_by_cpr(std::string cpr);
- // Get Docmenu by Name and CPR
- std::string docmenu_get_by_cpr_and_name(std::string cpr, std::string name);
-#endif
+ // Get Dokmenu by Name and CPR
+ std::string dokmenu_get_by_cpr_and_name(std::string cpr, std::string name);
// POST:
// Add To Journal
@@ -259,8 +265,8 @@ public:
// Update Aftale
// Add Aftale
// Delete Aftale
- // Add File to Docmenu
- // Delete File from Docmenu
+ // Add File to Dokmenu
+ // Delete File from Dokmenu
private:
std::string get_sogenr(std::string sogenr);
diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc
index 597b853..95efffe 100644
--- a/server/src/saxparser.cc
+++ b/server/src/saxparser.cc
@@ -259,7 +259,7 @@ public:
return read(fd, data, size);
}
- void startTag(std::string name, std::map< std::string, std::string> attributes)
+ void startTag(std::string name, attributes_t &attributes)
{
//printf("<%s>\n", name.c_str());
}
@@ -275,7 +275,7 @@ private:
class MyBufferParser :public SAXParser {
public:
- void startTag(std::string name, std::map< std::string, std::string> attributes)
+ void startTag(std::string name, attributes_t &attributes)
{
//printf("<%s>\n", name.c_str());
}
diff --git a/tools/PracroAdd b/tools/add_file
index ff3bc9a..ff3bc9a 100644..100755
--- a/tools/PracroAdd
+++ b/tools/add_file