List of usage examples for org.joda.time MutablePeriod setMonths
public void setMonths(int months)
From source file:org.openehr.rm.datatypes.quantity.datetime.DvDuration.java
License:LGPL
/** * Helper method to negate a copy of period * //from w ww . ja v a2s . com * @param mPeriod * @return a negated copy of period */ static Period negatePeriod(Period period) { MutablePeriod mPeriod = period.toMutablePeriod(); mPeriod.setYears(-mPeriod.getYears()); mPeriod.setMonths(-mPeriod.getMonths()); mPeriod.setWeeks(-mPeriod.getWeeks()); mPeriod.setDays(-mPeriod.getDays()); mPeriod.setHours(-mPeriod.getHours()); mPeriod.setMinutes(-mPeriod.getMinutes()); mPeriod.setSeconds(-mPeriod.getSeconds()); mPeriod.setMillis(-mPeriod.getMillis()); return mPeriod.toPeriod(); }
From source file:org.phenotips.data.internal.controller.MedicationController.java
License:Open Source License
@Override public PatientData<Medication> load(Patient patient) { try {/* w w w .j a v a2s . co m*/ XWikiDocument doc = (XWikiDocument) this.documentAccessBridge.getDocument(patient.getDocument()); List<BaseObject> data = doc.getXObjects(Medication.CLASS_REFERENCE); if (data == null || data.isEmpty()) { this.logger.debug("No medication data for patient [{}]", patient.getDocument()); return null; } List<Medication> result = new LinkedList<>(); for (BaseObject medication : data) { if (medication == null) { continue; } MutablePeriod p = new MutablePeriod(); p.setYears(medication.getIntValue(DURATION_YEARS)); p.setMonths(medication.getIntValue(DURATION_MONTHS)); result.add(new Medication(medication.getStringValue(Medication.NAME), medication.getStringValue(Medication.GENERIC_NAME), medication.getStringValue(Medication.DOSE), medication.getStringValue(Medication.FREQUENCY), p.toPeriod(), medication.getStringValue(Medication.EFFECT), medication.getLargeStringValue(Medication.NOTES))); } if (!result.isEmpty()) { return new IndexedPatientData<Medication>(DATA_NAME, result); } } catch (Exception ex) { this.logger.error("Could not find requested document or some unforeseen" + " error has occurred during controller loading ", ex.getMessage()); } return null; }