Exemplo n.º 1
0
  public ActionForward updateAppointmentReason(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    OscarAppointmentDao appointmentDao =
        (OscarAppointmentDao) SpringUtils.getBean("oscarAppointmentDao");

    Appointment appointment =
        appointmentDao.find(Integer.parseInt(request.getParameter("appointmentNo")));

    if (appointment != null) {
      appointment.setReason(request.getParameter("reason"));
      appointmentDao.merge(appointment);

      hashMap.put("success", true);
      hashMap.put("appointmentNo", appointment.getId());
    }

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 2
0
  public ActionForward getBillingDxAutocompleteList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DiagnosticCodeDao diagnosticCodeDao =
        (DiagnosticCodeDao) SpringUtils.getBean("diagnosticCodeDao");

    String query = request.getParameter("query");

    List<DiagnosticCode> queryResults =
        diagnosticCodeDao.findByDiagnosticCodeAndRegion(query, "ON");
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    hashMap.put("dxCode", queryResults);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 3
0
  public ActionForward getBillingAutocompleteList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BillingServiceDao billingServiceDao =
        (BillingServiceDao) SpringUtils.getBean("billingServiceDao");

    String query = request.getParameter("query");

    List<BillingService> queryResults =
        billingServiceDao.findBillingCodesByCode("%" + query + "%", "ON", new Date(), 1);
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    hashMap.put("billing", queryResults);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 4
0
  public String showJson() {
    JsonConfig jsonConfig = new JsonConfig();
    jsonConfig.registerJsonBeanProcessor(
        Sucursal.class,
        new JsonBeanProcessor() {

          @Override
          public JSONObject processBean(Object bean, JsonConfig jsonConfig) {
            Sucursal sucursal = (Sucursal) bean;
            JSONObject row = new JSONObject();
            row.element("id", sucursal.getId());

            JSONArray cell = new JSONArray();
            cell.add(sucursal.getNombre());
            cell.add(sucursal.getDireccion());
            cell.add(sucursal.getTelefono());

            row.element("cell", cell);

            return row;
          }
        });

    JSONObject rootObj = new JSONObject();
    JSONArray jrows = (JSONArray) JSONSerializer.toJSON(sucursales, jsonConfig);

    rootObj.element("rows", jrows);
    rootObj.element("records", sucursales.size());
    rootObj.element("total", Math.ceil((double) sucursales.size() / rows));
    rootObj.element("page", page);

    writeResponse(rootObj);
    return JSON;
  }
Exemplo n.º 5
0
  public ActionForward saveMacro(
      ActionMapping maping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    EyeformMacroDao eyeformMacroDao = (EyeformMacroDao) SpringUtils.getBean("eyeformMacroDao");
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    try {
      EyeformMacro macro = new EyeformMacro();
      if (request.getParameter("macroIdField") != null
          && request.getParameter("macroIdField").length() > 0) {
        macro = eyeformMacroDao.find(Integer.parseInt(request.getParameter("macroIdField")));
        macro = (macro == null ? new EyeformMacro() : macro);
      }

      macro.setMacroName(request.getParameter("macroNameBox"));
      macro.setImpressionText(request.getParameter("macroImpressionBox"));
      macro.setPlanText(request.getParameter("macroPlanBox"));
      macro.setCopyFromLastImpression(
          Boolean.parseBoolean(request.getParameter("macroCopyFromLastImpression")));

      if (request.getParameter("billingData") != null
          && request.getParameter("billingData").length() > 0) {
        String[] billingItems = request.getParameterValues("billingData");

        List<EyeformMacroBillingItem> billingItemList = new LinkedList<EyeformMacroBillingItem>();
        for (String b : billingItems) {
          EyeformMacroBillingItem billingItem = new EyeformMacroBillingItem();
          String billingCode = b.substring(0, b.indexOf("|"));
          String multiplier = b.substring(b.indexOf("|"));

          billingItem.setBillingServiceCode(billingCode);
          billingItem.setMultiplier(Double.parseDouble(multiplier));

          billingItemList.add(billingItem);
        }

        macro.setBillingItems(billingItemList);
      }

      eyeformMacroDao.merge(macro);

      hashMap.put("saved", macro.getId());
    } catch (Exception e) {
      hashMap.put("error", e.getMessage());
    }

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 6
0
  public ActionForward getProviders(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");
    List<Provider> activeProviders = providerDao.getActiveProviders();

    HashMap<String, List<Provider>> hashMap = new HashMap<String, List<Provider>>();
    hashMap.put("providers", activeProviders);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 7
0
  public ActionForward getMacroList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    EyeformMacroDao eyeformMacroDao = (EyeformMacroDao) SpringUtils.getBean("eyeformMacroDao");

    List<EyeformMacro> macroList = eyeformMacroDao.getMacros();
    HashMap<String, Object> hashMap = new HashMap<String, Object>();
    hashMap.put("macros", macroList);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 8
0
  public ActionForward getTickler(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);

    if (!securityInfoManager.hasPrivilege(
        LoggedInInfo.getLoggedInInfoFromSession(request), "_tickler", "r", null)) {
      throw new SecurityException("missing required security object (_demographic)");
    }

    Tickler t =
        ticklerManager.getTickler(
            loggedInInfo, Integer.parseInt(request.getParameter("tickler_no")));

    HashMap<String, HashMap<String, Object>> hashMap =
        new HashMap<String, HashMap<String, Object>>();
    HashMap<String, Object> ticklerMap = new HashMap<String, Object>();

    ticklerMap.put("message", t.getMessage());
    ticklerMap.put("updateDate", t.getUpdateDate());
    ticklerMap.put("provider", t.getProvider().getFormattedName());
    ticklerMap.put("providerNo", t.getProvider().getProviderNo());
    ticklerMap.put("toProvider", t.getAssignee().getFormattedName());
    ticklerMap.put("toProviderNo", t.getAssignee().getProviderNo());

    hashMap.put("tickler", ticklerMap);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
Exemplo n.º 9
0
  public ActionForward getBillingArgs(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);

    DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao");
    OscarAppointmentDao appointmentDao =
        (OscarAppointmentDao) SpringUtils.getBean("oscarAppointmentDao");

    Appointment appointment = null;
    try {
      appointment = appointmentDao.find(Integer.parseInt(request.getParameter("appointment_no")));
    } catch (Exception e) {
      // appointment_no is not a number, I guess
      appointment = null;
    }

    Demographic demographic = demographicDao.getDemographic(request.getParameter("demographic_no"));

    hashMap.put("ohip_version", "V03G");

    if (demographic != null) {
      Integer sex = null;
      if (demographic.getSex().equalsIgnoreCase("M")) sex = 1;
      else if (demographic.getSex().equalsIgnoreCase("F")) sex = 2;

      String dateOfBirth =
          StringUtils.join(
              new String[] {
                demographic.getYearOfBirth(),
                demographic.getMonthOfBirth(),
                demographic.getDateOfBirth()
              },
              "");

      hashMap.put("hin", demographic.getHin());
      hashMap.put("ver", demographic.getVer());
      hashMap.put("hc_type", demographic.getHcType());
      hashMap.put("sex", sex);
      hashMap.put("demographic_dob", dateOfBirth);
      hashMap.put("demographic_name", demographic.getLastName() + "," + demographic.getFirstName());
    }

    if (appointment != null) {
      hashMap.put("apptProvider_no", appointment.getProviderNo());
      hashMap.put("start_time", appointment.getStartTime().toString());
      hashMap.put("appointment_date", appointment.getAppointmentDate().getTime());
    }

    hashMap.put("current_provider_no", loggedInInfo.getLoggedInProviderNo());
    hashMap.put("demo_mrp_provider_no", demographic.getProviderNo());

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
  public JsonUtils() {
    jsonConfig = new JsonConfig();

    jsonConfig.registerJsonValueProcessor(
        DateTime.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            return new JSONRawString("Timeline.DateTime." + ((DateTime) arg1).toString());
          }
        });
    jsonConfig.registerJsonBeanProcessor(
        JsonConstructor.class,
        new JsonBeanProcessor() {

          public JSONObject processBean(Object arg0, JsonConfig arg1) {
            return (JSONObject)
                arg1.findJsonValueProcessor(JsonConstructor.class)
                    .processObjectValue(null, arg0, arg1);
          }
        });
    jsonConfig.registerJsonValueProcessor(
        JsonConstructor.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            return processObjectValue(null, arg0, arg1);
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            JsonConstructor<?> constructor = (JsonConstructor<?>) arg1;
            return new JSONRawString(
                constructor.getName()
                    + "("
                    + WebUtils.toString(JSONObject.fromObject(constructor.getObject(), arg2))
                    + ")");
          }
        });
    jsonConfig.registerJsonValueProcessor(
        RawString.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            return new JSONRawString(((RawString) arg1).toString());
          }
        });
    jsonConfig.registerJsonValueProcessor(
        RawString.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            return new JSONRawString(((RawString) arg1).toString());
          }
        });
    jsonConfig.registerJsonValueProcessor(
        Date.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            Date date = (Date) arg1;
            String dateString = new SimpleDateFormat("yyyy").format(date);
            String retval = "Timeline.DateTime.parseGregorianDateTime(\"" + dateString + "\")";
            return new JSONRawString(retval);
          }
        });
    jsonConfig.registerJsonValueProcessor(
        Date.class,
        new JsonValueProcessor() {
          public Object processArrayValue(Object arg0, JsonConfig arg1) {
            throw new UnsupportedOperationException();
          }

          public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) {
            Date date = (Date) arg1;
            String dateString = new SimpleDateFormat("yyyy").format(date);
            String retval = "Timeline.DateTime.parseGregorianDateTime(\"" + dateString + "\")";
            return new JSONRawString(retval);
          }
        });
  }