updateClaimSubmissionDetails method

dynamic updateClaimSubmissionDetails({
  1. dynamic corpId,
  2. dynamic policyNumId,
  3. dynamic employeeId,
  4. dynamic employeeMemberId,
  5. dynamic reasonForClaim,
  6. dynamic reportAmount,
  7. dynamic hospitalizationDate,
  8. dynamic hospitalName,
  9. dynamic hospitalAddress,
  10. dynamic pincode,
  11. dynamic city,
  12. dynamic state,
  13. dynamic dischargeDate,
  14. dynamic context,
  15. dynamic remark,
})

Implementation

updateClaimSubmissionDetails(
    {corpId,
    policyNumId,
    employeeId,
    employeeMemberId,
    reasonForClaim,
    reportAmount,
    hospitalizationDate,
    hospitalName,
    hospitalAddress,
    pincode,
    city,
    state,
    dischargeDate,
    context,
    remark}) async {
  var checkStatusCode;

  await gettingClaimSubmissionDetails(
      intimationID: ClaimSubmissionNumber == null
          ? ""
          : ClaimSubmissionNumber.toString());
  try {
    http.Response response = await http.post(
        Uri.parse('${choice_Base_Url}save_claim_submission_details'),
        body: {
          "intimate_claim_id": ClaimSubmissionNumber == null
              ? ""
              : ClaimSubmissionNumber.toString(),
          "corporate_id": corpId.toString(),
          "policy_id": policyNumId.toString(),
          "employee_details_id": employeeId.toString(),
          "member_id": employeeMemberId.toString(),
          "reason_for_claim": reasonForClaim.toString(),
          "report_amount": reportAmount.toString(),
          "hospitalization_date": hospitalizationDate.toString(),
          "hospital_name": hospitalName.toString(),
          "hospital_address": hospitalAddress.toString(),
          "claim_type": 'Reimbursement',
          "pincode": pincode.toString(),
          "city": city.toString(),
          "state": state.toString(),
          "discharge_date": dischargeDate.toString(),
          "remark": remark.toString(),
          "source": Platform.isAndroid ? '0' : '1'
        },
        headers: {
          "Authorization": choiceToken,
        });
    TokenRefresh(refreshtoken: response.headers['authorization'].toString());
    checkStatusCode = response.statusCode;

    var decodedResponse = await json.decode(response.body);
    ClaimSubmissionNumber = decodedResponse['claim_intimation_id'];

    Get.back();
    if (decodedResponse['status'] == false) {
      showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return ChoiceAlertPopup(
            messag: "${decodedResponse['message'] ?? errorMessage}",
            image:
                '${BASE_URL}assets/images/medibhai_images/lottie/Error.json',
          );
        },
      );
    } else {
      isEditable = false;
      Get.to(ChoiceSecondPageClaimSubmission());
      showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return ChoiceAlertPopup(
            messag: "${decodedResponse['message']}",
            image:
                '${BASE_URL}assets/images/medibhai_images/lottie/Upload_Successful.json',
          );
        },
      );
    }
  } catch (err) {
    AutoLogoutThreeTry();
    if (checkStatusCode == 401) {
      await updateClaimSubmissionDetails(
        context: context,
        corpId: corpId.toString(),
        policyNumId: policyNumId.toString(),
        employeeId: employeeId.toString(),
        employeeMemberId: employeeMemberId.toString(),
        reasonForClaim: reasonForClaim.toString(),
        reportAmount: reportAmount.toString(),
        hospitalizationDate: hospitalizationDate.toString(),
        hospitalName: hospitalName.toString(),
        hospitalAddress: hospitalAddress.toString(),
        pincode: pincode.toString(),
        city: city.toString(),
        state: state.toString(),
        dischargeDate: dischargeDate.toString(),
        remark: remark.toString(),
      );
      (commonContext as Element).reassemble();
    } else {}
  }
}