// patient Chart Management Tools
#include "clog.h"
#include "cgi.h"
#include "input.h"
#include "mermsemr_api.h"
#include "safestring.h"
#include <string>
#include "pgsql.h"
#include "pgsql_wrapper.h"
#include <curl/curl.h>
#include "medTEmails.h"

/* -- */
#include "function_members.h"
#include "function_providers_charts.h"
#include "function_members.h"




long provider_chart(CVars in, CVars &out) {

    long ret = -1;
   try{
		

   
    }  catch (bad_parameter) {
        logfmt(logINFO, "ERROR CALL long provider_chart(CVars in, CVars &out)");
    }
    return ret;

}




/*
	
long provider_createmember1(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;
}





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;	
}

*/

