@SuppressWarnings("unchecked") public VitalSignsWebServiceVoCollection getPatientVitalSigns(Integer patientId, Integer lastNumberOfDays) { if(patientId == null) throw new CodingRuntimeException("Invalid patient Id."); if(lastNumberOfDays == null || (lastNumberOfDays != null && lastNumberOfDays < 0)) return null; DomainFactory factory = getDomainFactory(); String query = "select vs from VitalSigns as vs left join vs.careContext as cc left join cc.episodeOfCare as ec left join ec.careSpell as cs left join cs.patient as p where p.id = :patient and vs.vitalsTakenDateTime >= :lastDate order by vs.vitalsTakenDateTime"; List listOrder = factory.find(query, new String[] {"patient", "lastDate"}, new Object[] {patientId, (new DateTime()).addDays(-lastNumberOfDays).getJavaDate()}); return VitalSignsWebServiceVoAssembler.createVitalSignsWebServiceVoCollectionFromVitalSigns(listOrder); }
public void recordVitalSigns(Integer patientId, VitalSignsWebServiceVo vitalSigns) { if(patientId == null) throw new CodingRuntimeException("Invalid patient Id."); if(vitalSigns == null) throw new CodingRuntimeException("No vital signs to save."); CareContextRefVo careContext = getInpatientCareContext(patientId); if(careContext == null) throw new DomainRuntimeException("This patient doesn't have a care context of type Inpatient."); DomainFactory factory = getDomainFactory(); vitalSigns.setCareContext(careContext); vitalSigns.setVitalsTakenDateTime(new DateTime()); vitalSigns.setAuthoringInformation(getAuthoringInfo()); String[] errors = vitalSigns.validate(); if(errors != null && errors.length > 0) { String conCatString = ""; for(int i=0; i<errors.length; i++) { conCatString += errors[i] + ";"; } throw new DomainRuntimeException("This Vital Sign has validation errors. " + conCatString); } VitalSigns doVitals = VitalSignsWebServiceVoAssembler.extractVitalSigns(factory, vitalSigns); try { factory.save(doVitals); } catch (StaleObjectException e) { throw new DomainRuntimeException("Unable to save. Record changed by another user."); } }