public HospitalAtNightCutOverPointsConfigVo getCurrentHospitalAtNightConfig(ILocation currentHospital) { if(currentHospital == null) return null; DomainFactory factory = getDomainFactory(); List<?> config = factory.find("from HospitalAtNightCutOverPointsConfig as h where h.hospital.id = :HospitalId", new String[] {"HospitalId"}, new Object[] {currentHospital.getID()}); if(config == null || config.size() == 0) return null; return HospitalAtNightCutOverPointsConfigVoAssembler.create((HospitalAtNightCutOverPointsConfig) config.get(0)); }
public HospitalAtNightCutOverPointsConfigVo getCurrentHospitalAtNightConfig(ILocation currentLocation) { if(currentLocation == null) return null; DomainFactory factory = getDomainFactory(); Location currentHospital = getHospital((Location) factory.getDomainObject(Location.class, currentLocation.getID())); if(currentHospital == null) return null; List<?> config = factory.find("from HospitalAtNightCutOverPointsConfig as h where h.hospital.id = :HospitalId", new String[] {"HospitalId"}, new Object[] {currentHospital.getId()}); if(config == null || config.size() == 0) return null; return HospitalAtNightCutOverPointsConfigVoAssembler.create((HospitalAtNightCutOverPointsConfig) config.get(0)); }
private void setSearchCriteriaDates() { if(form.cmbHospital().getValue() != null) { HospitalAtNightCutOverPointsConfigVo hospitalConfig = domain.getCurrentHospitalAtNightConfig(form.cmbHospital().getValue()); // WDEV-13968 - starts here Time startTime = hospitalConfig.getStartTime(); Time endTime = hospitalConfig.getEndTime(); Time currentTime = new Time(); currentTime.setSecond(0); DateTime startDateTime = null; DateTime endDateTime = null; if(startTime.isGreaterOrEqualThan(endTime)) { if(currentTime.isLessOrEqualThan(endTime)) { startDateTime = new DateTime(new Date().addDay(-1), startTime); endDateTime = new DateTime(new Date(), endTime); } else { startDateTime = new DateTime(new Date(), startTime); endDateTime = new DateTime(new Date().addDay(1), endTime); } } else if(startTime.isLessThan(endTime)) { if(currentTime.isLessOrEqualThan(endTime)) { startDateTime = new DateTime(new Date(), startTime); endDateTime = new DateTime(new Date(), endTime); } else { startDateTime = new DateTime(new Date().addDay(1), startTime); endDateTime = new DateTime(new Date().addDay(1), endTime); } } form.dtimFrom().setValue(startDateTime); form.dtimTo().setValue(endDateTime); // WDEV-13968 - ends here } }
public Boolean isPatientAlreadyAddedToHospAtNightList(PatientRefVo patient, HospitalAtNightCutOverPointsConfigVo hospitalAtNightConfig)// WDEV-13968 { if(patient == null) throw new CodingRuntimeException("Cannot check if patent is already added in Hospital At Night lists on a null Patient Id."); if(hospitalAtNightConfig == null)// WDEV-13968 throw new CodingRuntimeException("Cannot check if patent is already added in Hospital At Night lists on a null HospitalAtNightConfig Id."); DomainFactory factory = getDomainFactory(); // WDEV-13968 - starts here Time startTime = hospitalAtNightConfig.getStartTime(); Time endTime = hospitalAtNightConfig.getEndTime(); Time currentTime = new Time(); currentTime.setSecond(0); DateTime startDateTime = null; DateTime endDateTime = null; if(startTime.isGreaterOrEqualThan(endTime)) { if(currentTime.isLessOrEqualThan(endTime)) { startDateTime = new DateTime(new Date().addDay(-1), startTime); endDateTime = new DateTime(new Date(), endTime); } else { startDateTime = new DateTime(new Date(), startTime); endDateTime = new DateTime(new Date().addDay(1), endTime); } } else if(startTime.isLessThan(endTime)) { if(currentTime.isLessOrEqualThan(endTime)) { startDateTime = new DateTime(new Date(), startTime); endDateTime = new DateTime(new Date(), endTime); } else { startDateTime = new DateTime(new Date().addDay(1), startTime); endDateTime = new DateTime(new Date().addDay(1), endTime); } } String query = "select p from HospitalAtNightListandDates as h left join h.patientDetails as pd left join pd.currentStatus as cs left join pd.patient as p where h.cutOverPoints.id = :HospConfig and h.shiftStartDate = :ShiftStartDate and h.shiftEndDate = :ShiftEndDate and p.id = :PatId and (cs.status.id = :New or cs.status.id = :Active)"; List<?> list = factory.find(query, new String[] {"HospConfig", "ShiftStartDate", "ShiftEndDate", "PatId", "New", "Active"}, new Object[] {hospitalAtNightConfig.getID_HospitalAtNightCutOverPointsConfig(), startDateTime.getJavaDate(), endDateTime.getJavaDate(), patient.getID_Patient(), HospitalAtNightPatientStatus.NEW.getID(), HospitalAtNightPatientStatus.ACTIVE.getID()}); // WDEV-13968 - ends here if(list != null && list.size() > 0) return true; return false; }