}
@Override
public Patient getPatient() {
// preemptively create a relationship
RelationshipType type = Context.getPersonService().getRelationshipType(1);
Patient parent = Context.getPatientService().getPatient(2);
Person child = Context.getPersonService().getPerson(6);
Relationship rel = new Relationship(parent, child, type);
Context.getPersonService().saveRelationship(rel);
Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
return parent;
};
@Override
public String[] widgetLabels() {
return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
}
@Override
public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
request.addParameter(widgets.get("Date:"), dateAsString(date));
request.addParameter(widgets.get("Location:"), "2");
request.addParameter(widgets.get("Provider:"), "502");
// hack because person widget is a hidden input with no label
request.addParameter("w7", "7");
}
@Override
public void testResults(SubmissionResults results) {
// check the basics
results.assertNoErrors();
results.assertEncounterCreated();
results.assertProvider(502);
results.assertLocation(2);
// now make sure the old the relationship is gone and the new one has been created
RelationshipType type = Context.getPersonService().getRelationshipType(1);
Person parent = Context.getPersonService().getPerson(2);
Person child1 = Context.getPersonService().getPerson(6);
Person child2 = Context.getPersonService().getPerson(7);
Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child1, type).size());