/** * Method used to retrieve Admission Details. */ public AdmissionDetailLiteWithInpatientEpisodeVo getAdmission(AdmissionDetailRefVo admission) { // Check admission record parameter if (admission == null || !admission.getID_AdmissionDetailIsNotNull()) return null; AdmissionDetailLiteWithInpatientEpisodeVo admissionDetails = AdmissionDetailLiteWithInpatientEpisodeVoAssembler.create((AdmissionDetail) getDomainFactory().getDomainObject(AdmissionDetail.class, admission.getID_AdmissionDetail())); // Get Inpatient episode if exists String query = "SELECT inpEp FROM InpatientEpisode AS inpEp LEFT JOIN inpEp.pasEvent AS pas1, AdmissionDetail AS admtDetail LEFT JOIN admtDetail.pasEvent AS pas2 WHERE pas1.id = pas2.id AND admtDetail.id = :ADM_ID AND inpEp.isRIE is null"; ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); paramNames.add("ADM_ID"); paramValues.add(admissionDetails.getID_AdmissionDetail()); InpatientEpisodeBedNumberUpdateVo inpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.create((InpatientEpisode) getDomainFactory().findFirst(query, paramNames, paramValues)); admissionDetails.setInpatientEpisode(inpatientEpisode); return admissionDetails; }
/** * Method used to save Admission Details. */ public AdmissionDetailLiteWithInpatientEpisodeVo saveAdmission(AdmissionDetailLiteWithInpatientEpisodeVo admission) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException { // Check for validated parameter if (admission == null || admission.isValidated() == false) throw new DomainRuntimeException("Logical error - can't save null or not-validated object"); boolean hasInpatient = admission.getInpatientEpisodeIsNotNull(); // Extract domain objects (admission details & inpatient episode for bed number) AdmissionDetail domainAdmissionDetail = AdmissionDetailLiteVoAssembler.extractAdmissionDetail(getDomainFactory(), admission); InpatientEpisode domainInpatientEpisode = null; if (hasInpatient) { domainInpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.extractInpatientEpisode(getDomainFactory(), admission.getInpatientEpisode()); } // Commit to database both domain objects getDomainFactory().save(domainAdmissionDetail); if (hasInpatient) { getDomainFactory().save(domainInpatientEpisode); } AdmissionDetailLiteWithInpatientEpisodeVo admissionDetails = AdmissionDetailLiteWithInpatientEpisodeVoAssembler.create(domainAdmissionDetail); if (hasInpatient) { InpatientEpisodeBedNumberUpdateVo inpatientEpisode = InpatientEpisodeBedNumberUpdateVoAssembler.create(domainInpatientEpisode); admissionDetails.setInpatientEpisode(inpatientEpisode); } // Return saved record return admissionDetails; }