/** * If the html form contains both PatientTags and Encounter tags then initialize it with the * Patient and Encounter associated with the Form else if htmlform only contains PatientTags * then initialize it with the Patient associated with the Form. */ public void prepareForSubmit() { submissionActions = new FormSubmissionActions(); if (hasPatientTag() && !hasEncouterTag()) { try { submissionActions.beginPerson(patient); } catch (InvalidActionException e) { log.error("Programming error: should be no errors starting a patient", e); } } else { if (context.getMode() == Mode.EDIT) { if (encounter == null) throw new RuntimeException("Programming exception: encounter shouldn't be null in EDIT mode"); } else { encounter = new Encounter(); } try { submissionActions.beginPerson(patient); submissionActions.beginEncounter(encounter); } catch (InvalidActionException e) { log.error("Programming error: should be no errors starting a patient and encounter", e); } } }