const URL = "/one-api/v1/report-usergroup/";

export async function save(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/addnewreport', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}
export async function saveaddeditreport(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/saveaddeditreport', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}
export async function saveallreportdetail(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/saveallreport', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}
export async function lookup(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/lookupreportbyid', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

export async function xdelete(token,id) {
    try {
        var resp = await axios.post(URL + 'usergroup/deletereport', { id: id ,token:token});
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}
export async function getstatus(token) {
    try {
        var resp = await axios.post(URL + 'usergroup/getstatus',{token:token});
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}
export async function searchuser(prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchuser',prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
 export async function searchtest(prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchtest',prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
 export async function searchdoctor(prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchdoctor',prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
export async function lookupbyname(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/lookupreportbyname', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

export async function selectaddressdoctor(prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/selectaddressdoctor',prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }