summaryrefslogtreecommitdiff
path: root/server/src/praxisd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/praxisd.cc')
-rw-r--r--server/src/praxisd.cc62
1 files changed, 44 insertions, 18 deletions
diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc
index 3ccdf0d..8a5b6d6 100644
--- a/server/src/praxisd.cc
+++ b/server/src/praxisd.cc
@@ -59,6 +59,7 @@ static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
}
Praxisd::Praxisd(std::string h, int port)
+ throw(const char*)
{
ch = curl_easy_init();
host = h;
@@ -82,6 +83,7 @@ Praxisd::~Praxisd()
// Get Journal By CPR
std::string Praxisd::journal_get_by_cpr(std::string cpr)
+ throw(const char*)
{
std::string journal;
@@ -93,16 +95,14 @@ std::string Praxisd::journal_get_by_cpr(std::string cpr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
- time_t time;
- errornum = curl_easy_getinfo(ch, CURLINFO_FILETIME, &time);
-
return journal;
}
time_t Praxisd::journal_last_changed(std::string cpr)
+ throw(const char*)
{
std::string journal;
@@ -114,17 +114,21 @@ time_t Praxisd::journal_last_changed(std::string cpr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ 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);
+ }
return time;
}
void Praxisd::journal_add(std::string cpr, std::string entry)
+ throw(const char*)
{
std::string xml;
xml += "<praxisd version=\"1.0\">\n";
@@ -150,12 +154,13 @@ void Praxisd::journal_add(std::string cpr, std::string entry)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch: %d %s\n", errornum, reply.c_str());
+ throw curl_easy_strerror(errornum);
}
}
void Praxisd::add_sogeord(std::string cpr, std::string sogeord,
std::string sogetxt)
+ throw(const char*)
{
std::string datestr = strtime(false);
@@ -187,7 +192,7 @@ void Praxisd::add_sogeord(std::string cpr, std::string sogeord,
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch: %d %s\n", errornum, reply.c_str());
+ throw curl_easy_strerror(errornum);
}
}
@@ -259,6 +264,7 @@ private:
};
Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr)
+ throw(const char*)
{
patient_t p;
@@ -272,11 +278,9 @@ Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
- // printf("Get Patient: %d %s\n", xml.length(), xml.c_str()); fflush(stdout);
-
PatientParser parser(p);
parser.parse(xml.data(), xml.length());
@@ -284,6 +288,7 @@ Praxisd::patient_t Praxisd::patient_get_by_cpr(std::string cpr)
}
std::string Praxisd::get_sogenr(std::string sogenr)
+ throw(const char*)
{
std::string xml;
@@ -296,7 +301,7 @@ std::string Praxisd::get_sogenr(std::string sogenr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
return xml;
@@ -331,6 +336,7 @@ private:
};
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);
@@ -365,6 +371,7 @@ private:
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);
@@ -398,6 +405,7 @@ private:
};
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);
@@ -431,6 +439,7 @@ private:
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);
@@ -464,6 +473,7 @@ private:
};
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);
@@ -495,6 +505,7 @@ private:
};
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);
@@ -530,6 +541,7 @@ private:
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);
@@ -563,6 +575,7 @@ private:
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);
@@ -595,6 +608,7 @@ private:
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);
@@ -632,6 +646,7 @@ private:
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);
@@ -666,6 +681,7 @@ private:
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);
@@ -699,6 +715,7 @@ private:
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);
@@ -736,6 +753,7 @@ private:
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);
@@ -775,8 +793,9 @@ static std::string i2s(int i) {
return buf;
}
std::vector<Praxisd::aftale_t>
-Praxisd::aftale_get_all_by_date_and_calendar(int cal, int year, int month,
- int day)
+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;
@@ -792,7 +811,7 @@ Praxisd::aftale_get_all_by_date_and_calendar(int cal, int year, int month,
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
AftaleParser parser(aft);
@@ -802,6 +821,7 @@ Praxisd::aftale_get_all_by_date_and_calendar(int cal, int year, int month,
}
std::vector<Praxisd::aftale_t> Praxisd::aftale_get_all_by_cpr(std::string cpr)
+ throw(const char*)
{
std::vector<Praxisd::aftale_t> aft;
@@ -815,7 +835,7 @@ std::vector<Praxisd::aftale_t> Praxisd::aftale_get_all_by_cpr(std::string cpr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
AftaleParser parser(aft);
@@ -825,6 +845,7 @@ std::vector<Praxisd::aftale_t> Praxisd::aftale_get_all_by_cpr(std::string cpr)
}
bool Praxisd::authenticate(std::string user, std::string pass)
+ throw(const char*)
{
std::string uri = host + "/praxisd/1.0/authenticate?user=" + user + "&pass=" +
pass;
@@ -835,11 +856,14 @@ bool Praxisd::authenticate(std::string user, std::string pass)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- return false;
+ 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;
@@ -876,6 +900,7 @@ private:
};
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;
@@ -888,7 +913,7 @@ std::vector<Praxisd::dokmenu_t> Praxisd::dokmenu_get_all_by_cpr(std::string cpr)
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
DokMenuParser parser(dokmenu);
@@ -900,6 +925,7 @@ std::vector<Praxisd::dokmenu_t> Praxisd::dokmenu_get_all_by_cpr(std::string cpr)
// 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;
@@ -912,7 +938,7 @@ std::string Praxisd::dokmenu_get_by_cpr_and_name(std::string cpr,
CURLcode errornum = curl_easy_perform(ch);
if(errornum != CURLE_OK) {
- printf("Ouch %d\n", errornum);
+ throw curl_easy_strerror(errornum);
}
return data;