List of usage examples for org.apache.commons.validator GenericValidator isBlankOrNull
public static boolean isBlankOrNull(String value)
Checks if the field isn't null and length of the field is greater than zero not including whitespace.
From source file:us.mn.state.health.lims.common.provider.query.TestNamesProvider.java
@SuppressWarnings("unchecked") private String createJsonTestNames(String testId, JSONObject jsonResult) throws IllegalStateException { if (GenericValidator.isBlankOrNull(testId)) { throw new IllegalStateException("TestNamesProvider testId was blank. It must have a value"); }/*from w ww. j av a 2 s .c o m*/ Test test = new TestService(testId).getTest(); if (test != null) { List<ResultLimit> resultLimits = resultLimitDAO.getAllResultLimitsForTest(test); if (!resultLimits.isEmpty()) { jsonResult.put("resultLimitSize", resultLimits.size()); JSONObject resultLimitItemObject = new JSONObject(); for (int x = 0; x < resultLimits.size(); x++) { JSONObject normalRangeObject = new JSONObject(); normalRangeObject.put("minAge", resultLimits.get(x).getMinAge()); normalRangeObject.put("maxAge", resultLimits.get(x).getMaxAge()); normalRangeObject.put("gender", resultLimits.get(x).getGender()); normalRangeObject.put("lowNormal", resultLimits.get(x).getLowNormal()); normalRangeObject.put("highNormal", resultLimits.get(x).getHighNormal()); normalRangeObject.put("lowValid", resultLimits.get(x).getLowValid()); normalRangeObject.put("highValid", resultLimits.get(x).getHighValid()); normalRangeObject.put("id", resultLimits.get(x).getId()); resultLimitItemObject.put("resultLimitItem_" + x, normalRangeObject); } jsonResult.put("resultLimit", resultLimitItemObject); } Localization nameLocalization = test.getLocalizedTestName(); Localization reportNameLocalization = test.getLocalizedReportingName(); JSONObject nameObject = new JSONObject(); nameObject.put("english", nameLocalization.getEnglish()); nameObject.put("french", nameLocalization.getFrench()); nameObject.put("vietnamese", nameLocalization.getVietnamese()); jsonResult.put("name", nameObject); JSONObject reportingNameObject = new JSONObject(); reportingNameObject.put("english", reportNameLocalization.getEnglish()); reportingNameObject.put("french", reportNameLocalization.getFrench()); reportingNameObject.put("vietnamese", reportNameLocalization.getVietnamese()); jsonResult.put("reportingName", reportingNameObject); if (test.getUnitOfMeasure() != null) { jsonResult.put("unitOfMeasure", test.getUnitOfMeasure().getName()); } return VALID; } return INVALID; }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexCD4Provider.java
private boolean initialConditionsSatisfied(String resultIds, String values, String childRow) { return GenericValidator.isBlankOrNull(resultIds) || GenericValidator.isBlankOrNull(values) || GenericValidator.isBlankOrNull(childRow) || GenericValidator.isBlankOrNull(CD4_TEST_ID) || GenericValidator.isBlankOrNull(GB_TEST_ID) || GenericValidator.isBlankOrNull(LYMPH_TEST_ID); }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexCD4Provider.java
private String fetchIfNeeded(String testId, String currentResult, String validResultId) { if (!GenericValidator.isBlankOrNull(currentResult)) { return currentResult; }//from www . j a va2 s .c om Result result = resultDAO.getResultById(validResultId); Sample sample = result.getAnalysis().getSampleItem().getSample(); List<Result> resultList = resultDAO.getResultsForTestAndSample(sample.getId(), testId); if (resultList.isEmpty()) { return null; } else { return resultList.get(0).getValue(); } }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexUserChoiceProvider.java
@Override public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String resultIds = request.getParameter("resultIds"); String analysisIds = request.getParameter("analysisIds"); String testIds = request.getParameter("testIds"); String rowIndex = request.getParameter("rowIndex"); String accessionNumber = request.getParameter("accessionNumber"); String jResult = ""; JSONObject jsonResult = new JSONObject(); String jString = ""; if (GenericValidator.isBlankOrNull(resultIds) || GenericValidator.isBlankOrNull(testIds) || GenericValidator.isBlankOrNull(rowIndex) || (GenericValidator.isBlankOrNull(analysisIds) && GenericValidator.isBlankOrNull(accessionNumber))) { jResult = INVALID;// w w w . j ava 2 s.c o m jString = "Internal error, please contact Admin and file bug report"; } else { jResult = createJsonTestReflex(resultIds, analysisIds, testIds, accessionNumber, rowIndex, jsonResult); StringWriter out = new StringWriter(); try { jsonResult.writeJSONString(out); jString = out.toString(); } catch (IOException e) { e.printStackTrace(); jResult = INVALID; jString = "Internal error, please contact Admin and file bug report"; } } ajaxServlet.sendData(jString, jResult, request, response); }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexUserChoiceProvider.java
private String createJsonTestReflex(String resultIds, String analysisIds, String testIds, String accessionNumber, String rowIndex, JSONObject jsonResult) { TestReflexUtil reflexUtil = new TestReflexUtil(); String[] resultIdSeries = resultIds.split(ID_SEPERATOR); /*//ww w. j a va 2 s . co m * Here's the deal. If the UC test reflex has both an add_test_id and a * scriptlet_id then we are done. If it has only one Then we need to * look for the other */ ArrayList<TestReflex> selectableReflexes = new ArrayList<TestReflex>(); HashSet<String> reflexTriggers = new HashSet<String>(); HashSet<String> reflexTriggerIds = new HashSet<String>(); // Both test given results on client if (resultIdSeries.length > 1) { /* String[] testIdSeries = testIds.split(ID_SEPERATOR); List<TestReflex> testReflexesForResultOne = reflexUtil.getTestReflexsForDictioanryResultTestId(resultIdSeries[0], testIdSeries[0], true); if (!testReflexesForResultOne.isEmpty()) { List<TestReflex> sibTestReflexList = reflexUtil.getTestReflexsForDictioanryResultTestId(resultIdSeries[1], testIdSeries[1], true); boolean allChoicesFound = false; for (TestReflex reflexFromResultOne : testReflexesForResultOne) { for (TestReflex sibReflex : sibTestReflexList) { if (areSibs(reflexFromResultOne, sibReflex) && TestReflexUtil.isUserChoiceReflex( reflexFromResultOne )) { if (reflexFromResultOne.getActionScriptlet() != null) { testReflexOne = reflexFromResultOne; allChoicesFound = true; break; } else if (testReflexOne == null) { testReflexOne = reflexFromResultOne; } else { testReflexTwo = reflexFromResultOne; allChoicesFound = true; break; } } if (allChoicesFound) { break; } } } } */ // One test given results on client, the other is in the DB } else { // for each reflex we are going to try and find a sibling reflex // which is currently satisfied // get their common sample Sample sample = getSampleForKnownTest(analysisIds, accessionNumber, ANALYSIS_DAO); Dictionary dictionaryResult = new DictionaryDAOImpl().getDictionaryById(resultIds); List<Analysis> analysisList = ANALYSIS_DAO.getAnalysesBySampleId(sample.getId()); List<TestReflex> candidateReflexList = reflexUtil.getTestReflexsForDictioanryResultTestId(resultIds, testIds, true); for (TestReflex candidateReflex : candidateReflexList) { if (TestReflexUtil.isUserChoiceReflex(candidateReflex)) { if (GenericValidator.isBlankOrNull(candidateReflex.getSiblingReflexId())) { selectableReflexes.add(candidateReflex); reflexTriggers.add(candidateReflex.getTest().getLocalizedName() + ":" + dictionaryResult.getDictEntry()); // reflexTriggerIds.add( candidateReflex.getTest().getId() ); } else { // find if the sibling reflex is satisfied TestReflex sibTestReflex = new TestReflex(); sibTestReflex.setId(candidateReflex.getSiblingReflexId()); TEST_REFLEX_DAO.getData(sibTestReflex); TestResult sibTestResult = new TestResult(); sibTestResult.setId(sibTestReflex.getTestResultId()); TEST_RESULT_DAO.getData(sibTestResult); for (Analysis analysis : analysisList) { List<Result> resultList = RESULT_DAO.getResultsByAnalysis(analysis); Test test = analysis.getTest(); for (Result result : resultList) { TestResult testResult = TEST_RESULT_DAO .getTestResultsByTestAndDictonaryResult(test.getId(), result.getValue()); if (testResult != null && testResult.getId().equals(sibTestReflex.getTestResultId())) { selectableReflexes.add(candidateReflex); reflexTriggers.add(candidateReflex.getTest().getLocalizedName() + ":" + dictionaryResult.getDictEntry()); // reflexTriggerIds.add( candidateReflex.getTest().getId() ); } } } } } } } if (selectableReflexes.size() > 1) { jsonResult.put("rowIndex", rowIndex); createTriggerList(reflexTriggers, resultIds, jsonResult); createChoiceElement(selectableReflexes, jsonResult); createPlaceholderForSelectedReflexes(jsonResult); return VALID; } return INVALID; }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexUserChoiceProvider.java
private Sample getSampleForKnownTest(String analysisIds, String accessionNumber, AnalysisDAO analysisDAO) { //We use the analysisId for logbook results and accessionNumber for analysis results, we should accessionNumber for both. if (GenericValidator.isBlankOrNull(analysisIds)) { return new SampleDAOImpl().getSampleByAccessionNumber(accessionNumber); } else {//from w w w.j a va 2s . c om Analysis knownAnalysis = new Analysis(); knownAnalysis.setId(analysisIds); analysisDAO.getData(knownAnalysis); return knownAnalysis.getSampleItem().getSample(); } }
From source file:us.mn.state.health.lims.common.provider.query.TestReflexUserChoiceProvider.java
private boolean areSibs(TestReflex testReflex, TestReflex sibTestReflex) { return !GenericValidator.isBlankOrNull(testReflex.getSiblingReflexId()) && !GenericValidator.isBlankOrNull(sibTestReflex.getSiblingReflexId()) && testReflex.getSiblingReflexId().equals(sibTestReflex.getId()) && sibTestReflex.getSiblingReflexId().equals(testReflex.getId()); }
From source file:us.mn.state.health.lims.common.provider.query.workerObjects.PatientSearchLocalAndClinicWorker.java
/** * @see us.mn.state.health.lims.common.provider.query.workerObjects.PatientSearchWorker#createSearchResultXML(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.StringBuilder) *//* ww w . java 2 s .co m*/ @Override public String createSearchResultXML(String lastName, String firstName, String STNumber, String subjectNumber, String nationalID, String patientID, String guid, StringBuilder xml) { // just to make the name shorter ConfigurationProperties config = ConfigurationProperties.getInstance(); String success = IActionConstants.VALID; if (GenericValidator.isBlankOrNull(lastName) && GenericValidator.isBlankOrNull(firstName) && GenericValidator.isBlankOrNull(STNumber) && GenericValidator.isBlankOrNull(subjectNumber) && GenericValidator.isBlankOrNull(nationalID) && GenericValidator.isBlankOrNull(patientID) && GenericValidator.isBlankOrNull(guid)) { xml.append("No search terms were entered"); return IActionConstants.INVALID; } ExternalPatientSearch externalSearch = new ExternalPatientSearch(); externalSearch.setSearchCriteria(lastName, firstName, STNumber, subjectNumber, nationalID, guid); externalSearch.setConnectionCredentials(config.getPropertyValue(Property.PatientSearchURL), config.getPropertyValue(Property.PatientSearchUserName), config.getPropertyValue(Property.PatientSearchPassword), (int) SystemConfiguration.getInstance().getSearchTimeLimit()); Thread searchThread = new Thread(externalSearch); List<PatientSearchResults> localResults = null; List<PatientDemographicsSearchResults> clinicResults = null; List<PatientDemographicsSearchResults> newPatientsFromClinic = new ArrayList<PatientDemographicsSearchResults>(); try { searchThread.start(); SearchResultsDAO localSearch = createLocalSearchResultDAOImp(); localResults = localSearch.getSearchResults(lastName, firstName, STNumber, subjectNumber, nationalID, nationalID, patientID, guid); searchThread.join(SystemConfiguration.getInstance().getSearchTimeLimit() + 500); if (externalSearch.getSearchResultStatus() == 200) { clinicResults = externalSearch.getSearchResults(); } else { // TODO do something with the errors } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException ise) { } findNewPatients(localResults, clinicResults, newPatientsFromClinic); insertNewPatients(newPatientsFromClinic); localResults.addAll(newPatientsFromClinic); setLocalSourceIndicators(localResults); sortPatients(localResults); if (localResults != null && localResults.size() > 0) { for (PatientSearchResults singleResult : localResults) { appendSearchResultRow(singleResult, xml); } } else { success = IActionConstants.INVALID; xml.append("No results were found for search. Check spelling or remove some of the fields"); } return success; }
From source file:us.mn.state.health.lims.common.provider.query.workerObjects.PatientSearchLocalAndClinicWorker.java
public void persistIdentityType(PatientIdentityDAO identityDAO, String paramValue, String type, String patientId) throws LIMSRuntimeException { if (!GenericValidator.isBlankOrNull(paramValue)) { String typeID = PatientIdentityTypeMap.getInstance().getIDForType(type); PatientIdentity identity = new PatientIdentity(); identity.setPatientId(patientId); identity.setIdentityTypeId(typeID); identity.setSysUserId(sysUserId); identity.setIdentityData(paramValue); identity.setLastupdatedFields(); identityDAO.insertData(identity); }/*www . j ava2 s.c om*/ }