/** * @see EncounterValidator#validate(Object,Errors) */ @Test public void validate_shouldPassValidationIfFieldLengthsAreCorrect() { encounter.setEncounterType(new EncounterType()); encounter.setPatient(new Patient()); encounter.setEncounterDatetime(new Date()); encounter.setVoidReason("voidReason"); encounterValidator.validate(encounter, errors); Assert.assertFalse(errors.hasErrors()); }
/** * @see EncounterValidator#validate(Object,Errors) */ @Test public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() { encounter.setEncounterType(new EncounterType()); encounter.setPatient(new Patient()); encounter.setEncounterDatetime(new Date()); encounter .setVoidReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text"); encounterValidator.validate(encounter, errors); Assert.assertTrue(errors.hasFieldErrors("voidReason")); } }
encounter.setLocation(location); encounter.setForm(form); encounter.setEncounterType(encounterType); encounter.setCreator(enterer); encounter.setDateCreated(new Date());
/** * @see VisitService#saveVisit(Visit) */ @Test(expected = TransientObjectException.class) public void saveVisit_shouldNotPersistNewEncounter() { Visit visit = visitService.getVisit(1); Encounter encounter = new Encounter(); encounter.setEncounterDatetime(new Date()); encounter.setEncounterType(Context.getEncounterService().getEncounterType(1)); encounter.setPatient(visit.getPatient()); encounter.setLocation(visit.getLocation()); visit.addEncounter(encounter); visitService.saveVisit(visit); Context.flushSession(); }
private Encounter buildEncounter() { // First, create a new Encounter Encounter enc = new Encounter(); enc.setLocation(Context.getLocationService().getLocation(1)); enc.setEncounterType(Context.getEncounterService().getEncounterType(1)); enc.setEncounterDatetime(new Date()); enc.setPatient(Context.getPatientService().getPatient(3)); enc.addProvider(Context.getEncounterService().getEncounterRole(1), Context.getProviderService().getProvider(1)); return enc; }
Encounter encounter = new Encounter(); encounter.setLocation(new Location(2)); encounter.setEncounterType(new EncounterType(1)); encounter.setEncounterDatetime(new Date()); encounter.setPatient(new Patient(2));
/** * Gets encounter and adds edit privilege to it * * @return encounter with type having non null edit privilege */ private Encounter getEncounterWithEditPrivilege() { // create service to be used for encounter manipulations EncounterService encounterService = Context.getEncounterService(); Encounter encounter = encounterService.getEncounter(1); EncounterType encounterType = encounter.getEncounterType(); // make sure that encounter type is not null assertNotNull(encounterType); // set view privilege on this encounter type Privilege editPrivilege = Context.getUserService().getPrivilege("Some Privilege For Edit Encounter Types"); encounterType.setEditPrivilege(editPrivilege); encounter.setEncounterType(encounterType); // update encounter encounter = encounterService.saveEncounter(encounter); // make sure that encounter type updated successfully assertNotNull(encounter); return encounter; }
/** * Gets encounter and adds view privilege to it * * @return encounter with type having non null view privilege */ private Encounter getEncounterWithViewPrivilege() { // create service to be used for encounter manipulations EncounterService encounterService = Context.getEncounterService(); Encounter encounter = encounterService.getEncounter(1); EncounterType encounterType = encounter.getEncounterType(); // make sure that encounter type is not null assertNotNull(encounterType); // set view privilege on this encounter type Privilege viewPrivilege = Context.getUserService().getPrivilege("Some Privilege For View Encounter Types"); encounterType.setViewPrivilege(viewPrivilege); encounter.setEncounterType(encounterType); // update encounter encounter = encounterService.saveEncounter(encounter); // make sure that encounter was updated successfully assertNotNull(encounter); return encounter; }
/** * @see VisitService#saveVisit(Visit) */ @Test public void saveVisit_shouldAssociateEncounterWithVisitOnSaveEncounter() { Visit visit = visitService.getVisit(1); EncounterService es = Context.getEncounterService(); Encounter encounter = new Encounter(); encounter.setEncounterDatetime(new Date()); encounter.setPatient(visit.getPatient()); encounter.setLocation(visit.getLocation()); encounter.setEncounterType(es.getEncounterType(1)); visit.addEncounter(encounter); Context.getEncounterService().saveEncounter(encounter); Integer encounterId = encounter.getEncounterId(); Context.flushSession(); Context.clearSession(); // reload the visit visit = visitService.getVisit(1); assertEquals(1, visit.getEncounters().size()); assertEquals(encounterId, ((Encounter) visit.getEncounters().toArray()[0]).getEncounterId()); }
Encounter encounter = new Encounter(); encounter.setLocation(Context.getLocationService().getLocation(1)); encounter.setEncounterType(es.getEncounterType(1)); encounter.setEncounterDatetime(new Date()); encounter.setPatient(Context.getPatientService().getPatient(3));
EncounterType encounterType = new EncounterType(1); encounter.setEncounterType(encounterType);
encounter.setEncounterType(new EncounterType(1)); encounter.setEncounterDatetime(new Date()); encounter.setPatient(new Patient(3));
EncounterType encounterType = new EncounterType(1); encounterType.setViewPrivilege(Context.getUserService().getPrivilege("Some Privilege For View Encounter Types")); encounter.setEncounterType(encounterType);
target.setEncounterType(getEncounterType()); target.setForm(getForm()); target.setLocation(getLocation());
encounter.setEncounterType(Context.getEncounterService().getEncounterType(1)); encounter.setEncounterDatetime(new Date());
encounter.setEncounterType(new EncounterType(1)); encounter.setEncounterDatetime(new Date()); encounter.setPatient(new Patient(3));
encounter.setEncounterType(encType2); encounter.setEncounterDatetime(d2); encounter.setPatient(pat2);
encounter.setEncounterType(new EncounterType()); encounter.setForm(new Form()); encounter.setLocation(new Location());
encounter.setEncounterType(Context.getEncounterService().getEncounterType(1)); encounter.setEncounterDatetime(new Date());
encounter.setEncounterType(new EncounterType(1)); encounter.setEncounterDatetime(new Date()); encounter.setPatient(new Patient(3));