本文整理了Java中org.openmrs.Obs.setObsDatetime()
方法的一些代码示例,展示了Obs.setObsDatetime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.setObsDatetime()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:setObsDatetime
暂无
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setObsDatetime(Date)
*/
@Test
public void setObsDateTime_shouldNotMarkTheObsAsDirtyWhenDateIsNotChangedAndExistingValueIsOfTimeStampType(){
Obs obs = new Obs();
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
obs.setObsDatetime(timestamp);
obs.setId(1);
assertFalse(obs.isDirty());
obs.setObsDatetime(date);
assertFalse(obs.isDirty());
}
代码示例来源: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 ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfValueTextIsGreaterThanTheMaximumLength() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(19));
obs.setObsDatetime(new Date());
// Generate 65535+ characters length text.
StringBuilder valueText = new StringBuilder();
for (int i = 0; i < 730; i++) {
valueText
.append("This text should not exceed 65535 characters. Below code will generate a text more than 65535");
}
obs.setValueText(valueText.toString());
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("valueText"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfValueTextIsLessThanTheMaximumLength() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(19));
obs.setObsDatetime(new Date());
// Generate 2700+ characters length text.
StringBuilder valueText = new StringBuilder();
for (int i = 0; i < 30; i++) {
valueText
.append("This text should not exceed 65535 characters. Below code will generate a text Less than 65535");
}
obs.setValueText(valueText.toString());
Errors errors = new BindException(obs, "obs");
new ObsValidator().validate(obs, errors);
Assert.assertFalse(errors.hasFieldErrors("person"));
Assert.assertFalse(errors.hasFieldErrors("concept"));
Assert.assertFalse(errors.hasFieldErrors("obsDatetime"));
Assert.assertFalse(errors.hasFieldErrors("valueText"));
}
}
代码示例来源: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
/**
* @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 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_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_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_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_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(Object,Errors)
*/
@Test
public void validate_shouldPassIfAnswerConceptAndConceptOfValueDrugMatch() {
Obs obs = new Obs();
obs.setPerson(new Person(7));
obs.setObsDatetime(new Date());
Concept questionConcept = new Concept(100);
ConceptDatatype dt = new ConceptDatatype(1);
dt.setUuid(ConceptDatatype.CODED_UUID);
questionConcept.setDatatype(dt);
obs.setConcept(questionConcept);
Concept answerConcept = new Concept(101);
obs.setValueCoded(answerConcept);
Drug drug = new Drug();
drug.setConcept(answerConcept);
obs.setValueDrug(drug);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldRejectAnInvalidConceptAndDrugCombination() {
Obs obs = new Obs();
obs.setPerson(new Person(7));
obs.setObsDatetime(new Date());
Concept questionConcept = new Concept(100);
ConceptDatatype dt = new ConceptDatatype(1);
dt.setUuid(ConceptDatatype.CODED_UUID);
questionConcept.setDatatype(dt);
obs.setConcept(questionConcept);
obs.setValueCoded(new Concept(101));
Drug drug = new Drug();
drug.setConcept(new Concept(102));
obs.setValueDrug(drug);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.hasFieldErrors("valueDrug"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ConceptService#purgeConcept(Concept)
*/
@Test(expected = ConceptNameInUseException.class)
public void purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs() {
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));
ConceptName conceptName = new ConceptName(1847);
o.setValueCodedName(conceptName);
Context.getObsService().saveObs(o, null);
//ensure that the association between the conceptName and the obs has been established
Assert.assertEquals(true, conceptService.hasAnyObservation(conceptName));
Concept concept = conceptService.getConceptByName("cd4 count");
//make sure the name concept name exists
Assert.assertNotNull(concept);
conceptService.purgeConcept(concept);
}
内容来源于网络,如有侵权,请联系作者删除!