if (concept.getDatatype().isBoolean()) { obs.setValueBoolean("1".equals(value)); } else if (concept.getDatatype().isNumeric()) { try { obs.setValueNumeric(Double.valueOf(value));
} else if (conceptDatatype.isNumeric()) { this.datatype = Datatype.NUMERIC; } else if (conceptDatatype.isDate()) {
errors.rejectValue("groupMembers", "Obs.error.inGroupMember"); } else if (dt.isNumeric() && obs.getValueNumeric() == null) { if (atRootNode) { errors.rejectValue("valueNumeric", "error.null"); errors.rejectValue("groupMembers", "Obs.error.inGroupMember"); } else if (dt.isNumeric()) { ConceptNumeric cn = Context.getConceptService().getConceptNumeric(c.getConceptId());
ret.append(valueWidget.generateHtml(context)); if (showUnits) { if (concept == null || !concept.getDatatype().isNumeric()) { throw new IllegalArgumentException("Can only show units when the concept is numeric");
ConceptDatatype datatype = concept.getDatatype(); if (datatype.isNumeric()) { while (obsIterator.hasNext()) { currentObs = obsIterator.next();
/** * Given a FormField, infers the related widget from the ConceptDatatype associated with that FormField. */ public static WidgetTypeHint inferWidgetTypeHint(FormField formField) { ConceptDatatype dt = formField.getField().getConcept().getDatatype(); if (dt.isText()) { return WidgetTypeHint.TEXT; } else if (dt.isNumeric()) { return WidgetTypeHint.NUMBER; } else if (dt.isDate()) { return WidgetTypeHint.DATE; } else if (dt.isCoded()) { if (formField.getField().isSelectMultiple()) return WidgetTypeHint.CHECKBOX_LIST; else if (formField.getField().getDefaultValue() != null) return WidgetTypeHint.CHECKBOX; else return WidgetTypeHint.DROPDOWN; } else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) { return WidgetTypeHint.UPLOAD_WIDGET; } else { throw new IllegalArgumentException( "Autodetecting widget type from concept datatype not yet implemented for " + dt.getName()); } }
obs.setConcept(concept); ConceptDatatype dt = obs.getConcept().getDatatype(); if (dt.isNumeric()) { obs.setValueNumeric(Double.parseDouble(value.toString())); } else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) {
ConceptDatatype datatype1 = mock(ConceptDatatype.class); when(datatype1.getName()).thenReturn("Numeric"); when(datatype1.isNumeric()).thenReturn(true); when(concept1.getDatatype()).thenReturn(datatype1); field1.setQuestion(concept1);
value = field.getExistingObs().getValueDate() != null ? timeFormat.format(field.getExistingObs().getValueDate()) : ""; } else if (datatype.isNumeric()) { value = field.getExistingObs().getValueNumeric() != null ? field.getExistingObs().getValueNumeric().toString() : "";
MRSObservation convertOpenMRSToMRSObservation(Obs obs) { ConceptDatatype datatype = obs.getConcept().getDatatype(); if (datatype.isAnswerOnly()) { return createMRSObservation(obs, null); } else if (datatype.isBoolean()) { return createMRSObservation(obs, obs.getValueAsBoolean()); } else if (datatype.isDateTime()) { return createMRSObservation(obs, obs.getValueDatetime()); } else if (datatype.isNumeric()) { return createMRSObservation(obs, obs.getValueNumeric()); } else if (datatype.isText()) { return createMRSObservation(obs, obs.getValueText()); } else if (datatype.isCoded()) { return createMRSObservation(obs, new OpenMRSConcept(new OpenMRSConceptName(obs.getValueCoded().getName().getName()))); } else { throw new IllegalArgumentException("Invalid value of the createMRSObservation from DB-" + obs); } }