List of usage examples for org.apache.commons.lang StringUtils endsWith
public static boolean endsWith(String str, String suffix)
Check if a String ends with a specified suffix.
From source file:org.openmrs.module.patientdashboard.web.controller.ClinicalSummaryController.java
@RequestMapping(method = RequestMethod.GET) public String firstView(@RequestParam("patientId") Integer patientId, Model model) { PatientDashboardService dashboardService = Context.getService(PatientDashboardService.class); String orderLocationId = "1"; Location location = Context.getLocationService().getLocation(Integer.parseInt(orderLocationId)); Patient patient = Context.getPatientService().getPatient(patientId); String gpOPDEncType = Context.getAdministrationService() .getGlobalProperty(PatientDashboardConstants.PROPERTY_OPD_ENCOUTNER_TYPE); EncounterType labOPDType = Context.getEncounterService().getEncounterType(gpOPDEncType); ConceptService conceptService = Context.getConceptService(); AdministrationService administrationService = Context.getAdministrationService(); String gpDiagnosis = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_PROVISIONAL_DIAGNOSIS); Concept cFinalDiagnosis = conceptService.getConcept("FINAL DIAGNOSIS"); String gpProcedure = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE); //String gpInternalReferral = administrationService.getGlobalProperty(PatientDashboardConstants.PROPERTY_INTERNAL_REFERRAL); Concept conDiagnosis = conceptService.getConcept(gpDiagnosis); Concept conProcedure = conceptService.getConcept(gpProcedure); List<Encounter> encounters = dashboardService.getEncounter(patient, location, labOPDType, null); // condiagnosis // //from w w w . ja v a 2 s . c o m // command String diagnosis = ""; String procedure = ""; List<Clinical> clinicalSummaries = new ArrayList<Clinical>(); for (Encounter enc : encounters) { diagnosis = ""; String note = ""; procedure = ""; Clinical clinical = new Clinical(); for (Obs obs : enc.getAllObs()) { //diagnosis if (obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId())) { // obs.getV if (obs.getValueCoded() != null) { diagnosis += obs.getValueCoded().getName() + ", "; } if (StringUtils.isNotBlank(obs.getValueText())) { note = "Note: " + obs.getValueText(); } //System.out.println(obs.getva); } //final diagnosis if (obs.getConcept().getConceptId().equals(cFinalDiagnosis.getConceptId())) { // obs.getV if (obs.getValueCoded() != null) { diagnosis += obs.getValueCoded().getName() + ", "; } if (StringUtils.isNotBlank(obs.getValueText())) { note = "Note: " + obs.getValueText(); } //System.out.println(obs.getva); } //procedure if (obs.getConcept().getConceptId().equals(conProcedure.getConceptId())) { // obs.getV if (obs.getValueCoded() != null) { procedure += obs.getValueCoded().getName() + ", "; } if (StringUtils.isNotBlank(obs.getValueText())) { procedure += obs.getValueText() + ", "; } } } diagnosis += note; if (StringUtils.endsWith(diagnosis, ", ")) { diagnosis = StringUtils.removeEnd(diagnosis, ", "); } if (StringUtils.endsWith(procedure, ", ")) { procedure = StringUtils.removeEnd(procedure, ", "); } //${patient.givenName} ${patient.middleName} ${patient.familyName} clinical.setTreatingDoctor( enc.getCreator().getPerson().getGivenName() + " " + enc.getCreator().getPerson().getMiddleName() + " " + enc.getCreator().getPerson().getFamilyName()); SimpleDateFormat sdf = new SimpleDateFormat("EEE dd/MM/yyyy hh:mm a"); clinical.setDateOfVisit(sdf.format(enc.getDateCreated())); clinical.setId(enc.getId()); clinical.setDiagnosis(diagnosis); clinical.setProcedures(procedure); clinicalSummaries.add(clinical); // set value to command object // add command to list } ; model.addAttribute("patient", patient); model.addAttribute("clinicalSummaries", clinicalSummaries); return "module/patientdashboard/clinicalSummary"; }
From source file:org.openmrs.module.patientdashboard.web.controller.global.IPDRecordUtil.java
private String getDiagnosisProcedure(IpdPatientAdmissionLog currentAdmissionLog, int type) { String results = ""; // get diagnosis concept ConceptService conceptService = Context.getConceptService(); AdministrationService administrationService = Context.getAdministrationService(); Set<Obs> listObsByObsGroup = currentAdmissionLog.getIpdEncounter().getAllObs(); //System.out.println("listObsByObsGroup ;"+listObsByObsGroup); if (type == 1) { String gpDiagnosis = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_PROVISIONAL_DIAGNOSIS); Concept conDiagnosis = conceptService.getConcept(gpDiagnosis); if (CollectionUtils.isNotEmpty(listObsByObsGroup)) { for (Obs obs : listObsByObsGroup) { // System.out.println("obs : "+obs.getId()); if (obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId())) { if (obs.getValueCoded() != null) { // System.out.println(" value coded : "+obs.getValueCoded().getName()); results += obs.getValueCoded().getName() + "<br/>"; }//from www. j a v a 2s . c om if (StringUtils.isNotBlank(obs.getValueText())) { // System.out.println(" value text : "+obs.getValueAsString(Context.getLocale())); results += obs.getValueText() + "<br/>"; } } } } } else if (type == 2) { String gpProcedure = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE); Concept conProcedure = conceptService.getConcept(gpProcedure); if (CollectionUtils.isNotEmpty(listObsByObsGroup)) { for (Obs obs : listObsByObsGroup) { // System.out.println("obs : "+obs.getId()); if (obs.getConcept().getConceptId().equals(conProcedure.getConceptId())) { if (obs.getValueCoded() != null) { // System.out.println(" value coded : "+obs.getValueCoded().getName()); results += obs.getValueCoded().getName() + "<br/>"; } if (StringUtils.isNotBlank(obs.getValueText())) { // System.out.println(" value text : "+obs.getValueAsString(Context.getLocale())); results += obs.getValueText() + "<br/>"; } } } } } if (StringUtils.endsWith(results, "<br/>")) { results = StringUtils.removeEnd(results, "<br/>"); } return results; }
From source file:org.openmrs.module.patientdashboard.web.controller.global.IPDRecordUtil.java
private String getProcedure(IpdPatientAdmissionLog currentAdmissionLog) { String procedure = ""; // get diagnosis concept ConceptService conceptService = Context.getConceptService(); AdministrationService administrationService = Context.getAdministrationService(); String gpProcedure = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE); Concept conProcedure = conceptService.getConcept(gpProcedure); List<Obs> listObsByObsGroup = Context.getObsService() .findObsByGroupId(currentAdmissionLog.getOpdObsGroup().getId()); if (CollectionUtils.isNotEmpty(listObsByObsGroup)) { for (Obs obs : listObsByObsGroup) { if (obs.getConcept().getConceptId().equals(conProcedure.getConceptId()) && obs.getObsGroup() != null && obs.getObsGroup().getId().equals(currentAdmissionLog.getOpdObsGroup().getId())) { if (obs.getValueCoded() != null) { procedure += obs.getValueCoded().getName() + "<br/>"; }//from w ww . j a v a2 s .c o m if (StringUtils.isNotBlank(obs.getValueText())) { procedure += obs.getValueText() + "<br/>"; } } } } if (StringUtils.endsWith(procedure, "<br/>")) { procedure = StringUtils.removeEnd(procedure, "<br/>"); } return procedure; }
From source file:org.openmrs.module.patientdashboard.web.controller.IPDRecordController.java
@RequestMapping(method = RequestMethod.GET) public String view(Model model, @RequestParam("patientId") Integer patientId) { IpdService ipdService = Context.getService(IpdService.class); //HospitalCoreService hospitalCore = Context.getService(HospitalCoreService.class); List<IpdPatientAdmissionLog> currentAdmissionList = ipdService.listIpdPatientAdmissionLog(patientId, null, IpdPatientAdmitted.STATUS_ADMITTED, 0, 1); IpdPatientAdmissionLog currentAdmission = CollectionUtils.isEmpty(currentAdmissionList) ? null : currentAdmissionList.get(0); if (currentAdmission != null) { IpdPatientAdmitted admitted = ipdService.getAdmittedByPatientId(patientId); model.addAttribute("admitted", admitted); String diagnosis = ""; List<Obs> listObsByObsGroup = Context.getObsService() .findObsByGroupId(currentAdmission.getOpdObsGroup().getId()); //get diagnosis ConceptService conceptService = Context.getConceptService(); AdministrationService administrationService = Context.getAdministrationService(); String gpDiagnosis = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_PROVISIONAL_DIAGNOSIS); String gpProcedure = administrationService .getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE); Concept conDiagnosis = conceptService.getConcept(gpDiagnosis); Concept conProcedure = conceptService.getConcept(gpProcedure); if (CollectionUtils.isNotEmpty(listObsByObsGroup)) { for (Obs obs : listObsByObsGroup) { //diagnosis if (obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId()) && obs.getObsGroup() != null && obs.getObsGroup().getId() == currentAdmission.getOpdObsGroup().getId()) { // obs.getV if (obs.getValueCoded() != null) { diagnosis += obs.getValueCoded().getName() + "<br/>"; }/*from www . java 2s .com*/ if (StringUtils.isNotBlank(obs.getValueText())) { diagnosis += obs.getValueText() + "<br/>"; } //System.out.println(obs.getva); } } } if (StringUtils.endsWith(diagnosis, "<br/>")) { diagnosis = StringUtils.removeEnd(diagnosis, "<br/>"); } String finalDiagnosis = ""; String finalProcedures = ""; if (currentAdmission.getIpdEncounter() != null && CollectionUtils.isNotEmpty(currentAdmission.getIpdEncounter().getAllObs())) { for (Obs obs : currentAdmission.getIpdEncounter().getAllObs()) { //diagnosis if (obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId())) { // obs.getV if (obs.getValueCoded() != null) { finalDiagnosis += obs.getValueCoded().getName() + "<br/>"; } if (StringUtils.isNotBlank(obs.getValueText())) { finalDiagnosis += obs.getValueText() + "<br/>"; } //System.out.println(obs.getva); } //procedure if (obs.getConcept().getConceptId().equals(conProcedure.getConceptId())) { // obs.getV if (obs.getValueCoded() != null) { finalProcedures += obs.getValueCoded().getName() + "<br/>"; } if (StringUtils.isNotBlank(obs.getValueText())) { finalProcedures += obs.getValueText() + "<br/>"; } } } } if (StringUtils.endsWith(finalDiagnosis, "<br/>")) { finalDiagnosis = StringUtils.removeEnd(finalDiagnosis, "<br/>"); } if (StringUtils.endsWith(finalProcedures, "<br/>")) { finalProcedures = StringUtils.removeEnd(finalProcedures, "<br/>"); } model.addAttribute("finalProcedures", finalProcedures); model.addAttribute("finalDiagnosis", finalDiagnosis); model.addAttribute("diagnosis", diagnosis); } List<IpdPatientAdmissionLog> listPatientDischarge = ipdService.listIpdPatientAdmissionLog(patientId, null, IpdPatientAdmitted.STATUS_DISCHARGE, 0, 0); List<IpdPatientAdmittedLog> admittedLogs = ipdService.listAdmittedLogByPatientId(patientId); IPDRecordUtil util = new IPDRecordUtil(); List<IPDRecord> records = util.generateIPDRecord(listPatientDischarge, admittedLogs); model.addAttribute("patientId", patientId); model.addAttribute("records", records); /*IpdService ipdService = Context.getService(IpdService.class); // Get list all admitted in log table if( listAdmitted == null || listAdmitted.size() == 0 ){ return "module/patientdashboard/ipdEntry"; } model.addAttribute("listAdmitted", listAdmitted); // Get current admitted record ( One patient has only one admitted record at one time ) IpdPatientAdmitted curAdmitted = ipdService.getAdmittedByPatientId(patientId); model.addAttribute("currentAdmitted", curAdmitted); // Get OPD Diagnosis String gpOPDEncType = Context.getAdministrationService().getGlobalProperty(PatientDashboardConstants.PROPERTY_OPD_ENCOUTNER_TYPE); EncounterType encounterType = Context.getEncounterService().getEncounterType(gpOPDEncType); Patient patient = Context.getPatientService().getPatient(patientId); if( patient == null ){ return "module/patientdashboard/ipdRecord"; } PatientDashboardService dashboardService = Context.getService(PatientDashboardService.class); String orderLocationId = "1"; Location location = Context.getLocationService().getLocation(Integer.parseInt(orderLocationId)) ; List<Encounter> encounters = dashboardService.getEncounter(patient, location, encounterType, null); String gpDiagnosis = Context.getAdministrationService().getGlobalProperty(PatientDashboardConstants.PROPERTY_PROVISIONAL_DIAGNOSIS); Concept conDiagnosis = Context.getConceptService().getConcept(gpDiagnosis); String gpProcedure = Context.getAdministrationService().getGlobalProperty(PatientDashboardConstants.PROPERTY_POST_FOR_PROCEDURE); Concept conProcedure = Context.getConceptService().getConcept(gpProcedure); String diagnosis = ""; String procedure=""; for( Encounter enc: encounters ){ diagnosis = ""; procedure=""; for( Obs obs : enc.getAllObs()){ //diagnosis if( obs.getConcept().getConceptId().equals(conDiagnosis.getConceptId()) ){ // obs.getV if(obs.getValueCoded() != null){ diagnosis +=obs.getValueCoded().getName()+", "; } if(StringUtils.isNotBlank(obs.getValueAsString(Context.getLocale()))){ diagnosis +=obs.getValueAsString(Context.getLocale())+", "; } //System.out.println(obs.getva); } //procedure if( obs.getConcept().getConceptId().equals(conProcedure.getConceptId()) ){ // obs.getV if(obs.getValueCoded() != null){ procedure +=obs.getValueCoded().getName()+", "; } if(StringUtils.isNotBlank(obs.getValueAsString(Context.getLocale()))){ procedure +=obs.getValueAsString(Context.getLocale())+", "; } } } if( StringUtils.endsWith(diagnosis, ", ")){ diagnosis = StringUtils.removeEnd(diagnosis, ", "); } if( StringUtils.endsWith(procedure, ", ")){ procedure = StringUtils.removeEnd(procedure, ", "); } }; model.addAttribute("currentDiagnosis", diagnosis); model.addAttribute("procedure", procedure);*/ model.addAttribute("currentAdmission", currentAdmission); return "module/patientdashboard/ipdRecord"; }
From source file:org.opennms.features.topology.app.internal.IpLikeSearchProvider.java
/** * Validate if the query string has any chance of being an IPLIKE query. * /*from w w w . ja va 2 s .c o m*/ * FIXME: validates iplike strings that have an octet ending in '-' such as: * 10.7-.*.* * * @param queryString * @return true if the string contains a '*' or '-' or ',' ". */ private boolean isIpLikeQuery(String queryString) { // Matcher iplikeMatcher = m_iplikePattern.matcher(queryString); // return iplikeMatcher.matches(); boolean validity = false; int ipv4delimCnt = StringUtils.countMatches(queryString, "."); int ipv6delimCnt = StringUtils.countMatches(queryString, ":"); if ((ipv4delimCnt == 3 || ipv6delimCnt == 7) && !StringUtils.endsWith(queryString, "-")) { validity = true; } else { validity = false; } return validity; }
From source file:org.pentaho.di.core.refinery.publish.agilebi.ModelServerPublish.java
public int publishDsw(InputStream metadataFile, String domainId) throws Exception { if (!StringUtils.endsWith(domainId, ".xmi")) { throw new IllegalArgumentException("Domain ID for DSW must end in .xmi"); }/*from w w w .j a va 2 s . com*/ final String publishDswUrl = biServerConnection.getUrl() + "plugin/data-access/api/datasource/dsw/import"; WebResource resource = getClient().resource(publishDswUrl); FormDataMultiPart part = new FormDataMultiPart(); part.field("domainId", domainId, MediaType.MULTIPART_FORM_DATA_TYPE).field("metadataFile", metadataFile, MediaType.MULTIPART_FORM_DATA_TYPE); if (this.isForceOverwrite()) { part.field("overwrite", Boolean.toString(this.isForceOverwrite()), MediaType.MULTIPART_FORM_DATA_TYPE); } addAclToRequest(part); // TODO do we want this? part.field("checkConnection", Boolean.TRUE.toString(), MediaType.MULTIPART_FORM_DATA_TYPE); try { Builder builder = resourceBuilder(resource, part); ClientResponse resp = httpPut(builder); if (resp != null) { // TODO: we can get more info from the response; switch (ClientResponse.Status.fromStatusCode(resp.getStatus())) { case OK: case CREATED: return PUBLISH_SUCCESS; default: return PUBLISH_FAILED; } } } catch (Exception ex) { Log.error(ex.getMessage()); } return PUBLISH_FAILED; }
From source file:org.pentaho.di.job.entries.build.JobEntryBuildModel.java
public BiServerConnection environmentSubstitute(BiServerConnection conn) { if (conn == null) { return null; }/*from www. j a va2 s.com*/ BiServerConnection substituted = new BiServerConnection(); // BiServerConnection always adds a trailing '/' if not there.. including vars String url = environmentSubstitute(conn.getUrl()); if (StringUtils.endsWith(url, "//")) { url = StringUtils.chop(url); } substituted.setUrl(url); substituted.setUserId(environmentSubstitute(conn.getUserId())); substituted.setPassword(environmentSubstitute(conn.getPassword())); return substituted; }
From source file:org.pentaho.di.ui.job.entries.common.ServerConnectionGroupWrapper.java
public BiServerConnection getBiServerConnection(boolean resolveVariables) { BiServerConnection biServerModel = new BiServerConnection(); if (resolveVariables) { String url = this.jobMeta.environmentSubstitute(wPublishUrl.getText()); if (StringUtils.endsWith(url, "//")) { url = StringUtils.chop(url); }/*from w w w . ja va2s.com*/ biServerModel.setUrl(url); biServerModel.setUserId(this.jobMeta.environmentSubstitute(wPublishUser.getText())); biServerModel.setPassword(this.jobMeta.environmentSubstitute(wPublishPassword.getText())); } else { biServerModel.setUrl(wPublishUrl.getText()); biServerModel.setUserId(wPublishUser.getText()); biServerModel.setPassword(wPublishPassword.getText()); } return biServerModel; }
From source file:org.pentaho.platform.dataaccess.datasource.api.DataSourceWizardService.java
protected boolean endsWith(String str, String suffix) { return StringUtils.endsWith(str, suffix); }
From source file:org.rapidcontext.app.web.StorageWebService.java
/** * Processes an HTTP GET request.//from w w w.j ava 2 s . c o m * * @param request the request to process */ protected void doGet(Request request) { ApplicationContext ctx = ApplicationContext.getInstance(); Path orig = new Path(request.getPath()); Metadata meta = null; Object res = null; boolean isHtml = false; boolean isJson = false; boolean isProps = false; boolean isXml = false; boolean isDefault = true; Dict dict; // TODO: Change to read-access here once a solution has been devised // to disable search queries for certain paths and/or users. if (!SecurityContext.hasWriteAccess(request.getPath())) { errorUnauthorized(request); return; } try { // TODO: Extend data lookup via query language Path path = normalizePath(orig); if (path != null && !path.equals(orig)) { isHtml = StringUtils.endsWith(orig.name(), EXT_HTML); isJson = StringUtils.endsWith(orig.name(), EXT_JSON); isXml = StringUtils.endsWith(orig.name(), EXT_XML); } isProps = StringUtils.endsWith(orig.name(), EXT_PROPERTIES); isDefault = (!isHtml && !isJson && !isProps && !isXml); if (path != null) { res = ctx.getStorage().load(path); meta = ctx.getStorage().lookup(path); } if (res instanceof Index) { res = serializeIndex((Index) res, isDefault || isHtml); } else if (res instanceof Binary && !isDefault) { res = serializeBinary((Binary) res, request, path); } // Render result as raw data, Properties, HTML, JSON or XML if (res == null) { errorNotFound(request); } else if (isDefault && res instanceof Binary) { request.sendBinary((Binary) res, true); } else if (isDefault || isHtml) { sendHtml(request, path, meta, res); } else if (isJson) { dict = new Dict(); dict.set("metadata", serializeMetadata(meta, request)); dict.set("data", res); request.sendText(Mime.JSON[0], JsSerializer.serialize(dict, true)); } else if (isProps) { request.sendText(Mime.TEXT[0], PropertiesSerializer.serialize(res)); } else if (isXml) { dict = new Dict(); dict.set("metadata", serializeMetadata(meta, request)); dict.set("data", res); request.sendText(Mime.XML[0], XmlSerializer.serialize("results", dict)); } else { request.sendError(STATUS.NOT_ACCEPTABLE); } } catch (Exception e) { LOG.log(Level.WARNING, "failed to process storage request", e); // TODO: How do users want their error messages? dict = new Dict(); dict.set("error", e.getMessage()); res = dict; if (isJson) { request.sendText(Mime.JSON[0], JsSerializer.serialize(res, true)); } else if (isXml) { request.sendText(Mime.XML[0], XmlSerializer.serialize("error", res)); } else { errorInternal(request, e.getMessage()); } } }