本文整理了Java中org.openmrs.Obs.setValueNumeric()
方法的一些代码示例,展示了Obs.setValueNumeric()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.setValueNumeric()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:setValueNumeric
暂无
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsBoolean()
*/
@Test
public void getValueAsBoolean_shouldReturnNullForValue_numericConceptsIfValueIsNeither1Nor0() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(24.8);
Assert.assertNull(obs.getValueAsBoolean());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsString(Locale)
*/
@Test
public void getValueAsString_shouldUseCommasOrDecimalPlacesDependingOnLocale() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(123456789.3);
String str = "123456789,3";
Assert.assertEquals(str, obs.getValueAsString(Locale.GERMAN));
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveObs_shouldNotChangeStatusOfPreliminaryWhenModifyingAnObs() throws Exception {
Obs existing = obsService.getObs(9);
existing.setValueNumeric(175.0);
Obs newObs = obsService.saveObs(existing, "testing");
assertThat(newObs.getValueNumeric(), is(175.0));
assertThat(newObs.getStatus(), is(Obs.Status.PRELIMINARY));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsBoolean()
*/
@Test
public void getValueAsBoolean_shouldReturnFalseForValue_numericConceptsIfValueIs0() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(0.0);
Assert.assertEquals(false, obs.getValueAsBoolean());
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void getValueAsString_shouldNotReturnLongDecimalNumbersAsScientificNotation() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(123456789.0);
String str = "123456789.0";
Assert.assertEquals(str, obs.getValueAsString(Locale.US));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsBoolean()
*/
@Test
public void getValueAsBoolean_shouldReturnTrueForValue_numericConceptsIfValueIs1() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(1.0);
Assert.assertEquals(true, obs.getValueAsBoolean());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsString(Locale)
*/
@Test
public void getValueAsString_shouldReturnRegularNumberForSizeOfZeroToOrGreaterThanTenDigits() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(1234567890.0);
String str = "1234567890.0";
Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsString(Locale)
*/
@Test
public void getValueAsString_shouldReturnRegularNumberIfDecimalPlacesAreAsHighAsSix() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(123456789.012345);
String str = "123456789.012345";
Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getValueAsString(Locale)
*/
@Test
public void getValueAsString_shouldNotUseThousandSeparator() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(123456789.0);
String str = "123456789.0";
Assert.assertEquals(str, obs.getValueAsString(Locale.ENGLISH));
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveObs_shouldSetStatusToAmendedWhenModifyingAnObsWithFinalStatus() throws Exception {
Obs existing = obsService.getObs(7);
existing.setValueNumeric(60.0);
Obs amended = obsService.saveObs(existing, "testing");
assertThat(amended.getValueNumeric(), is(60.0));
assertThat(amended.getStatus(), is(Obs.Status.AMENDED));
assertThat(existing.getStatus(), is(Obs.Status.FINAL));
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveObs_shouldLetYouChangeStatusFromPreliminaryToFinalWhenModifyingAnObs() throws Exception {
Obs existing = obsService.getObs(9);
existing.setValueNumeric(175.0);
existing.setStatus(Obs.Status.FINAL);
Obs newObs = obsService.saveObs(existing, "testing");
assertThat(newObs.getValueNumeric(), is(175.0));
assertThat(newObs.getStatus(), is(Obs.Status.FINAL));
}
代码示例来源:origin: openmrs/openmrs-core
private Obs buildObs() {
Obs newObs = new Obs();
newObs.setConcept(Context.getConceptService().getConcept(1));
newObs.setValueNumeric(50d);
newObs.setLocation(new Location(2));
return newObs;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
public void saveObs_shouldVoidTheGivenObsInTheDatabase() {
Obs obs = Context.getObsService().getObs(7);
obs.setValueNumeric(1.0);
Context.getObsService().saveObs(obs, "just testing");
// fetch the obs from the database again
obs = Context.getObsService().getObs(7);
Assert.assertTrue(obs.getVoided());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfAllValuesPresent() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
obs.setValueNumeric(1.0);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasErrors());
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void getValueAsString_shouldReturnNonPreciseValuesForNumericConcepts() throws Exception {
Obs obs = new Obs();
obs.setValueNumeric(25.125);
ConceptNumeric cn = new ConceptNumeric();
ConceptDatatype cdt = new ConceptDatatype();
cdt.setHl7Abbreviation("NM");
cn.setDatatype(cdt);
cn.setAllowDecimal(false);
obs.setConcept(cn);
String str = "25";
Assert.assertEquals(str, obs.getValueAsString(Locale.US));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfPersonIdIsNull() {
Obs obs = new Obs();
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
obs.setValueNumeric(1.0);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertFalse(errors.hasFieldErrors("valueNumeric"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setObsDatetime(new Date());
obs.setValueNumeric(1.0);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertTrue(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertFalse(errors.hasFieldErrors("valueNumeric"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
public void saveObs_shouldSetCreatorAndDateCreatedOnNewObs() {
Obs o = new Obs();
o.setConcept(Context.getConceptService().getConcept(3));
o.setPerson(new Patient(2));
o.setEncounter(new Encounter(3));
o.setObsDatetime(new Date());
o.setLocation(new Location(1));
o.setValueNumeric(50d);
Context.getObsService().saveObs(o, null);
assertNotNull(o.getDateCreated());
assertNotNull(o.getCreator());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
public void saveObs_shouldCopyTheFormNamespaceAndPathFieldInEditedObs() {
executeDataSet(INITIAL_OBS_XML);
Obs obs = Context.getObsService().getObs(7);
obs.setValueNumeric(5.0);
Obs o2 = Context.getObsService().saveObs(obs, "just testing");
Assert.assertNotNull(obs.getFormFieldNamespace());
// fetch the obs from the database again
obs = Context.getObsService().getObs(o2.getObsId());
Assert.assertNotNull(obs.getFormFieldNamespace());
Assert.assertNotNull(obs.getFormFieldPath());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfObsDatetimeIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setValueNumeric(1.0);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertTrue(errors.hasFieldErrors("obsDatetime"));
assertFalse(errors.hasFieldErrors("valueNumeric"));
}
内容来源于网络,如有侵权,请联系作者删除!