/** * Function used to refresh the screen * - clear screen * - list admission episodes from database * - */ public void open() throws ims.framework.exceptions.PresentationLogicException { // Clear screen clear(); // List admission episodes by patient AdmissionDetailLiteVoCollection admissionEpisodes = domain.listAdmissionEpisodes(form.getGlobalContext().Core.getPatientShort()); // Populate admission episodes to record browser populateRecordBrowser(admissionEpisodes); // Populate selected admission record to instance controls populateInstanceControls(form.getLocalContext().getSelectedAdmission()); // Set form to VIEW mode form.setMode(FormMode.VIEW); }
/** * Methods used to retrieve all Admission Episodes for given patient. */ public AdmissionDetailLiteVoCollection listAdmissionEpisodes(PatientRefVo patient) { // Test patient parameter if (patient == null || !patient.getID_PatientIsNotNull()) throw new DomainRuntimeException("Logical error - can't not list admision details"); // Build query String query = "SELECT admissionDetails FROM AdmissionDetail AS admissionDetails LEFT JOIN admissionDetails.pasEvent AS pas LEFT JOIN pas.patient AS patient WHERE patient.id = :ID ORDER BY admissionDetails.admissionDateTime DESC"; ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); paramNames.add("ID"); paramValues.add(patient.getID_Patient()); // Query database & return results return AdmissionDetailLiteVoAssembler.createAdmissionDetailLiteVoCollectionFromAdmissionDetail(getDomainFactory().find(query, paramNames, paramValues)); }
/** * Function used to populate admission records to record browser */ private void populateRecordBrowser(AdmissionDetailLiteVoCollection admissionEpisodes) { // Clear record browser form.recbrAdmissions().clear(); // Check collection - if null or empty if (admissionEpisodes == null || admissionEpisodes.size() == 0) { // If the collection is null then the selected admission record will also be null form.getLocalContext().setSelectedAdmission(null); return; } // Add records to record browser for (AdmissionDetailLiteVo admission : admissionEpisodes) { // Build string to be displayed String displayString = createDisplayString(admission); // Add admission record to screen form.recbrAdmissions().newRow(admission, displayString); } // Default to first admission record (the most recent one) form.recbrAdmissions().setValue(admissionEpisodes.get(0)); // Reselect last edited or default to most recent // - if the selected record is null - default to first record in record browser if (!form.getLocalContext().getSelectedAdmissionIsNotNull()) { form.getLocalContext().setSelectedAdmission(domain.getAdmission(admissionEpisodes.get(0))); } else { // - attempt to select the record in the record browser form.recbrAdmissions().setValue(form.getLocalContext().getSelectedAdmission()); // - refresh the selected admission record form.getLocalContext().setSelectedAdmission(domain.getAdmission(form.recbrAdmissions().getValue())); } }