summaryrefslogtreecommitdiff
path: root/server/src/pracrodaopgsql.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/pracrodaopgsql.cc')
-rw-r--r--server/src/pracrodaopgsql.cc34
1 files changed, 17 insertions, 17 deletions
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc
index ee544df..1c96035 100644
--- a/server/src/pracrodaopgsql.cc
+++ b/server/src/pracrodaopgsql.cc
@@ -85,19 +85,18 @@ PracroDAOPgsql::~PracroDAOPgsql()
}
}
-void PracroDAOPgsql::commitTransaction(std::string user,
- std::string patientid,
+void PracroDAOPgsql::commitTransaction(Transaction &transaction,
+ Commit &commit,
Macro &_macro,
- Fields &fields,
time_t now)
{
DEBUG(db, "(%s, %s, %s, <%u fields>, %ld)\n",
- user.c_str(), patientid.c_str(),
+ transaction.user.c_str(), transaction.cpr.c_str(),
_macro.attributes["name"].c_str(),
- fields.size(), now);
+ commit.fields.size(), now);
if(!conn) DEBUG(db, "No pgsql connection\n");
- if(fields.size() == 0) return;
+ if(commit.fields.size() == 0) return;
std::string version = _macro.attributes["version"];
std::string macro = _macro.attributes["name"];
@@ -105,27 +104,28 @@ void PracroDAOPgsql::commitTransaction(std::string user,
std::string ts;
try {
- ts = "INSERT INTO transactions (uid, patientid, macro, version,"
+ ts = "INSERT INTO transactions (uid, patientid, template, macro, version,"
" \"timestamp\", \"user\") VALUES ("
" nextval('trseq'), "
- " '" + W->esc(patientid) + "', "
+ " '" + W->esc(transaction.cpr) + "', "
+ " '" + W->esc(commit.templ) + "', "
" '" + W->esc(macro) + "', "
" '" + W->esc(version) + "', "
" '" + W->esc(timestamp.str()) + "', "
- " '" + W->esc(user) + "' "
+ " '" + W->esc(transaction.user) + "' "
");"
;
DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W->exec(ts);
statements += ts + "\n";
- if(fields.size() > 0) {
+ if(commit.fields.size() > 0) {
// field table lookup
ts = "SELECT name FROM fieldnames WHERE name IN ( ";
- std::map< std::string, std::string >::iterator i = fields.begin();
+ std::map< std::string, std::string >::iterator i = commit.fields.begin();
ts += "'" + W->esc(i->first) + "'";
i++;
- while(i != fields.end()) {
+ while(i != commit.fields.end()) {
ts += ", '" + W->esc(i->first) + "'";
i++;
}
@@ -135,26 +135,26 @@ void PracroDAOPgsql::commitTransaction(std::string user,
// statements += ts + "\n";
DEBUG(db, "input fields: %d, output fields: %lu\n",
- fields.size(), R.size());
+ commit.fields.size(), R.size());
// Store known fields
pqxx::result::const_iterator ri = R.begin();
if(ri != R.end()) {
std::string name = (*ri)[0].c_str();
DEBUG(db, "Storing: %s with value %s\n",
- name.c_str(), fields[name].c_str());
+ name.c_str(), commit.fields[name].c_str());
ts = "INSERT INTO fields (transaction, name, value) "
"VALUES ( currval('trseq'), '" + W->esc(name) + "', '" +
- W->esc(fields[name]) + "')";
+ W->esc(commit.fields[name]) + "')";
ri++;
while(ri != R.end()) {
name = (*ri)[0].c_str();
DEBUG(db, "Storing: %s with value %s\n",
- name.c_str(), fields[name].c_str());
+ name.c_str(), commit.fields[name].c_str());
ts += ", (currval('trseq'), '" + W->esc(name) + "', '" +
- W->esc(fields[name]) + "')";
+ W->esc(commit.fields[name]) + "')";
ri++;
}
ts += ";";