diff options
-rw-r--r-- | client/luapraxisd.cc | 8 | ||||
-rw-r--r-- | client/pcpviewer.cc | 24 | ||||
-rw-r--r-- | client/pcpviewer.h | 2 | ||||
-rw-r--r-- | client/praxisd.cc | 76 | ||||
-rw-r--r-- | client/praxisd.h | 146 |
5 files changed, 148 insertions, 108 deletions
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<QString> cavelist; - Praxisd::patient_t patient = pxu->px->patient_get_by_cpr(cpr); - QVector<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()) { QString cavesogeord = i->sogenr.mid(1, i->sogenr.size() - 1); - QVector<Praxisd::cave_t> cave = pxu->px->diverse_get_cave(cavesogeord); + 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); 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<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); 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 <stdio.h> + +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<Praxisd::dokmenu_t> d = - praxisd.dokmenu_get_all_by_cpr(patientid.toStdString()); - std::vector<Praxisd::dokmenu_t>::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 <stdio.h> + #include <QDomDocument> #include <QNetworkReply> #define DOCAVE(x) if(element.tagName() == #x) cave.x = element.text() -static QVector<Praxisd::cave_t> getCaveList(QByteArray data) +static CaveVector getCaveList(QByteArray data) { QDomDocument doc; doc.setContent(data); - QVector<Praxisd::cave_t> 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<Praxisd::cave_t> 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<Praxisd::dokmenu_t> getDokMenu(QByteArray data) +static DokMenuVector getDokMenu(QByteArray data) { QDomDocument doc; doc.setContent(data); - QVector<Praxisd::dokmenu_t> 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<Praxisd::dokmenu_t> getDokMenu(QByteArray data) Praxisd::Praxisd(QString host, unsigned short int port) { + qRegisterMetaType<CaveVector>("CaveVector"); + qRegisterMetaType<DokMenuVector>("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<Praxisd::cave_t>)), - this, SLOT(gotCaveList(QVector<Praxisd::cave_t>))); + 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<Praxisd::cave_t> 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<Praxisd::cave_t> 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<Praxisd::cave_t> 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<Praxisd::dokmenu_t> PraxisdSync::dokmenu_get_all_by_cpr(QString cpr) +DokMenuVector PraxisdSync::dokmenu_get_all_by_cpr(QString cpr) { - cpr = ""; - return QVector<Praxisd::dokmenu_t>(); + 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 <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: @@ -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_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; 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_t> cave); - void gotPatient(patient_t patient); - void gotDokMenu(QVector<dokmenu_t> 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<Praxisd::cave_t> diverse_get_cave(QString sogenr); - Praxisd::patient_t patient_get_by_cpr(QString cpr); - QVector<Praxisd::dokmenu_t> 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<Praxisd::cave_t>); + 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<Praxisd::cave_t> cavelist; + CaveVector cavelist; + DokMenuVector dokmenu; }; #endif/*__PRACRO_PRAXISD_H__*/ |