summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/Makefile.am15
-rw-r--r--server/src/luapraxisd.cc572
-rw-r--r--server/src/luapraxisd.h250
-rw-r--r--server/src/praxisd.cc1070
-rw-r--r--server/src/praxisd.h303
5 files changed, 8 insertions, 2202 deletions
diff --git a/server/src/Makefile.am b/server/src/Makefile.am
index 5edec4e..cd2d291 100644
--- a/server/src/Makefile.am
+++ b/server/src/Makefile.am
@@ -9,7 +9,8 @@ pracrod_LDADD = $(LD_EFENCE) $(PQ_LIBS) $(CONFIG_LIBS) \
pracrod_CXXFLAGS = $(PQ_CFLAGS) $(CONFIG_CXXFLAGS) \
$(LUA_CFLAGS) $(HTTPD_CFLAGS) $(EXPAT_CFLAGS) \
$(PTHREAD_CFLAGS) $(ATF_CFLAGS) $(CURL_CFLAGS) \
- -I$(top_srcdir)/../hugin -DWITH_HUG_FILTER
+ -I$(top_srcdir)/../hugin -DWITH_HUG_FILTER \
+ -I$(top_srcdir)/../praxisdif/curl/
pracrod_CFLAGS = -DWITH_HUG_FILTER
@@ -40,7 +41,6 @@ pracrod_SOURCES = \
log.cc \
luascript.cc \
luaoncommit.cc \
- luapraxisd.cc \
luaquerymapper.cc \
luaresume.cc \
luautil.cc \
@@ -52,7 +52,6 @@ pracrod_SOURCES = \
pracrodao.cc \
pracrodaopgsql.cc \
pracrodaotest.cc \
- praxisd.cc \
queryhandlerpentominos.cc \
queryhandlerpracro.cc \
queryparser.cc \
@@ -76,7 +75,9 @@ pracrod_SOURCES = \
widgetgenerator.cc \
xml_encode_decode.cc \
$(top_srcdir)/../hugin/hugin.c \
- $(top_srcdir)/../hugin/hugin_filter.c
+ $(top_srcdir)/../hugin/hugin_filter.c \
+ $(top_srcdir)/../praxisdif/curl/praxisd.cc \
+ $(top_srcdir)/../praxisdif/curl/luapraxisd.cc
EXTRA_DIST = \
artefact.h \
@@ -105,7 +106,6 @@ EXTRA_DIST = \
log.h \
luascript.h \
luaoncommit.h \
- luapraxisd.h \
luaquerymapper.h \
luaresume.h \
luautil.h \
@@ -117,7 +117,6 @@ EXTRA_DIST = \
pracrodao.h \
pracrodaopgsql.h \
pracrodaotest.h \
- praxisd.h \
queryhandler.h \
queryhandlerpentominos.h \
queryhandlerpracro.h \
@@ -144,7 +143,9 @@ EXTRA_DIST = \
widgetvalue.h \
widgetgenerator.h \
xml_encode_decode.h \
- $(top_srcdir)/../hugin/hugin.h
+ $(top_srcdir)/../hugin/hugin.h \
+ $(top_srcdir)/../praxisdif/curl/praxisd.h \
+ $(top_srcdir)/../praxisdif/curl/luapraxisd.h
################
# Test Section #
diff --git a/server/src/luapraxisd.cc b/server/src/luapraxisd.cc
deleted file mode 100644
index 39cb0eb..0000000
--- a/server/src/luapraxisd.cc
+++ /dev/null
@@ -1,572 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * luapraxisd.cc
- *
- * Wed Apr 27 11:59:53 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 "luapraxisd.h"
-
-#include "praxisd.h"
-
-#include <lauxlib.h>
-#include <strings.h>
-
-#include <hugin.hpp>
-
-#define luaL_checkbool(L, i) \
- (lua_isboolean(L,i) ? lua_toboolean(L,i) : luaL_checkint(L,i))
-
-#define error(L, m) \
- { ERR(luapraxisd, "%s\n", m); lua_pushstring(L, m); lua_error(L); }
-
-typedef struct px_userdata {
- Praxisd *px;
-} px_userdata;
-
-int px_addcave(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
- const char *cave = luaL_checkstring(L, 3);
- const char *txt = luaL_checkstring(L, 4);
-
- std::string sogeord;
- std::string sogetxt;
-
- try {
- std::vector<Praxisd::cave_t> cavelist = pxu->px->diverse_get_cave("");
- std::vector<Praxisd::cave_t>::iterator i = cavelist.begin();
- while(i != cavelist.end()) {
- Praxisd::cave_t &c = *i;
- if(strcasecmp(cave, c.cave.c_str()) == 0) {
- pxu->px->add_sogeord(cpr, c.sogenr, txt);
- return 0;
- }
- i++;
- }
-
- std::string text = cave;
- text += " ";
- text += txt;
- pxu->px->add_sogeord(cpr, "CA0003", text.c_str()); // CA0003 == 'ANDET'
- } catch(const char *msg) {
- error(L, msg);
- }
-
- return 0;
-}
-
-int px_addbehandling(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
- const char *behandling = luaL_checkstring(L, 3);
- const char *text = luaL_checkstring(L, 4);
-
- std::string sogeord;
- std::string sogetxt;
-
- try {
- std::vector<Praxisd::behandling_t> bhlst =
- pxu->px->diverse_get_behandling("");
- std::vector<Praxisd::behandling_t>::iterator i = bhlst.begin();
- while(i != bhlst.end()) {
- Praxisd::behandling_t &b = *i;
- if(strcasecmp(behandling, b.kode.c_str()) == 0) {
- pxu->px->add_sogeord(cpr, b.sogenr, text);
- return 0;
- }
- i++;
- }
- } catch(const char *msg) {
- error(L, msg);
- }
-
- return 0;
-}
-
-int px_adddiagnose(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
- const char *diagnose = luaL_checkstring(L, 3);
- const char *text = luaL_checkstring(L, 4);
-
- std::string sogeord;
- std::string sogetxt;
-
- try {
- std::vector<Praxisd::diagnose_t> dialst =
- pxu->px->diverse_get_diagnose("");
- std::vector<Praxisd::diagnose_t>::iterator i = dialst.begin();
- while(i != dialst.end()) {
- Praxisd::diagnose_t &d = *i;
- if(strcasecmp(diagnose, d.kode.c_str()) == 0) {
- pxu->px->add_sogeord(cpr, d.sogenr, text);
- return 0;
- }
- i++;
- }
- } catch(const char *msg) {
- error(L, msg);
- }
-
- return 0;
-}
-
-class cavedata_t : public Praxisd::cave_t {
-public:
- std::string sogetxt;
- std::string sogedato;
-};
-int px_getcave(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
-
- std::vector<cavedata_t> cavelist;
-
- try {
- Praxisd::patient_t pat = pxu->px->patient_get_by_cpr(cpr);
- std::vector<Praxisd::sogeord_t>::iterator i = pat.sogeord.begin();
- while(i != pat.sogeord.end()) {
- Praxisd::sogeord_t &s = *i;
- if(s.sogenr[0] == 'C') {
- std::string csogenr = s.sogenr.substr(1, s.sogenr.length() - 1);
- std::vector<Praxisd::cave_t> cl = pxu->px->diverse_get_cave(csogenr);
- if(cl.size() == 1) {
- cavedata_t cdata;
- cdata.cave = cl[0].cave;
- cdata.bemaerkning1 = cl[0].bemaerkning1;
- cdata.bemaerkning2 = cl[0].bemaerkning2;
- cdata.bemaerkning3 = cl[0].bemaerkning3;
- cdata.sogetxt = s.sogetxt;
- cdata.sogedato = s.sogedato;
- cavelist.push_back(cdata);
- }
- }
-
- i++;
- }
- } catch(const char *msg) {
- error(L, msg);
- }
-
- int num = cavelist.size();
- int sz = 6; // 4 fields in cave_t + 1 sogetxt and 1 sogedato
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, cavelist[i - 1].cave.c_str());
- if(j == 2) lua_pushstring(L, cavelist[i - 1].bemaerkning1.c_str());
- if(j == 3) lua_pushstring(L, cavelist[i - 1].bemaerkning2.c_str());
- if(j == 4) lua_pushstring(L, cavelist[i - 1].bemaerkning3.c_str());
- if(j == 5) lua_pushstring(L, cavelist[i - 1].sogetxt.c_str());
- if(j == 6) lua_pushstring(L, cavelist[i - 1].sogedato.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-class behandlingdata_t : public Praxisd::behandling_t {
-public:
- std::string sogetxt;
- std::string sogedato;
-};
-int px_getbehandling(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
-
- std::vector<behandlingdata_t> behandlinglist;
-
- try {
- Praxisd::patient_t pat = pxu->px->patient_get_by_cpr(cpr);
- std::vector<Praxisd::sogeord_t>::iterator i = pat.sogeord.begin();
- while(i != pat.sogeord.end()) {
- Praxisd::sogeord_t &s = *i;
- if(s.sogenr[0] == 'B') {
- std::string csogenr = s.sogenr.substr(1, s.sogenr.length() - 1);
- std::vector<Praxisd::behandling_t> cl = pxu->px->diverse_get_behandling(csogenr);
- if(cl.size() == 1) {
- behandlingdata_t cdata;
- cdata.kode = cl[0].kode;
- cdata.behandling = cl[0].behandling;
- cdata.bemaerkning = cl[0].bemaerkning;
- cdata.udregning = cl[0].udregning;
- cdata.sogetxt = s.sogetxt;
- cdata.sogedato = s.sogedato;
- behandlinglist.push_back(cdata);
- }
- }
-
- i++;
- }
- } catch(const char *msg) {
- error(L, msg);
- }
-
- int num = behandlinglist.size();
- int sz = 6; // 4 fields in behandling_t + 1 sogetxt and 1 sogedato
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, behandlinglist[i - 1].kode.c_str());
- if(j == 2) lua_pushstring(L, behandlinglist[i - 1].behandling.c_str());
- if(j == 3) lua_pushstring(L, behandlinglist[i - 1].bemaerkning.c_str());
- if(j == 4) lua_pushstring(L, behandlinglist[i - 1].udregning.c_str());
- if(j == 5) lua_pushstring(L, behandlinglist[i - 1].sogetxt.c_str());
- if(j == 6) lua_pushstring(L, behandlinglist[i - 1].sogedato.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-class diagnosedata_t : public Praxisd::diagnose_t {
-public:
- std::string sogetxt;
- std::string sogedato;
-};
-int px_getdiagnose(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *cpr = luaL_checkstring(L, 2);
-
- std::vector<diagnosedata_t> diagnoselist;
-
- try {
- Praxisd::patient_t pat = pxu->px->patient_get_by_cpr(cpr);
- std::vector<Praxisd::sogeord_t>::iterator i = pat.sogeord.begin();
- while(i != pat.sogeord.end()) {
- Praxisd::sogeord_t &s = *i;
- if(s.sogenr[0] == 'D') {
- std::string csogenr = s.sogenr.substr(1, s.sogenr.length() - 1);
- std::vector<Praxisd::diagnose_t> cl = pxu->px->diverse_get_diagnose(csogenr);
- if(cl.size() == 1) {
- diagnosedata_t cdata;
- cdata.kode = cl[0].kode;
- cdata.diagnose = cl[0].diagnose;
- cdata.bemaerkning = cl[0].bemaerkning;
- cdata.sogetxt = s.sogetxt;
- cdata.sogedato = s.sogedato;
- diagnoselist.push_back(cdata);
- }
- }
-
- i++;
- }
- } catch(const char *msg) {
- error(L, msg);
- }
-
- int num = diagnoselist.size();
- int sz = 5; // 3 fields in diagnose_t + 1 sogetxt and 1 sogedato
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, diagnoselist[i - 1].kode.c_str());
- if(j == 2) lua_pushstring(L, diagnoselist[i - 1].diagnose.c_str());
- if(j == 3) lua_pushstring(L, diagnoselist[i - 1].bemaerkning.c_str());
- if(j == 4) lua_pushstring(L, diagnoselist[i - 1].sogetxt.c_str());
- if(j == 5) lua_pushstring(L, diagnoselist[i - 1].sogedato.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-int px_cavelist(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *sogenr = luaL_checkstring(L, 2);
-
- std::vector<Praxisd::cave_t> cavelist;
- try {
- cavelist = pxu->px->diverse_get_cave(sogenr);
- } catch(const char *msg) {
- error(L, msg);
- }
-
-
- int num = cavelist.size();
- int sz = 4; // 4 fields in cave_t
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, cavelist[i - 1].cave.c_str());
- if(j == 2) lua_pushstring(L, cavelist[i - 1].bemaerkning1.c_str());
- if(j == 3) lua_pushstring(L, cavelist[i - 1].bemaerkning2.c_str());
- if(j == 4) lua_pushstring(L, cavelist[i - 1].bemaerkning3.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-int px_behandlinglist(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *sogenr = luaL_checkstring(L, 2);
-
- std::vector<Praxisd::behandling_t> behandlinglist;
- try {
- behandlinglist = pxu->px->diverse_get_behandling(sogenr);
- } catch(const char *msg) {
- error(L, msg);
- }
-
- int num = behandlinglist.size();
- int sz = 4; // 4 fields in behandling_t
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, behandlinglist[i - 1].kode.c_str());
- if(j == 2) lua_pushstring(L, behandlinglist[i - 1].behandling.c_str());
- if(j == 3) lua_pushstring(L, behandlinglist[i - 1].bemaerkning.c_str());
- if(j == 4) lua_pushstring(L, behandlinglist[i - 1].udregning.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-int px_diagnoselist(lua_State *L)
-{
- px_userdata *pxu;
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- const char *sogenr = luaL_checkstring(L, 2);
-
- std::vector<Praxisd::diagnose_t> diagnoselist;
- try {
- diagnoselist = pxu->px->diverse_get_diagnose(sogenr);
- } catch(const char *msg) {
- error(L, msg);
- }
-
- int num = diagnoselist.size();
- int sz = 3; // 3 fields in diagnose_t
-
- lua_createtable(L, num, 0);
- int toptop = lua_gettop(L);
-
- for(int i = 1; i <= num; i++) {
- lua_createtable(L, 0, sz);
- int top = lua_gettop(L);
-
- for(int j = 1; j <= sz; j++) {
- if(j == 1) lua_pushstring(L, diagnoselist[i - 1].kode.c_str());
- if(j == 2) lua_pushstring(L, diagnoselist[i - 1].diagnose.c_str());
- if(j == 3) lua_pushstring(L, diagnoselist[i - 1].bemaerkning.c_str());
- lua_rawseti(L, top, j);
- }
-
- lua_rawseti(L, toptop, i);
- }
-
- return 1;
-}
-
-int px_new(lua_State *L)
-{
- const char *host = luaL_checkstring(L, 1);
- int port = (int)luaL_checknumber(L, 2);
-
- px_userdata *pxu;
- pxu = (px_userdata *)lua_newuserdata(L, sizeof(px_userdata));
-
- luaL_getmetatable(L, "Praxisd");
- lua_setmetatable(L, -2);
-
- try {
- pxu->px = new Praxisd(host, port);
- } catch(const char *msg) {
- error(L, msg);
- }
-
- return 1;
-}
-
-int px_gc(lua_State *L)
-{
- px_userdata *pxu;
-
- pxu = (px_userdata *)luaL_checkudata(L, 1, "Praxisd");
- luaL_argcheck(L, pxu, 1, "Praxisd expected");
-
- delete pxu->px;
-
- return 0;
-}
-
-void register_praxisd(lua_State *L)
-{
- luaL_newmetatable(L, "Praxisd");
- lua_pushliteral(L, "__index");
- lua_pushvalue(L, -2);
- lua_rawset(L, -3);
- luaL_register(L, NULL, px_meths);
- luaL_openlib (L, "Praxisd", px_funcs, 0);
-}
-
-#ifdef TEST_LUAPRAXISD
-//deps: praxisd.cc debug.cc saxparser.cc log.cc mutex.cc
-//cflags: -I.. $(LUA_CFLAGS) $(CURL_CFLAGS) $(EXPAT_CFLAGS)
-//libs: $(LUA_LIBS) $(CURL_LIBS) $(EXPAT_LIBS)
-#include "test.h"
-
-TEST_BEGIN;
-
-lua_State *L = luaL_newstate();
-if(L == NULL) {
- ERR(luaresume, "Could not create LUA state.\n");
-}
-
-luaL_openlibs(L);
-
-register_praxisd(L);
-
-/////
-std::string program =
- "px = Praxisd.new('localhost', 10000)\n"
- "--cl = px:cavelist('')\n"
- "--for i=1,#cl do\n"
- "-- print(cl[i])\n"
- "--end\n"
- "\n"
- "pcl = px:addcave('1505050505', 'AZOPT', 'test')\n"
- "\n"
- "--pcl = px:addcave('1505050505', os.date('%H%M%S'))\n"
- "\n"
- "--pcl = px:getbehandling('1505050505')\n"
- "--print('#pcl: ' .. #pcl)\n"
- "--for i=1,#pcl do\n"
- "-- pc = pcl[i]\n"
- "-- print('#pc: ' .. #pc)\n"
- "-- for j=1,#pc do\n"
- "-- print(' pc: ' .. j .. ': ' .. pc[j])\n"
- "-- end\n"
- "--end\n"
- ;
-
-//int top = lua_gettop(L);
-
-if(luaL_loadbuffer(L, program.c_str(), program.size(), "luapraxisd test")) {
- ERR(luaresume, "loadbufer: %s\n", lua_tostring(L, lua_gettop(L)));
- printf("loadbuffer error: %s", lua_tostring(L, lua_gettop(L)));
-}
-
-if(lua_pcall(L, 0, LUA_MULTRET, 0)) {
- ERR(luaresume, "pcall: %s\n" , lua_tostring(L, lua_gettop(L)));
- printf("pcall error: %s", lua_tostring(L, lua_gettop(L)));
-}
-/*
-if(top != lua_gettop(L) - 1) {
- ERR(luaresume, "Program did not return a single value.\n");
-}
-
-if(lua_isstring(L, lua_gettop(L)) == false) {
- ERR(luaresume, "Program did not return a string value.\n");
-}
-
-std::string res = lua_tostring(L, lua_gettop(L));
-lua_pop(L, 1);
-*/
-lua_close(L);
-
-TEST_END;
-
-#endif/*TEST_LUAPRAXISD*/
diff --git a/server/src/luapraxisd.h b/server/src/luapraxisd.h
deleted file mode 100644
index 82445e1..0000000
--- a/server/src/luapraxisd.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * luapraxisd.h
- *
- * Wed Apr 27 11:59:53 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_LUAPRAXISD_H__
-#define __PRACRO_LUAPRAXISD_H__
-
-#include <lua.hpp>
-
-/***
- * Praxisd Class
- * @class Praxisd
- * @serverside
- * @clientside
- * The praxisd class connects and handles communication with the praxisd
- * daemon process.
- */
-
-/***
- * @method object Praxisd.new(string host, int port)
- * Create a new Praxisd connection object.
- * @param host The hostname to connect to.
- * @param port The port number to connect to.
- * @return The newly created communication object.
- * @example Create a new praxisd object:
- * px = Praxisd.new('localhost', 10000)
- */
-int px_new(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:cavelist()
- * Get server cave list.
- * To retrieve cavelist for a patient see @see praxisd:getcave().
- * @return The complete list of known (possible) cave from the server.
- * The returned stringlist are indexed as follows: 1: cave - 2: bemaerkning1 -
- * 3: bemaerkning2 - 4: bemaerkning3
- * @example Create a new praxisd object, get and print cavelist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:cavelist()
- * for i=0,#lst do
- * print('cave: ' .. lst[i][1])
- * print('bemaerkning1: ' .. lst[i][2])
- * print('bemaerkning2: ' .. lst[i][3])
- * print('bemaerkning3: ' .. lst[i][4])
- * end
- */
-int px_cavelist(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:behandlinglist()
- * Get server behandling list.
- * To retrieve behandlinglist for a patient see @see praxisd:getbehandling().
- * @return The complete list of known (possible) behandling from the server.
- * The returned stringlist are indexed as follows: 1: kode - 2: behandling -
- * 3: bemaerkning - 4: udregning.
- * @example Create a new praxisd object, get and print behandlinglist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:behandlinglist()
- * for i=0,#lst do
- * print('kode: ' .. lst[i][1])
- * print('behandling: ' .. lst[i][2])
- * print('bemaerkning: ' .. lst[i][3])
- * print('udregning: ' .. lst[i][4])
- * end
- */
-int px_behandlinglist(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:diagnoselist()
- * Get server diagnose list.
- * To retrieve diagnoselist for a patient see @see praxisd:getdiagnose().
- * @return The complete list of known (possible) diagnose from the server.
- * The returned stringlist are indexed as follows: 1: kode - 2: diagnose -
- * 3: bemaerkning.
- * @example Create a new praxisd object, get and print diagnoselist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:diagnoselist()
- * for i=0,#lst do
- * print('kode: ' .. lst[i][1])
- * print('diagnose: ' .. lst[i][2])
- * print('bemaerkning: ' .. lst[i][3])
- * end
- */
-int px_diagnoselist(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:getcave(string patientid)
- * Get cave list from a patient.
- * To retrieve cavelist from the server see @see praxisd:cavelist(). To add cave
- * to a patient see @see praxisd:addcave().
- * @param patientid A string containing the patientid.
- * @return The list cave registered with the patient.
- * The returned stringlist are indexed as follows: 1: cave - 2: bemaerkning1 -
- * 3: bemaerkning2 - 4: bemaerkning3 - 5: sogetxt - 6: sogedato.
- * @example Create a new praxisd object, get and print cavelist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:getcave('1234567890')
- * for i=0,#lst do
- * print('cave: ' .. lst[i][1])
- * print('bemaerkning1: ' .. lst[i][2])
- * print('bemaerkning2: ' .. lst[i][3])
- * print('bemaerkning3: ' .. lst[i][4])
- * print('sogetxt: ' .. lst[i][5])
- * print('sogedato: ' .. lst[i][6])
- * end
- */
-int px_getcave(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:getbehandling(string patientid)
- * Get behandling list from a patient.
- * To retrieve behandlinglist from the server see @see praxisd:behandlinglist(). To add behandling
- * to a patient see @see praxisd:addbehandling().
- * @param patientid A string containing the patientid.
- * @return The list behandling registered with the patient.
- * The returned stringlist are indexed as follows: 1: kode - 2: behandling -
- * 3: bemaerkning - 4: udregning - 5: sogetxt - 6: sogedato.
- * @example Create a new praxisd object, get and print behandlinglist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:getbehandling('1234567890')
- * for i=0,#lst do
- * print('kode: ' .. lst[i][1])
- * print('behandling: ' .. lst[i][2])
- * print('bemaerkning: ' .. lst[i][3])
- * print('udregning: ' .. lst[i][4])
- * print('sogetxt: ' .. lst[i][5])
- * print('sogedato: ' .. lst[i][6])
- * end
- */
-int px_getbehandling(lua_State *L);
-
-/***
- * @method stringlist-list praxisd:getdiagnose(string patientid)
- * Get diagnose list from a patient.
- * To retrieve diagnoselist from the server see @see praxisd:diagnoselist(). To add diagnose
- * to a patient see @see praxisd:adddiagnose().
- * @param patientid A string containing the patientid.
- * @return The list diagnose registered with the patient.
- * The returned stringlist are indexed as follows: 1: kode - 2: diagnose -
- * 3: bemaerkning - 4: sogetxt - 5: sogedato.
- * @example Create a new praxisd object, get and print diagnoselist:
- * px = Praxisd.new('localhost', 10000)
- * lst = px:getdiagnose('1234567890')
- * for i=0,#lst do
- * print('kode: ' .. lst[i][1])
- * print('diagnose: ' .. lst[i][2])
- * print('bemaerkning: ' .. lst[i][3])
- * print('sogetxt: ' .. lst[i][4])
- * print('sogedato: ' .. lst[i][5])
- * end
- */
-int px_getdiagnose(lua_State *L);
-
-/***
- * @method nil praxisd:addcave(string patientid, string cave, string text)
- * Add a cave entry to a patient. To retrieve list of cave from a patient
- * see @see praxisd:getcave().
- * NOTE: This function is only available on the server.
- * @param patientid A string containing the patientid.
- * @param diagnose The cave string.
- * @param text A text to store with the cave entry. NOTE: This is not shown in
- * PCPraxis! The string mat be up to 6 characters long. If longer it will be
- * trunkated.
- * @example Create a new praxisd object and add a cave entry:
- * px = Praxisd.new('localhost', 10000)
- * px:addcave('1234567890', 'AZOPT', '')
- */
-int px_addcave(lua_State *L);
-
-/***
- * @method nil praxisd:addbehandling(string patientid, string behandling, string text)
- * Add a behandling to a patient. To retrieve list of behandling from a patient
- * see @see praxisd:getbehandling().
- * NOTE: This function is only available on the server.
- * @param patientid A string containing the patientid.
- * @param diagnose The behandling code.
- * @param text A text to store with the behandling code. The string mat be up to 6
- * characters long. If longer it will be trunkated.
- * @example Create a new praxisd object and add a behandling:
- * px = Praxisd.new('localhost', 10000)
- * px:addbehandling('1234567890', 'B0001', 'o.sin')
- */
-int px_addbehandling(lua_State *L);
-
-/***
- * @method nil praxisd:adddiagnose(string patientid, string diagnose, string text)
- * Add a diagnose to a patient. To retrieve list of diagnose from a patient
- * see @see praxisd:getdiagnose().
- * NOTE: This function is only available on the server.
- * @param patientid A string containing the patientid.
- * @param diagnose The diagnose code.
- * @param text A text to store with the diagnose code. The string mat be up to 6
- * characters long. If longer it will be trunkated.
- * @example Create a new praxisd object and add a diagnose:
- * px = Praxisd.new('localhost', 10000)
- * px:adddiagnose('1234567890', 'C0001', 'o.dxt')
- */
-int px_adddiagnose(lua_State *L);
-
-/***
- * @method nil __gc()
- * Garbage collector. Closes connection and frees all allocated memory.
- */
-int px_gc(lua_State *L);
-
-void register_praxisd(lua_State *L);
-
-const struct luaL_Reg px_meths[] = {
- {"__gc", px_gc},
- {"cavelist", px_cavelist},
- {"behandliglist", px_behandlinglist},
- {"diagnoselist", px_diagnoselist},
- {"getcave", px_getcave},
- {"getbehandling", px_getbehandling},
- {"getdiagnose", px_getdiagnose},
- {"addcave", px_addcave},
- {"addbehandling", px_addbehandling},
- {"adddiagnose", px_adddiagnose},
- {NULL, NULL}
-};
-
-const struct luaL_reg px_funcs[] = {
- {"new", px_new},
- {NULL, NULL}
-};
-
-#endif/*__PRACRO_LUAPRAXISD_H__*/
diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc
deleted file mode 100644
index c8dfa6f..0000000
--- a/server/src/praxisd.cc
+++ /dev/null
@@ -1,1070 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * praxisd.cc
- *
- * Tue Apr 19 09:00:29 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "praxisd.h"
-
-#include "saxparser.h"
-
-static const char* str2err(std::string msg)
-{
- static char errbuf[1024];
- sprintf(errbuf, "%s", msg.c_str());
- return errbuf;
-}
-
-static std::string strtime(bool with_sec = true)
-{
- std::string ret;
-
- time_t epoch = time(NULL);
- struct tm t;
- localtime_r(&epoch, &t);
- char buf[32];
- snprintf(buf, sizeof(buf), "%04d-%02d-%02d",
- t.tm_year + 1900, t.tm_mon + 1, t.tm_mday);
- ret = buf;
-
- if(with_sec) {
- snprintf(buf, sizeof(buf), "%02d:%02d:%02d",
- t.tm_hour, t.tm_min, t.tm_sec);
- ret += " ";
- ret += buf;
- }
-
- return ret;
-}
-
-static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
-{
- std::string *str = (std::string*)userp;
- str->append((char*)buffer, size * nmemb);
- return size * nmemb;
-}
-
-Praxisd::Praxisd(std::string h, int port)
- throw(const char*)
-{
- ch = curl_easy_init();
- host = h;
-
- curl_easy_setopt(ch, CURLOPT_PORT, port);
- curl_easy_setopt(ch, CURLOPT_FAILONERROR, 0L/*1L*/);
- curl_easy_setopt(ch, CURLOPT_TIMEOUT, 150L);
- curl_easy_setopt(ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
- curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 15L);
- curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt(ch, CURLOPT_USERAGENT, "libpraxisd");
- curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_data);
- curl_easy_setopt(ch, CURLOPT_FILETIME, 1L);
- curl_easy_setopt(ch, CURLOPT_HEADER, 0L);
-}
-
-Praxisd::~Praxisd()
-{
- curl_easy_cleanup(ch);
-}
-
-// Get Journal By CPR
-std::string Praxisd::journal_get_by_cpr(std::string cpr)
- throw(const char*)
-{
- std::string journal;
-
- std::string uri = host + "/praxisd/1.0/journal/get_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, &journal);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(journal);
- }
-
- return journal;
-}
-
-time_t Praxisd::journal_last_changed(std::string cpr)
- throw(const char*)
-{
- std::string journal;
-
- std::string uri = host + "/praxisd/1.0/journal/get_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, &journal);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- time_t time;
- errornum = curl_easy_getinfo(ch, CURLINFO_FILETIME, &time);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(journal);
- }
-
- return time;
-}
-
-
-void Praxisd::journal_add(std::string cpr, std::string entry)
- throw(const char*)
-{
- std::string xml;
- xml += "<praxisd version=\"1.0\">\n";
- xml += " <journal cpr=\""+cpr+"\">"+entry+"</journal>\n";
- xml += "</praxisd>\n";
-
- curl_easy_setopt(ch, CURLOPT_POSTFIELDSIZE, (long)xml.length());
- curl_easy_setopt(ch, CURLOPT_POSTFIELDS, xml.c_str());
- curl_easy_setopt(ch, CURLOPT_POST, 1L);
-
- struct curl_slist *slist = NULL;
- // Unset 'Expect' header, set by CURLOPT_POSTFIELDS
- slist = curl_slist_append(slist, "Expect:");
- slist = curl_slist_append(slist, "Content-Type: text/xml");
- // slist = curl_slist_append(slist, "Connection: keep-alive");
- curl_easy_setopt(ch, CURLOPT_HTTPHEADER, slist);
-
- std::string uri = host + "/praxisd/1.0/journal/add";
- curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
-
- std::string reply;
- curl_easy_setopt(ch, CURLOPT_WRITEDATA, &reply);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(reply);
- }
-}
-
-void Praxisd::add_sogeord(std::string cpr, std::string sogeord,
- std::string sogetxt)
- throw(const char*)
-{
-
- std::string datestr = strtime(false);
-
- std::string xml;
- xml += "<praxisd version=\"1.0\">\n";
- xml += " <addsogeord cpr=\""+cpr+"\">\n";
- xml += " <sogeord sogenr=\""+sogeord+"\" date=\""+datestr+"\">"+
- sogetxt+"</sogeord>\n";
- xml += " </addsogeord>\n";
- xml += "</praxisd>\n";
-
- curl_easy_setopt(ch, CURLOPT_POSTFIELDSIZE, (long)xml.length());
- curl_easy_setopt(ch, CURLOPT_POSTFIELDS, xml.c_str());
- curl_easy_setopt(ch, CURLOPT_POST, 1L);
-
- struct curl_slist *slist = NULL;
- // Unset 'Expect' header, set by CURLOPT_POSTFIELDS
- slist = curl_slist_append(slist, "Expect:");
- slist = curl_slist_append(slist, "Content-Type: text/xml");
- slist = curl_slist_append(slist, "Connection: keep-alive");
- curl_easy_setopt(ch, CURLOPT_HTTPHEADER, slist);
-
- std::string uri = host + "/praxisd/1.0/patient/add_sogeord";
- curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
-
- std::string reply;
- curl_easy_setopt(ch, CURLOPT_WRITEDATA, &reply);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(reply);
- }
-}
-
-#define DOTAG(x) if(name == #x) str = &p.x;
-
-class PatientParser : public SAXParser {
-public:
- PatientParser(Praxisd::patient_t &_p) : p(_p) { str = NULL; }
-
- void characterData(std::string &data)
- {
- if(str) *str += data;
- }
-
- void startTag(std::string name, attributes_t &attr)
- {
- DOTAG(fornavne);
- DOTAG(efternavn);
- DOTAG(stilling);
- DOTAG(gade);
- DOTAG(by);
- DOTAG(telefonnumre);
- DOTAG(sikringsgr);
- DOTAG(amtsnr);
- DOTAG(sygekontor);
- DOTAG(henvnr);
- DOTAG(frilinie1);
- DOTAG(frilinie2);
- DOTAG(frilinie3);
- DOTAG(frilinie4);
- DOTAG(frilinie5);
- DOTAG(ydernr);
- DOTAG(created);
- DOTAG(donottouch);
- DOTAG(visus);
- DOTAG(labkort);
- DOTAG(medkort);
- DOTAG(jlock);
- DOTAG(unknown1);
- DOTAG(henvdato);
- DOTAG(aarhund);
- DOTAG(fakturadato);
- DOTAG(fakturabelob);
- DOTAG(betaldato);
- DOTAG(betalbelob);
- DOTAG(jdato);
- 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("sogedato") != attr.end()) s.sogedato = attr["sogedato"];
- p.sogeord.push_back(s);
- str = &p.sogeord[p.sogeord.size() - 1].sogetxt;
- }
- }
-
- void endTag(std::string)
- {
- str = NULL;
- }
-
-private:
- std::string *str;
- Praxisd::patient_t &p;
-};
-
-Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr)
- throw(const char*)
-{
- patient_t p;
-
- std::string xml;
-
- std::string uri = host + "/praxisd/1.0/patient/get_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) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(xml);
- }
-
- PatientParser parser(p);
- parser.parse(xml.data(), xml.length());
-
- return p;
-}
-
-std::string Praxisd::get_sogenr(std::string sogenr)
- throw(const char*)
-{
- std::string xml;
-
- std::string uri = host + "/praxisd/1.0/diverse/get_all_by_sogenr?sogenr=" +
- sogenr;
- 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) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(xml);
- }
-
- return xml;
-}
-
-#define DODIVTAG(x) if(name == #x) str = &div[div.size() - 1].x;
-
-class AdresseParser : public SAXParser {
-public:
- AdresseParser(std::vector<Praxisd::adresse_t> &al) : div(al) { str = NULL; }
- void characterData(std::string &data) { if(str) *str += data; }
- void endTag(std::string) { str = NULL; }
- void startTag(std::string name, attributes_t &attr)
- {
- if(name == "div_adresse") {
- Praxisd::adresse_t a;
- if(attr.find("sogenr") != attr.end()) a.sogenr = attr["sogenr"];
- div.push_back(a);
- }
- DODIVTAG(edi_adresse);
- DODIVTAG(navn);
- DODIVTAG(att);
- DODIVTAG(gade);
- DODIVTAG(by);
- DODIVTAG(tlf);
- DODIVTAG(fax);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::adresse_t> &div;
-};
-
-std::vector<Praxisd::adresse_t> Praxisd::diverse_get_adresse(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::adresse_t> lst;
- std::string xml = get_sogenr("A"+sogenr);
- AdresseParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class BehandlingParser : public SAXParser {
-public:
- BehandlingParser(std::vector<Praxisd::behandling_t> &d) : div(d)
- { 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 == "div_behandling") {
- Praxisd::behandling_t a;
- if(attr.find("sogenr") != attr.end()) a.sogenr = attr["sogenr"];
- div.push_back(a);
- }
- DODIVTAG(kode);
- DODIVTAG(behandling);
- DODIVTAG(bemaerkning);
- DODIVTAG(udregning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::behandling_t> &div;
-};
-
-std::vector<Praxisd::behandling_t>
-Praxisd::diverse_get_behandling(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::behandling_t> lst;
- std::string xml = get_sogenr("B"+sogenr);
- BehandlingParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class CaveParser : public SAXParser {
-public:
- CaveParser(std::vector<Praxisd::cave_t> &d) : div(d)
- { 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 == "div_cave") {
- Praxisd::cave_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(cave);
- DODIVTAG(bemaerkning1);
- DODIVTAG(bemaerkning2);
- DODIVTAG(bemaerkning3);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::cave_t> &div;
-};
-
-std::vector<Praxisd::cave_t> Praxisd::diverse_get_cave(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::cave_t> lst;
- std::string xml = get_sogenr("C"+sogenr);
- CaveParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class DiagnoseParser : public SAXParser {
-public:
- DiagnoseParser(std::vector<Praxisd::diagnose_t> &d) : div(d)
- { 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 == "div_diagnose") {
- Praxisd::diagnose_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(kode);
- DODIVTAG(diagnose);
- DODIVTAG(bemaerkning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::diagnose_t> &div;
-};
-
-std::vector<Praxisd::diagnose_t>
-Praxisd::diverse_get_diagnose(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::diagnose_t> lst;
- std::string xml = get_sogenr("D"+sogenr);
- DiagnoseParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class FraseParser : public SAXParser {
-public:
- FraseParser(std::vector<Praxisd::frase_t> &d) : div(d)
- { 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 == "div_frase") {
- Praxisd::frase_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(frase1);
- DODIVTAG(frase2);
- DODIVTAG(frase3);
- DODIVTAG(frase4);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::frase_t> &div;
-};
-
-std::vector<Praxisd::frase_t> Praxisd::diverse_get_frase(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::frase_t> lst;
- std::string xml = get_sogenr("F"+sogenr);
- FraseParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class GrafikParser : public SAXParser {
-public:
- GrafikParser(std::vector<Praxisd::grafik_t> &d) : div(d)
- { 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 == "div_grafik") {
- Praxisd::grafik_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(navn);
- DODIVTAG(bemaerkning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::grafik_t> &div;
-};
-
-std::vector<Praxisd::grafik_t> Praxisd::diverse_get_grafik(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::grafik_t> lst;
- std::string xml = get_sogenr("G"+sogenr);
- GrafikParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class IndholdstofParser : public SAXParser {
-public:
- IndholdstofParser(std::vector<Praxisd::indholdstof_t> &d) : div(d)
- { 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 == "div_indholdstof") {
- Praxisd::indholdstof_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(indholdstof);
- DODIVTAG(form1);
- DODIVTAG(form2);
- DODIVTAG(form3);
- DODIVTAG(form4);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::indholdstof_t> &div;
-};
-
-std::vector<Praxisd::indholdstof_t>
-Praxisd::diverse_get_indholdstof(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::indholdstof_t> lst;
- std::string xml = get_sogenr("I"+sogenr);
- IndholdstofParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class KlageParser : public SAXParser {
-public:
- KlageParser(std::vector<Praxisd::klage_t> &d) : div(d)
- { 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 == "div_klage") {
- Praxisd::klage_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(kode);
- DODIVTAG(klage);
- DODIVTAG(bemaerkning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::klage_t> &div;
-};
-
-std::vector<Praxisd::klage_t>
-Praxisd::diverse_get_klage(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::klage_t> lst;
- std::string xml = get_sogenr("K"+sogenr);
- KlageParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class OversigtParser : public SAXParser {
-public:
- OversigtParser(std::vector<Praxisd::oversigt_t> &d) : div(d)
- { 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 == "div_oversigt") {
- Praxisd::oversigt_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(navn);
- DODIVTAG(bemaerkning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::oversigt_t> &div;
-};
-
-std::vector<Praxisd::oversigt_t>
-Praxisd::diverse_get_oversigt(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::oversigt_t> lst;
- std::string xml = get_sogenr("O"+sogenr);
- OversigtParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class PostnummerParser : public SAXParser {
-public:
- PostnummerParser(std::vector<Praxisd::postnummer_t> &d) : div(d)
- { 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 == "div_postnummer") {
- Praxisd::postnummer_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(postnummer);
- DODIVTAG(by_gade);
- DODIVTAG(kbh);
- DODIVTAG(amtsnr);
- DODIVTAG(kommunenr);
- DODIVTAG(regionnavn);
- DODIVTAG(kommunenavn);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::postnummer_t> &div;
-};
-
-std::vector<Praxisd::postnummer_t>
-Praxisd::diverse_get_postnummer(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::postnummer_t> lst;
- std::string xml = get_sogenr("P"+sogenr);
- PostnummerParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class TypeParser : public SAXParser {
-public:
- TypeParser(std::vector<Praxisd::type_t> &d) : div(d)
- { 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 == "div_type") {
- Praxisd::type_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(type);
- DODIVTAG(bemaerkning1);
- DODIVTAG(bemaerkning2);
- DODIVTAG(bemaerkning3);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::type_t> &div;
-};
-
-std::vector<Praxisd::type_t>
-Praxisd::diverse_get_type(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::type_t> lst;
- std::string xml = get_sogenr("T"+sogenr);
- TypeParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class UndersoegelseParser : public SAXParser {
-public:
- UndersoegelseParser(std::vector<Praxisd::undersoegelse_t> &d) : div(d)
- { 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 == "div_undersoegelse") {
- Praxisd::undersoegelse_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(kode);
- DODIVTAG(undersoegelse);
- DODIVTAG(udregning);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::undersoegelse_t> &div;
-};
-
-std::vector<Praxisd::undersoegelse_t>
-Praxisd::diverse_get_undersoegelse(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::undersoegelse_t> lst;
- std::string xml = get_sogenr("U"+sogenr);
- UndersoegelseParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-class YdelseParser : public SAXParser {
-public:
- YdelseParser(std::vector<Praxisd::ydelse_t> &d) : div(d)
- { 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 == "div_ydelse") {
- Praxisd::ydelse_t d;
- if(attr.find("sogenr") != attr.end()) d.sogenr = attr["sogenr"];
- div.push_back(d);
- }
- DODIVTAG(nr);
- DODIVTAG(gr1);
- DODIVTAG(gr2);
- DODIVTAG(privat);
- DODIVTAG(journal1);
- DODIVTAG(journal2);
- DODIVTAG(moms);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::ydelse_t> &div;
-};
-
-std::vector<Praxisd::ydelse_t>
-Praxisd::diverse_get_ydelse(std::string sogenr)
- throw(const char*)
-{
- std::vector<Praxisd::ydelse_t> lst;
- std::string xml = get_sogenr("Y"+sogenr);
- YdelseParser parser(lst);
- parser.parse(xml.data(), xml.length());
- return lst;
-}
-
-
-class AftaleParser : public SAXParser {
-public:
- AftaleParser(std::vector<Praxisd::aftale_t> &a) : div(a) { str = NULL; }
- void characterData(std::string &data) { if(str) *str += data; }
- void endTag(std::string) { str = NULL; }
- void startTag(std::string name, attributes_t &attr)
- {
- if(name == "aftale") {
- Praxisd::aftale_t a;
- if(attr.find("date") != attr.end()) a.date = attr["date"];
- if(attr.find("calendar") != attr.end()) a.calendar = attr["calendar"];
- div.push_back(a);
- }
- DODIVTAG(cpr);
- DODIVTAG(cref);
- DODIVTAG(cmrk);
- DODIVTAG(ctxt);
- DODIVTAG(cres);
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::aftale_t> &div;
-};
-static std::string i2s(int i) {
- char buf[32];
- snprintf(buf, sizeof(buf), "%d", i);
- return buf;
-}
-std::vector<Praxisd::aftale_t>
-Praxisd::aftale_get_all_by_date_and_calendar(int cal,
- int year, int month, int day)
- throw(const char*)
-{
- std::vector<Praxisd::aftale_t> aft;
-
- std::string xml;
-
- std::string uri = host + "/praxisd/1.0/aftale/get_all_by_date_and_calendar?"
- "calendar=" + i2s(cal) + "&year=" + i2s(year) + "&month=" + i2s(month) +
- "&day=" + i2s(day);
- 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) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(xml);
- }
-
- AftaleParser parser(aft);
- parser.parse(xml.data(), xml.length());
-
- return aft;
-}
-
-std::vector<Praxisd::aftale_t> Praxisd::aftale_get_all_by_cpr(std::string cpr)
- throw(const char*)
-{
- std::vector<Praxisd::aftale_t> aft;
-
- std::string xml;
-
- std::string uri = host + "/praxisd/1.0/aftale/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) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(xml);
- }
-
- AftaleParser parser(aft);
- parser.parse(xml.data(), xml.length());
-
- return aft;
-}
-
-bool Praxisd::authenticate(std::string user, std::string pass)
- throw(const char*)
-{
- std::string uri = host + "/praxisd/1.0/authenticate?user=" + user + "&pass=" +
- pass;
- curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
-
- curl_easy_setopt(ch, CURLOPT_POST, 0L);
- curl_easy_setopt(ch, CURLOPT_WRITEDATA, NULL);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
- if(code == 401) return false;
- if(code == 200) return true;
-
- return false; // Don't interpret an error as successful login.
-}
-
-class DokMenuParser : public SAXParser {
-public:
- DokMenuParser(std::vector<Praxisd::dokmenu_t> &a) : div(a) { str = NULL; }
- void characterData(std::string &data) { if(str) *str += data; }
- void endTag(std::string) { str = NULL; }
- void startTag(std::string name, attributes_t &attr)
- {
- if(name == "dokmenu") {
- Praxisd::dokmenu_t a;
- if(attr.find("date") != attr.end()) a.date = attr["date"];
- if(attr.find("calendar") != attr.end()) a.date = attr["calendar"];
- div.push_back(a);
- }
-
- DODIVTAG(group);
- DODIVTAG(subject);
-
- DODIVTAG(filename);
- if(name == "filename") {
- div[div.size() - 1].filesize = atoi(attr["filesize"].c_str());
- div[div.size() - 1].date = attr["date"];
- }
- }
-
-private:
- std::string *str;
- std::vector<Praxisd::dokmenu_t> &div;
-};
-
-std::vector<Praxisd::dokmenu_t> Praxisd::dokmenu_get_all_by_cpr(std::string cpr)
- throw(const char*)
-{
- std::vector<Praxisd::dokmenu_t> dokmenu;
- std::string xml;
-
- std::string uri = host + "/praxisd/1.0/dokmenu/get_all_by_cpr?cpr=" + cpr;
- curl_easy_setopt(ch, CURLOPT_URL, uri.c_str());
-
- curl_easy_setopt(ch, CURLOPT_POST, 0L);
- curl_easy_setopt(ch, CURLOPT_WRITEDATA, &xml);
-
- CURLcode errornum = curl_easy_perform(ch);
- if(errornum != CURLE_OK) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(xml);
- }
-
- 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)
- throw(const char*)
-{
- 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) {
- throw curl_easy_strerror(errornum);
- }
-
- long code = 0;
- errornum = curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &code);
- if(code != 200) {
- throw str2err(data);
- }
-
- return data;
-}
-
-#ifdef TEST_PRAXISD
-//deps: saxparser.cc debug.cc log.cc mutex.cc
-//cflags: -I.. $(CURL_CFLAGS) $(EXPAT_CFLAGS) $(PTHREAD_CFLAGS)
-//libs: $(CURL_LIBS) $(EXPAT_LIBS) $(PTHREAD_LIBS)
-#include "test.h"
-
-#define NL "\r\n"
-#define CPR "1505050505"
-
-TEST_BEGIN;
-
-Praxisd p("http://localhost", 10000);
-
-std::string j = p.journal_get_by_cpr(CPR);
-TEST_NOTEQUAL(j, "", "Did we get a journal?");
-
-std::string more = "less is more... much much more.";
-p.journal_add(CPR, more);
-
-time_t changed = p.journal_last_changed(CPR);
-TEST_EQUAL_INT(changed, time(NULL), "Changed just now?");
-
-Praxisd::patient_t patient = p.patient_get_by_cpr(CPR);
-TEST_EQUAL_STR(patient.fornavne, "Kristian", "Who are you?");
-
-/*
-std::string exp = j + more + NL;
-std::string j2 = p.journal_get_by_cpr(CPR);
-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");
-
-{
- std::vector<Praxisd::cave_t> cave = p.diverse_get_cave("A0001");
- TEST_EQUAL_INT(cave.size(), 1, "Precicely one result.");
- TEST_EQUAL_STR(cave[0].cave, "AZOPT", "The correct one?");
-}
-
-{
- std::vector<Praxisd::cave_t> cave = p.diverse_get_cave("");
- TEST_EQUAL_INT(cave.size(), 25, "Get them all.");
-}
-
-{
- std::vector<Praxisd::dokmenu_t> dm = p.dokmenu_get_all_by_cpr(CPR);
- TEST_NOTEQUAL_INT(dm.size(), 0, "Empty result?");
-
- std::string file = p.dokmenu_get_by_cpr_and_name(CPR, dm[0].filename);
- TEST_EQUAL_INT(file.size(), dm[0].filesize, "Size matters?");
-}
-
-TEST_END;
-
-#endif/*TEST_PRAXISD*/
diff --git a/server/src/praxisd.h b/server/src/praxisd.h
deleted file mode 100644
index 785cba1..0000000
--- a/server/src/praxisd.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * praxisd.h
- *
- * Tue Apr 19 09:00:29 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#ifndef __PRACRO_PRAXISD_H__
-#define __PRACRO_PRAXISD_H__
-
-#include <string>
-#include <vector>
-
-#include <curl/curl.h>
-
-#include <time.h>
-
-class Praxisd {
-public:
- Praxisd(std::string host, int port)
- throw(const char*);
- ~Praxisd();
-
- time_t journal_last_changed(std::string cpr)
- throw(const char*);
-
- // Get Journal By CPR
- std::string journal_get_by_cpr(std::string cpr)
- throw(const char*);
-
- // Get Patient By CPR
- typedef struct {
- std::string sogenr;
- std::string sogedato;
- std::string sogetxt;
- } sogeord_t;
-
- typedef struct {
- std::string cpr;
- std::string fornavne;
- std::string efternavn;
- std::string stilling;
- std::string gade;
- std::string by;
- std::string telefonnumre;
- std::string sikringsgr;
- std::string amtsnr;
- std::string sygekontor;
- std::string henvnr;
- std::string frilinie1;
- std::string frilinie2;
- std::string frilinie3;
- std::string frilinie4;
- std::string frilinie5;
- std::vector<sogeord_t> sogeord;
- std::string ydernr;
- std::string created;
- std::string donottouch;
- std::string visus;
- std::string labkort;
- std::string medkort;
- std::string jlock;
- std::string unknown1;
- std::string henvdato;
- std::string aarhund;
- std::string fakturadato;
- std::string fakturabelob;
- std::string betaldato;
- std::string betalbelob;
- std::string jdato;
- std::string unknown250;
- std::string unknown251;
- std::string jtime;
- } patient_t;
- patient_t patient_get_by_cpr(std::string cpr)
- throw(const char*);
-
- // Get Diverse From Sogenr
- typedef struct {
- std::string sogenr;
- std::string edi_adresse;
- std::string navn;
- std::string att;
- std::string gade;
- std::string by;
- std::string tlf;
- std::string fax;
- } adresse_t;
- std::vector<adresse_t> diverse_get_adresse(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string kode;
- std::string behandling;
- std::string bemaerkning;
- std::string udregning;
- } behandling_t;
- std::vector<behandling_t> diverse_get_behandling(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string cave;
- std::string bemaerkning1;
- std::string bemaerkning2;
- std::string bemaerkning3;
- } cave_t;
- std::vector<cave_t> diverse_get_cave(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string kode;
- std::string diagnose;
- std::string bemaerkning;
- } diagnose_t;
- std::vector<diagnose_t> diverse_get_diagnose(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string frase1;
- std::string frase2;
- std::string frase3;
- std::string frase4;
- } frase_t;
- std::vector<frase_t> diverse_get_frase(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string navn;
- std::string bemaerkning;
- } grafik_t;
- std::vector<grafik_t> diverse_get_grafik(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string indholdstof;
- std::string form1;
- std::string form2;
- std::string form3;
- std::string form4;
- } indholdstof_t;
- std::vector<indholdstof_t> diverse_get_indholdstof(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string kode;
- std::string klage;
- std::string bemaerkning;
- } klage_t;
- std::vector<klage_t> diverse_get_klage(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string navn;
- std::string bemaerkning;
- } oversigt_t;
- std::vector<oversigt_t> diverse_get_oversigt(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string postnummer;
- std::string by_gade;
- std::string kbh;
- std::string amtsnr;
- std::string kommunenr;
- std::string regionnavn;
- std::string kommunenavn;
- } postnummer_t;
- std::vector<postnummer_t> diverse_get_postnummer(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string type;
- std::string bemaerkning1;
- std::string bemaerkning2;
- std::string bemaerkning3;
- std::string recept;
- } type_t;
- std::vector<type_t> diverse_get_type(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string kode;
- std::string undersoegelse;
- std::string bemaerkning;
- std::string udregning;
- } undersoegelse_t;
- std::vector<undersoegelse_t> diverse_get_undersoegelse(std::string sogenr)
- throw(const char*);
-
- typedef struct {
- std::string sogenr;
- std::string nr;
- std::string navn;
- std::string gr1;
- std::string gr2;
- std::string privat;
- std::string journal1;
- std::string journal2;
- std::string moms;
- } ydelse_t;
- std::vector<ydelse_t> diverse_get_ydelse(std::string sogenr)
- throw(const char*);
-
-
- // Get Aftale All by Date and Calendar
- typedef struct {
- std::string date;
- std::string calendar;
- std::string cpr;
- std::string cref;
- std::string cmrk;
- std::string ctxt;
- std::string cres;
- } aftale_t;
- std::vector<aftale_t> aftale_get_all_by_date_and_calendar(int cal, int year,
- int month, int day)
- throw(const char*);
-
- // Get Aftale All by CPR
- std::vector<aftale_t> aftale_get_all_by_cpr(std::string cpr)
- throw(const char*);
-
- // Authenticate
- bool authenticate(std::string user, std::string pass)
- throw(const char*);
-
-#if 0
- // Get Name by UserID
- std::string user_get_name_by_id(std::string user)
- throw(const char*);
-#endif
-
- // Get All Dokmenu by CPR
- typedef struct {
- std::string group;
- std::string subject;
- std::string filename;
- size_t filesize;
- std::string date;
- } dokmenu_t;
- std::vector<dokmenu_t> dokmenu_get_all_by_cpr(std::string cpr)
- throw(const char*);
-
- // Get Dokmenu by Name and CPR
- std::string dokmenu_get_by_cpr_and_name(std::string cpr, std::string name)
- throw(const char*);
-
- // POST:
- // Add To Journal
- void journal_add(std::string cpr, std::string entry)
- throw(const char*);
-
- // Update Patient
-
- // Add Sogeord to Patient
- void add_sogeord(std::string cpr, std::string sogeord, std::string sogetxt)
- throw(const char*);
-
- // Update Aftale
- // Add Aftale
- // Delete Aftale
- // Add File to Dokmenu
- // Delete File from Dokmenu
-
-private:
- std::string get_sogenr(std::string sogenr)
- throw(const char*);
- CURL *ch;
- std::string host;
-};
-
-#endif/*__PRACRO_PRAXISD_H__*/