diff --git a/mermsemr/src/include/mermsemr_api.h b/mermsemr/src/include/mermsemr_api.h index 04c0db1..53a4d7e 100644 --- a/mermsemr/src/include/mermsemr_api.h +++ b/mermsemr/src/include/mermsemr_api.h @@ -100,6 +100,8 @@ enum { #define MERMS_PROVIDERS_UPDATEPROFILE 150040 #define MERMS_PROVIDERS_REMINDERS 150045 #define MERMS_PROVIDERS_CREATEMEMBER 150055 +#define MERMS_PROVIDERS_LINKMEMBER 150057 + #define MERMS_PROVIDERS_CREATECHART 150060 // //#define 120001 // // -- diff --git a/mermsemr/src/shared_tool/providers.cc b/mermsemr/src/shared_tool/providers.cc index f10cd09..e8d1ed8 100644 --- a/mermsemr/src/shared_tool/providers.cc +++ b/mermsemr/src/shared_tool/providers.cc @@ -21,6 +21,8 @@ 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 provider_linkIdemember(CVars in, CVars &out); +void GenerateLongID(char * number, int sz, int seed); long providers_call(CVars in, CVars &out) { long ret = PHP_API_BAD_PARAM; @@ -42,6 +44,11 @@ long providers_call(CVars in, CVars &out) { // create chart from provider side now return provider_chart(in, out); break; + + case MERMS_PROVIDERS_LINKMEMBER: + return provider_linkIdemember(in, out); + break; + case EXISTING_CARD: REQ_LONG(in, "paymentid", 0, -1); // now we have to make sure the payment id is valid for this customer @@ -90,6 +97,57 @@ try{ //000 +long provider_linkIdemember(CVars in, CVars &out) { + + long ret = PHP_API_BAD_PARAM; + logfmt(logINFO, "Provider provider_linkIdemember()"); + long qret = 0; + try { + + REQ_LONG(in, "practice_id", 0, -1); + REQ_LONG(in, "practice_user_id", 0, -1); + REQ_STRING(in, "patient_link_id", 5, 15, "(.*)"); + out["member_id"] = "0"; + qret = (load_db_record(out, "SELECT *, id AS member_id FROM members WHERE acc_link = '%s'", in["patient_link_id"].c_str()) == true); + if (qret) { + logfmt(logINFO, "Provider provider_linkIdemember() QERT=>%lu", qret); + + + if (load_db_record(out, "SELECT * from patients WHERE practice_id =%lu AND member_id=%lu ", in["practice_id"].Long(), out["member_id"].Long()) == true) { + + out["message"] = "Member already linked"; + } else { + CVars x; + char vname[15]; + GenerateLongID(vname, sizeof (vname), 10); + //snprintf(vname, sizeof (vname), "ME%05d", i); + out["long_id"] = vname; + + + 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"] = out["member_id"]; + x["member_id"].set_valid(true); + + x["long_id"] = vname; + x["long_id"].set_valid(true); + out["patient_id"] = insert_db_record(DBS_VALID, "patients", "patients_id_seq", x); + out["message"] = "Member add completed"; + } + + } else { + out["message"] = "Link Id not found"; + } + + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL Provider provider_linkIdemember"); + } + logfmt(logINFO, "/Provider provider_linkIdemember()"); + return ret; + +} @@ -170,7 +228,7 @@ long provider_createmember(CVars in, CVars &out){ 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; @@ -198,7 +256,7 @@ long provider_acceptmember(CVars in, CVars &out){ x["long_id"] = vname; x["long_id"].set_valid(true); - out["patient_id_id"] = insert_db_record(DBS_VALID, "patients", "patients_id_seq", x); + out["patient_id"] = insert_db_record(DBS_VALID, "patients", "patients_id_seq", x); diff --git a/providerwww/application/controllers/Patient.php b/providerwww/application/controllers/Patient.php index 1beea59..ad06792 100644 --- a/providerwww/application/controllers/Patient.php +++ b/providerwww/application/controllers/Patient.php @@ -100,20 +100,21 @@ class Patient extends Provider_Controller { } public function linkpatient(){ - echo 'Ameye'; + // echo 'Ameye'; if ($_GET) { $data['patient_link_id'] = trim($this->input->get('patient_link_id')); $data['practice_id'] = $_SESSION['practice_id']; - $data['practice_user_id'] = $_SESSION['practice_id']; + $data['practice_user_id'] = $_SESSION['practice_id']; + $data["loc"] = $_SERVER["REMOTE_ADDR"]; $data["action"] = MERMS_PROVIDERS_LINKMEMBER; $out = array(); $ret = $this->mermsemr_api($data, $out); - $data["account_message"] = "This is the return " . $ret; - echo "Linked Result :"; + //$data["account_message"] = "This is the return " . $ret; + echo $out["message"]; } else { diff --git a/providerwww/application/views/provider/patient/newpatient.php b/providerwww/application/views/provider/patient/newpatient.php index 675f95b..599a22c 100644 --- a/providerwww/application/views/provider/patient/newpatient.php +++ b/providerwww/application/views/provider/patient/newpatient.php @@ -160,7 +160,9 @@ function connectLinkID() { var patient_link_id = document.linkform.patient_link_id.value; - if (patient_link_id === '' || )) { + // alert(patient_link_id); + + if (patient_link_id === '' ) { alert('You must enter valid linkID to continue!'); return false; } @@ -177,10 +179,6 @@ }); return false; } - - - - // -->