/*
General Header
ChiefSoft July 2017
 */
#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 "cfg.h"
#include <curl/curl.h>
/*
Other Headers
 */
#include "medTrMembers.h"
#include "function_backoffice.h"
#include "function_members.h"
#include "function_users.h"
#include "creditcards.h"
#include "payments.h"


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) {
    logfmt(logINFO, "members_call()");

    long action = REQ_LONG(in, "action", 0, -1);
    CVars x;
    long ret = 0;
    const char * loc = getenv("REMOTE_ADDR");

    switch (action) {
        case MERMS_USER_LOGIN:
            return MemberLogin(in, out);
            break;

        case MERMS_USER_CREATEACCOUNT:
            return CreateMember(in, out);
            break;

        case MERMS_USER_REMINDERS:
            return MemberReminders(in, out);
            break;
			
		case MERMS_USER_LOADPROFILE:
		case MERMS_USER_UPDATEPROFILE:
			return MemberProfile(in, out);
			break;
			
        case MERMS_USER_PRACTICES:
            return getMemberPractice(in, out);
            break;
			
    }
    logfmt(logINFO, "/members_call()");
    return ret;
}

