function add_nurse_control()
{
    if (filter_input(INPUT_GET, 'nurse_id') && filter_input(INPUT_GET, 'fname') && filter_input(INPUT_GET, 'sname') && filter_input(INPUT_GET, 'zone') && filter_input(INPUT_GET, 'phone') && filter_input(INPUT_GET, 'gender')) {
        $obj = get_nurse_model();
        $nurse_id = sanitize_string(filter_input(INPUT_GET, 'nurse_id'));
        $fname = sanitize_string(filter_input(INPUT_GET, 'fname'));
        $sname = sanitize_string(filter_input(INPUT_GET, 'sname'));
        $district_zone = sanitize_string(filter_input(INPUT_GET, 'zone'));
        $phone = sanitize_string(filter_input(INPUT_GET, 'phone'));
        $gender = sanitize_string(filter_input(INPUT_GET, 'gender'));
        if ($obj->add_nurses($nurse_id, $fname, $sname, $district_zone, $phone, $gender)) {
            echo '{"result":1,"message": "nurse added successfully"}';
        } else {
            echo '{"result":0,"message": "unable to add nurse"}';
        }
    }
}
/**
 * controller function to login users
 */
function user_login_control()
{
    $obj = $username = $pass = '';
    if (filter_input(INPUT_GET, 'user') && filter_input(INPUT_GET, 'pass')) {
        $obj = get_user_model();
        $username = sanitize_string(filter_input(INPUT_GET, 'user'));
        $pass = sanitize_string(filter_input(INPUT_GET, 'pass'));
        $pass = encrypt($pass);
        if ($obj->get_user($username, $pass)) {
            $row = $obj->fetch();
            if ($row == 0) {
                echo "Invalid user";
            } else {
                $username = $row['username'];
                $user_id = $row['user_id'];
                $user_type = $row['user_type'];
                $email = $row['email'];
                setUserSessionDetails($username, $user_id, $user_type, $email);
                echo '{"result":1,"user_type":"' . $user_type . '"}';
                if (strcmp($user_type, 'admin') == 0) {
                    $admin = get_admin_model();
                    if ($admin->get_details($user_id)) {
                        $row = $admin->fetch();
                        $sname = $row['sname'];
                        $fname = $row['fname'];
                        $district = $row['district'];
                        $phone = $row['phone'];
                        $gender = $row['gender'];
                        setUserSessionValues($sname, $fname, $phone, $district, $gender);
                        //echo "user_name ". $sname. " phone ". $phone;
                    }
                } elseif (strcmp($user_type, 'nurse') == 0) {
                    $nurse = get_nurse_model();
                    if ($nurse->get_details($user_id)) {
                        $row = $nurse->fetch();
                        $sname = $row['sname'];
                        $fname = $row['fname'];
                        $district = $row['district_zone'];
                        $phone = $row['phone'];
                        $gender = $row['gender'];
                        setUserSessionValues($sname, $fname, $phone, $district, $gender);
                        //echo "user_name ". $sname. " phone ". $phone;
                    }
                } elseif (strcmp($user_type, 'supervisor') == 0) {
                    $supervisor = get_admin_model();
                    if ($supervisor->get_details($user_id)) {
                        $row = $supervisor->fetch();
                        $sname = $row['sname'];
                        $fname = $row['fname'];
                        $district = $row['district_zone'];
                        $phone = $row['phone'];
                        $gender = $row['gender'];
                        setUserSessionValues($sname, $fname, $phone, $district, $gender);
                        //echo "user_name ". $sname. " phone ". $phone;
                    }
                }
            }
        } else {
            echo '{"result":0,"message": "Invalid User"}';
            $_SESSION['logged_in'] = false;
        }
    } else {
        echo '{"result":0,"message": "Invalid Credentials"}';
        $_SESSION['logged_in'] = false;
    }
}