Пример #1
0
  public Result searchPost() {
    // searchPost validates the search before redirecting to either indexGet
    // or editGet

    SearchViewModel searchViewModel = searchViewModelForm.bindFromRequest().get();
    int id = searchViewModel.getId();

    ServiceResponse<IPatient> patientServiceResponse = searchService.findPatientById(id);
    if (patientServiceResponse.hasErrors()) {
      return redirect(routes.MedicalController.indexGet(0, "That patient can not be found."));
    }

    ServiceResponse<IPatientEncounter> patientEncounterServiceResponse =
        searchService.findCurrentEncounterByPatientId(id);
    IPatientEncounter patientEncounter = patientEncounterServiceResponse.getResponseObject();

    boolean hasPatientBeenCheckedIn =
        medicalService.hasPatientBeenCheckedIn(patientEncounter.getId());
    if (hasPatientBeenCheckedIn == true) {
      String message;
      ServiceResponse<DateTime> dateResponse =
          medicalService.getDateOfCheckIn(patientEncounter.getId());
      if (dateResponse.hasErrors()) {
        return redirect(
            routes.MedicalController.indexGet(
                0, "A fatal error has been encountered. Please try again."));
      }

      DateTime dateNow = dateUtils.getCurrentDateTime();
      DateTime dateTaken = dateResponse.getResponseObject();

      if (dateNow.dayOfYear().equals(dateTaken.dayOfYear())) {
        message =
            "That patient has already been seen today. Would you like to edit their encounter?";
      } else {
        message = "That patient's encounter has been closed.";
        id = 0;
      }

      return redirect(routes.MedicalController.indexGet(id, message));
    }
    return redirect(routes.MedicalController.editGet(searchViewModel.getId()));
  }
Пример #2
0
  @Test
  public void testDate() {
    DateTime dt = DateTime.now().millisOfDay().withMinimumValue();
    ;
    System.out.println(JodatimeUtils.formatDateTime(dt.toDate()));

    DateTime date = JodatimeUtils.parse("2015-03-18");
    System.out.println("date: " + date.getDayOfMonth());
    Assert.assertEquals(18, date.getDayOfMonth());

    date = JodatimeUtils.parse("2016-04-13");
    System.out.println("week: " + date.getWeekOfWeekyear());
    Assert.assertEquals(15, date.getWeekOfWeekyear());

    DateTime dateTime = DateTime.parse("2016-04-13");
    System.out.println("dateTime:" + dateTime);
    DateTime start = dateTime.dayOfWeek().withMinimumValue();
    DateTime end = start.plusWeeks(1);
    System.out.println("start:" + start);
    System.out.println("end:" + end);
    Assert.assertEquals("2016-04-11", start.toString("yyyy-MM-dd"));
    Assert.assertEquals("2016-04-18", end.toString("yyyy-MM-dd"));

    start = dateTime.dayOfMonth().withMinimumValue();
    end = start.plusMonths(1);
    System.out.println("start:" + start);
    System.out.println("end:" + end);
    Assert.assertEquals("2016-04-01", start.toString("yyyy-MM-dd"));
    Assert.assertEquals("2016-05-01", end.toString("yyyy-MM-dd"));

    start = dateTime.dayOfYear().withMinimumValue();
    end = start.plusYears(1);
    System.out.println("start:" + start);
    System.out.println("end:" + end);
    Assert.assertEquals("2016-01-01", start.toString("yyyy-MM-dd"));
    Assert.assertEquals("2017-01-01", end.toString("yyyy-MM-dd"));
  }
Пример #3
0
  void drawTimeLine() {

    // draw the base timeline

    int minorTickHeight = (int) (20 * scaleFactorY);
    int majorTickHeight = (int) (40 * scaleFactorY);
    parent.strokeWeight(10);
    parent.stroke(0);
    parent.line(lineStart, lineY, lineStop, lineY);
    // draw days
    // int maxDays = Days.daysBetween(timelineStartDate,
    // timelineEndDate).getDays();
    int maxHours = Hours.hoursBetween(timelineStartDate, timelineEndDate).getHours();
    // println("Interval  is " + fullTimeInterval);
    // println("Period is " + Days.daysBetween(minDate, maxDate).getDays());
    // println("Max days is " + maxDays);

    DateTime tempdt = new DateTime(timelineStartDate);
    String previousMonth = timelineStartDate.monthOfYear().getAsText();
    int previousDay = -1; // =tempdt.dayOfYear().get();
    int monthStart = lineStart;
    parent.textAlign(PConstants.CENTER, PConstants.TOP);

    for (int a = 0; a < maxHours; a++) {
      // println(a);
      parent.textAlign(PConstants.CENTER, PConstants.TOP);
      // draw label
      parent.textFont(parent.font);
      parent.textSize(10 * fontScale);

      if (tempdt.dayOfYear().get() != previousDay) {
        int tx = (int) (PApplet.map(a, 0, maxHours, lineStart, lineStop));
        // draw tick
        parent.strokeWeight(1);
        parent.line(tx, lineY, tx, lineY + minorTickHeight);
        previousDay = tempdt.dayOfYear().get();
        parent.fill(0);
        if (tempdt.dayOfMonth().get() == 1) {
          // special case!
          parent.textSize(14 * fontScale);
          parent.text(
              tempdt.dayOfMonth().getAsString(),
              tx,
              lineY + majorTickHeight + parent.textDescent());
        } else {
          parent.text(
              tempdt.dayOfMonth().getAsString(),
              tx,
              lineY + minorTickHeight + parent.textDescent());
        }

        // check if need to draw monthName
        if (!previousMonth.equals(tempdt.monthOfYear().getAsText())) {
          // draw some visual markers!
          // line(monthStart, lineY, monthStart,
          // lineY+majorTickHeight);
          parent.line(tx, lineY, tx, lineY + majorTickHeight);
          // position halfway between monthStart and tx, draw
          // monthname
          parent.textSize(18 * fontScale);
          // check! do we overlap the next month? if so, change
          // alignment
          if (parent.textWidth(previousMonth) / 2 + monthStart > tx) {
            parent.textAlign(PConstants.RIGHT, PConstants.TOP);
          }
          parent.text(
              previousMonth,
              (tx + monthStart) / 2,
              lineY + minorTickHeight + 2 * (parent.textAscent() + parent.textDescent()));
          previousMonth = tempdt.monthOfYear().getAsText();
          monthStart = tx;
        }
      }
      tempdt = tempdt.plus(Period.hours(1));
    }
    // draw final day
    parent.line(lineStop, lineY, lineStop, lineY + minorTickHeight);
    if (tempdt.dayOfMonth().get() == 1) {
      // special case!
      parent.text(
          tempdt.dayOfMonth().getAsString(),
          lineStop,
          lineY + majorTickHeight + parent.textDescent());
    } else {
      parent.text(
          tempdt.dayOfMonth().getAsString(),
          lineStop,
          lineY + minorTickHeight + parent.textDescent());
    }
    // draw final month!
    parent.textSize(18 * fontScale);
    parent.text(
        tempdt.monthOfYear().getAsText(),
        (lineStop + monthStart) / 2,
        lineY + minorTickHeight + 2 * (parent.textAscent() + parent.textDescent()));
  }
  @Override
  public void init() {
    buttonCancel = new Button("Batalkan");
    buttonCancel.addClickListener(this);

    buttonShow = new Button("Tampilkan Laporan");
    buttonShow.addClickListener(this);

    buttonPrint = new Button("Cetak");
    buttonPrint.addClickListener(this);
    buttonPrint.setIcon(new ThemeResource("icons/image/icon-print.png"));

    opener = new BrowserWindowOpener(ReportPrint.class);
    opener.setFeatures("height=200,width=400,resizable");
    // A button to open the printer-friendly page.
    opener.extend(buttonPrint);

    DateTime now = DateTime.now();
    Date beginYear =
        now.withDayOfYear(now.dayOfYear().getMinimumValue())
            .withHourOfDay(now.hourOfDay().getMinimumValue())
            .toDate();
    Date endYear =
        now.withDayOfYear(now.dayOfYear().getMaximumValue())
            .withHourOfDay(now.hourOfDay().getMaximumValue())
            .toDate();

    selectStartDate = new DateField("Dari Tanggal");
    selectStartDate.setImmediate(true);
    selectStartDate.setWidth(function.FORM_WIDTH);
    selectStartDate.setValue(beginYear);

    selectEndDate = new DateField("Hingga Tanggal");
    selectEndDate.setImmediate(true);
    selectEndDate.setWidth(function.FORM_WIDTH);
    selectEndDate.setValue(endYear);
    selectAcceptance = new OptionGroup("Persetujuan");
    Item itemType1 = selectAcceptance.addItem("diterima");
    Item itemType2 = selectAcceptance.addItem("belumditerima");
    selectAcceptance.setImmediate(true);
    selectAcceptance.setValue("diterima");

    selectAcceptance.setItemCaption("diterima", "Barang Kadaluarsa Disetujui");

    selectAcceptance.setItemCaption("belumditerima", "Barang Kadaluarsa Belum Disetujui");
    selectContent = new ComboBox("Pilih Tampilan");
    selectContent.setImmediate(true);
    selectContent.addItem(ReportContent.CHART);
    selectContent.addItem(ReportContent.TABLE);
    selectContent.addItem(ReportContent.TABLE_CHART);
    selectContent.setItemCaption(ReportContent.CHART, "Tampilkan Chart");
    selectContent.setItemCaption(ReportContent.TABLE, "Tampilkan Tabel");
    selectContent.setItemCaption(ReportContent.TABLE_CHART, "Tampilkan Tabel dan Chart");
    selectContent.setItemCaption(4, "Minggu Ke-4");
    selectContent.setValue(ReportContent.TABLE);

    selectAcceptance.addValueChangeListener(this);
    selectStartDate.addValueChangeListener(this);
    selectEndDate.addValueChangeListener(this);
    selectContent.addValueChangeListener(this);
    updateWindowOpener();

    construct();
  }