From b730250bdd6cd6db4204ea14ba82f2a50e9dcda8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 12 Mar 2014 14:18:42 +0100 Subject: Switch to new praxisdif. --- client/luapraxisd.cc | 293 --------------------------------------------------- 1 file changed, 293 deletions(-) delete mode 100644 client/luapraxisd.cc (limited to 'client/luapraxisd.cc') diff --git a/client/luapraxisd.cc b/client/luapraxisd.cc deleted file mode 100644 index 3b8e430..0000000 --- a/client/luapraxisd.cc +++ /dev/null @@ -1,293 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * luapraxisd.cc - * - * Thu May 5 11:16:20 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 "../server/src/luapraxisd.h" - -#include "praxisd.h" - -#include -#include - -#include "debug.h" - -#define luaL_checkbool(L, i) \ - (lua_isboolean(L,i) ? lua_toboolean(L,i) : luaL_checkint(L,i)) - -typedef struct px_userdata { - PraxisdSync *px; -} px_userdata; - -int px_addcave(lua_State *L) -{ - lua_pushstring(L, "Add cave not implemented on client."); - lua_error(L); - return 0; -} - -int px_addbehandling(lua_State *L) -{ - lua_pushstring(L, "Add behandling not implemented on client."); - lua_error(L); - return 0; -} - -int px_adddiagnose(lua_State *L) -{ - lua_pushstring(L, "Add diagnose not implemented on client."); - lua_error(L); - return 0; -} - -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); - - QVector cavelist; - - Patient patient = pxu->px->patient_get_by_cpr(cpr); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - 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); - if(cave.size() == 1) { - if(cave[0].cave != "ANDET") cavelist.push_back(cave[0].cave); - else cavelist.push_back(i->sogetxt); - } - i++; - } - - lua_createtable(L, 0, cavelist.size()); - int top = lua_gettop(L); - - for(int i = 0; i < cavelist.size(); i++) { - QString c = cavelist[i]; - DEBUG(cavelist, "CAVE '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, i); - } - - return 1; -} - -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); - - QVector behandlinglist; - - Patient patient = pxu->px->patient_get_by_cpr(cpr); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - QVector::iterator i = patient.sogeord.begin(); - while(i != patient.sogeord.end()) { - QString behandlingsogeord = i->sogenr;//.mid(1, i->sogenr.size() - 1); - QVector behandling = pxu->px->diverse_get_behandling(behandlingsogeord); - if(behandling.size() == 1) behandlinglist.push_back(i->sogetxt); - i++; - } - - lua_createtable(L, 0, behandlinglist.size()); - int top = lua_gettop(L); - - for(int i = 0; i < behandlinglist.size(); i++) { - QString c = behandlinglist[i]; - DEBUG(behandlinglist, "BEHANDLING '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, i); - } - - return 1; -} - -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); - - QVector diagnoselist; - - Patient patient = pxu->px->patient_get_by_cpr(cpr); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - QVector::iterator i = patient.sogeord.begin(); - while(i != patient.sogeord.end()) { - QString diagnosesogeord = i->sogenr;//.mid(1, i->sogenr.size() - 1); - QVector diagnose = pxu->px->diverse_get_diagnose(diagnosesogeord); - if(diagnose.size() == 1) diagnoselist.push_back(i->sogetxt); - i++; - } - - lua_createtable(L, 0, diagnoselist.size()); - int top = lua_gettop(L); - - for(int i = 0; i < diagnoselist.size(); i++) { - QString c = diagnoselist[i]; - DEBUG(diagnoselist, "DIAGNOSE '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, 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"); - - QVector cavelist = pxu->px->diverse_get_cave("C"); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - - lua_createtable(L, 0, cavelist.size()); - int top = lua_gettop(L); - - for(size_t i = 0; i < (size_t)cavelist.size(); i++) { - QString c = cavelist[i].cave; - DEBUG(cavelist, "CAVE '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, 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"); - - QVector behandlinglist = pxu->px->diverse_get_behandling("C"); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - - lua_createtable(L, 0, behandlinglist.size()); - int top = lua_gettop(L); - - for(size_t i = 0; i < (size_t)behandlinglist.size(); i++) { - QString c = behandlinglist[i].behandling; - DEBUG(behandlinglist, "BEHANDLING '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, 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"); - - QVector diagnoselist = pxu->px->diverse_get_diagnose("C"); - if(pxu->px->hasError()) { - lua_pushstring(L, pxu->px->errorString().toStdString().c_str()); - lua_error(L); - return 1; - } - - lua_createtable(L, 0, diagnoselist.size()); - int top = lua_gettop(L); - - for(size_t i = 0; i < (size_t)diagnoselist.size(); i++) { - QString c = diagnoselist[i].diagnose; - DEBUG(diagnoselist, "DIAGNOSE '%s'\n", c.toStdString().c_str()); - lua_pushstring(L, c.toStdString().c_str()); - lua_rawseti(L, top, i); - } - - return 1; -} - -int px_new(lua_State *L) -{ - const char *host = luaL_checkstring(L, 1); - int port = luaL_checknumber(L, 2); - - px_userdata *pxu; - pxu = (px_userdata *)lua_newuserdata(L, sizeof(px_userdata)); - - luaL_getmetatable(L, "Praxisd"); - lua_setmetatable(L, -2); - - pxu->px = new PraxisdSync(host, port); - - 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); -} -- cgit v1.2.3