const URL = "/one-api/mockup/mcuoffline/";

export async function search(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/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 generatesetup(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/generatesetup', 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 + 'preregister/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 + 'preregister/save',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 newpatient(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/newpatient',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(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/deletepatient',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 getaddress(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/getaddress',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 searchcity(token,prm) {
    try {
       var resp = await axios.post(URL + 'preregister/searchcity',{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 getdistrict(token,prm) {
    try {
       var resp = await axios.post(URL + 'preregister/getdistrict',{id:prm.M_CityID,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 + 'preregister/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
       };
    }
 }

 
export async function savenewaddress(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/savenewaddress',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 saveeditaddress(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/saveeditaddress',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 deleteaddress(prm) {
    try {
        var resp = await axios.post(URL + 'preregister/deleteaddress',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 {
       console.log('aye')
       console.log(prm)
       var resp = await axios.post(URL + 'preregister/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 searchcompany(prm) {
   try {
      var resp = await axios.post(URL + 'preregister/searchcompany',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 getmou(prm) {
    try {
       var resp = await axios.post(URL + 'preregister/getmou',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 savepreregister(prm) {
    try {
       var resp = await axios.post(URL + 'preregister/savepreregister',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 gotoreg(prm) {
    try {
       var resp = await axios.post(URL + 'preregister/gotoreg',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
       };
    }
 }