本文整理了Java中org.openmrs.Obs.setConcept()
方法的一些代码示例,展示了Obs.setConcept()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.setConcept()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:setConcept
暂无
代码示例来源:origin: openmrs/openmrs-core
@Test
public void getValueAsString_shouldReturnDateInCorrectFormat() throws Exception {
Obs obs = new Obs();
obs.setValueDatetime(new Date());
Concept cn = new Concept();
ConceptDatatype cdt = new ConceptDatatype();
cdt.setHl7Abbreviation("DT");
cn.setDatatype(cdt);
obs.setConcept(cn);
Date utilDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateString = dateFormat.format(utilDate);
Assert.assertEquals(dateString, obs.getValueAsString(Locale.US));
}
代码示例来源: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 ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailIfObsHasNoValuesAndNotParent() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(18));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.getGlobalErrorCount() > 0);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptDatatypeIsTextAndValueTextIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(19));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.hasFieldErrors("valueText"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#isComplex()
*/
@Test
public void isComplex_shouldReturnTrueIfTheConceptIsComplex() throws Exception {
ConceptDatatype cd = new ConceptDatatype();
cd.setName("Complex");
cd.setHl7Abbreviation("ED");
ConceptComplex complexConcept = new ConceptComplex();
complexConcept.setDatatype(cd);
Obs obs = new Obs();
obs.setConcept(complexConcept);
Assert.assertTrue(obs.isComplex());
}
代码示例来源: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
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfObsAncestorsContainsObs() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(3)); // datatype = N/A
obs.setObsDatetime(new Date());
Set<Obs> group = new HashSet<>();
group.add(obs);
obs.setGroupMembers(group);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("groupMembers"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
public void saveObs_shouldCreateVeryBasicObsAndAddNewObsId() {
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);
Obs oSaved = Context.getObsService().saveObs(o, null);
// make sure the returned Obs and the passed in obs
// now both have primary key obsIds
assertTrue(oSaved.getObsId().equals(o.getObsId()));
}
代码示例来源: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
@Test
public void newInstance_shouldCopyMostFields() throws Exception {
Obs obs = new Obs();
obs.setStatus(Obs.Status.PRELIMINARY);
obs.setInterpretation(Obs.Interpretation.LOW);
obs.setConcept(new Concept());
obs.setValueNumeric(1.2);
Obs copy = Obs.newInstance(obs);
// these fields are not copied
assertThat(copy.getObsId(), nullValue());
assertThat(copy.getUuid(), not(obs.getUuid()));
// other fields are copied
assertThat(copy.getConcept(), is(obs.getConcept()));
assertThat(copy.getValueNumeric(), is(obs.getValueNumeric()));
assertThat(copy.getStatus(), is(obs.getStatus()));
assertThat(copy.getInterpretation(), is(obs.getInterpretation()));
// TODO test that the rest of the fields are set
}
代码示例来源: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
@Test
public void getValueAsString_shouldReturnLocalizedCodedConcept() throws Exception {
ConceptDatatype cdt = new ConceptDatatype();
cdt.setHl7Abbreviation("CWE");
Concept cn = new Concept();
cn.setDatatype(cdt);
cn.addName(new ConceptName(VERO, Locale.ITALIAN));
Obs obs = new Obs();
obs.setValueCoded(cn);
obs.setConcept(cn);
obs.setValueCodedName(new ConceptName("True", Locale.US));
Assert.assertEquals(VERO, obs.getValueAsString(Locale.ITALIAN));
}
代码示例来源: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 ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptDatatypeIsBooleanAndValueBooleanIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(18));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("valueBoolean"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptDatatypeIsNumericAndValueNumericIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("valueNumeric"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptDatatypeIsCodedAndValueCodedIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(4));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("valueCoded"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptDatatypeIsDateAndValueDatetimeIsNull() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(20));
obs.setObsDatetime(new Date());
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("valueDatetime"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldNotValidateIfObsIsVoided() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
obs.setValueNumeric(null);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.hasFieldErrors("valueNumeric"));
obs.setVoided(true);
errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasErrors());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
obs.setValueNumeric(1.0);
obs.setAccessionNumber("AccessionNumber");
obs.setValueModifier("m");
obs.setValueComplex("ValueComplex");
obs.setVoidReason("VoidReason");
obs.setComment("comment");
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasErrors());
}
代码示例来源: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"));
}
内容来源于网络,如有侵权,请联系作者删除!