@Test public void generateHtml_shouldReturnEmptyIfNoPatient() { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("conceptId", "a09ab2c5-878e-4905-b25d-5784167d0216"); Assert.assertThat(new RecentObsElement(context, parameters).generateHtml(context), is("")); }
@Override public String generateHtml(FormEntryContext context) { if (context.getExistingPatient() == null) { return ""; } KenyaUiUtils kenyaui = Context.getRegisteredComponents(KenyaUiUtils.class).get(0); PatientWrapper patient = new PatientWrapper(context.getExistingPatient()); Obs obs = patient.lastObs(MetadataUtils.existing(Concept.class, conceptId)); StringBuilder sb = new StringBuilder("<span>"); if (obs != null) { sb.append(kenyaui.formatObsValue(obs)); if (showDate) { sb.append(" <small>(" + kenyaui.formatDate(obs.getObsDatetime()) + ")</small>"); } } else if (noneMessage != null) { sb.append(noneMessage); } sb.append("</span>"); return sb.toString(); }
RecentObsElement implements HtmlGeneratorElement { @Override public String generateHtml(FormEntryContext context) { if (context.getExistingPatient() == null) { return ""; } KenyaUiUtils kenyaui = Context.getRegisteredComponents(KenyaUiUtils.class).get(0); PatientWrapper patient = new PatientWrapper(context.getExistingPatient()); Obs obs = patient.lastObs(MetadataUtils.existing(Concept.class, conceptId)); StringBuilder sb = new StringBuilder("<span>"); if (obs != null) { sb.append(kenyaui.formatObsValue(obs)); if (showDate) { sb.append(" <small>(" + kenyaui.formatDate(obs.getObsDatetime()) + ")</small>"); } } else if (noneMessage != null) { sb.append(noneMessage); } sb.append("</span>"); return sb.toString(); } }
RecentObsElement implements HtmlGeneratorElement { @Override public String generateHtml(FormEntryContext context) { if (context.getExistingPatient() == null) { return ""; } KenyaUiUtils kenyaui = Context.getRegisteredComponents(KenyaUiUtils.class).get(0); PatientWrapper patient = new PatientWrapper(context.getExistingPatient()); Obs obs = patient.lastObs(MetadataUtils.existing(Concept.class, conceptId)); StringBuilder sb = new StringBuilder("<span>"); if (obs != null) { sb.append(kenyaui.formatObsValue(obs)); if (showDate) { sb.append(" <small>(" + kenyaui.formatDate(obs.getObsDatetime()) + ")</small>"); } } else if (noneMessage != null) { sb.append(noneMessage); } sb.append("</span>"); return sb.toString(); } RecentObsElement(FormEntryContext context, Map<String, String> parameters); }
RecentObsElement implements HtmlGeneratorElement { @Override public String generateHtml(FormEntryContext context) { if (context.getExistingPatient() == null) { return ""; } KenyaUiUtils kenyaui = Context.getRegisteredComponents(KenyaUiUtils.class).get(0); PatientWrapper patient = new PatientWrapper(context.getExistingPatient()); Obs obs = patient.lastObs(MetadataUtils.existing(Concept.class, conceptId)); StringBuilder sb = new StringBuilder("<span>"); if (obs != null) { sb.append(kenyaui.formatObsValue(obs)); if (showDate) { sb.append(" <small>(" + kenyaui.formatDate(obs.getObsDatetime()) + ")</small>"); } } else if (noneMessage != null) { sb.append(noneMessage); } sb.append("</span>"); return sb.toString(); } RecentObsElement(FormEntryContext context, Map<String, String> parameters); @Override String generateHtml(FormEntryContext context); }
RecentObsElement implements HtmlGeneratorElement { @Override public String generateHtml(FormEntryContext context) { if (context.getExistingPatient() == null) { return ""; } KenyaUiUtils kenyaui = Context.getRegisteredComponents(KenyaUiUtils.class).get(0); PatientWrapper patient = new PatientWrapper(context.getExistingPatient()); Obs obs = patient.lastObs(MetadataUtils.existing(Concept.class, conceptId)); StringBuilder sb = new StringBuilder("<span>"); if (obs != null) { sb.append(kenyaui.formatObsValue(obs)); if (showDate) { sb.append(" <small>(" + kenyaui.formatDate(obs.getObsDatetime()) + ")</small>"); } } else if (noneMessage != null) { sb.append(noneMessage); } sb.append("</span>"); return sb.toString(); } RecentObsElement(FormEntryContext context, Map<String, String> parameters); @Override String generateHtml(FormEntryContext context);  }