コード例 #1
0
  /** Create a patient and then requery it */
  @Test
  public void testGetById() throws Exception {
    Patient patient = roleHelper.createPatient("564564564", testRenalUnit, testDiseaseUnit);

    patientManager.save(patient);

    Patient returnPatient = patientManager.getById(patient.getId());

    Assert.assertNotNull("There must be a patient returned", returnPatient);
    Assert.assertTrue(
        "The two patients must have the same id", patient.getId().equals(patient.getId()));
  }
コード例 #2
0
  @Test
  public void testExecute() throws Exception {

    int uktFilesSize = 0;

    String parentDir =
        ResourceUtils.getFile("classpath:schedule/test-uktstatus.gpg.txt").getParent();

    setUktDirectory(parentDir);

    File uktDir = new File(uktDirectory);
    File[] uktFiles =
        uktDir.listFiles(
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.endsWith("uktstatus.gpg.txt");
              }
            });

    if (uktFiles != null) {
      uktFilesSize = uktFiles.length;
    }

    assertTrue("Can not read UKT files", uktFilesSize != 0);

    uktImportExportScheduler.setUktDirectory(parentDir);
    uktImportExportScheduler.setUktExportDirectory(parentDir);
    uktImportExportScheduler.execute();

    UktStatus uktStatus = ukTransplantManager.getUktStatus("9876543210");

    if (uktFilesSize > 0) {
      assertNotNull("UktStatus not be saved", uktStatus);
      File file = ResourceUtils.getFile("classpath:schedule/ukt_rpv_export.txt");
      CSVParser uktParser = new CSVParser(new FileReader(file));
      uktParser.changeDelimiter(',');
      String[][] uktValues = uktParser.getAllValues();

      assertEquals("nhsno not same", patient.getNhsno(), uktValues[0][0]);
      assertEquals("surname not same", patient.getSurname(), uktValues[0][1]);
      assertEquals("forname not same", patient.getForename(), uktValues[0][2]);
      assertEquals("postcode not same", patient.getPostcode(), uktValues[0][4]);

      uktParser.close();
    } else {
      assertNull("Wrong entity exists.", uktStatus);
    }
  }
コード例 #3
0
  @Before
  public void setupSystem() throws Exception {

    specialty = repositoryHelpers.createSpecialty("Specialty1", "ten1", "A test specialty");

    user =
        repositoryHelpers.createUserWithMapping(
            "username", "*****@*****.**", "p", "username", "UNITCODEA", "9876543211", specialty);

    patient = new Patient();
    patient.setNhsno("9876543211");
    patient.setUnitcode("UNITCODEA");
    patient.setSurname("surname");
    patient.setForename("forname");
    patient.setPostcode("postcode");
    patient.setDateofbirth(new Date());

    patientDao.save(patient);
  }
コード例 #4
0
  public void saveTreatment(Treatment treatment) throws InvalidModelException {

    // validation
    List<String> errors = new ArrayList<String>();
    List<Treatment> treatmentsList =
        treatmentDao.getTreatmentsByRadarNumber(treatment.getRadarNumber());

    //  Cannot start a new treatment after a previous treatment start date which has not been closed
    for (Treatment existingTreatment : treatmentsList) {
      if (existingTreatment.getId().equals(treatment.getId())) {
        continue;
      }
      if (existingTreatment.getEndDate() == null
          && treatment.getStartDate().compareTo(existingTreatment.getStartDate()) > 0) {
        if (treatment.getEndDate() != null) {
          if (treatment.getEndDate().compareTo(existingTreatment.getStartDate()) > 0) {
            errors.add(TreatmentManager.PREVIOUS_TREATMENT_NOT_CLOSED_ERROR);
            break;
          }
        }
      }
    }

    // dates must not overlap
    for (Treatment existingTreatment : treatmentsList) {
      if (existingTreatment.getId().equals(treatment.getId())) {
        continue;
      }
      if (RadarUtility.isEventsOverlapping(
          existingTreatment.getStartDate(),
          existingTreatment.getEndDate(),
          treatment.getStartDate(),
          treatment.getEndDate())) {
        errors.add(TreatmentManager.OVERLAPPING_ERROR);
        break;
      }
    }

    List<Date> datesToCheck = Arrays.asList(treatment.getStartDate(), treatment.getEndDate());

    // cannot be before date of birth
    Patient patient = patientManager.getPatientByRadarNumber(treatment.getRadarNumber());
    if (patient != null) {
      Date dob = patient.getDob();
      if (dob != null) {
        for (Date date : datesToCheck) {
          if (date != null) {
            if (dob.compareTo(date) > 0) {
              errors.add(TreatmentManager.BEFORE_DOB_ERROR);
              break;
            }
          }
        }
      }
    }

    // cannot be after today
    Date today = new Date();
    for (Date date : datesToCheck) {
      if (date != null) {
        if (today.compareTo(date) < 0) {
          errors.add(TreatmentManager.AFTER_TODAY_ERROR);
          break;
        }
      }
    }

    if (!errors.isEmpty()) {
      InvalidModelException exception = new InvalidModelException("treatment model is not valid");
      exception.setErrors(errors);
      throw exception;
    }
    treatmentDao.saveTreatment(treatment);
  }
コード例 #5
0
  public AdminPatientPage(PageParameters parameters) {
    super();

    final Patient patient;
    final PatientUser patientUser;

    StringValue idValue = parameters.get(PARAM_ID);
    patientUser = userManager.getPatientUser(idValue.toLong());
    patient = patientManager.getPatientByRadarNumber(patientUser.getRadarNumber());

    CompoundPropertyModel<PatientUser> patientUserModel =
        new CompoundPropertyModel<PatientUser>(patientUser);

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    feedback.setOutputMarkupPlaceholderTag(true);
    add(feedback);

    final Form<PatientUser> userForm =
        new Form<PatientUser>("patientForm", patientUserModel) {
          protected void onSubmit() {
            try {
              userManager.savePatientUser(getModelObject());
            } catch (Exception e) {
              error("Could not save patient: " + e.toString());
            }
          }
        };
    add(userForm);

    userForm.add(new Label("radarNo", patientUser.getRadarNumber().toString()));
    userForm.add(new Label("forename", patient.getForename()));
    userForm.add(new Label("surname", patient.getSurname()));
    userForm.add(new RequiredTextField("username"));
    userForm.add(new Label("dob", patientUser.getDateOfBirth().toString()));
    userForm.add(new Label("dateRegistered", patientUser.getDateRegistered().toString()));

    userForm.add(
        new AjaxSubmitLink("updateTop") {
          protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            setResponsePage(AdminPatientsPage.class);
          }

          protected void onError(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            ajaxRequestTarget.add(feedback);
          }
        });

    userForm.add(
        new AjaxLink("cancelTop") {
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            setResponsePage(AdminPatientsPage.class);
          }
        });

    userForm.add(
        new AjaxSubmitLink("updateBottom") {
          protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            setResponsePage(AdminPatientsPage.class);
          }

          protected void onError(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            ajaxRequestTarget.add(feedback);
          }
        });

    userForm.add(
        new AjaxLink("cancelBottom") {
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            setResponsePage(AdminPatientsPage.class);
          }
        });
  }