public EncounterListItem(Encounter encounter) { if (encounter != null) { encounterId = encounter.getEncounterId(); encounterDateTime = encounter.getEncounterDatetime(); encounterDateString = Format.format(encounter.getEncounterDatetime()); PersonName pn = encounter.getPatient().getPersonName(); if (pn != null) { personName = ""; if (pn.getGivenName() != null) { personName += pn.getGivenName(); } if (pn.getMiddleName() != null) { personName += " " + pn.getMiddleName(); } if (pn.getFamilyName() != null) { personName += " " + pn.getFamilyName(); } } if (encounter.getProvider() != null) { providerName = encounter.getProvider().getPersonName().getFullName(); } if (encounter.getLocation() != null) { location = encounter.getLocation().getName(); } if (encounter.getEncounterType() != null) { encounterType = encounter.getEncounterType().getName(); } if (encounter.getForm() != null) { formName = encounter.getForm().getName(); formId = encounter.getForm().getFormId(); } voided = encounter.isVoided(); if (encounter.getCreator() != null) { PersonName entererPersonName = encounter.getCreator().getPersonName(); if (entererPersonName != null) { entererName = ""; if (entererPersonName.getGivenName() != null) { entererName += entererPersonName.getGivenName(); } if (entererPersonName.getMiddleName() != null) { entererName += " " + entererPersonName.getMiddleName(); } if (entererPersonName.getFamilyName() != null) { entererName += " " + entererPersonName.getFamilyName(); } } } } }
@Test public void testEvaluate() throws Exception { EncounterEvaluationContext context = new EncounterEvaluationContext(); context.setBaseEncounters(new EncounterIdSet(encounter.getId())); EvaluatedEncounterData result = encounterDataService.evaluate(new AuditInfoEncounterDataDefinition(), context); assertThat(result.getData().size(), is(1)); AuditInfo auditInfo = (AuditInfo) result.getData().get(encounter.getId()); assertThat(auditInfo.getCreator(), is(encounter.getCreator())); assertThat(auditInfo.getDateCreated(), is(encounter.getDateCreated())); assertThat(auditInfo.getChangedBy(), is(encounter.getChangedBy())); assertThat(auditInfo.getDateChanged(), is(encounter.getDateChanged())); assertThat(auditInfo.getVoided(), is(encounter.getVoided())); assertThat(auditInfo.getVoidedBy(), is(encounter.getVoidedBy())); assertThat(auditInfo.getDateVoided(), is(encounter.getDateVoided())); assertThat(auditInfo.getVoidReason(), is(encounter.getVoidReason())); }
/** * * Returns the encounter with the obs that aren't used when populating form are removed. * This *doesn't* save the encounter. * TODO: handle Orders? * * @param e * @param htmlform * @return * @throws Exception */ public static Encounter trimEncounterToMatchForm(Encounter e, HtmlForm htmlform) throws Exception { //this should move existing obs from session to tag handlers. FormEntrySession session = new FormEntrySession(e.getPatient(), e, FormEntryContext.Mode.VIEW, htmlform, null); // session gets a null HttpSession session.getHtmlToDisplay(); if (log.isDebugEnabled()){ Map<Concept, List<Obs>> map = session.getContext().getExistingObs(); if (map != null){ for (Map.Entry<Concept, List<Obs>> existingObs : map.entrySet()){ List<Obs> oList = existingObs.getValue(); for (Obs oInner : oList) log.debug("Obs in existingObs " + existingObs.getKey() + " " + oInner.getConcept()); } } Map<Obs, Set<Obs>> map2 = session.getContext().getExistingObsInGroups(); if (map2 != null){ for (Map.Entry<Obs, Set<Obs>> existingObsInGroups : map2.entrySet()){ Set<Obs> oList = existingObsInGroups.getValue(); for (Obs oInner : oList) log.debug("Obs in existingObsInGroups " + existingObsInGroups.getKey().getConcept() + " " + oInner.getConcept()); } } } Encounter ret = new Encounter(); ret.setCreator(e.getCreator()); ret.setEncounterDatetime(e.getEncounterDatetime()); EncounterCompatibility.setProvider(ret, EncounterCompatibility.getProvider(e)); ret.setLocation(e.getLocation()); ret.setDateCreated(e.getDateCreated()); ret.setPatient(e.getPatient()); //renders new encounter unsave-able: ret.setEncounterId(e.getEncounterId()); for (Obs oTest : e.getAllObs()){ boolean found = false; if (session.getContext().getExistingObs() != null && !oTest.isObsGrouping()){ List<Obs> obsList = session.getContext().getExistingObs().get(oTest.getConcept()); if (obsList != null && obsList.size() > 0){ for (Obs o : obsList){ if (o.getObsId().equals(oTest.getObsId())){ found = true; continue; } } } } if (!found && session.getContext().getExistingObsInGroups() != null){ for (Map.Entry<Obs, Set<Obs>> mapEntry : session.getContext().getExistingObsInGroups().entrySet()){ if (mapEntry.getKey().equals(oTest)){ found = true; continue; } else { Set<Obs> oSet = mapEntry.getValue(); //note: oSet.contains fails for some reason for (Obs o:oSet){ if (o.getObsId().equals(oTest.getObsId())){ found = true; continue; } } } } } if (!found) ret.addObs(oTest); } session = null; return ret; }