@Ignore @Test public void simpleRegimenHistory_shouldConvertNonEmptyHistory() throws IOException, SAXException, ParserConfigurationException { Concept medset = org.openmrs.module.kenyaemr.Dictionary.getConcept(Dictionary.ANTIRETROVIRAL_DRUGS); final Date t0 = TestUtils.date(2006, 1, 1); final Date t1 = TestUtils.date(2006, 2, 1); final Date t2 = TestUtils.date(2006, 3, 1); final Date t3 = TestUtils.date(2006, 4, 1); Concept drug1 = Dictionary.getConcept("78643AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); Concept drug2 = Dictionary.getConcept("86663AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); Concept drug3 = Dictionary.getConcept("84309AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); DrugOrder order1 = TestUtils.saveDrugOrder(TestUtils.getPatient(6), drug1, t0, t2); order1.setDiscontinuedReasonNonCoded("Testing"); DrugOrder order2 = TestUtils.saveDrugOrder(TestUtils.getPatient(6), drug2, t1, t3); order2.setDiscontinuedReason(Dictionary.getConcept(Dictionary.DIED)); TestUtils.saveDrugOrder(TestUtils.getPatient(6), drug3, t2, null); RegimenChangeHistory emptyHistory = RegimenChangeHistory.forPatient(Context.getPatientService().getPatient(6), medset); List<SimpleObject> objs = kenyaUi.simpleRegimenHistory(emptyHistory, ui); Assert.assertThat(objs, hasSize(4)); Assert.assertThat(objs.get(0), hasEntry("startDate", (Object) "01-Jan-2006")); Assert.assertThat((List<String>) objs.get(1).get("changeReasons"), contains("Testing")); }
public List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui) { List<RegimenChange> changes = history.getChanges(); List<SimpleObject> ret = new ArrayList<SimpleObject>(); if (changes.size() == 0) { return ret; } Date now = new Date(); for (int i = 0; i < changes.size(); ++i) { RegimenChange change = changes.get(i); Date startDate = change.getDate(); RegimenOrder regimen = change.getStarted(); Date endDate = null; List<String> changeReasons = new ArrayList<String>(); if (i + 1 < changes.size()) { RegimenChange next = changes.get(i + 1); endDate = next.getDate(); if (next.getChangeReasons() != null) { for (Concept c : next.getChangeReasons()) { changeReasons.add(ui.format(c)); } } if (next.getChangeReasonsNonCoded() != null) { changeReasons.addAll(next.getChangeReasonsNonCoded()); } } boolean current = OpenmrsUtil.compare(startDate, now) <= 0 && (endDate == null || OpenmrsUtil.compare(endDate, now) > 0); ret.add(SimpleObject.create( "startDate", kenyaUi.formatDate(startDate), "endDate", kenyaUi.formatDate(endDate), "regimen", simpleRegimen(regimen, ui), "changeReasons", changeReasons, "current", current )); } return ret; }
EmrUiUtils { public List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui) { List<RegimenChange> changes = history.getChanges(); List<SimpleObject> ret = new ArrayList<SimpleObject>(); if (changes.size() == 0) { return ret; } Date now = new Date(); for (int i = 0; i < changes.size(); ++i) { RegimenChange change = changes.get(i); Date startDate = change.getDate(); RegimenOrder regimen = change.getStarted(); Date endDate = null; List<String> changeReasons = new ArrayList<String>(); if (i + 1 < changes.size()) { RegimenChange next = changes.get(i + 1); endDate = next.getDate(); if (next.getChangeReasons() != null) { for (Concept c : next.getChangeReasons()) { changeReasons.add(ui.format(c)); } } if (next.getChangeReasonsNonCoded() != null) { changeReasons.addAll(next.getChangeReasonsNonCoded()); } } boolean current = OpenmrsUtil.compare(startDate, now) <= 0 && (endDate == null || OpenmrsUtil.compare(endDate, now) > 0); ret.add(SimpleObject.create( "startDate", kenyaUi.formatDate(startDate), "endDate", kenyaUi.formatDate(endDate), "regimen", simpleRegimen(regimen, ui), "changeReasons", changeReasons, "current", current )); } return ret; } }
EmrUiUtils { public List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui) { List<RegimenChange> changes = history.getChanges(); List<SimpleObject> ret = new ArrayList<SimpleObject>(); if (changes.size() == 0) { return ret; } Date now = new Date(); for (int i = 0; i < changes.size(); ++i) { RegimenChange change = changes.get(i); Date startDate = change.getDate(); RegimenOrder regimen = change.getStarted(); Date endDate = null; List<String> changeReasons = new ArrayList<String>(); if (i + 1 < changes.size()) { RegimenChange next = changes.get(i + 1); endDate = next.getDate(); if (next.getChangeReasons() != null) { for (Concept c : next.getChangeReasons()) { changeReasons.add(ui.format(c)); } } if (next.getChangeReasonsNonCoded() != null) { changeReasons.addAll(next.getChangeReasonsNonCoded()); } } boolean current = OpenmrsUtil.compare(startDate, now) <= 0 && (endDate == null || OpenmrsUtil.compare(endDate, now) > 0); ret.add(SimpleObject.create( "startDate", kenyaUi.formatDate(startDate), "endDate", kenyaUi.formatDate(endDate), "regimen", simpleRegimen(regimen, ui), "changeReasons", changeReasons, "current", current )); } return ret; }  }
EmrUiUtils { public List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui) { List<RegimenChange> changes = history.getChanges(); List<SimpleObject> ret = new ArrayList<SimpleObject>(); if (changes.size() == 0) { return ret; } Date now = new Date(); for (int i = 0; i < changes.size(); ++i) { RegimenChange change = changes.get(i); Date startDate = change.getDate(); RegimenOrder regimen = change.getStarted(); Date endDate = null; List<String> changeReasons = new ArrayList<String>(); if (i + 1 < changes.size()) { RegimenChange next = changes.get(i + 1); endDate = next.getDate(); if (next.getChangeReasons() != null) { for (Concept c : next.getChangeReasons()) { changeReasons.add(ui.format(c)); } } if (next.getChangeReasonsNonCoded() != null) { changeReasons.addAll(next.getChangeReasonsNonCoded()); } } boolean current = OpenmrsUtil.compare(startDate, now) <= 0 && (endDate == null || OpenmrsUtil.compare(endDate, now) > 0); ret.add(SimpleObject.create( "startDate", kenyaUi.formatDate(startDate), "endDate", kenyaUi.formatDate(endDate), "regimen", simpleRegimen(regimen, ui), "changeReasons", changeReasons, "current", current )); } return ret; }  String formatDrug(DrugReference drugRef, UiUtils ui); String formatRegimenShort(RegimenOrder regimen, UiUtils ui); String formatRegimenLong(RegimenOrder regimen, UiUtils ui); SimpleObject simpleRegimen(RegimenOrder regimen, UiUtils ui); List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui); List<SimpleObject> simpleRegimenDefinitions(Collection<RegimenDefinition> definitions, UiUtils ui); }
EmrUiUtils { public List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui) { List<RegimenChange> changes = history.getChanges(); List<SimpleObject> ret = new ArrayList<SimpleObject>(); if (changes.size() == 0) { return ret; } Date now = new Date(); for (int i = 0; i < changes.size(); ++i) { RegimenChange change = changes.get(i); Date startDate = change.getDate(); RegimenOrder regimen = change.getStarted(); Date endDate = null; List<String> changeReasons = new ArrayList<String>(); if (i + 1 < changes.size()) { RegimenChange next = changes.get(i + 1); endDate = next.getDate(); if (next.getChangeReasons() != null) { for (Concept c : next.getChangeReasons()) { changeReasons.add(ui.format(c)); } } if (next.getChangeReasonsNonCoded() != null) { changeReasons.addAll(next.getChangeReasonsNonCoded()); } } boolean current = OpenmrsUtil.compare(startDate, now) <= 0 && (endDate == null || OpenmrsUtil.compare(endDate, now) > 0); ret.add(SimpleObject.create( "startDate", kenyaUi.formatDate(startDate), "endDate", kenyaUi.formatDate(endDate), "regimen", simpleRegimen(regimen, ui), "changeReasons", changeReasons, "current", current )); } return ret; }  String formatDrug(DrugReference drugRef, UiUtils ui); String formatRegimenShort(RegimenOrder regimen, UiUtils ui); String formatRegimenLong(RegimenOrder regimen, UiUtils ui); SimpleObject simpleRegimen(RegimenOrder regimen, UiUtils ui); List<SimpleObject> simpleRegimenHistory(RegimenChangeHistory history, UiUtils ui); List<SimpleObject> simpleRegimenDefinitions(Collection<RegimenDefinition> definitions, UiUtils ui);  }