summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-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
7 files changed, 711 insertions, 36 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__*/