From 8f3147414128ef6500832695d755e9df89f7aab7 Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Tue, 12 Mar 2019 00:18:56 +0000 Subject: [PATCH] Backend Service --- mermsemr/src/shared_tool/providers.cc | 162 +++++- .../application/controllers/Patient.php | 13 +- .../provider/components/patient_listing.php | 473 +----------------- .../views/template/menu/sidemain.php | 8 +- 4 files changed, 164 insertions(+), 492 deletions(-) diff --git a/mermsemr/src/shared_tool/providers.cc b/mermsemr/src/shared_tool/providers.cc index 0bf4d68..97bd922 100644 --- a/mermsemr/src/shared_tool/providers.cc +++ b/mermsemr/src/shared_tool/providers.cc @@ -19,7 +19,7 @@ long provider_login(CVars in, CVars &out); long PracticeLogin(CVars in, CVars &out); long PracticeSessionCheck(long practice_id, long practice_users_id, const char *sessionid, int create); long provider_createmember(CVars in, CVars &out); - +long provider_acceptmember(CVars in, CVars &out); long providers_call(CVars in, CVars &out) { long ret = PHP_API_BAD_PARAM; @@ -64,15 +64,6 @@ long providers_call(CVars in, CVars &out) { -long provider_createmember(CVars in, CVars &out){ -logfmt(logINFO, "ENTER CALL long providers_createmember(CVars in, CVars &out)"); - -return 0; -} - - - - long provider_login(CVars in, CVars &out) { long ret = -1; @@ -89,15 +80,158 @@ try{ } catch (bad_parameter) { logfmt(logINFO, "ERROR CALL long provider_login(CVars in, CVars &out)"); } - - - - return ret; } +//000 + + + +long provider_createmember(CVars in, CVars &out){ + + long ret = PHP_API_BAD_PARAM; + logfmt(logINFO, "Provider CreateMember()"); + + try { + + REQ_LONG(in, "practice_id", 0, -1); + REQ_LONG(in, "practice_user_id", 0, -1); + REQ_STRING(in, "username", 5, 49, "(.*)"); + REQ_STRING(in, "firstname", 2, 49, "(.*)"); + REQ_STRING(in, "lastname", 2, 49, "(.*)"); + OPTIONAL(in, "phone") REQ_STRING(in, "phone", 5, 23, "(.*)"); + REQ_STRING(in, "password", 5, 49, "(.*)"); + OPTIONAL(in, "phone") REQ_STRING(in, "loc", 5, 16, "(.*)"); + OPTIONAL(in, "login") REQ_LONG(in, "login", 0, -1); + + long member_id = 0; + + //REQ_STRING (in, "sessionid", 4, 40, "(.*)"); + const char * loc = getenv("REMOTE_ADDR"); + out["member_id"]="0"; + + ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE LOWER(username)=LOWER('%s') ", in["username"].c_str()); + logfmt(logINFO, "Provider CreateMember()member_id=%lu",out["member_id"].Long()); + if (out["member_id"].Long() == 0) { + + // LETS CREATE THE ACOUNT NOW + CVars x; + const char * loc = getenv("REMOTE_ADDR"); + x["loc"] = loc; + x["loc"].set_valid(true); + x["username"] = in["username"]; + x["username"].set_valid(true); + x["firstname"] = in["firstname"]; + x["firstname"].set_valid(true); + x["lastname"] = in["lastname"]; + x["lastname"].set_valid(true); + x["phone"] = in["phone"]; + x["phone"].set_valid(true); + // x["loc"] = in["loc"]; + // x["loc"].set_valid(true); + x["email"] = in["email"]; + x["email"].set_valid(true); + // x["password"] = in["email"]; + // x["password"].set_valid(true); + out["member_id"] = insert_db_record(DBS_VALID, "members", "members_id_seq", x); + + if (out["member_id"].Long() > 0) { + pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu", in["password"].c_str(), out["member_id"].Long()); // setting the password MD5 now + // Now Send Email + ret = PHP_API_OK; + //make your patient + CVars z; + z["practice_id"] = in["practice_id"]; + z["practice_id"].set_valid(true); + z["practice_user_id"] = in["practice_user_id"]; + z["practice_user_id"].set_valid(true); + z["member_id"] = out["member_id"]; + z["member_id"].set_valid(true); + provider_acceptmember(z, out); + + out["status"] = "OK"; + member_id = out["member_id"].Long(); + in["member_id"] = out["member_id"]; + in["member_id"].set_valid(true); + medTrUpdateProfile(in, out); + + // ============== + } + } // if username + }catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL Provider CreateMember"); + } + logfmt(logINFO, "/Provider CreateMember()"); + return ret; +} +void GenerateLongID(char * number, int sz, int seed); + +long provider_acceptmember(CVars in, CVars &out){ + long ret = PHP_API_BAD_PARAM; + logfmt(logINFO, "provider_acceptmember()"); + char vname[15]; + try{ + + REQ_LONG(in, "practice_id", 0, -1); + REQ_LONG(in, "practice_user_id", 0, -1); + REQ_LONG(in, "member_id", 0, -1); + + GenerateLongID(vname, sizeof (vname), 10); + //snprintf(vname, sizeof (vname), "ME%05d", i); + out["long_id"] = vname; + + + + CVars x; + x["practice_id"] = in["practice_id"]; + x["practice_id"].set_valid(true); + x["practice_user_id"] = in["practice_user_id"]; + x["practice_user_id"].set_valid(true); + x["member_id"] = in["member_id"]; + x["member_id"].set_valid(true); + + x["long_id"] = vname; + x["long_id"].set_valid(true); + out["patient_id_id"] = insert_db_record(DBS_VALID, "patients", "patients_id_seq", x); + + + + }catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL Provider CreateMember"); + } + logfmt(logINFO, "/provider_acceptmember()"); + return ret; +} + + +void GenerateLongID(char * number, int sz, int seed) { + char chars[] = "WRB01234WRB56789WRB"; + int n = sizeof (chars); + int i; + /* + time_t t; + time( &t ); + pid_t pid = getpid(); + + srand(t+pid); + */ + srand((unsigned int) time((time_t *) NULL)); + + for (i = 0; i < 10 && i < sz - 1; i++) { + int k = seed % n; + if (seed > 1 && k == i) { + number[i] = chars[n - k]; + } else { + number[i] = chars[ (int) ((n - 1.0) * rand() / (RAND_MAX + 1.0)) ]; + } + } + number[i] = 0; +} + + +//XXX long PracticeLogin(CVars in, CVars &out) { long ret = PHP_API_BAD_PARAM; diff --git a/providerwww/application/controllers/Patient.php b/providerwww/application/controllers/Patient.php index 68ef641..501da8e 100644 --- a/providerwww/application/controllers/Patient.php +++ b/providerwww/application/controllers/Patient.php @@ -11,17 +11,24 @@ class Patient extends Provider_Controller { public function addnew() { $data = array(); - $data["account_message"] = ""; - $data["firstname"] = $data["lastname"] = $data["email"] = $data["password"]= $data["street1"] = $data["street2"]= $data["city"] = $data["zipcode"]=""; + $data["account_message"] = ""; + $data["firstname"] = $data["lastname"] = $data["email"] = $data["password"]= $data["street1"] = $data["street2"]= $data["city"] = $data["zipcode"]=""; if ($_POST){ + $data['password'] = trim($this->input->post('password')); + $data['practice_id'] = $_SESSION['practice_id']; + $data['practice_user_id'] = $_SESSION['practice_id']; + $data['username'] = "NON-USER-".rand(1000000,99999999); + $data['password'] = "NON-USER-".rand(1000000,99999999); + $data['country'] = "NG"; $data['firstname'] = trim($this->input->post('firstname')); $data['lastname'] = trim($this->input->post('lastname')); $data['email'] = trim($this->input->post('email')); - $data['password'] = trim($this->input->post('password')); + $data['street1'] = trim($this->input->post('street1')); $data['street2'] = trim($this->input->post('street2')); $data['city'] = trim($this->input->post('city')); $data['state'] = trim($this->input->post('state')); +$data["loc"] = $_SERVER["REMOTE_ADDR"]; $data["action"] = MERMS_PROVIDERS_CREATEMEMBER; $out = array(); diff --git a/providerwww/application/views/provider/components/patient_listing.php b/providerwww/application/views/provider/components/patient_listing.php index 3c92c2a..35e17d0 100644 --- a/providerwww/application/views/provider/components/patient_listing.php +++ b/providerwww/application/views/provider/components/patient_listing.php @@ -1,6 +1,6 @@ -
+

Patients List

@@ -45,474 +45,9 @@ $icc++; - - 1 - Cold Shoulder Bling Dress - $65.342 - -
-
-
- - Active - - - - 2 - PlayStation 4 Pro 1TB Console - $47.655 - -
-
-
- - Active - - - - 3 - Extra Fine Wool Jumpers - $56.479 - -
-
-
- - Canceled - - - - 4 - Long Sleeve Bow Top - $04.786 - -
-
-
- - Active - - - - 5 - Shine Stripe Long Sleeve Ruffle - $23.456 - -
-
-
- - Active - - - - 6 - Long Sleeve Micro Thermal Shirt - $65.598 - -
-
-
- - info - - - - 7 - Standard Fit Bomber Sweater - $87.659 - -
-
-
- - Warning - - - - 8 - Standard Fit Crew T-Shirt - $32.466 - -
-
-
- - Active - - - - 9 - Standard Fit Short Sleeve V-Neck - $03.544 - -
-
-
- - Active - - - - 10 - Sanus Classic Small Full Motion Wall - $14.489 - -
-
-
- - Active - - - - 11 - Jena Gaines - $78.654 - -
-
-
- - Active - - - - 12 - Quinn Flynn - $23.486 - -
-
-
- - Active - - - - 13 - Charde Marshall - $65.453 - -
-
-
- - Active - - - - 14 - Haley Kennedy - $78.645 - -
-
-
- - Active - - - - 15 - Tatyana Fitzpatrick - $65.342 - -
-
-
- - Active - - - - 16 - Michael Silva - $07.456 - -
-
-
- - Active - - - - 17 - Paul Byrd - $36.478 - -
-
-
- - Active - - - - 18 - Gloria Little - $84.798 - -
-
-
- - Active - - - - 19 - Bradley Greer - $12.356 - -
-
-
- - Active - - - - 20 - Dai Rios - $45.655 - -
-
-
- - Active - - - - 21 - Jenette Caldwell - $47.586 - -
-
-
- - Active - - - - 22 - Yuri Berry - $36.756 - -
-
-
- - Active - - - - 23 - Caesar Vance - $78.659 - -
-
-
- - Active - - - - 24 - Doris Wilder - $56.484 - -
-
-
- - Active - - - - 25 - Angelica Ramos - $36.796 - -
-
-
- - Active - - - - 26 - Gavin Joyce - $25.365 - -
-
-
- - Active - - - - 27 - Jennifer Chang - $78.489 - -
-
-
- - Active - - - - 28 - Brenden Wagner - $35.987 - -
-
-
- - Active - - - - 29 - Fiona Green - $78.464 - -
-
-
- - Active - - - - 30 - Shou Itou - $61.444 - -
-
-
- - Active - - - - 31 - Michelle House - $85.488 - -
-
-
- - Active - - - - 32 - Suki Burks - $89.463 - -
-
-
- - Active - - - - 33 - Prescott Bartlett - $23.464 - -
-
-
- - Active - - - - 34 - Gavin Cortez - $12.254 - -
-
-
- - Active - - - - 35 - Martena Mccray - $24.478 - -
-
-
- - Active - - - - 36 - Unity Butler - $36.478 - -
-
-
- - Active - - - - 37 - Howard Hatfield - $48.654 - -
-
-
- - Active - - - - 38 - Hope Fuentes - $78.654 - -
-
-
- - Active - - - - 39 - Vivian Harrell - $26.154 - -
-
-
- - Active - - + + + diff --git a/providerwww/application/views/template/menu/sidemain.php b/providerwww/application/views/template/menu/sidemain.php index 3f7181f..6af2ab3 100644 --- a/providerwww/application/views/template/menu/sidemain.php +++ b/providerwww/application/views/template/menu/sidemain.php @@ -58,13 +58,9 @@
  • - +