From 29b92e2906823878a7c516dc454d9ae8654de8fb Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 12 Oct 2011 08:08:15 +0200 Subject: Initial work on pcp viewer including a new Praxisd class based on Qt-only components. --- client/client.pro | 2 + client/pcpviewer.cc | 50 +++++++++++++++++++++++++ client/pcpviewer.h | 45 +++++++++++++++++++++++ client/pracro.cc | 20 ++++++++-- client/praxisd.cc | 46 +++++++++++++++++++++++ client/praxisd.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 263 insertions(+), 4 deletions(-) create mode 100644 client/pcpviewer.cc create mode 100644 client/pcpviewer.h create mode 100644 client/praxisd.cc create mode 100644 client/praxisd.h (limited to 'client') diff --git a/client/client.pro b/client/client.pro index 44fc02c..445f29f 100644 --- a/client/client.pro +++ b/client/client.pro @@ -61,6 +61,7 @@ HEADERS += \ macrodrawer.h \ messagebox.h \ netcom.h \ + pcpviewer.h \ resumewidget.h \ template.h \ widgets.h \ @@ -100,6 +101,7 @@ SOURCES += \ macrodrawer.cc \ messagebox.cc \ netcom.cc \ + pcpviewer.cc \ resumewidget.cc \ template.cc \ widgets/common.cc \ diff --git a/client/pcpviewer.cc b/client/pcpviewer.cc new file mode 100644 index 0000000..c665cf2 --- /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" + +PCPViewer::PCPViewer(QString patientid) : praxisd("gargamel", 10000) +{ + this->patientid = patientid; + + std::string j = praxisd.journal_get_by_cpr(patientid.toStdString()); + printf("%s\n", j.c_str()); + + std::vector d = + praxisd.dokmenu_get_all_by_cpr(patientid.toStdString()); + std::vector::iterator di = d.begin(); + while(di != d.end()) { + printf("%s %s %s %d %s\n", + di->group.c_str(), + di->subject.c_str(), + di->filename.c_str(), + di->filesize, + di->date.c_str()); + di++; + } + +} diff --git a/client/pcpviewer.h b/client/pcpviewer.h new file mode 100644 index 0000000..dd86fea --- /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 + +#include "../server/src/praxisd.h" + +class PCPViewer : public QWidget { +Q_OBJECT +public: + PCPViewer(QString patientid); + +private: + Praxisd 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..2367eb1 --- /dev/null +++ b/client/praxisd.cc @@ -0,0 +1,46 @@ +/* -*- 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" + +#ifdef TEST_PRAXISD +//Additional dependency files +//deps: +//Required cflags (autoconf vars may be used) +//cflags: +//Required link options (autoconf vars may be used) +//libs: +#include "test.h" + +TEST_BEGIN; + +// TODO: Put some testcode here (see test.h for usable macros). +TEST_TRUE(false, "No tests yet!"); + +TEST_END; + +#endif/*TEST_PRAXISD*/ diff --git a/client/praxisd.h b/client/praxisd.h new file mode 100644 index 0000000..dfaac59 --- /dev/null +++ b/client/praxisd.h @@ -0,0 +1,104 @@ +/* -*- 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__ + +class Praxisd { +Q_OBJECT +public; + Praxisd(); + + QString journal_get_by_cpr(QString patientid); + + typedef struct { + QString sogenr; + QString cave; + QString bemaerkning1; + QString bemaerkning2; + QString bemaerkning3; + } cave_t; + QVector diverse_get_cave(QString sogenr); + + 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; + 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; + patient_t patient_get_by_cpr(QString cpr); + + typedef struct { + QString group; + QString subject; + QString filename; + size_t filesize; + QString date; + } dokmenu_t; + QVector dokmenu_get_all_by_cpr(QString cpr); + + QString dokmenu_get_by_cpr_and_name(QString cpr, QString name); +}; + +#endif/*__PRACRO_PRAXISD_H__*/ -- cgit v1.2.3 From ffc19fdcd0845dbd85c2bba990c590fcc5fba670 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 12 Oct 2011 12:09:50 +0200 Subject: Finalised the praxisd communination code. Still untested though... --- client/client.pro | 14 +-- client/luapraxisd.cc | 30 ++--- client/pcpviewer.cc | 4 +- client/pcpviewer.h | 2 +- client/praxisd.cc | 336 +++++++++++++++++++++++++++++++++++++++++++++++++-- client/praxisd.h | 85 +++++++++++-- 6 files changed, 417 insertions(+), 54 deletions(-) (limited to 'client') diff --git a/client/client.pro b/client/client.pro index 445f29f..97d9d7d 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 += \ @@ -62,6 +50,7 @@ HEADERS += \ messagebox.h \ netcom.h \ pcpviewer.h \ + praxisd.h \ resumewidget.h \ template.h \ widgets.h \ @@ -102,6 +91,7 @@ SOURCES += \ messagebox.cc \ netcom.cc \ pcpviewer.cc \ + praxisd.cc \ resumewidget.cc \ template.cc \ widgets/common.cc \ diff --git a/client/luapraxisd.cc b/client/luapraxisd.cc index 1d9da4c..6fc4891 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 #include @@ -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) @@ -54,13 +52,13 @@ static int px_getcave(lua_State *L) QVector cavelist; Praxisd::patient_t patient = pxu->px->patient_get_by_cpr(cpr); - std::vector::iterator i = patient.sogeord.begin(); + QVector::iterator i = patient.sogeord.begin(); while(i != patient.sogeord.end()) { - std::string cavesogeord = i->sogenr.substr(1, i->sogenr.size() - 1); - std::vector cave = pxu->px->diverse_get_cave(cavesogeord); + QString cavesogeord = i->sogenr.mid(1, i->sogenr.size() - 1); + QVector 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 cavelist = pxu->px->diverse_get_cave(""); + QVector 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 index c665cf2..f0059f4 100644 --- a/client/pcpviewer.cc +++ b/client/pcpviewer.cc @@ -30,7 +30,7 @@ PCPViewer::PCPViewer(QString patientid) : praxisd("gargamel", 10000) { this->patientid = patientid; - + /* std::string j = praxisd.journal_get_by_cpr(patientid.toStdString()); printf("%s\n", j.c_str()); @@ -46,5 +46,5 @@ PCPViewer::PCPViewer(QString patientid) : praxisd("gargamel", 10000) di->date.c_str()); di++; } - + */ } diff --git a/client/pcpviewer.h b/client/pcpviewer.h index dd86fea..5b57fd6 100644 --- a/client/pcpviewer.h +++ b/client/pcpviewer.h @@ -30,7 +30,7 @@ #include -#include "../server/src/praxisd.h" +#include "praxisd.h" class PCPViewer : public QWidget { Q_OBJECT diff --git a/client/praxisd.cc b/client/praxisd.cc index 2367eb1..d8b3444 100644 --- a/client/praxisd.cc +++ b/client/praxisd.cc @@ -27,20 +27,330 @@ */ #include "praxisd.h" -#ifdef TEST_PRAXISD -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" +#include -TEST_BEGIN; +#include -// TODO: Put some testcode here (see test.h for usable macros). -TEST_TRUE(false, "No tests yet!"); +#define DOCAVE(x) if(element.tagName() == #x) cave.x = element.text() +static QVector getCaveList(QByteArray data) +{ + QDomDocument doc; + doc.setContent(data); -TEST_END; + QVector cavelist; -#endif/*TEST_PRAXISD*/ + QDomNode praxisd = doc.documentElement().firstChild(); + 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") { + + Praxisd::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 Praxisd::patient_t getPatient(QByteArray data) +{ + QDomDocument doc; + doc.setContent(data); + + Praxisd::patient_t patient; + + QDomNode praxisd = doc.documentElement().firstChild(); + 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") { + Praxisd::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() +QVector getDokMenu(QByteArray data) +{ + QDomDocument doc; + doc.setContent(data); + + QVector dokmenus; + + QDomNode praxisd = doc.documentElement().firstChild(); + 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") { + + Praxisd::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) +{ + 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 gotCave(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 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::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 params; + params["cpr"] = cpr; + makeTransfer(journal, "/praxisd/1.0/journal/get_by_cpr", params); +} + +void Praxisd::diverse_get_cave(QString sogenr) +{ + QMap params; + params["sogenr"] = sogenr; + makeTransfer(cavelist, "/praxisd/1.0/diverse/get_all_by_sogenr", params); +} + +void Praxisd::patient_get_by_cpr(QString cpr) +{ + QMap params; + params["cpr"] = cpr; + makeTransfer(patient, "/praxisd/1.0/patient/get_by_cpr", params); +} + +void Praxisd::dokmenu_get_all_by_cpr(QString cpr) +{ + QMap 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 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) + : praxisd(host, port) +{ + connect(&praxisd, SIGNAL(gotCaveList(QVector)), + this, SLOT(gotCaveList(QVector))); + + start(); +} + +void PraxisdSync::run() +{ + while(true) { + wsem.acquire(); + + switch(request_type) { + case Praxisd::journal: + break; + case Praxisd::cavelist: + praxisd.diverse_get_cave(request_sogenr); + break; + case Praxisd::patient: + break; + case Praxisd::dokmenu: + break; + case Praxisd::dokmenufile: + break; + } + } +} + +void PraxisdSync::gotCaveList(QVector cl) +{ + cavelist = cl; + rsem.release(); +} + +QString PraxisdSync::journal_get_by_cpr(QString cpr) +{ + return cpr; +} + +QVector PraxisdSync::diverse_get_cave(QString sogenr) +{ + request_type = Praxisd::cavelist; + request_sogenr = sogenr; + + wsem.release(); + rsem.acquire(); + + return cavelist; +} + +Praxisd::patient_t PraxisdSync::patient_get_by_cpr(QString cpr) +{ + cpr = ""; + return Praxisd::patient_t(); +} + +QVector PraxisdSync::dokmenu_get_all_by_cpr(QString cpr) +{ + cpr = ""; + return QVector(); +} + +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 index dfaac59..c9ccaf3 100644 --- a/client/praxisd.h +++ b/client/praxisd.h @@ -28,12 +28,31 @@ #ifndef __PRACRO_PRAXISD_H__ #define __PRACRO_PRAXISD_H__ -class Praxisd { +#include +#include +#include + +#include +#include + +#include +#include +#include + +class Praxisd : public QObject { Q_OBJECT -public; - Praxisd(); +public: + typedef enum { + journal, + cavelist, + patient, + dokmenu, + dokmenufile + } reply_t; - QString journal_get_by_cpr(QString patientid); + Praxisd(QString host, quint16 port); + + void journal_get_by_cpr(QString patientid); typedef struct { QString sogenr; @@ -42,7 +61,7 @@ public; QString bemaerkning2; QString bemaerkning3; } cave_t; - QVector diverse_get_cave(QString sogenr); + void diverse_get_cave(QString sogenr); typedef struct { QString sogenr; @@ -87,18 +106,70 @@ public; QString unknown251; QString jtime; } patient_t; - patient_t patient_get_by_cpr(QString cpr); + void patient_get_by_cpr(QString cpr); typedef struct { + QString cpr; QString group; QString subject; QString filename; size_t filesize; QString date; } dokmenu_t; - QVector dokmenu_get_all_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 gotCave(QVector cave); + void gotPatient(patient_t patient); + void gotDokMenu(QVector dokmenu); + void gotDokMenuFile(QString data); + +public slots: + void replyFinished(QNetworkReply*); + +private: + void makeTransfer(reply_t t, QString uri, QMap params); + + QNetworkAccessManager *manager; + QNetworkRequest request; + QString host; + unsigned short int port; + + QMap replytypes; +}; + +class PraxisdSync : public QThread { +Q_OBJECT +public: + PraxisdSync(QString host, unsigned short int port); + + QString journal_get_by_cpr(QString patientid); + QVector diverse_get_cave(QString sogenr); + Praxisd::patient_t patient_get_by_cpr(QString cpr); + QVector dokmenu_get_all_by_cpr(QString cpr); QString dokmenu_get_by_cpr_and_name(QString cpr, QString name); + + void run(); + +public slots: + void gotCaveList(QVector); + +private: + Praxisd praxisd; + QSemaphore rsem; + QSemaphore wsem; + + Praxisd::reply_t request_type; + QString request_sogenr; + + QVector cavelist; }; #endif/*__PRACRO_PRAXISD_H__*/ -- cgit v1.2.3 From c73d1d01ba6b57f664c21a189fa9297e2c75456a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 13 Oct 2011 10:30:38 +0200 Subject: Finished Praxisd code. Now it works both in sync and async modes. --- client/luapraxisd.cc | 8 +-- client/pcpviewer.cc | 24 ++++----- client/pcpviewer.h | 2 +- client/praxisd.cc | 76 ++++++++++++++++++--------- client/praxisd.h | 146 ++++++++++++++++++++++++++++----------------------- 5 files changed, 148 insertions(+), 108 deletions(-) (limited to 'client') diff --git a/client/luapraxisd.cc b/client/luapraxisd.cc index 6fc4891..1a92ea8 100644 --- a/client/luapraxisd.cc +++ b/client/luapraxisd.cc @@ -51,11 +51,11 @@ static int px_getcave(lua_State *L) QVector cavelist; - Praxisd::patient_t patient = pxu->px->patient_get_by_cpr(cpr); - QVector::iterator i = patient.sogeord.begin(); + Patient patient = pxu->px->patient_get_by_cpr(cpr); + QVector::iterator i = patient.sogeord.begin(); while(i != patient.sogeord.end()) { QString cavesogeord = i->sogenr.mid(1, i->sogenr.size() - 1); - QVector cave = pxu->px->diverse_get_cave(cavesogeord); + QVector cave = pxu->px->diverse_get_cave(cavesogeord); if(cave.size() == 1) { if(cave[0].cave != "ANDET") cavelist.push_back(cave[0].cave); else cavelist.push_back(i->sogetxt); @@ -80,7 +80,7 @@ static int px_cavelist(lua_State *L) pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd"); luaL_argcheck(L, pxu, 1, "Praxisd expected"); - QVector cavelist = pxu->px->diverse_get_cave(""); + QVector cavelist = pxu->px->diverse_get_cave(""); lua_createtable(L, 0, cavelist.size()); int top = lua_gettop(L); diff --git a/client/pcpviewer.cc b/client/pcpviewer.cc index f0059f4..f5347d6 100644 --- a/client/pcpviewer.cc +++ b/client/pcpviewer.cc @@ -27,24 +27,24 @@ */ #include "pcpviewer.h" -PCPViewer::PCPViewer(QString patientid) : praxisd("gargamel", 10000) +#include + +PCPViewer::PCPViewer(QString patientid) : praxisd("localhost", 10000) { this->patientid = patientid; - /* - std::string j = praxisd.journal_get_by_cpr(patientid.toStdString()); - printf("%s\n", j.c_str()); - std::vector d = - praxisd.dokmenu_get_all_by_cpr(patientid.toStdString()); - std::vector::iterator di = d.begin(); + // 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.c_str(), - di->subject.c_str(), - di->filename.c_str(), + di->group.toStdString().c_str(), + di->subject.toStdString().c_str(), + di->filename.toStdString().c_str(), di->filesize, - di->date.c_str()); + di->date.toStdString().c_str()); di++; } - */ } diff --git a/client/pcpviewer.h b/client/pcpviewer.h index 5b57fd6..479b587 100644 --- a/client/pcpviewer.h +++ b/client/pcpviewer.h @@ -38,7 +38,7 @@ public: PCPViewer(QString patientid); private: - Praxisd praxisd; + PraxisdSync praxisd; QString patientid; }; diff --git a/client/praxisd.cc b/client/praxisd.cc index d8b3444..5309b66 100644 --- a/client/praxisd.cc +++ b/client/praxisd.cc @@ -27,26 +27,28 @@ */ #include "praxisd.h" +#include + #include #include #define DOCAVE(x) if(element.tagName() == #x) cave.x = element.text() -static QVector getCaveList(QByteArray data) +static CaveVector getCaveList(QByteArray data) { QDomDocument doc; doc.setContent(data); - QVector cavelist; + CaveVector cavelist; - QDomNode praxisd = doc.documentElement().firstChild(); + 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") { - Praxisd::cave_t cave; + cave_t cave; cave.sogenr = element.attribute("sogenr"); QDomNodeList nodes = element.childNodes(); @@ -67,14 +69,14 @@ static QVector getCaveList(QByteArray data) } #define DOPATIENT(x) if(element.tagName() == #x) patient.x = element.text() -static Praxisd::patient_t getPatient(QByteArray data) +static Patient getPatient(QByteArray data) { QDomDocument doc; doc.setContent(data); - Praxisd::patient_t patient; + Patient patient; - QDomNode praxisd = doc.documentElement().firstChild(); + QDomNode praxisd = doc.documentElement(); QDomNode patnode = praxisd.firstChild(); QDomElement patelement = patnode.toElement(); @@ -102,7 +104,7 @@ static Praxisd::patient_t getPatient(QByteArray data) DOPATIENT(frilinie5); if(element.tagName() == "sogeords") { - Praxisd::sogeord_t sogeord; + sogeord_t sogeord; QDomNodeList nodes = element.childNodes(); for(int j = 0; j < nodes.count(); j++) { @@ -140,21 +142,20 @@ static Praxisd::patient_t getPatient(QByteArray data) } #define DODOKMENU(x) if(element.tagName() == #x) dokmenu.x = element.text() -QVector getDokMenu(QByteArray data) +static DokMenuVector getDokMenu(QByteArray data) { QDomDocument doc; doc.setContent(data); - QVector dokmenus; + DokMenuVector dokmenus; - QDomNode praxisd = doc.documentElement().firstChild(); + 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") { - - Praxisd::dokmenu_t dokmenu; + dokmenu_t dokmenu; dokmenu.cpr = element.attribute("cpr"); QDomNodeList nodes = element.childNodes(); @@ -179,6 +180,9 @@ QVector getDokMenu(QByteArray data) Praxisd::Praxisd(QString host, unsigned short int port) { + qRegisterMetaType("CaveVector"); + qRegisterMetaType("DokMenuVector"); + QUrl url; url.setHost(host); url.setPort(port); @@ -202,7 +206,7 @@ void Praxisd::replyFinished(QNetworkReply *reply) break; case cavelist: - emit gotCave(getCaveList(reply->readAll())); + emit gotCaveList(getCaveList(reply->readAll())); break; case patient: @@ -287,16 +291,23 @@ void Praxisd::dokmenu_get_by_cpr_and_name(QString cpr, QString name) } PraxisdSync::PraxisdSync(QString host, unsigned short int port) - : praxisd(host, port) { - connect(&praxisd, SIGNAL(gotCaveList(QVector)), - this, SLOT(gotCaveList(QVector))); + 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(gotDokMenu(DokMenuVector)), + this, SLOT(gotDokMenu(DokMenuVector)), Qt::DirectConnection); + while(true) { wsem.acquire(); @@ -309,17 +320,29 @@ void PraxisdSync::run() case Praxisd::patient: break; case Praxisd::dokmenu: + praxisd.dokmenu_get_all_by_cpr(request_cpr); break; case Praxisd::dokmenufile: break; } + + exec(); } } -void PraxisdSync::gotCaveList(QVector cl) +void PraxisdSync::gotCaveList(CaveVector cl) { cavelist = cl; rsem.release(); + + quit(); +} + +void PraxisdSync::gotDokMenu(DokMenuVector d) +{ + dokmenu = d; + rsem.release(); + quit(); } QString PraxisdSync::journal_get_by_cpr(QString cpr) @@ -327,7 +350,7 @@ QString PraxisdSync::journal_get_by_cpr(QString cpr) return cpr; } -QVector PraxisdSync::diverse_get_cave(QString sogenr) +CaveVector PraxisdSync::diverse_get_cave(QString sogenr) { request_type = Praxisd::cavelist; request_sogenr = sogenr; @@ -338,16 +361,21 @@ QVector PraxisdSync::diverse_get_cave(QString sogenr) return cavelist; } -Praxisd::patient_t PraxisdSync::patient_get_by_cpr(QString cpr) +Patient PraxisdSync::patient_get_by_cpr(QString cpr) { cpr = ""; - return Praxisd::patient_t(); + return Patient(); } -QVector PraxisdSync::dokmenu_get_all_by_cpr(QString cpr) +DokMenuVector PraxisdSync::dokmenu_get_all_by_cpr(QString cpr) { - cpr = ""; - return QVector(); + 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) diff --git a/client/praxisd.h b/client/praxisd.h index c9ccaf3..b4b673c 100644 --- a/client/praxisd.h +++ b/client/praxisd.h @@ -39,6 +39,71 @@ #include #include +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; + 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 CaveVector; +typedef patient_t Patient; +typedef QVector DokMenuVector; + class Praxisd : public QObject { Q_OBJECT public: @@ -54,68 +119,10 @@ public: void journal_get_by_cpr(QString patientid); - typedef struct { - QString sogenr; - QString cave; - QString bemaerkning1; - QString bemaerkning2; - QString bemaerkning3; - } cave_t; void diverse_get_cave(QString sogenr); - 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; - 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; void patient_get_by_cpr(QString cpr); - typedef struct { - QString cpr; - QString group; - QString subject; - QString filename; - size_t filesize; - QString date; - } dokmenu_t; void dokmenu_get_all_by_cpr(QString cpr); void dokmenu_get_by_cpr_and_name(QString cpr, QString name); @@ -125,9 +132,9 @@ signals: void networkError(QString text); void gotJournal(QString data); - void gotCave(QVector cave); - void gotPatient(patient_t patient); - void gotDokMenu(QVector dokmenu); + void gotCaveList(CaveVector cave); + void gotPatient(Patient patient); + void gotDokMenu(DokMenuVector dokmenu); void gotDokMenuFile(QString data); public slots: @@ -151,25 +158,30 @@ public: PraxisdSync(QString host, unsigned short int port); QString journal_get_by_cpr(QString patientid); - QVector diverse_get_cave(QString sogenr); - Praxisd::patient_t patient_get_by_cpr(QString cpr); - QVector dokmenu_get_all_by_cpr(QString cpr); + 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(QVector); + void gotCaveList(CaveVector); + void gotDokMenu(DokMenuVector); private: - Praxisd praxisd; + QString host; + quint16 port; + QSemaphore rsem; QSemaphore wsem; Praxisd::reply_t request_type; QString request_sogenr; + QString request_cpr; - QVector cavelist; + CaveVector cavelist; + DokMenuVector dokmenu; }; #endif/*__PRACRO_PRAXISD_H__*/ -- cgit v1.2.3 From 3a7e8f62d40f9fc03fd212a71b0f9a9a8b9bd5fe Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 13 Oct 2011 11:30:41 +0200 Subject: Add Patient request. --- client/praxisd.cc | 11 +++++++++++ client/praxisd.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'client') diff --git a/client/praxisd.cc b/client/praxisd.cc index 5309b66..740825e 100644 --- a/client/praxisd.cc +++ b/client/praxisd.cc @@ -181,6 +181,7 @@ static DokMenuVector getDokMenu(QByteArray data) Praxisd::Praxisd(QString host, unsigned short int port) { qRegisterMetaType("CaveVector"); + qRegisterMetaType("Patient"); qRegisterMetaType("DokMenuVector"); QUrl url; @@ -305,6 +306,9 @@ void PraxisdSync::run() 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); @@ -318,6 +322,7 @@ void PraxisdSync::run() 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); @@ -334,7 +339,13 @@ void PraxisdSync::gotCaveList(CaveVector cl) { cavelist = cl; rsem.release(); + quit(); +} +void PraxisdSync::gotPatient(Patient p) +{ + patient = p; + rsem.release(); quit(); } diff --git a/client/praxisd.h b/client/praxisd.h index b4b673c..1268be7 100644 --- a/client/praxisd.h +++ b/client/praxisd.h @@ -167,6 +167,7 @@ public: public slots: void gotCaveList(CaveVector); + void gotPatient(Patient); void gotDokMenu(DokMenuVector); private: @@ -181,6 +182,7 @@ private: QString request_cpr; CaveVector cavelist; + Patient patient; DokMenuVector dokmenu; }; -- cgit v1.2.3 From d602bdeb65d0e4007a8a02e5c6d4b9b271287aa9 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 13 Oct 2011 11:30:57 +0200 Subject: Fix bug in cavelist lookup. --- client/luapraxisd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/luapraxisd.cc b/client/luapraxisd.cc index 1a92ea8..0696674 100644 --- a/client/luapraxisd.cc +++ b/client/luapraxisd.cc @@ -54,7 +54,7 @@ static int px_getcave(lua_State *L) Patient patient = pxu->px->patient_get_by_cpr(cpr); QVector::iterator i = patient.sogeord.begin(); while(i != patient.sogeord.end()) { - QString cavesogeord = i->sogenr.mid(1, i->sogenr.size() - 1); + QString cavesogeord = i->sogenr;//.mid(1, i->sogenr.size() - 1); QVector cave = pxu->px->diverse_get_cave(cavesogeord); if(cave.size() == 1) { if(cave[0].cave != "ANDET") cavelist.push_back(cave[0].cave); -- cgit v1.2.3