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

export async function lookup(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/lookup', 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/lookupuserbyname', 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 getsexreg(token) {
    try {
        var resp = await axios.post(URL + 'usergroup/getsexreg',{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 save(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/addnewuser', 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 update(prm) {
    try {
        var resp = await axios.post(URL + 'usergroup/edituser', 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/deleteuser', { 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 selectnonlab(token) {
    try {
       var resp = await axios.post(URL + 'usergroup/selectnonlab',{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 searchdetail(token,prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchdetail',{token:token,search: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(token,prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchdoctor',{token:token,search: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 searchinstrument(token,tes) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchinstrument',{token:token,search:tes});
       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 searchtemplate(token,tes) {
    try {
       var resp = await axios.post(URL + 'usergroup/searchtemplate',{token:token,search:tes});
       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 getdistrict(token,prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/getdistrict',{id:prm.Nat_NormalValueDetailID,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 getkelurahan(token,prm) {
    try {
       var resp = await axios.post(URL + 'usergroup/getkelurahan',{token:token,id:prm.M_DistrictID});
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }