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."); } }