Backend Service

This commit is contained in:
2019-03-17 21:05:52 +00:00
parent aea9090510
commit be67ec3729
5 changed files with 100 additions and 11 deletions
@@ -545,7 +545,62 @@ long getMemberReminders(CVars in, CVars &out) {
return ret;
}
/*
mermsemr_dev=> select p.id AS partient_id,p.added AS patient_added,p.long_id AS long_id, pra.* from patients p LEFT JOIN practice pra ON pra.id=p.practice_id WHERE p.member_id=3;
partient_id | patient_added | long_id | id | name | firstname | lastname | email | phone | username | password | added | loc | last_login | status
-------------+----------------------------+-------------+----+---------------------------+-----------+----------+--------------------------+------------+----------+----------------------------------+---------------------------+----------+------------+--------
3 | 2019-03-11 14:31:54.207198 | INT00000003 | 1 | University Hospital Space | Sanya | Ameye | ses66181+merms@gmail.com | 6784564356 | sameye | d0fbea2563b377ea7074bced45c88dcb | 2019-03-03 21:35:51.48451 | 10.0.0.1 | | 1
(1 row)
*/
long getMemberPractice(CVars in, CVars &out) {
long ret = PHP_API_BAD_PARAM;
char vname[20];
try {
// REQ_LONG(in, "status", 0, -1);
REQ_LONG(in, "member_id", 0, -1);
out["total_record"] = "0";
const PGresult *res = pgsql_query("SELECT p.id AS patient_id,p.status AS patient_status, pra.* FROM patients p LEFT JOIN practice pra ON pra.id=p.practice_id WHERE p.member_id = %lu", in["member_id"].Long());
if (res != NULL && pgsql_num_rows(res) > 0) {
out["total_record"] = pgsql_num_rows(res);
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
if (f.empty()) continue;
CVars rec;
map_to_cvars(f, rec);
snprintf(vname, sizeof (vname), "id_%05d", i);
out[vname] = rec["id"];
snprintf(vname, sizeof (vname), "patient_id_%05d", i);
out[vname] = rec["patient_id"];
snprintf(vname, sizeof (vname), "name_%05d", i);
out[vname] = rec["name"];
snprintf(vname, sizeof (vname), "long_id_%05d", i);
out[vname] = rec["long_id"];
snprintf(vname, sizeof (vname), "patient_added_%05d", i);
out[vname] = rec["patient_added"];
snprintf(vname, sizeof (vname), "patient_status_%05d", i);
out[vname] = rec["patient_status"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long getMemberPractice(CVars in, CVars &out)");
}
return ret;
}
//------------------------------------------------------
+6 -2
View File
@@ -25,7 +25,7 @@ Other Headers
long MemberReminders(CVars in, CVars &out);
long MemberProfile(CVars in, CVars &out);
long getMemberPractice(CVars in, CVars &out);
long members_call(CVars in, CVars &out) {
@@ -53,7 +53,11 @@ long members_call(CVars in, CVars &out) {
case MERMS_USER_UPDATEPROFILE:
return MemberProfile(in, out);
break;
case MERMS_USER_PRACTICES:
return getMemberPractice(in, out);
break;
}
logfmt(logINFO, "/members_call()");
return ret;