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:org.squale.welcom.taglib.table.TableNavigatorTag.java
/** * Initialise les proprietes/*from w w w . jav a 2 s .c o m*/ * * @throws JspException : Exception */ protected void init() throws JspException { response = (HttpServletResponse) pageContext.getResponse(); request = (HttpServletRequest) pageContext.getRequest(); baseURL = ((HttpServletRequest) pageContext.getRequest()).getContextPath(); if (table == null) { final Object bean = RequestUtils.lookup(pageContext, name, null); if (!(bean instanceof Collection)) { throw new JspException("Bean should be type of HTMLTable"); } table = (HTMLTable) bean; } if (table == null) { throw new JspException("Table not set for pagination"); } from = table.getFrom(); volume = table.getVolume(); length = table.getLength(); if (pagesPerNavBar != null) { ipagesPerNavBar = Integer.parseInt(pagesPerNavBar); } if (WelcomConfigurator.getCharte().isV2()) { // Recalcule la taille if (((volume / length) <= PAGES_PER_NAVIGATIONBAR) && GenericValidator.isBlankOrNull(pagesPerNavBar)) { ipagesPerNavBar = 1; } if (ipagesPerNavBar != 1) { txtPrev += " (" + ipagesPerNavBar + ")"; txtNext += " (" + ipagesPerNavBar + ")"; } } // Recupere le formBean formName = getFormName(); }
From source file:org.squale.welcom.taglib.table.TableTag.java
/** * @return le "unique" name//from w w w . j av a2 s .co m */ private String generateUniqueName() { String nom = ""; final String tbl = (String) pageContext.getRequest().getAttribute("welcomTable"); if (GenericValidator.isBlankOrNull(tbl)) { pageContext.getRequest().setAttribute("welcomTable", "1"); nom = "welcomTable1"; } else { final int intdrpdwn = Integer.parseInt(tbl) + 1; nom = "welcomTable" + (intdrpdwn); pageContext.getRequest().setAttribute("welcomTable", "" + intdrpdwn); } return nom; }
From source file:org.squale.welcom.taglib.table.TableTag.java
/** * @see javax.servlet.jsp.tagext.Tag#doEndTag() *///from w w w . j av a 2s. com public int doEndTag() throws JspException { final TrimStringBuffer sb = new TrimStringBuffer(); if (getBodyContent() != null) { sb.append(getBodyContent().getString()); } if ((!(collectionForDisplay.isEmpty()) || (collectionForDisplay.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) && displayFooter) { sb.append(writeTableBottom()); } sb.append("<input type=\"hidden\" name=\"" + uniqueName + ".savedFrom\" value=\""); sb.append(offSet); sb.append("\">"); ResponseUtils.write(pageContext, sb.toString()); if (displayNavigation && !(collectionForDisplay.isEmpty())) { if ((totalLabelPos.indexOf(BOTTOM) >= 0) || (paginationPos.indexOf(BOTTOM) >= 0)) { writeTableNavigation(BOTTOM); } writePixGris(); } return EVAL_PAGE; }
From source file:org.squale.welcom.taglib.table.TableTag.java
/** * @return retourne le message calcul Va voir en premier si on a definit une clef, alors recupere celle-ci, sinon, * prend celle dans l' applicationresource.properties *//*from www .j a v a2 s . c o m*/ private String getMessageComputed() { String message; if (!GenericValidator.isBlankOrNull(totalLabelKey)) { message = resources.getMessage(localeRequest, totalLabelKey, Integer.toString(collection.size())); } else { message = resources.getMessage(localeRequest, DEFAULT_TOTAL_LABEL_KEY, Integer.toString(collection.size())); } if (message == null) { message = totalLabelKey; } return message; }
From source file:org.squale.welcom.taglib.write.WWriteTag.java
/** * @see org.apache.struts.taglib.bean.WriteTag#formatValue(java.lang.Object) *//*from w w w . j a v a 2s . co m*/ protected String formatValue(final Object valueToFormat) throws JspException { if (GenericValidator.isBlankOrNull(dateFormat) && GenericValidator.isBlankOrNull(dateFormatKey)) { return super.formatValue(valueToFormat); } else { // On retrouve le simpleDateFormat SimpleDateFormat simpleDateFormat; final MessageResources resources = (MessageResources) pageContext.getServletContext() .getAttribute(Globals.MESSAGES_KEY); final Locale localeRequest = (Locale) pageContext.getSession().getAttribute(Globals.LOCALE_KEY); if (!GenericValidator.isBlankOrNull(dateFormatKey)) { simpleDateFormat = new SimpleDateFormat(resources.getMessage(localeRequest, dateFormatKey), localeRequest); } else { simpleDateFormat = new SimpleDateFormat(dateFormat, localeRequest); } // on formate la date String result = ""; if (valueToFormat instanceof Date) { result = simpleDateFormat.format((Date) valueToFormat); } else if (valueToFormat instanceof String && !GenericValidator.isBlankOrNull((String) valueToFormat)) { result = simpleDateFormat.format(new Date(Long.parseLong((String) valueToFormat))); } return result; } }
From source file:oscar.form.pageUtil.FrmFormAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionMessages errors = new ActionMessages(); boolean valid = true; logger.debug("FrmFormAction is called " + currentMem()); logger.debug("current mem 1 " + currentMem()); FrmFormForm frm = (FrmFormForm) form; HttpSession session = request.getSession(); EctSessionBean bean = (EctSessionBean) request.getSession().getAttribute("EctSessionBean"); request.getSession().setAttribute("EctSessionBean", bean); String formName = (String) frm.getValue("formName"); logger.debug("formNme Top " + formName); String formId = (String) frm.getValue("formId"); String dateEntered = UtilDateUtilities.DateToString(UtilDateUtilities.Today(), _dateFormat); String timeStamp = UtilDateUtilities.DateToString(UtilDateUtilities.Today(), "yyyy-MM-dd hh:mm:ss"); //String visitCod = UtilDateUtilities.DateToString(UtilDateUtilities.Today(),"yyyyMMdd"); String today = UtilDateUtilities.DateToString(UtilDateUtilities.Today(), "yyyy-MM-dd"); logger.debug("current mem 2 " + currentMem()); Properties props = new Properties(); EctFormProp formProp = EctFormProp.getInstance(); Vector measurementTypes = EctFormProp.getMeasurementTypes(); logger.debug("num measurements " + measurementTypes.size()); String demographicNo = null;/* w ww. j ava2 s. co m*/ String providerNo = (String) session.getAttribute("user"); if (bean != null) demographicNo = bean.getDemographicNo(); logger.debug("current mem 3 " + currentMem()); errors.clear(); valid = true; logger.debug("current mem 4 " + currentMem()); String submit = request.getParameter("submit"); EctMeasurementTypesBean mt; EctValidationsBean validation; EctValidation ectValidation = new EctValidation(); //Validate each measurement long startTime = System.currentTimeMillis(); logger.debug("current mem 5 " + currentMem()); for (int i = 0; i < measurementTypes.size(); i++) { mt = (EctMeasurementTypesBean) measurementTypes.elementAt(i); validation = (EctValidationsBean) mt.getValidationRules().elementAt(0); String inputValue = (String) frm.getValue(mt.getType() + "Value"); String observationDate = (String) frm.getValue(mt.getType() + "Date"); if (observationDate == null) { observationDate = today; } else if (observationDate.compareTo("") == 0) { observationDate = today; } //parse the checkbox value inputValue = parseCheckBoxValue(inputValue, validation.getName()); //validate valid = validate(inputValue, observationDate, mt, validation, request, errors); } valid = ectValidation.isDate((String) frm.getValue("visitCod")); logger.debug("current mem 6 " + currentMem()); long endTime = System.currentTimeMillis(); long delTime = endTime - startTime; logger.debug("Time spent on validation: " + Long.toString(delTime)); if (valid) { DemographicData demoData = new DemographicData(); org.oscarehr.common.model.Demographic demo = demoData.getDemographic(demographicNo); logger.debug("is valid, procede write to table"); //Store form information as properties for saving to form table props.setProperty("demographic_no", demographicNo); props.setProperty("provider_no", providerNo); props.setProperty("visitCod", (String) frm.getValue("visitCod")); props.setProperty("dob", DemographicData.getDob(demo, "-")); props.setProperty("gender", demo.getSex()); props.setProperty("surname", demo.getLastName()); props.setProperty("givenName", demo.getFirstName()); String diagnosisVT = org.apache.commons.lang.StringEscapeUtils .escapeSql((String) frm.getValue("diagnosisVT")); String subjective = org.apache.commons.lang.StringEscapeUtils .escapeSql((String) frm.getValue("subjective")); String objective = org.apache.commons.lang.StringEscapeUtils .escapeSql((String) frm.getValue("objective")); String assessment = org.apache.commons.lang.StringEscapeUtils .escapeSql((String) frm.getValue("assessment")); String plan = org.apache.commons.lang.StringEscapeUtils.escapeSql((String) frm.getValue("plan")); //for VTForm props.setProperty("Diagnosis", diagnosisVT); props.setProperty("Subjective", subjective); props.setProperty("Objective", objective); props.setProperty("Assessment", assessment); props.setProperty("Plan", plan); startTime = System.currentTimeMillis(); for (int i = 0; i < measurementTypes.size(); i++) { logger.debug("current mem 7.1." + i + " " + currentMem()); mt = (EctMeasurementTypesBean) measurementTypes.elementAt(i); validation = (EctValidationsBean) mt.getValidationRules().elementAt(0); String type = mt.getType(); String inputValue = (String) frm.getValue(type + "Value"); String lastData = (String) frm.getValue(type + "LastData"); String lastDataEnteredDate = (String) frm.getValue(type + "LastDataEnteredDate"); String observationDate = (String) frm.getValue(type + "Date"); if (observationDate == null) { observationDate = today; } else if (observationDate.compareTo("") == 0) { observationDate = today; } String comments = (String) frm.getValue(type + "Comments"); comments = org.apache.commons.lang.StringEscapeUtils.escapeSql(comments); logger.debug("type: " + type + " inputValue: " + inputValue); //parse the checkbox value inputValue = parseCheckBoxValue(inputValue, validation.getName()); //Write to Measurement Table if (inputValue != null) { if (submit.equalsIgnoreCase("exit") && !inputValue.equalsIgnoreCase("")) write2MeasurementTable(demographicNo, providerNo, mt, inputValue, observationDate, comments); } //Store all input value as properties for saving to form table if (lastData != null) props.setProperty(type + "LastData", lastData); if (lastDataEnteredDate != null) props.setProperty(type + "LastDataEnteredDate", lastDataEnteredDate); props.setProperty(type + "Date", observationDate == null ? dateEntered : observationDate); props.setProperty(type + "Comments", comments == null ? "" : comments); if (!GenericValidator.isBlankOrNull(inputValue)) { props.setProperty(type + "Value", inputValue); if (type.equalsIgnoreCase("BP")) { //extract SBP and DBP for blood pressure String bp = inputValue; if (bp != null) { int sbpIndex = bp.indexOf("/"); if (sbpIndex >= 0) { String sbp = bp.substring(0, sbpIndex); String dbp = bp.substring(sbpIndex + 1); props.setProperty("SBPValue", sbp); props.setProperty("DBPValue", dbp); } } } } logger.debug("current mem 7.2." + i + " " + currentMem()); } endTime = System.currentTimeMillis(); delTime = endTime - startTime; logger.debug("Time spent on write2Measurements: " + Long.toString(delTime)); //Store the the form table for keeping the current record logger.debug("current mem 8 " + currentMem()); try { String sql = "SELECT * FROM form" + formName + " WHERE demographic_no='" + demographicNo + "' AND ID=0"; FrmRecordHelp frh = new FrmRecordHelp(); frh.setDateFormat(_dateFormat); (frh).saveFormRecord(props, sql); } catch (SQLException e) { logger.error("Error", e); } logger.debug("current mem 9 " + currentMem()); //Send to Mils thru xml-rpc Properties nameProps = convertName(formName); String xmlData = FrmToXMLUtil.convertToXml(measurementTypes, nameProps, props); String decisionSupportURL = connect2OSDSF(xmlData); request.setAttribute("decisionSupportURL", decisionSupportURL); logger.debug("current mem 9 " + currentMem()); } else { //return to the orignal form return (new ActionForward("/form/SetupForm.do?formName=" + formName + "&formId=0")); } //return mapping.findForward("success"); //forward to the for with updated formId logger.debug("submit value: " + submit); if (submit.equalsIgnoreCase("exit")) { String toEChart = "[" + timeStamp + ".: Vascular Tracker] \n\n"; request.setAttribute("diagnosisVT", "See Vascular Tracker Template"); return (new ActionForward("/form/formSaveAndExit.jsp")); } logger.debug("formName from Frm ForamAction" + formName); EncounterFormDao encounterFormDao = (EncounterFormDao) SpringUtils.getBean("encounterFormDao"); EncounterForm encounterForm = encounterFormDao .find("../form/SetupForm.do?formName=" + formName + "&demographic_no="); String formNameByFormTable = encounterForm.getFormName(); logger.debug("formNameByFormTable" + formNameByFormTable); String[] formPath = { "", "0" }; try { formPath = (new FrmData()).getShortcutFormValue(demographicNo, formNameByFormTable); } catch (SQLException e) { logger.error("Error", e); } return (new ActionForward("/form/SetupForm.do?formName=" + formName + "&formId=" + formPath[1])); }
From source file:oscar.form.pageUtil.FrmFormAction.java
private boolean validate(String inputValue, String observationDate, EctMeasurementTypesBean mt, EctValidationsBean validation, HttpServletRequest request, ActionMessages errors) { EctValidation ectValidation = new EctValidation(); boolean valid = true; String inputTypeDisplay = mt.getTypeDesc(); String inputValueName = mt.getType() + "Value"; String inputDateName = mt.getType() + "Date"; String regExp = validation.getRegularExp(); double dMax = Double.parseDouble(validation.getMaxValue() == null ? "0" : validation.getMaxValue()); double dMin = Double.parseDouble(validation.getMinValue() == null ? "0" : validation.getMinValue()); int iMax = Integer.parseInt(validation.getMaxLength() == null ? "0" : validation.getMaxLength()); int iMin = Integer.parseInt(validation.getMinLength() == null ? "0" : validation.getMinLength()); int iIsDate = Integer.parseInt(validation.getIsDate() == null ? "0" : validation.getIsDate()); int iIsNumeric = Integer.parseInt(validation.getIsNumeric() == null ? "0" : validation.getIsNumeric()); if (!GenericValidator.isBlankOrNull(inputValue)) { if (iIsNumeric == 1 && !ectValidation.isInRange(dMax, dMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.range", inputTypeDisplay, Double.toString(dMin), Double.toString(dMax))); saveErrors(request, errors); valid = false;/*from w ww . j a v a 2 s .c om*/ } if (!ectValidation.maxLength(iMax, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.maxlength", inputTypeDisplay, Integer.toString(iMax))); saveErrors(request, errors); valid = false; } if (!ectValidation.minLength(iMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.minlength", inputTypeDisplay, Integer.toString(iMin))); saveErrors(request, errors); valid = false; } if (!ectValidation.matchRegExp(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.invalid", inputTypeDisplay)); saveErrors(request, errors); valid = false; } if (mt.getType().equalsIgnoreCase("BP") && !ectValidation.isValidBloodPressure(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("error.bloodPressure")); saveErrors(request, errors); valid = false; } if (iIsDate == 1 && !ectValidation.isDate(inputValue)) { errors.add(inputValueName, new ActionMessage("errors.invalidDate", inputTypeDisplay)); saveErrors(request, errors); valid = false; } if (!ectValidation.isDate(observationDate)) { errors.add(inputDateName, new ActionMessage("errors.invalidDate", inputTypeDisplay)); saveErrors(request, errors); valid = false; } } return valid; }
From source file:oscar.form.pageUtil.FrmFormAction.java
private boolean write2MeasurementTable(String demographicNo, String providerNo, EctMeasurementTypesBean mt, String inputValue, String dateObserved, String comments) { boolean newDataAdded = false; try {//from w w w .j av a 2 s . c om org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator(); if (!GenericValidator.isBlankOrNull(inputValue)) { //Find if the same data has already been entered into the system String sql = "SELECT * FROM measurements WHERE demographicNo='" + demographicNo + "' AND type='" + mt.getType() + "' AND dataField='" + inputValue + "' AND measuringInstruction='" + mt.getMeasuringInstrc() + "' AND comments='" + comments + "' AND dateObserved='" + dateObserved + "'"; ResultSet rs = DBHandler.GetSQL(sql); if (!rs.next()) { newDataAdded = true; //Write to the Dababase if all input values are valid sql = "INSERT INTO measurements" + "(type, demographicNo, providerNo, dataField, measuringInstruction, comments, dateObserved, dateEntered)" + " VALUES ('" + mt.getType() + "','" + demographicNo + "','" + providerNo + "','" + inputValue + "','" + mt.getMeasuringInstrc() + "','" + comments + "','" + dateObserved + "', now())"; DBHandler.RunSQL(sql); } rs.close(); } } catch (SQLException e) { logger.error("Error", e); } return newDataAdded; }
From source file:oscar.form.util.FrmToXMLUtil.java
/** * @param args the command line arguments *///from www .j ava 2 s . c o m public static String convertToXml(Vector measurementTypes, Properties nameProps, Properties dataProps) { // TODO code application logic here String _dateFormat = "yyyy-MM-dd hh:mm:ss"; String dateEntered = UtilDateUtilities.DateToString(UtilDateUtilities.Today(), _dateFormat); ProviderData prData = new ProviderData(dataProps.getProperty("provider_no")); String vType = "Other"; //Other if (prData.getProvider_type().equalsIgnoreCase("doctor")) vType = "FamilyMDVisit"; //FamilyMDVisit else if (prData.getProvider_type().equalsIgnoreCase("nurse")) vType = "NurseVisit"; //NurseVisit XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(3); String xmlStr = ""; SitePatientVisitRecordsDocument visitDocument = SitePatientVisitRecordsDocument.Factory.newInstance(); SitePatientVisitRecordsDocument.SitePatientVisitRecords visitRecord = visitDocument .addNewSitePatientVisitRecords(); SitePatientVisitRecordsDocument.SitePatientVisitRecords.SitePatientVisit visit = visitRecord .addNewSitePatientVisit(); visitRecord.setVersion(visitRecord.getVersion()); try { String who = dataProps.getProperty("provider_no"); String how = "EMR"; String when = dateEntered; SitePatientVisitRecordsDocument.SitePatientVisitRecords.SitePatientVisit.SelVisitType visitType = visit .addNewSelVisitType(); visitType.setValue(vType); visitType.setSignedWhen(when); visitType.setSignedHow(how); visitType.setSignedWho(who); visit.setPatientCod(dataProps.getProperty("demographic_no")); visit.setVisitCod(dataProps.getProperty("visitCod")); Class cls = visit.getClass(); // Add dob Method addNewMethod = cls.getMethod("addNewDatBirthDate", new Class[] {}); Object obj = addNewMethod.invoke(visit, new Object[] {}); String value = dataProps.getProperty("dob"); value = translate(value, "DatBirthDate"); setWhoWhatWhereWhen(obj, how, who, when, value); //Add Surname addNewMethod = cls.getMethod("addNewTxtSurname", new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty("surname"); value = translate(value, "TxtSurname"); setWhoWhatWhereWhen(obj, how, who, when, value); //Add givien Name addNewMethod = cls.getMethod("addNewTxtGivenNames", new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty("givenName"); value = translate(value, "TxtGivenNames"); setWhoWhatWhereWhen(obj, how, who, when, value); //Add Gender addNewMethod = cls.getMethod("addNewSelGender", new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty("gender"); value = translate(value, "SelGender"); setWhoWhatWhereWhen(obj, how, who, when, value); ///FLU SHOT if (getFluShotBillingDate(dataProps.getProperty("demographic_no")) != null) { addNewMethod = cls.getMethod("addNewBFluShotDoneThisSeason", new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); setWhoWhatWhereWhen(obj, how, who, when, "true"); } EctMeasurementTypesBean mt; for (int i = 0; i < measurementTypes.size(); i++) { mt = (EctMeasurementTypesBean) measurementTypes.elementAt(i); String itemName = mt.getType(); String methodCall = (String) nameProps.get(itemName + "Value"); MiscUtils.getLogger().debug("method " + methodCall); org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator(); if (mt.getType().equalsIgnoreCase("BP") && !GenericValidator.isBlankOrNull(dataProps.getProperty("SBPValue"))) { methodCall = (String) nameProps.get("SBPValue"); if (methodCall != null) { cls = visit.getClass(); addNewMethod = cls.getMethod("addNew" + methodCall, new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty("SBPValue"); setWhoWhatWhereWhen(obj, how, who, when, value); } methodCall = (String) nameProps.get("DBPValue"); if (methodCall != null) { cls = visit.getClass(); addNewMethod = cls.getMethod("addNew" + methodCall, new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty("DBPValue"); setWhoWhatWhereWhen(obj, how, who, when, value); } methodCall = (String) nameProps.get("BPDate"); if (methodCall != null) { cls = visit.getClass(); addNewMethod = cls.getMethod("addNew" + methodCall, new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty(itemName + "Date"); setWhoWhatWhereWhen(obj, how, who, when, value); } } else if (methodCall != null && !GenericValidator.isBlankOrNull(dataProps.getProperty(itemName + "Value"))) { cls = visit.getClass(); addNewMethod = cls.getMethod("addNew" + methodCall, new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty(itemName + "Value"); value = translate(value, methodCall); MiscUtils.getLogger() .debug(itemName + " who " + who + " how " + how + " when " + when + " value " + value); setWhoWhatWhereWhen(obj, how, who, when, value); //String date = dataProps.getProperty(itemName+"Date"); //setWhoWhatWhereWhen(obj,how,who,when,date); methodCall = (String) nameProps.get(itemName + "Date"); if (methodCall != null) { cls = visit.getClass(); addNewMethod = cls.getMethod("addNew" + methodCall, new Class[] {}); obj = addNewMethod.invoke(visit, new Object[] {}); value = dataProps.getProperty(itemName + "Date"); setWhoWhatWhereWhen(obj, how, who, when, value); } } } //get drug list RxPatientData.Patient p = RxPatientData .getPatient(Integer.parseInt(dataProps.getProperty("demographic_no") == null ? "0" : dataProps.getProperty("demographic_no"))); RxPrescriptionData.Prescription[] prescribedDrugs = p.getPrescribedDrugsUnique(); for (int i = 0; i < prescribedDrugs.length; i++) { SitePatientVisitRecordsDocument.SitePatientVisitRecords.SitePatientVisit.SitePatientVisitDrug drug = visit .addNewSitePatientVisitDrug(); String atccode = prescribedDrugs[i].getAtcCode().trim(); if (atccode == null || atccode.equalsIgnoreCase("null") || atccode.equals("")) { drug.setDrugCod("NAM_" + prescribedDrugs[i].getDrugName()); } else { drug.setDrugCod("ATC_" + prescribedDrugs[i].getAtcCode().trim()); } SitePatientVisitRecordsDocument.SitePatientVisitRecords.SitePatientVisit.SitePatientVisitDrug.TxtDrugName drugName = drug .addNewTxtDrugName(); drugName.setSignedHow(how); drugName.setSignedWho(who); drugName.setSignedWhen(when); drugName.setValue(prescribedDrugs[i].getDrugName()); } } catch (NoSuchMethodException e) { MiscUtils.getLogger().error("Error", e); } catch (IllegalAccessException e) { MiscUtils.getLogger().error("Error", e); } catch (Exception e) { MiscUtils.getLogger().error("Error", e); } xmlStr = xmlStr + visitDocument.xmlText(xmlOptions); MiscUtils.getLogger() .debug("*********************************************************************************"); MiscUtils.getLogger() .debug("************************** XML GENERATED BY OSCAR *******************************"); MiscUtils.getLogger() .debug("*********************************************************************************"); MiscUtils.getLogger().debug(xmlStr); return xmlStr; }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.EctMeasurementsAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EctMeasurementsForm frm = (EctMeasurementsForm) form; HttpSession session = request.getSession(); //request.getSession().setAttribute("EctMeasurementsForm", frm); EctSessionBean bean = (EctSessionBean) request.getSession().getAttribute("EctSessionBean"); String demographicNo = null;//from w w w .ja v a 2 s .co m String providerNo = (String) session.getAttribute("user"); //if form has demo use it since session bean could have been overwritten if ((demographicNo = (String) frm.getValue("demographicNo")) == null) { if (bean != null) demographicNo = bean.getDemographicNo(); } String template = request.getParameter("template"); MeasurementFlowSheet mFlowsheet = null; if (template != null) { WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(session.getServletContext()); FlowSheetCustomizationDao flowSheetCustomizationDao = (FlowSheetCustomizationDao) ctx .getBean("flowSheetCustomizationDao"); MeasurementTemplateFlowSheetConfig templateConfig = MeasurementTemplateFlowSheetConfig.getInstance(); List<FlowSheetCustomization> custList = flowSheetCustomizationDao.getFlowSheetCustomizations(template, (String) session.getAttribute("user"), demographicNo); mFlowsheet = templateConfig.getFlowSheet(template, custList); } //request.getSession().setAttribute("EctSessionBean", bean); //TODO replace with a date format call. Actually revamp to use hibernate java.util.Calendar calender = java.util.Calendar.getInstance(); String day = Integer.toString(calender.get(java.util.Calendar.DAY_OF_MONTH)); String month = Integer.toString(calender.get(java.util.Calendar.MONTH) + 1); String year = Integer.toString(calender.get(java.util.Calendar.YEAR)); String hour = Integer.toString(calender.get(java.util.Calendar.HOUR_OF_DAY)); String min = Integer.toString(calender.get(java.util.Calendar.MINUTE)); String second = Integer.toString(calender.get(java.util.Calendar.SECOND)); String dateEntered = year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + second; String numType = (String) frm.getValue("numType"); int iType = Integer.parseInt(numType); MsgStringQuote str = new MsgStringQuote(); Properties p = (Properties) session.getAttribute("providerBean"); String by = ""; if (p != null) { by = p.getProperty(providerNo, ""); } String textOnEncounter = ""; //"**"+StringUtils.rightPad(by,80,"*")+"\\n"; //if parent window content has changed then we need to propagate change so //we do not write to parent String parentChanged = (String) frm.getValue("parentChanged"); request.setAttribute("parentChanged", parentChanged); boolean valid = true; try { EctValidation ectValidation = new EctValidation(); ActionMessages errors = new ActionMessages(); String inputValueName, inputTypeName, inputTypeDisplayName, mInstrcName, commentsName; String dateName, validationName, inputValue, inputType, inputTypeDisplay, mInstrc; String comments, dateObserved, validation; String regExp = null; double dMax = 0; double dMin = 0; int iMax = 0; int iMin = 0; ResultSet rs; String regCharExp; //goes through each type to check if the input value is valid for (int i = 0; i < iType; i++) { inputValueName = "inputValue-" + i; inputTypeName = "inputType-" + i; inputTypeDisplayName = "inputTypeDisplayName-" + i; mInstrcName = "inputMInstrc-" + i; commentsName = "comments-" + i; dateName = "date-" + i; inputValue = (String) frm.getValue(inputValueName); inputType = (String) frm.getValue(inputTypeName); inputTypeDisplay = (String) frm.getValue(inputTypeDisplayName); mInstrc = (String) frm.getValue(mInstrcName); comments = (String) frm.getValue(commentsName); dateObserved = (String) frm.getValue(dateName); regExp = null; dMax = 0; dMin = 0; iMax = 0; iMin = 0; rs = ectValidation.getValidationType(inputType, mInstrc); regCharExp = ectValidation.getRegCharacterExp(); if (rs.next()) { dMax = rs.getDouble("maxValue"); dMin = rs.getDouble("minValue"); iMax = rs.getInt("maxLength"); iMin = rs.getInt("minLength"); regExp = oscar.Misc.getString(rs, "regularExp"); } rs.close(); if (!ectValidation.isInRange(dMax, dMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.range", inputTypeDisplay, Double.toString(dMin), Double.toString(dMax))); saveErrors(request, errors); valid = false; } if (!ectValidation.maxLength(iMax, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.maxlength", inputTypeDisplay, Integer.toString(iMax))); saveErrors(request, errors); valid = false; } if (!ectValidation.minLength(iMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.minlength", inputTypeDisplay, Integer.toString(iMin))); saveErrors(request, errors); valid = false; } if (!ectValidation.matchRegExp(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.invalid", inputTypeDisplay)); saveErrors(request, errors); valid = false; } if (!ectValidation.isValidBloodPressure(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("error.bloodPressure")); saveErrors(request, errors); valid = false; } if (!ectValidation.isDate(dateObserved) && inputValue.compareTo("") != 0) { errors.add(dateName, new ActionMessage("errors.invalidDate", inputTypeDisplay)); saveErrors(request, errors); valid = false; } } //Write to database and to encounter form if all the input values are valid if (valid) { for (int i = 0; i < iType; i++) { inputValueName = "inputValue-" + i; inputTypeName = "inputType-" + i; mInstrcName = "inputMInstrc-" + i; commentsName = "comments-" + i; validationName = "validation-" + i; dateName = "date-" + i; inputValue = (String) frm.getValue(inputValueName); inputType = (String) frm.getValue(inputTypeName); mInstrc = (String) frm.getValue(mInstrcName); comments = (String) frm.getValue(commentsName); comments = org.apache.commons.lang.StringEscapeUtils.escapeSql(comments); validation = (String) frm.getValue(validationName); dateObserved = (String) frm.getValue(dateName); org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator(); if (!GenericValidator.isBlankOrNull(inputValue)) { //Find if the same data has already been entered into the system String sql = "SELECT * FROM measurements WHERE demographicNo='" + demographicNo + "' AND dataField='" + inputValue + "' AND measuringInstruction='" + mInstrc + "' AND comments='" + comments + "' AND dateObserved='" + dateObserved + "' and type = '" + inputType + "'"; rs = DBHandler.GetSQL(sql); if (!rs.next()) { //Write to the Dababase if all input values are valid sql = "INSERT INTO measurements" + "(type, demographicNo, providerNo, dataField, measuringInstruction, comments, dateObserved, dateEntered)" + " VALUES ('" + str.q(inputType) + "','" + str.q(demographicNo) + "','" + str.q(providerNo) + "','" + str.q(inputValue) + "','" + str.q(mInstrc) + "','" + str.q(comments) + "','" + str.q(dateObserved) + "','" + str.q(dateEntered) + "')"; DBHandler.RunSQL(sql); //prepare input values for writing to the encounter form if (mFlowsheet == null) { textOnEncounter = textOnEncounter + inputType + " " + inputValue + " " + mInstrc + " " + comments + "\\n"; } else { textOnEncounter += mFlowsheet.getFlowSheetItem(inputType).getDisplayName() + " " + inputValue + " " + comments + "\\n"; } } rs.close(); } } // textOnEncounter = textOnEncounter + "**********************************************************************************\\n"; } else { String groupName = (String) frm.getValue("groupName"); String css = (String) frm.getValue("css"); request.setAttribute("groupName", groupName); request.setAttribute("css", css); return (new ActionForward(mapping.getInput())); } /* select the correct db specific command */ String db_type = OscarProperties.getInstance().getProperty("db_type").trim(); String dbSpecificCommand; if (db_type.equalsIgnoreCase("mysql")) { dbSpecificCommand = "SELECT LAST_INSERT_ID()"; } else if (db_type.equalsIgnoreCase("postgresql")) { dbSpecificCommand = "SELECT CURRVAL('consultationrequests_numeric')"; } else throw new SQLException("ERROR: Database " + db_type + " unrecognized."); } catch (SQLException e) { MiscUtils.getLogger().error("Error", e); } //put the inputvalue to the encounter form session.setAttribute("textOnEncounter", textOnEncounter); return mapping.findForward("success"); }