Пример #1
0
  private TrackingAttendanceStatusVo populateTrackingAttendanceStatus(TrackingStatus status) {
    TrackingAttendanceStatusVo trackingAttStatus = new TrackingAttendanceStatusVo();

    trackingAttStatus.setPatient(form.getGlobalContext().Core.getPatientShort());
    trackingAttStatus.setEpisode(form.getGlobalContext().Core.getEpisodeofCareShort());
    trackingAttStatus.setAttendance(form.getGlobalContext().Core.getCurrentCareContext());
    trackingAttStatus.setTrackingArea(form.getLocalContext().getcurrentTracking().getCurrentArea());

    trackingAttStatus.setStatusDatetime(new DateTime());

    Object mos = domain.getMosUser();
    if (mos instanceof MemberOfStaffLiteVo) {
      trackingAttStatus.setCreatedBy((MemberOfStaffLiteVo) mos);
    }

    trackingAttStatus.setStatus(status);
    // WDEV-16777
    trackingAttStatus.setPrevStatus(
        (form.getLocalContext().getcurrentTracking() != null
                && form.getLocalContext().getcurrentTracking().getCurrentStatus() != null)
            ? form.getLocalContext().getcurrentTracking().getCurrentStatus().getStatus()
            : null);

    return trackingAttStatus;
  }
Пример #2
0
  private boolean save(boolean bSave) {
    BedAvailabilityVo bedAvailabilityToSave = null; // 	WDEV-15162

    bedAvailabilityToSave =
        populateDataFromScreen(form.getLocalContext().getcurrentBedAvailability());

    String[] errors = bedAvailabilityToSave.validate(getUIErrors());
    if (errors != null && errors.length > 0) {
      engine.showErrors(errors);
      return false;
    }

    // Check SOE
    if (bedAvailabilityToSave.getID_BedAvailabilityIsNotNull()
        && domain.isStale(bedAvailabilityToSave)) {
      engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
      engine.close(DialogResult.ABORT);
      return false;
    }

    try {
      TrackingForBedAvailabilityVo trackingToSave = form.getLocalContext().getcurrentTracking();

      // Create new current status (Decision To Admit) for tracking
      TrackingAttendanceStatusVo newStatus = new TrackingAttendanceStatusVo();

      newStatus.setPatient(trackingToSave.getPatient());
      newStatus.setEpisode(form.getGlobalContext().Core.getEpisodeofCareShort());
      newStatus.setAttendance(form.getGlobalContext().Core.getCurrentCareContext());
      newStatus.setTrackingArea(trackingToSave.getCurrentArea());
      newStatus.setStatusDatetime(new DateTime());
      newStatus.setCreatedBy((MemberOfStaffRefVo) domain.getMosUser());
      newStatus.setStatus(TrackingStatus.DECISION_TO_ADMIT);

      newStatus.setPrevStatus(
          (trackingToSave != null && trackingToSave.getCurrentStatus() != null)
              ? trackingToSave.getCurrentStatus().getStatus()
              : null);
      newStatus.setPrevTrackingArea(
          (trackingToSave != null && trackingToSave.getCurrentStatus() != null)
              ? trackingToSave.getCurrentStatus().getTrackingArea()
              : null);

      trackingToSave.setCurrentStatus(newStatus);
      trackingToSave.getAttendance().setConclusionDateTime(form.dtimAwaitingBed().getValue());
      trackingToSave.getAttendance().setBedTypeRequested(form.cmbDTABedType().getValue());

      trackingToSave.setBedAvailability(bedAvailabilityToSave);

      trackingToSave.setAssociatedPendingEmergencyAdmission(
          populatePendingAdmission(trackingToSave));

      String[] errors1 = trackingToSave.validate();

      if (errors1 != null && errors1.length > 0) {
        engine.showErrors(errors1);
        return false;
      }

      form.getLocalContext().setcurrentBedAvailability(domain.save(null, trackingToSave));
    } catch (StaleObjectException e) {
      engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
      engine.close(DialogResult.ABORT);
      return false;
    } catch (UniqueKeyViolationException e) {
      engine.showMessage("There can only be one BedAvailability record for an attendance!");
      engine.close(DialogResult.ABORT);
      return false;
    }

    return true;
  }