/** * Returns the Person that was most recently added to the stack * * @return the Person most recently added to the stack */ public Person getCurrentPerson() { return highestOnStack(Person.class); }
/** * Returns the Encounter that was most recently added to the stack * * @return the Encounter most recently added to the stack */ public Encounter getCurrentEncounter() { return highestOnStack(Encounter.class); }
/** * Ends a Patient program. * <p/> * Note that this method does not commit the program enrollment change to the database but * instead adds the Program to a list of programs to remove. The changes are applied elsewhere * in the framework * * @param program Program to end the enrollment for the patient in */ public void completeProgram(Program program) { if (program == null) throw new IllegalArgumentException("Cannot end a blank program"); Patient patient = highestOnStack(Patient.class); if (patient == null) throw new IllegalArgumentException("Cannot find program without a patient"); Encounter encounter = highestOnStack(Encounter.class); if (encounter == null) throw new IllegalArgumentException("Cannot end enrollment in a program outside of an Encounter"); List<PatientProgram> pp = Context.getProgramWorkflowService().getPatientPrograms(patient, program, null, encounter.getEncounterDatetime(), new Date(), null, false); patientProgramsToComplete.addAll(pp); }
/** * 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); }
Obs obs = HtmlFormEntryUtil.createObs(concept, value, datetime, accessionNumber); Person person = highestOnStack(Person.class); if (person == null) throw new IllegalArgumentException("Cannot create an Obs outside of a Person."); Encounter encounter = highestOnStack(Encounter.class); Obs obsGroup = highestOnStack(Obs.class);
/** * 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); }
throw new IllegalArgumentException("Cannot enroll in a blank program"); Patient patient = highestOnStack(Patient.class); if (patient == null) throw new IllegalArgumentException("Cannot enroll in a program outside of a Patient"); Encounter encounter = highestOnStack(Encounter.class);
throw new IllegalArgumentException("Cannot change to a blank state"); Patient patient = highestOnStack(Patient.class); if (patient == null) throw new IllegalArgumentException("Cannot change state without a patient"); Encounter encounter = highestOnStack(Encounter.class); if (encounter == null) throw new IllegalArgumentException("Cannot change state without an Encounter");