private void saveClinic(ClinicVo clinic) throws HL7Exception {
   try {
     String[] errors = clinic.validate();
     if (errors != null) {
       throw new HL7Exception("Validation of Clinic failed. " + VoMapper.toDisplayString(errors));
     }
     orgLoc.saveClinic(clinic);
   } catch (StaleObjectException e) {
     LOG.error("StaleObjectException occurred saving clinic - " + e.getMessage(), e);
     throw new HL7Exception(
         "Clinic data has been updated by another user/process - please try again", e);
   }
 }
Exemple #2
0
  private void setPatientIntoContext(Patient patient) {
    PatientShort patientShort =
        new PatientShortHelper().getPatientShort(patient.DataCollection.get(0));

    ims.core.vo.PatientShort voPatient = null;

    if (patientShort != null) {
      try {
        voPatient = domain.getPatient(patientShort);
      } catch (StaleObjectException e) {
        engine.showMessage(e.getMessage());
      }
    }

    form.getGlobalContext().Core.setPatientShort(voPatient);
  }
  private synchronized void saveJob(FullSDSBatchVo job) {
    if (job == null) return;

    job.setProcessedGPRequestsNo(TotalGPsNo);
    job.setSuccessfulGPRequestsUpdatedNo(SuccessfulGPssNo);
    job.setProcessedPracticeRequestsNo(TotalPracticesNo);
    job.setSuccessfulPracticeRequestsUpdatedNo(SuccessfulPracticesNo);

    DomainFactoryBridge factory = getDomainFactory();
    FullSDSBatch batch = FullSDSBatchVoAssembler.extractFullSDSBatch(factory, job);
    try {
      factory.save(batch);
    } catch (StaleObjectException e) {
      trace("Job details save has failed! " + e.getMessage());
      return;
    }
  }
  protected Message processPatientLeave(Message msg, ProviderSystemVo providerSystem)
      throws HL7Exception {
    try {

      PatientShort patVo = (PatientShort) getPrimaryIdFromPid(msg, providerSystem);

      if (patVo != null) {
        patVo = getDemog().getPatient(patVo);

        if (patVo == null)
          return HL7Utils.buildRejAck(
              msg.get("MSH"),
              "This patient has not been registered within the system",
              HL7Errors.APP_INT_ERROR,
              toConfigItemArray(providerSystem.getConfigItems()));

        String eventCode = HL7Utils.getEventCode(msg);
        if (eventCode.equals("A21")
            || eventCode.equals(
                "A53")) // A21 set's patient on leave, A53 cancels the cancelled Patient Leave i.e.
          // sets them on leave again
          adt.recordInpatientLeave(patVo);
        else if (eventCode.equals("A22") || eventCode.equals("A52")) // Cancel Patient's Leave
        {
          PV1 pv1 = (PV1) msg.get("PV1");
          LocShortVo loc = null;
          loc =
              orgLoc.getLocationByTaxonomyType(
                  pv1.getAssignedPatientLocation().getPointOfCare().getValue(), TaxonomyType.PAS);
          patVo.setWard(loc);
          adt.cancelInpatientLeave(patVo); // A22
        }
      }
    } catch (StaleObjectException ex) {
      return HL7Utils.buildRejAck(
          msg.get("MSH"),
          "StaleObjectException occured recording Inpatient Leave - " + ex.getMessage(),
          HL7Errors.APP_INT_ERROR,
          toConfigItemArray(providerSystem.getConfigItems()));
    }

    Message ack =
        HL7Utils.buildPosAck(msg.get("MSH"), toConfigItemArray(providerSystem.getConfigItems()));
    return ack;
  }
 private void saveLocation(IfLocParentVo loc) throws HL7Exception {
   try {
     String[] errors = loc.validate();
     if (errors != null) {
       throw new HL7Exception(
           "Validation of Location failed. " + VoMapper.toDisplayString(errors));
     }
     ocsIfInbound.saveLocation(loc);
   } catch (StaleObjectException e) {
     LOG.error("StaleObjectException occurred saving location - " + e.getMessage(), e);
     throw new HL7Exception(
         "Location data has been updated by another user/process - please try again", e);
   } catch (UniqueKeyViolationException e) {
     LOG.error("UniqueKeyViolationException occurred saveLocationSite " + e.getMessage(), e);
     throw new HL7Exception(
         "UniqueKeyViolationException occurred saveLocationSite " + e.getMessage(), e);
   }
 }
Exemple #6
0
  protected void onUnArrivalClick() throws PresentationLogicException {
    // Apply to all appointments
    if (form.AllAppointments().getValue()) {
      for (int i = 0; i < form.AppointmentsGrid().getRows().size(); i++) {
        // Apply to arrived only
        if (form.AppointmentsGrid().getRows().get(i).getValue().Appt_stat.equals("-2196")) {
          // 10/06/2003 - Update the Sd_appt_dtsDTO
          Sd_appt_dts appts;
          try {
            appts =
                domain.getArrivalDetails(
                    form.AppointmentsGrid().getRows().get(i).getValue().Appt_head_id,
                    form.AppointmentsGrid().getRows().get(i).getValue().Appt_id);
          } catch (DomainInterfaceException e) {
            engine.showMessage(e.getMessage());
            return;
          }

          try {
            appts = domain.getForUpdateArrivalDetails(appts);
          } catch (StaleObjectException e) {
            engine.showMessage(e.getMessage());
            return;
          }

          appts.DataCollection.get(0).Arr_tme = "";
          appts.DataCollection.get(0).Att_stat = "";
          appts.DataCollection.get(0).Appt_stat = "-2189";
          // appts.Sd_appt_apdtsCollection[0].attHcp_booking1 = Context.UserID;
          // 20/01/2005 - Clear Inpatient value if Appt_stat = "-2189";
          appts.DataCollection.get(0).Appinpatstat = null;

          try {
            domain.updateArrivalDetails(appts);
          } catch (DomainInterfaceException e) {
            engine.showMessage(e.getMessage());
            return;
          }

          form.getLocalContext().setUnArrival(Boolean.TRUE);
        }
      }

      getAppointments(form.DateSelected().getValue());
      form.getLocalContext().setUnArrival(Boolean.FALSE);
    } else {
      // 10/06/2003 - Update the Sd_appt_dtsDTO
      if (form.getLocalContext().getappt_dts() != null) {
        Sd_appt_dts appts = form.getLocalContext().getappt_dts();

        Result result = appts.getForUpdate();
        if (result != null) {
          engine.showMessage(result.getMessage());
          return;
        }

        appts.DataCollection.get(0).Arr_tme = "";
        appts.DataCollection.get(0).Att_stat = "";
        appts.DataCollection.get(0).Appt_stat = "-2189";
        // appts.Sd_appt_apdtsCollection[0].attHcp_booking1 = Context.UserID;
        // 20/01/2005 - Clear Inapatient value if Appt_stat = "-2189";
        appts.DataCollection.get(0).Appinpatstat = null;

        result = appts.update();
        if (result != null) {
          engine.showMessage(result.getMessage());
          return;
        }

        form.getLocalContext().setUnArrival(Boolean.TRUE);
        // Refresh
        EnableButtons(false);
        getAppointments(form.DateSelected().getValue());
      }
    }
  }
Exemple #7
0
  protected void onArrivalClick() throws PresentationLogicException {
    if (form.Time().getValue() == null) {
      engine.showMessage("Please select a time.");
      return;
    }

    if (form.Action().getValue() == null) {
      engine.showMessage("Please select a Location.");
      return;
    }

    // Update all the records - apply to all appointments
    // except Cancelled reallocate, Cancel not Reallocate & Arrived
    if (form.AllAppointments().getValue()) {
      for (int i = 0; i < form.AppointmentsGrid().getRows().size(); i++) {
        // 12/06/2003 - Allow only
        if (form.AppointmentsGrid().getRows().get(i).getValue().Appt_stat.equals("-2189")
            || // Open
            form.AppointmentsGrid().getRows().get(i).getValue().Appt_stat.equals("-2194")
            || // Rebooked
            form.AppointmentsGrid().getRows().get(i).getValue().Appt_stat.equals("-2195")
            || // Moved
            form.AppointmentsGrid()
                .getRows()
                .get(i)
                .getValue()
                .Appt_stat
                .equals("-2197")) // Cancel Died
        {

          Sd_appt_dts appts = null;
          try {
            appts =
                domain.getArrivalDetails(
                    form.AppointmentsGrid().getRows().get(i).getValue().Appt_head_id,
                    form.AppointmentsGrid().getRows().get(i).getValue().Appt_id);
          } catch (DomainInterfaceException e) {
            engine.showMessage(e.getMessage());
            return;
          }

          try {
            appts = domain.getForUpdateArrivalDetails(appts);
          } catch (StaleObjectException e) {
            engine.showMessage(e.getMessage());
            return;
          }

          appts.DataCollection.get(0).Arr_tme = form.Time().getValue().toString(TimeFormat.FLAT6);
          appts.DataCollection.get(0).Att_stat =
              form.Action().getValue() != null
                  ? Integer.toString(form.Action().getValue().getID())
                  : "";
          // appts.Sd_appt_dtsCollection[0].attHcp_booking1 = Context.UserID;
          appts.DataCollection.get(0).Appt_stat = "-2196"; // Arrived
          // 19/01/2005 - Inpatient logic
          appts.DataCollection.get(0).Appinpatstat =
              isInpatient(appts.DataCollection.get(0).Ploc) ? "Y" : "N";
          // ----------------------------
          try {
            appts = domain.updateArrivalDetails(appts);
          } catch (DomainInterfaceException e) {
            engine.showMessage(e.getMessage());
            return;
          }
        }
      }

      getAppointments(form.DateSelected().getValue());
      form.getLocalContext().setUnArrival(Boolean.FALSE);
    } else {
      // 10/06/2003 - Update the Sd_appt_dtsDTO
      if (form.getLocalContext().getappt_dts() != null) {
        Sd_appt_dts appts = form.getLocalContext().getappt_dts();

        Result result = appts.getForUpdate();
        if (result != null) {
          engine.showMessage(result.getMessage());
          return;
        }

        appts.DataCollection.get(0).Arr_tme = form.Time().getValue().toString(TimeFormat.FLAT6);
        appts.DataCollection.get(0).Att_stat =
            form.Action().getValue() != null
                ? Integer.toString(form.Action().getValue().getID())
                : "";
        // appts.Sd_appt_dtsCollection[0].attHcp_booking1 = Context.UserID;
        appts.DataCollection.get(0).Appt_stat = "-2196"; // Arrived
        // 19/01/2005 - Inpatient logic
        appts.DataCollection.get(0).Appinpatstat =
            isInpatient(appts.DataCollection.get(0).Ploc) ? "Y" : "N";
        // ----------------------------
        result = appts.update();
        if (result != null) {
          engine.showMessage(result.getMessage());
          return;
        }

        getAppointments(form.DateSelected().getValue());
        form.getLocalContext().setUnArrival(Boolean.FALSE);
      }
    }
  }
  private boolean saveAdmission(
      PatientElectiveListBedAdmissionVo patientElectiveList,
      PatientElectiveListBedAdmissionVoCollection differentPatientElectiveListForService) {
    PasEventVo voPasEvent = new PasEventVo();
    if (form.qmbConsultant().getValue() != null) {
      MedicWithMappingsLiteVo medLite =
          new MedicWithMappingsLiteVo(
              form.qmbConsultant().getValue().getID_Hcp(),
              form.qmbConsultant().getValue().getVersion_Hcp());
      voPasEvent.setConsultant(medLite);
    }

    voPasEvent.setEventDateTime(form.dtimAdmDateTime().getValue());
    voPasEvent.setEventType(PasEventType.INPATIENT);
    voPasEvent.setIsVip(false);
    voPasEvent.setLocation(form.cmbWard().getValue());
    voPasEvent.setPatient(form.getGlobalContext().Core.getPatientShort());
    voPasEvent.setSpecialty(form.cmbSpecialty().getValue());
    voPasEvent.setPasEventId(new DateTime().toString());

    InpatientEpisodeVo voInpatientEpis = new InpatientEpisodeVo();
    voInpatientEpis.setIsOnLeave(false);
    voInpatientEpis.setAdmissionDateTime(form.dtimAdmDateTime().getValue());
    voInpatientEpis.setEstDischargeDate(form.dteEstDischDate().getValue());
    voInpatientEpis.setPasEvent(voPasEvent);
    voInpatientEpis.setBedNo(form.txtBedNo().getValue());
    voInpatientEpis.setAdmissionType(AdmissionType.DAY_CASE);

    String[] arrErrors = voInpatientEpis.validate(validateUILogic());
    if (arrErrors != null) {
      engine.showErrors(arrErrors);
      return false;
    }

    arrErrors = form.getGlobalContext().Core.getPatientShort().validate(arrErrors);
    if (arrErrors != null) {
      engine.showErrors(arrErrors);
      return false;
    }
    try {
      // CatsReferralWizardVo voCats =
      // domain.getCatsReferralWizardVoForCareContext(form.getGlobalContext().Core.getCurrentCareContext());
      CatsReferralWizardVo voCats =
          domain.getCatsReferral(form.getGlobalContext().Scheduling.getBookingAppointmentRef());
      if (voCats.getRequiresDischargeRep() == null) {
        voCats.setRequiresDischargeRep(null);
        String[] errors2 = voCats.validate();
        if (errors2 != null && errors2.length > 0) {
          engine.showErrors(errors2);
          return false;
        }
      }

      CareContextShortVo voCC =
          domain.admitPatient(
              form.getGlobalContext().Core.getPatientShort(),
              voInpatientEpis,
              form.getGlobalContext().Scheduling.getBookingAppointmentRef(),
              voCats,
              patientElectiveList,
              differentPatientElectiveListForService);
      if (voCC != null) form.getGlobalContext().Core.setCurrentCareContext(voCC);

      return true;
    } catch (DomainInterfaceException e) {
      engine.showMessage(e.getMessage());
      return false;
    } catch (StaleObjectException e) {
      engine.showMessage(e.getMessage());
      return false;
    } catch (ForeignKeyViolationException e) {
      engine.showMessage(e.getMessage());
      return false;
    } catch (UniqueKeyViolationException e) {
      engine.showMessage(e.getMessage());
      return false;
    }
  }