Пример #1
0
  @Test
  public void sample_save_should_form_test_to_sample_associations() throws Exception {
    testService.createOrUpdate(referenceDataTest);
    us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name");
    assertEquals("Test Name", savedTest.getTestName());
    assertEquals("New", savedTest.getTestSection().getTestSectionName());

    referenceDataSample.addTest(
        new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName()));
    typeOfSampleService.createOrUpdate(referenceDataSample);
    TypeOfSample savedSample = typeOfSampleDAO.getTypeOfSampleByUUID(sampleUuid);
    assertEquals("Sample Name", savedSample.getDescription());
    assertEquals("Sample Name", savedSample.getLocalAbbreviation());
    TypeOfSampleTest sampleTestAssoc =
        typeOfSampleTestDAO.getTypeOfSampleTestForTest(savedTest.getId());
    assertNotNull(sampleTestAssoc);
    assertEquals(savedTest.getId(), sampleTestAssoc.getTestId());
    assertEquals(savedSample.getId(), sampleTestAssoc.getTypeOfSampleId());
  }
  private HashMap populateHumanSampleOneMap(
      Patient patient,
      Person person,
      Provider provider,
      Person providerPerson,
      Sample sample,
      SampleHuman sampleHuman,
      SampleOrganization sampleOrganization,
      SampleItem sampleItem,
      List analyses) {
    HashMap humanSampleOneMap = new HashMap();

    List sampleProjects = new ArrayList();
    SampleProject sampleProject = null;
    SampleProject sampleProject2 = null;

    sampleProjects = sample.getSampleProjects();

    if (sampleProjects != null && sampleProjects.size() > 0) {
      sampleProject = (SampleProject) sampleProjects.get(0);
      if (sampleProjects.size() > 1) {
        sampleProject2 = (SampleProject) sampleProjects.get(1);
      }
    }

    if (sample.getAccessionNumber() != null) {
      humanSampleOneMap.put("accessionNumber", sample.getAccessionNumber());
    } else {
      humanSampleOneMap.put("accessionNumber", "");
    }

    if (patient.getBirthDateForDisplay() != null) {
      humanSampleOneMap.put("birthDateForDisplay", patient.getBirthDateForDisplay());
    } else {
      humanSampleOneMap.put("birthDateForDisplay", "");
    }

    if (sample.getCollectionDateForDisplay() != null) {
      humanSampleOneMap.put("collectionDateForDisplay", sample.getCollectionDateForDisplay());
    } else {
      humanSampleOneMap.put("collectionDateForDisplay", "");
    }

    if (sample.getCollectionTimeForDisplay() != null) {
      humanSampleOneMap.put("collectionTimeForDisplay", sample.getCollectionTimeForDisplay());
    } else {
      // bugzilla 1894
      humanSampleOneMap.put(
          "collectionTimeForDisplay",
          SystemConfiguration.getInstance().getHumanSampleOneDefaultCollectionTimeForDisplay());
    }

    // bugzilla 1904
    if (patient.getChartNumber() != null) {
      humanSampleOneMap.put("chartNumber", patient.getChartNumber());
    } else {
      humanSampleOneMap.put("chartNumber", "");
    }

    if (person.getCity() != null) {
      // bugzilla 1766
      humanSampleOneMap.put("city", person.getCity().toUpperCase().trim());
    } else {
      humanSampleOneMap.put("city", "");
    }

    if (sample.getClientReference() != null) {
      humanSampleOneMap.put("clientReference", sample.getClientReference());
    } else {
      humanSampleOneMap.put("clientReference", "");
    }

    if (patient.getExternalId() != null) {
      humanSampleOneMap.put("externalId", patient.getExternalId());
    } else {
      humanSampleOneMap.put("externalId", "");
    }

    if (person.getFirstName() != null) {
      humanSampleOneMap.put("firstName", person.getFirstName());
    } else {
      humanSampleOneMap.put("firstName", "");
    }

    if (patient.getGender() != null) {
      humanSampleOneMap.put("gender", patient.getGender());
    } else {
      humanSampleOneMap.put("gender", "");
    }

    if (person.getLastName() != null) {
      humanSampleOneMap.put("lastName", person.getLastName());
    } else {
      humanSampleOneMap.put("lastName", "");
    }

    if (person.getMiddleName() != null) {
      humanSampleOneMap.put("middleName", person.getMiddleName());
    } else {
      humanSampleOneMap.put("middleName", "");
    }

    if (person.getMultipleUnit() != null) {
      humanSampleOneMap.put("multipleUnit", person.getMultipleUnit());
    } else {
      humanSampleOneMap.put("multipleUnit", "");
    }

    if (sampleOrganization != null && sampleOrganization.getOrganization() != null) {
      // bugzilla 2069
      humanSampleOneMap.put(
          "organizationLocalAbbreviation",
          sampleOrganization.getOrganization().getOrganizationLocalAbbreviation());
      humanSampleOneMap.put(
          "organizationNameForDisplay", sampleOrganization.getOrganization().getOrganizationName());
    } else {
      humanSampleOneMap.put("organizationLocalAbbreviation", "");
      humanSampleOneMap.put("organizationNameForDisplay", "");
    }
    if (sampleProject != null && sampleProject.getProject() != null) {
      // bugzilla 2438
      humanSampleOneMap.put("projectId", sampleProject.getProject().getLocalAbbreviation());
      // bugzilla 1766 since we capitolize project name do this here
      // for comparison purposes
      humanSampleOneMap.put(
          "projectName", sampleProject.getProject().getProjectName().toUpperCase().trim());
    } else {
      humanSampleOneMap.put("projectId", "");
      humanSampleOneMap.put("projectName", "");
    }

    if (sampleProject2 != null && sampleProject2.getProject() != null) {
      // bugzilla 2438
      humanSampleOneMap.put("projectId2", sampleProject2.getProject().getLocalAbbreviation());
      // bugzilla 1766 since we capitolize project name do this here
      // for comparison purposes
      humanSampleOneMap.put(
          "projectName2", sampleProject2.getProject().getProjectName().toUpperCase().trim());
    } else {
      humanSampleOneMap.put("projectId2", "");
      humanSampleOneMap.put("projectName2", "");
    }

    if (providerPerson.getFirstName() != null) {
      humanSampleOneMap.put("providerFirstName", providerPerson.getFirstName());
    } else {
      humanSampleOneMap.put("providerFirstName", "");
    }

    if (providerPerson.getLastName() != null) {
      humanSampleOneMap.put("providerLastName", providerPerson.getLastName());
    } else {
      humanSampleOneMap.put("providerLastName", "");
    }

    if (providerPerson.getWorkPhone() != null) {
      String storedResult = providerPerson.getWorkPhone();
      humanSampleOneMap.put("providerWorkPhone", StringUtil.formatPhoneForDisplay(storedResult));
    } else {
      humanSampleOneMap.put("providerWorkPhone", "");
    }

    if (providerPerson.getWorkPhone() != null) {
      String storedResult = providerPerson.getWorkPhone();
      // bugzilla 2442
      String extension = StringUtil.formatExtensionForDisplay(storedResult);
      humanSampleOneMap.put("providerWorkPhoneExtension", StringUtil.trim(extension));
    } else {
      humanSampleOneMap.put("providerWorkPhoneExtension", "");
    }

    if (sample.getReceivedDateForDisplay() != null) {
      humanSampleOneMap.put("receivedDateForDisplay", sample.getReceivedDateForDisplay());
    } else {
      humanSampleOneMap.put("receivedDateForDisplay", "");
    }

    if (sample.getReferredCultureFlag() != null) {
      humanSampleOneMap.put("referredCultureFlag", sample.getReferredCultureFlag());
    } else {
      humanSampleOneMap.put("referredCultureFlag", "");
    }

    if (sampleItem.getSourceOfSample() != null) {
      SourceOfSample sos = (SourceOfSample) sampleItem.getSourceOfSample();
      // bugzilla 1766
      humanSampleOneMap.put("sourceOfSampleDesc", sos.getDescription().toUpperCase().trim());
      // bugzilla 1465
      humanSampleOneMap.put("sourceOfSampleId", sos.getId());
    } else {
      humanSampleOneMap.put("sourceOfSampleDesc", "");
      // bugzilla 1465
      humanSampleOneMap.put("sourceOfSampleId", "");
    }

    if (sampleItem.getSourceOther() != null) {
      humanSampleOneMap.put("sourceOther", sampleItem.getSourceOther().trim());
    } else {
      humanSampleOneMap.put("sourceOther", "");
    }

    if (person.getState() != null) {
      humanSampleOneMap.put("state", person.getState());
    } else {
      humanSampleOneMap.put("state", "");
    }

    if (sample.getStickerReceivedFlag() != null) {
      humanSampleOneMap.put("stickerReceivedFlag", sample.getStickerReceivedFlag());
    } else {
      humanSampleOneMap.put("stickerReceivedFlag", "");
    }

    if (person.getStreetAddress() != null) {
      humanSampleOneMap.put("streetAddress", person.getStreetAddress().trim());
    } else {
      humanSampleOneMap.put("streetAddress", "");
    }

    if (sampleItem.getTypeOfSample() != null) {
      TypeOfSample tos = (TypeOfSample) sampleItem.getTypeOfSample();
      // bugzilla 1766
      humanSampleOneMap.put("typeOfSampleDesc", tos.getDescription().toUpperCase().trim());
      // bugzilla 1465
      humanSampleOneMap.put("typeOfSampleId", tos.getId());
    } else {
      humanSampleOneMap.put("typeOfSampleDesc", "");
      // bugzilla 1465
      humanSampleOneMap.put("typeOfSampleId", "");
    }

    if (person.getZipCode() != null) {
      humanSampleOneMap.put("zipCode", person.getZipCode().trim());
    } else {
      humanSampleOneMap.put("zipCode", "");
    }

    return humanSampleOneMap;
  }