From 0c4371e69ab567b457eb410ac56da5530d8fca6f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 11 Oct 2011 14:01:44 +0200 Subject: Fix parameter type change in startTag method. --- server/src/saxparser.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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()); } -- cgit v1.2.3 From cffe0ba35e5129383d60e246858c944670966a5b Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 11 Oct 2011 14:04:26 +0200 Subject: Implement dokmenu_get_all_by_cpr and dokmenu_get_by_cpr_and_name. Fix Fix parameter type change in startTag methods. --- server/src/praxisd.cc | 120 ++++++++++++++++++++++++++++++++++++++++++-------- server/src/praxisd.h | 22 +++++---- 2 files changed, 116 insertions(+), 26 deletions(-) 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 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 &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 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 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 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 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 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 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 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 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 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 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 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 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 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 &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 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 &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 ÷ +}; + +std::vector Praxisd::dokmenu_get_all_by_cpr(std::string cpr) +{ + std::vector 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 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 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_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_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); -- cgit v1.2.3 From 00863883072e174190b0b5236faddc70d1d471e4 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 11 Oct 2011 14:11:56 +0200 Subject: Make executable. --- tools/PracroAdd | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/PracroAdd diff --git a/tools/PracroAdd b/tools/PracroAdd old mode 100644 new mode 100755 -- cgit v1.2.3 From 1200aa5154c9a1a35156d659818ab631a79f4b0d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 11 Oct 2011 14:12:43 +0200 Subject: Rename to add_file. --- tools/PracroAdd | 110 -------------------------------------------------------- tools/add_file | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 110 deletions(-) delete mode 100755 tools/PracroAdd create mode 100755 tools/add_file diff --git a/tools/PracroAdd b/tools/PracroAdd deleted file mode 100755 index ff3bc9a..0000000 --- a/tools/PracroAdd +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -PROJECT="Pracro" - -function allfile() { - WHO="`whoami`" - - echo "/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */" > $1; - echo "/* vim: set et sw=2 ts=2: */" >> $1; - echo "/***************************************************************************" >> $1; - echo " * $1" >> $1; - echo " *" >> $1 ; - echo " * `date`" >> $1; - echo -n " * Copyright " >> $1 - echo -n `date +%Y | xargs` >> $1 - if [ "$WHO" == "nemo" ]; - then - echo " Jonas Suhr Christensen" >> $1; - echo " * jsc@umbraculum.org" >> $1; - fi - if [ "$WHO" == "deva" ]; - then - echo " Bent Bisballe Nyeng" >> $1; - echo " * deva@aasimon.org" >> $1; - fi - if [ "$WHO" == "senator" ]; - then - echo "Lars Bisballe Jensen" >> $1; - echo " * elsenator@gmail.com" >> $1; - fi - if [ "$WHO" == "piparum" ]; - then - echo "Peter Skaarup" >> $1; - echo " * and piparum@piparum.dk" >> $1; - fi - echo " ****************************************************************************/" >> $1; - echo "" >> $1; - echo "/*" >> $1; - echo " * This file is part of $PROJECT." >> $1; - echo " *" >> $1; - echo " * $PROJECT is free software; you can redistribute it and/or modify" >> $1; - echo " * it under the terms of the GNU General Public License as published by" >> $1; - echo " * the Free Software Foundation; either version 2 of the License, or" >> $1; - echo " * (at your option) any later version." >> $1; - echo " *" >> $1; - echo " * $PROJECT is distributed in the hope that it will be useful," >> $1; - echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of" >> $1; - echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> $1; - echo " * GNU General Public License for more details." >> $1; - echo " *" >> $1; - echo " * You should have received a copy of the GNU General Public License" >> $1; - echo " * along with $PROJECT; if not, write to the Free Software" >> $1; - echo " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA." >> $1; - echo " */" >> $1; -} - -function ccfile() { - local hf=`echo -n $1 | cut -d'.' -f1`.h; - hfile $hf; - - allfile $1; - echo -n '#include "' >> $1; - echo -n $hf >> $1; - echo '"' >> $1; - echo '' >> $1; - - local hn=`echo $1 | cut -d'.' -f1 | tr 'a-z.' 'A-Z_'` - echo "#ifdef TEST_${hn}" >> $1; - echo "//Additional dependency files" >> $1; - echo "//deps:" >> $1; - echo "//Required cflags (autoconf vars may be used)" >> $1; - echo "//cflags:" >> $1; - echo "//Required link options (autoconf vars may be used)" >> $1; - echo "//libs:" >> $1; - echo "#include \"test.h\"" >> $1; - echo "" >> $1; - echo "TEST_BEGIN;" >> $1; - echo "" >> $1; - echo "// TODO: Put some testcode here (see test.h for usable macros)." >> $1; - echo "TEST_TRUE(false, \"No tests yet!\");" >> $1; - echo "" >> $1; - echo "TEST_END;" >> $1; - echo "" >> $1; - echo "#endif/*TEST_${hn}*/" >> $1; -} - -function hfile() { - allfile $1; - local hn=`echo $1 | tr 'a-z.' 'A-Z_'` - local pr=`echo $PROJECT | tr 'a-z.' 'A-Z_'` - echo "#ifndef __${pr}_${hn}__" >> $1; - echo "#define __${pr}_${hn}__" >> $1; - echo "#endif/*__${pr}_${hn}__*/" >> $1; -} - -if [ "$#" = "1" ]; then -if [ "CC" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then - ccfile $1; -fi; -if [ "H" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then - hfile $1; -fi; -else - echo "Usage: $0 filename"; - echo - echo "Examples:"; - echo "$0 myclass.cc Which will produce both myclass.cc and myclass.h"; - echo "$0 myinterface.h Which will only produce myinterface.h"; - echo - echo "NOTE: The files will be created in the current directory!"; -fi; diff --git a/tools/add_file b/tools/add_file new file mode 100755 index 0000000..ff3bc9a --- /dev/null +++ b/tools/add_file @@ -0,0 +1,110 @@ +#!/bin/bash +PROJECT="Pracro" + +function allfile() { + WHO="`whoami`" + + echo "/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */" > $1; + echo "/* vim: set et sw=2 ts=2: */" >> $1; + echo "/***************************************************************************" >> $1; + echo " * $1" >> $1; + echo " *" >> $1 ; + echo " * `date`" >> $1; + echo -n " * Copyright " >> $1 + echo -n `date +%Y | xargs` >> $1 + if [ "$WHO" == "nemo" ]; + then + echo " Jonas Suhr Christensen" >> $1; + echo " * jsc@umbraculum.org" >> $1; + fi + if [ "$WHO" == "deva" ]; + then + echo " Bent Bisballe Nyeng" >> $1; + echo " * deva@aasimon.org" >> $1; + fi + if [ "$WHO" == "senator" ]; + then + echo "Lars Bisballe Jensen" >> $1; + echo " * elsenator@gmail.com" >> $1; + fi + if [ "$WHO" == "piparum" ]; + then + echo "Peter Skaarup" >> $1; + echo " * and piparum@piparum.dk" >> $1; + fi + echo " ****************************************************************************/" >> $1; + echo "" >> $1; + echo "/*" >> $1; + echo " * This file is part of $PROJECT." >> $1; + echo " *" >> $1; + echo " * $PROJECT is free software; you can redistribute it and/or modify" >> $1; + echo " * it under the terms of the GNU General Public License as published by" >> $1; + echo " * the Free Software Foundation; either version 2 of the License, or" >> $1; + echo " * (at your option) any later version." >> $1; + echo " *" >> $1; + echo " * $PROJECT is distributed in the hope that it will be useful," >> $1; + echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of" >> $1; + echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> $1; + echo " * GNU General Public License for more details." >> $1; + echo " *" >> $1; + echo " * You should have received a copy of the GNU General Public License" >> $1; + echo " * along with $PROJECT; if not, write to the Free Software" >> $1; + echo " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA." >> $1; + echo " */" >> $1; +} + +function ccfile() { + local hf=`echo -n $1 | cut -d'.' -f1`.h; + hfile $hf; + + allfile $1; + echo -n '#include "' >> $1; + echo -n $hf >> $1; + echo '"' >> $1; + echo '' >> $1; + + local hn=`echo $1 | cut -d'.' -f1 | tr 'a-z.' 'A-Z_'` + echo "#ifdef TEST_${hn}" >> $1; + echo "//Additional dependency files" >> $1; + echo "//deps:" >> $1; + echo "//Required cflags (autoconf vars may be used)" >> $1; + echo "//cflags:" >> $1; + echo "//Required link options (autoconf vars may be used)" >> $1; + echo "//libs:" >> $1; + echo "#include \"test.h\"" >> $1; + echo "" >> $1; + echo "TEST_BEGIN;" >> $1; + echo "" >> $1; + echo "// TODO: Put some testcode here (see test.h for usable macros)." >> $1; + echo "TEST_TRUE(false, \"No tests yet!\");" >> $1; + echo "" >> $1; + echo "TEST_END;" >> $1; + echo "" >> $1; + echo "#endif/*TEST_${hn}*/" >> $1; +} + +function hfile() { + allfile $1; + local hn=`echo $1 | tr 'a-z.' 'A-Z_'` + local pr=`echo $PROJECT | tr 'a-z.' 'A-Z_'` + echo "#ifndef __${pr}_${hn}__" >> $1; + echo "#define __${pr}_${hn}__" >> $1; + echo "#endif/*__${pr}_${hn}__*/" >> $1; +} + +if [ "$#" = "1" ]; then +if [ "CC" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then + ccfile $1; +fi; +if [ "H" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then + hfile $1; +fi; +else + echo "Usage: $0 filename"; + echo + echo "Examples:"; + echo "$0 myclass.cc Which will produce both myclass.cc and myclass.h"; + echo "$0 myinterface.h Which will only produce myinterface.h"; + echo + echo "NOTE: The files will be created in the current directory!"; +fi; -- cgit v1.2.3 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 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(-) 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(-) 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(+) 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(-) 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