コード例 #1
0
  public void afterReturning(Object returnValue, Method method, Object[] args, Object target)
      throws Throwable {
    log.debug("Intercepted an Encounter Save");
    if (method.getName().equals("saveEncounter")) {
      User autheticatedUser = Context.getAuthenticatedUser();

      if (autheticatedUser != null) {
        Collection<Role> userRoles = autheticatedUser.getAllRoles();

        if (userRoles != null && userRoles.size() > 0) {
          String prop =
              Context.getAdministrationService()
                  .getGlobalProperty(OncologyPOCConstants.GP_INTERCEPTROLES);

          if (prop != null) {
            String[] interceptRoles = prop.split(",");
            boolean interceptThisOne = false;
            Role interceptedRole = null;

            for (String role : interceptRoles) {
              for (Role userRole : userRoles) {
                if (role.equalsIgnoreCase(userRole.getRole())) {
                  interceptThisOne = true;
                  interceptedRole = userRole;
                  break;
                }
              }
              if (interceptThisOne) break;
            }

            if (interceptThisOne) {
              Encounter encounter = (Encounter) returnValue;
              if (encounter != null
                  && encounter.getPatient() != null
                  && encounter.getForm() != null) {
                OncologyPOCService service =
                    (OncologyPOCService) Context.getService(OncologyPOCService.class);
                SubEncounter subEncounter = service.getSubEncounter(encounter.getEncounterId());

                if (interceptedRole.hasPrivilege(OncologyPOCConstants.PRIV_CLINICIAN)) {
                  log.debug("Deleting subEncounter");
                  service.deleteSubEncounter(subEncounter);
                } else {
                  log.debug("Saving subEncounter");
                  if (subEncounter == null) {
                    subEncounter = new SubEncounter();
                    subEncounter.setEncounterId(encounter.getEncounterId());
                  }
                  service.saveSubEncounter(subEncounter);
                }
              }
            }
          }
        }
      }
    }
  }
コード例 #2
0
  public synchronized JSONArray getArray(List<PharmacyLocationUsers> pharmacyLocations, int size) {

    drugNamess = new JSONArray();
    Collection<Role> xvc = userService.getAuthenticatedUser().getAllRoles();
    for (Role rl : xvc) {

      if ((rl.equals("System Developer")) || (rl.equals("Provider"))) {

        editPharmacy = true;
        deletePharmacy = true;
      }

      if (rl.hasPrivilege("Edit Pharmacy")) {
        editPharmacy = true;
      }

      if (rl.hasPrivilege("Delete Pharmacy")) {
        deletePharmacy = true;
      }
    }
    if (editPharmacy) {

      drugNamess.put("edit");
      editPharmacy = false;
    } else drugNamess.put("");
    drugNamess.put("");
    drugNamess.put(pharmacyLocations.get(size).getUuid());
    drugNamess.put(pharmacyLocations.get(size).getUserName());
    drugNamess.put(pharmacyLocations.get(size).getLocation());

    if (deletePharmacy) {
      drugNamess.put("void");
      deletePharmacy = false;
    } else drugNamess.put("");
    return drugNamess;
  }