{"size": 2649, "ext": "js", "max_stars_repo_path": "src/axios/hospital.js", "max_stars_repo_name": "elnemerahmed/dopmam-frontend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/axios/hospital.js", "max_issues_repo_name": "elnemerahmed/dopmam-frontend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/axios/hospital.js", "max_forks_repo_name": "elnemerahmed/dopmam-frontend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.9905660377, "max_line_length": 88, "alphanum_fraction": 0.5213288033}
import axios from "axios";
import moment from 'moment';

export const getPatient = (id, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/patients/getPatient",
        data: {
            id
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};

export const createNewPatient = (patient, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/patients/addPatient",
        data: {
            ...patient,
            nationalId: parseFloat(patient.nationalId),
            insuranceNumber: parseFloat(patient.insuranceNumber),
            insuranceDueDate: parseInt(moment(patient.insuranceDueDate).format("x")),
            dateOfBirth: parseInt(moment(patient.dateOfBirth).format("x"))
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};

export const createNewReport = (id, report, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/report/new",
        data: {
            patientNationalId: parseFloat(id),
            reportDate: parseInt(moment().format("x")),
            medicalHistoryAndClinicalFindings: report.medicalHistoryAndClinicalFindings,
            diagnosis: report.diagnosis,
            recommendation: report.recommendation
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};

export const getReports = (jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/reports",
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
}

export const getReport = (id, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/report",
        data: {
            id
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};

export const approveReport = (id, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/report/sign",
        data: {
            id
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};

export const rejectReport = (id, jwt) => {
    return axios({
        baseURL: process.env.REACT_APP_SERVER_URL,
        method: "POST",
        url: "/report/reject",
        data: {
            id
        },
        headers: {
            'Authorization': `Bearer ${jwt}`
        }
    });
};
