checkHospitalAddmissionData method

dynamic checkHospitalAddmissionData({
  1. dynamic corpId,
  2. dynamic policyNumId,
  3. dynamic employeeId,
  4. dynamic employeeMemberId,
  5. dynamic hospitalizationDate,
  6. dynamic context,
})

Implementation

checkHospitalAddmissionData(
    {corpId,
    policyNumId,
    employeeId,
    employeeMemberId,
    hospitalizationDate,
    context}) async {
  var checkStatusCode;

  try {
    http.Response response = await http.post(
        Uri.parse('${choice_Base_Url}claim_submission_check_hod'),
        body: {
          "corporate_id": corpId.toString(),
          "policy_no_id": policyNumId.toString(),
          "employee_id": employeeId.toString(),
          "emp_member_id": employeeMemberId.toString(),
          "hospitalization_date": hospitalizationDate.toString(),
        },
        headers: {
          "Authorization": choiceToken,
        });
    TokenRefresh(refreshtoken: response.headers['authorization'].toString());
    checkStatusCode = response.statusCode;
    var decodedResponse = await json.decode(response.body);
    Get.back();
    if (decodedResponse['status'] == false) {
      return null;
    } else {
      await showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return ChoiceAlertPopup(
            messag: "${decodedResponse['message'] ?? errorMessage}",
            image:
                '${BASE_URL}assets/images/medibhai_images/lottie/Upload_Successful.json',
          );
        },
      );
      Navigator.popAndPushNamed(context, '/wellnesspage');
    }
  } catch (err) {
    AutoLogoutThreeTry();
    if (checkStatusCode == 401) {
      await checkHospitalAddmissionData(
          corpId: corpId,
          policyNumId: policyNumId,
          employeeId: employeeId,
          employeeMemberId: employeeMemberId,
          hospitalizationDate: hospitalizationDate);
      (commonContext as Element).reassemble();
    } else {}
  }
}