return getValueDrug().getFullName(locale); } else { ConceptName codedName = getValueCodedName(); if (codedName != null) { return getValueCoded().getName(locale, false).getName(); return getValueDrug().getFullName(locale); } else { ConceptName valudeCodedName = getValueCodedName(); if (valudeCodedName != null) { return valudeCodedName.getName();
obs.setConcept(c); String title = null; if (obs.getValueCodedName() != null) { title = obs.getValueCodedName().getName();
ConceptName name = obss.get(0).getValueCodedName(); Assert.assertNotNull(name); Assert.assertEquals("The valueCodedName should be 2471", 2471, name.getId().intValue());
/** * @see ConceptService#mapConceptProposalToConcept(ConceptProposal,Concept,Locale) */ @Test public void mapConceptProposalToConcept_shouldSetValueCodedNameWhenAddSynonymIsSelected() { ConceptProposal cp = conceptService.getConceptProposal(2); Assert.assertEquals(OpenmrsConstants.CONCEPT_PROPOSAL_UNMAPPED, cp.getState()); final Concept civilStatusConcept = conceptService.getConcept(4); final int mappedConceptId = 6; final String finalText = "Weight synonym"; Assert.assertTrue(Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept).isEmpty()); Concept mappedConcept = conceptService.getConcept(mappedConceptId); mappedConcept.addDescription(new ConceptDescription("some description",Context.getLocale())); cp.setFinalText(finalText); cp.setObsConcept(civilStatusConcept); cp.setState(OpenmrsConstants.CONCEPT_PROPOSAL_SYNONYM); conceptService.mapConceptProposalToConcept(cp, mappedConcept, null); mappedConcept = conceptService.getConcept(mappedConceptId); List<Obs> observations = Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept); Assert.assertEquals(1, observations.size()); Obs obs = observations.get(0); Assert.assertNotNull(obs.getValueCodedName()); Assert.assertEquals(finalText, obs.getValueCodedName().getName()); }
/** * @see ConceptService#mapConceptProposalToConcept(ConceptProposal,Concept,Locale) */ @Test public void mapConceptProposalToConcept_shouldNotSetValueCodedNameWhenAddConceptIsSelected() { ConceptProposal cp = conceptService.getConceptProposal(2); Assert.assertEquals(OpenmrsConstants.CONCEPT_PROPOSAL_UNMAPPED, cp.getState()); final Concept civilStatusConcept = conceptService.getConcept(4); final int mappedConceptId = 6; Assert.assertTrue(Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept).isEmpty()); Concept mappedConcept = conceptService.getConcept(mappedConceptId); cp.setObsConcept(civilStatusConcept); cp.setState(OpenmrsConstants.CONCEPT_PROPOSAL_CONCEPT); conceptService.mapConceptProposalToConcept(cp, mappedConcept, null); mappedConcept = conceptService.getConcept(mappedConceptId); List<Obs> observations = Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept); Assert.assertEquals(1, observations.size()); Obs obs = observations.get(0); Assert.assertNull(obs.getValueCodedName()); }
else if (obs.getValueBoolean() == null && obs.getValueCoded() == null && obs.getValueCodedName() == null && obs.getValueComplex() == null && obs.getValueDatetime() == null && obs.getValueDrug() == null && obs.getValueModifier() == null && obs.getValueNumeric() == null && obs.getValueText() == null
} else if (value instanceof ConceptName) { obs.setValueCodedName((ConceptName) value); obs.setValueCoded(obs.getValueCodedName().getConcept()); } else if (value instanceof Concept) { obs.setValueCoded((Concept) value);
@Test @Verifies(value="shouldSetValueCodedNameGivenAConceptName",method="createObs(Concept concept, Object value, Date datetime, String accessionNumber)") public void createObs_shouldSetValueCodedNameGivenAConceptName() { Concept answerConcept = new Concept(); ConceptName answer = new ConceptName("Answer", Context.getLocale()); answerConcept.addName(answer); Concept question = new Concept(); question.setUuid(UUID.randomUUID().toString()); question.setDatatype(Context.getConceptService().getConceptDatatypeByName("Coded")); Obs created = HtmlFormEntryUtil.createObs(question, answer, new Date(), ""); assertThat(created.getValueCodedName(), is(answerConcept.getPreferredName(Context.getLocale()))); assertThat(created.getValueCoded(), is(answerConcept)); }
ConceptName conceptName7 = new ConceptName(); conceptName7.setName("TB"); when(obs7.getValueCodedName()).thenReturn(conceptName7); field7.setExistingObs(obs7); section1.addField(field7);
value = field.getExistingObs().getValueCodedName() != null ? field.getExistingObs().getValueCodedName().getName() : field.getExistingObs().getValueCoded() != null ? field.getExistingObs().getValueCoded().getName().getName() : "";