summaryrefslogtreecommitdiff
path: root/server/src/pracrodaopgsql.cc
diff options
context:
space:
mode:
authordeva <deva>2011-01-14 10:23:38 +0000
committerdeva <deva>2011-01-14 10:23:38 +0000
commit7a8185affa101ba8239a310321a3524eb3e6f650 (patch)
tree48b56008f613e099738ed2a2ecfaa843c32ed36d /server/src/pracrodaopgsql.cc
parent890c42ec53e4743a0bc737aa32b54049184a8cfe (diff)
Add 'template' to transactions table in db.
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 += ";";