Exemplo n.º 1
0
  private PendingEmergencyAdmissionShortVo populatePendingAdmission(
      TrackingForBedAvailabilityVo tracking) {
    PendingEmergencyAdmissionShortVo pendingAdmission =
        tracking.getAssociatedPendingEmergencyAdmission();
    if (pendingAdmission == null) pendingAdmission = new PendingEmergencyAdmissionShortVo();

    pendingAdmission.setAdmissionStatus(EmergencyAdmissionStatus.DTA);
    pendingAdmission.setDTADateTime(form.dtimAwaitingBed().getValue());
    pendingAdmission.setAdmissionType(AdmissionType.PLANNED);

    LocationLiteVo currentLocation = (LocationLiteVo) engine.getCurrentLocation();
    if (currentLocation != null) // WDEV-17615
    {
      // WDEV-17615
      LocationLiteVo currentHospital = domain.getCurrentHospital(currentLocation);
      pendingAdmission.setCurrentLocation(currentHospital);
    }

    if (pendingAdmission.getPasEvent() == null) {
      PasEventShortVo newPasEvent = new PasEventShortVo();

      newPasEvent.setEventDateTime(tracking.getAttendance().getRegistrationDateTime());
      newPasEvent.setPatient(form.getGlobalContext().Core.getPatientShort());
      newPasEvent.setPasEventId(new DateTime().toString());

      if (currentLocation != null) // WDEV-17615
      {
        // WDEV-17615
        LocationLiteVo currentHospital = domain.getCurrentHospital(currentLocation);
        newPasEvent.setLocation(currentHospital);
      }

      newPasEvent.setSpecialty(Specialty.EMERGENCY);

      pendingAdmission.setPasEvent(newPasEvent);
    }

    pendingAdmission.setBedTypeRequested(form.cmbDTABedType().getValue());

    return pendingAdmission;
  }
Exemplo n.º 2
0
  private boolean removeBed(TrackingAttendanceStatusVo newStatus) {
    try {
      if (form.getLocalContext().getcurrentTrackingIsNotNull()) {
        form.getLocalContext().getcurrentTracking().setCurrentStatus(newStatus);

        PendingEmergencyAdmissionShortVo temppend = null;
        if (form.getLocalContext()
            .getcurrentTracking()
            .getAssociatedPendingEmergencyAdmissionIsNotNull()) {
          temppend =
              form.getLocalContext().getcurrentTracking().getAssociatedPendingEmergencyAdmission();
          temppend.setAdmissionStatus(EmergencyAdmissionStatus.CANCELLED);
          temppend.setAllocatedWard(null);
        }

        form.getLocalContext().getcurrentTracking().setBedAvailability(null);
        form.getLocalContext().getcurrentTracking().getAttendance().setConclusionDateTime(null);
        form.getLocalContext().getcurrentTracking().getAttendance().setBedTypeRequested(null);

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

        domain.save(null, form.getLocalContext().getcurrentTracking());

        return true;
      }
    } catch (StaleObjectException e) {
      engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
      return true;
    } catch (UniqueKeyViolationException e) {
      engine.showMessage(e.getMessage());
      return false;
    }

    return false;
  }