/** * Legacy createObs methods without the comment argument */ public Obs createObs(Concept concept, Object value, Date datetime, String accessionNumber) { return createObs(concept, value, datetime, accessionNumber, null); }
private void handleDynamicAutocompleteSubmissionInEnterMode(FormEntrySession session, HttpServletRequest submission, Object value, Date obsDatetime, String accessionNumberValue) { List values = (List) value; // create an obs for each value for (Object val : values) { int conceptId = Integer.valueOf((String) val); ((DynamicAutocompleteWidget)valueWidget).addInitialValue(Context.getConceptService().getConcept(conceptId)); session.getSubmissionActions().createObs(concept, conceptId, obsDatetime, accessionNumberValue); } }
private void handleDynamicAutocompleteSubmissionInEditMode(FormEntrySession session, HttpServletRequest submission, Object value, Date obsDatetime, String accessionNumberValue) { List values = (List) value; List<Concept> newConceptList = new Vector<Concept>(); List<Concept> existingConceptList = ((DynamicAutocompleteWidget) valueWidget).getInitialValueList(); // get the list of concepts entered on the form for (Object val : values) { if (StringUtils.isNotBlank((String) val)) { int conceptId = Integer.valueOf((String) val); newConceptList.add(Context.getConceptService().getConcept(conceptId)); } } // figure out what obs we need to create and what ones we need to remove for (Concept c : existingConceptList) { if (newConceptList.contains(c)) newConceptList.remove(c); else { for (Obs o : existingObsList) { if (o.getValueCoded().equals(c)) session.getSubmissionActions().modifyObs(o, concept, null, obsDatetime, accessionNumberValue); } } } if (!newConceptList.isEmpty()) { for (Concept c : newConceptList) { session.getSubmissionActions().createObs(concept, c, obsDatetime, accessionNumberValue); } } }
@Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { Object value = valueWidget.getValue(session.getContext(), submission); try { if (value instanceof Concept) concept = (Concept) value; else concept = (Concept) HtmlFormEntryUtil.convertToType(value.toString(), Concept.class); } catch (Exception ex){ throw new RuntimeException("Unable to convert response to a concept!"); } Date obsDatetime = null; String accessionNumberValue = null; if (existingObs != null && session.getContext().getMode() == Mode.EDIT) { //TODO: we're going to need a new version of this that uses the conceptAnswer as the matching concept... session.getSubmissionActions().modifyObs(existingObs, concept, answerConcept, obsDatetime, accessionNumberValue, null); } else { if (value != null && !"".equals(value) && concept != null) { session.getSubmissionActions().createObs(concept, answerConcept, obsDatetime, accessionNumberValue, null); } } }
createObs(concept, newValue, newDatetime, accessionNumber, comment); } else { if(existingObs != null && StringUtils.isNotBlank(comment))
session.getSubmissionActions().createObs(vaccineQuestionConcept, vaccineConcept, date, null, null); session.getSubmissionActions().createObs(sequenceNumberConcept, sequenceNumber, date, null, null); if (dateWidget != null) { session.getSubmissionActions().createObs(vaccinationDateConcept, date, date, null, null);
} else { if (concepts != null && value != null && !"".equals(value) && concept != null) { session.getSubmissionActions().createObs(concept, answerConcept, obsDatetime, accessionNumberValue, comment); } else if (value != null && !"".equals(value)) { if (valueWidget instanceof DynamicAutocompleteWidget) { session.getSubmissionActions().createObs(concept, value, obsDatetime, accessionNumberValue, comment);