@RequestMapping(method = RequestMethod.POST)
  public String onSubmit(
      @RequestParam("patientId") Integer patientId,
      @RequestParam(value = "billId", required = false) Integer billId,
      @RequestParam(value = "encounterId", required = false) Integer encounterId) {
    if (encounterId != null) {
      BillingService billingService = (BillingService) Context.getService(BillingService.class);
      PatientServiceBill patientServiceBill = billingService.getPatientServiceBillById(billId);
      if (patientServiceBill != null && !patientServiceBill.getPrinted()) {
        patientServiceBill.setPrinted(true);
        BillCalculatorForBDService calculator = new BillCalculatorForBDService();
        if (patientServiceBill.getFreeBill().equals(1)) {
          String billType = "free";
          patientServiceBill.setFreeBill(calculator.isFreeBill(billType));
        } else if (patientServiceBill.getFreeBill().equals(2)) {
          String billType = "mixed";
          patientServiceBill.setFreeBill(2);
        } else {
          String billType = "paid";
          patientServiceBill.setFreeBill(calculator.isFreeBill(billType));
        }

        billingService.savePatientServiceBill(patientServiceBill);
      }
    }

    return "redirect:/module/billing/ipdbillingqueue.form";
  }