Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How To Add An Openmrs Conceptanswer

DZone's Guide to

How To Add An Openmrs Conceptanswer

·
Free Resource
private void addConceptAnswers(Concept concept, String[] answerNames, User creator) {
		Set
 
   currentAnswerIds = new HashSet
  
   ();
		for (ConceptAnswer answer : concept.getAnswers()) {
			currentAnswerIds.add(answer.getAnswerConcept().getConceptId());
		}
		boolean changed = false;
		for (String answerName : answerNames) {
			Concept answer = Context.getConceptService().getConcept(answerName);
			if (!currentAnswerIds.contains(answer.getConceptId())) {
				changed = true;
				ConceptAnswer conceptAnswer = new ConceptAnswer(answer);
				conceptAnswer.setCreator(creator);
				concept.addAnswer(conceptAnswer);
			}
		}
		if (changed) {
			Context.getConceptService().saveConcept(concept);
		}
	}
  
 
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}