use of org.openmrs.api.VisitService in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldFailIfPatientIsNotSet.
/**
* @see VisitValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfPatientIsNotSet() {
VisitService vs = Context.getVisitService();
Visit visit = new Visit();
visit.setVisitType(vs.getVisitType(1));
visit.setStartDatetime(new Date());
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertTrue(errors.hasFieldErrors("patient"));
}
use of org.openmrs.api.VisitService in project openmrs-core by openmrs.
the class VisitValidatorTest method validate_shouldFailIfStartDatetimeIsNotSet.
/**
* @see VisitValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfStartDatetimeIsNotSet() {
VisitService vs = Context.getVisitService();
Visit visit = new Visit();
visit.setVisitType(vs.getVisitType(1));
visit.setPatient(Context.getPatientService().getPatient(2));
Errors errors = new BindException(visit, "visit");
new VisitValidator().validate(visit, errors);
assertTrue(errors.hasFieldErrors("startDatetime"));
}
use of org.openmrs.api.VisitService in project openmrs-module-coreapps by openmrs.
the class VisitTypeHelper method getOrderedVisitTypes.
/**
* Returns a list of ordered visit types, provided by a global property
* If a visit type is present in the visitTypes argument, but not found in the global property string,
* it will be returned unordered, at the end of the visitTypesOrdered list
*
* @param visitTypes
* @return visitTypesOrdered
*/
public List<VisitType> getOrderedVisitTypes(List<VisitType> visitTypes) {
AdministrationService adminService = Context.getAdministrationService();
String propertyValue = adminService.getGlobalProperty(CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY);
VisitService vs = Context.getVisitService();
return getOrderedVisitTypes(visitTypes, propertyValue, vs);
}
use of org.openmrs.api.VisitService in project openmrs-module-coreapps by openmrs.
the class VisitTypeHelper method getUnRetiredVisitTypes.
public List<VisitType> getUnRetiredVisitTypes() {
VisitService visitService = Context.getVisitService();
List<VisitType> visitTypes = new ArrayList<VisitType>();
for (VisitType visitType : visitService.getAllVisitTypes()) {
if (visitType.getRetired() == false) {
visitTypes.add(visitType);
}
}
return visitTypes;
}
use of org.openmrs.api.VisitService in project openmrs-module-coreapps by openmrs.
the class VisitTypeHelper method setEncounterBasedOnVisitType.
/**
* Create encounters based on visit type
*
* @param visit
* @param loginLocation
* @param previousType
*/
public void setEncounterBasedOnVisitType(Visit visit, Location loginLocation, VisitType previousType) {
// all types are transfer type
boolean isTransferType = true;
if (visit.getVisitType() == previousType) {
// visit type is not changed: do nothing
return;
}
EncounterService es = Context.getEncounterService();
VisitService vs = Context.getVisitService();
Patient patient = visit.getPatient();
Person person = Context.getUserContext().getAuthenticatedUser().getPerson();
Encounter encounter = new Encounter();
setTransferEncounter(visit, vs, es, encounter, patient, person, loginLocation, previousType, isTransferType);
}
Aggregations