public AdmissionDetailLiteVo getMothersAdmission(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient is null or id not provided in method getMothersAdmission"); //get the patient to read ClientParent value Patient doPatient = (Patient) getDomainFactory().getDomainObject(patient); if(doPatient != null && doPatient.getClientParent() != null) { List admissions = getDomainFactory().find("from AdmissionDetail adm left join fetch adm.pasEvent as pe left join fetch pe.patient as pat where pat.id = " + doPatient.getClientParent().getId()); if(admissions != null && admissions.size() > 0) return AdmissionDetailLiteVoAssembler.create((AdmissionDetail) admissions.get(0)); } return null; }
/** * 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)); }
/** * 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; }
private AdmissionDetailLiteVo getAdmissionDetailsForPasEvent(PASEvent pasEvent) { if(pasEvent == null) throw new CodingRuntimeException("Cannot get AdmissionDetails on null PasEvent"); List<?> list = getDomainFactory().find("select admDet from AdmissionDetail as admDet left join admDet.pasEvent as pasEv where (pasEv.id = :pasEventId)", new String[] {"pasEventId"}, new Object[] {pasEvent.getId()}); if (list == null || list.size() == 0) return null; return AdmissionDetailLiteVoAssembler.createAdmissionDetailLiteVoCollectionFromAdmissionDetail(list).get(0); }