/** * Removes the most recently added Encounter from the submission stack. All objects added after * that Encounter are removed as well. * * @throws InvalidActionException */ public void endEncounter() throws InvalidActionException { if (!stackContains(Encounter.class)) throw new InvalidActionException("No Encounter on the stack"); while (true) { Object o = stack.pop(); if (o instanceof Encounter) break; } }
/** * Removes the most recently added ObsGroup from the submission stack. All objects added after * that ObsGroup are removed as well. * * @throws InvalidActionException */ public void endObsGroup() throws InvalidActionException { // there needs to be an Obs on the stack before this if (!stackContains(Obs.class)) throw new InvalidActionException("No Obs on the stack"); while (true) { Object o = stack.pop(); if (o instanceof Obs) break; } }
/** * Removes the most recently added Person from the submission stack. All other objects added * after that Person are removed as well. * <p/> * (So, in the current one-person-per-form model, this would empty the entire submission stack) * * @throws InvalidActionException */ public void endPerson() throws InvalidActionException { if (!stackContains(Person.class)) throw new InvalidActionException("No Person on the stack"); while (true) { Object o = stack.pop(); if (o instanceof Person) break; } }
/** * Adds an Encounter to the submission stack * * @param encounter the Encounter to add * @throws InvalidActionException */ public void beginEncounter(Encounter encounter) throws InvalidActionException { // there needs to be a Person on the stack before this if (!stackContains(Person.class)) throw new InvalidActionException("No Person on the stack"); if (encounter.getEncounterId() == null && !encountersToCreate.contains(encounter)) encountersToCreate.add(encounter); encounter.setPatient(highestOnStack(Patient.class)); stack.push(encounter); }
/** * Adds an Obs Group to the submission stack * * @param group the Obs Group to add * @throws InvalidActionException */ public void beginObsGroup(Obs group) throws InvalidActionException { // there needs to be a Person on the stack before this if (!stackContains(Person.class)) throw new InvalidActionException("No Person on the stack"); if (group.getObsId() == null && !obsToCreate.contains(group)) { obsToCreate.add(group); } Person person = highestOnStack(Person.class); Encounter encounter = highestOnStack(Encounter.class); group.setPerson(person); if (encounter != null) { addObsToEncounterIfNotAlreadyThere(encounter, group); } //this is for obs groups within obs groups Object o = stack.peek(); if (o instanceof Obs) { Obs oParent = (Obs) o; oParent.addGroupMember(group); } stack.push(group); }