private Date getPatientBirthdateAdjustedIfEstimated(Patient patient) { Date birthday = patient.getBirthdate(); if (patient.getBirthdateEstimated()) { Calendar cal = Calendar.getInstance(); cal.setTime(birthday); cal.add(Calendar.YEAR, calculateGracePeriodInYears(patient.getAge())); birthday = cal.getTime(); } return birthday; }
/** * Gets the patient's age * * @param motechId Motech id of the patient * @return The age of the patient if found, else null */ @Override public Integer getAgeOfPatientByMotechId(String motechId) { org.openmrs.Patient patient = getOpenmrsPatientByMotechId(motechId); return (patient != null) ? patient.getAge() : null; }
if (patient != null) { Date today = new Date(); RegistrantType registrantType = patient.getAge(today) <= 5 ? RegistrantType.CHILD_UNDER_FIVE : RegistrantType.OTHER; mother = validateMothersMotechId(mothersMotechId, errors, registrantType);
/** * @see {@link FormEntrySession#createForm(String)} */ @Test @Verifies(value = "should return correct xml with a greater than character in an includeIf tag", method = "createForm(String)") public void createForm_shouldReturnCorrectXmlWithAGreaterThanCharacterInAnIncludeIfTag() throws Exception { Integer age = patient.getAge(); String includeText = "Patient is atleast " + age; String htmlform = "<htmlform><includeIf velocityTest=\"$patient.age >= " + age + "\">" + includeText + "</includeIf></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); Assert.assertEquals("<div class=\"htmlform\">Patient is atleast " + age + "</div>", session.getHtmlToDisplay()); }
/** * @see {@link FormEntrySession#createForm(String)} */ @Test @Verifies(value = "should return correct xml with a greater than character in an excludeIf tag", method = "createForm(String)") public void createForm_shouldReturnCorrectXmlWithAGreaterThanCharacterInAnExcludeIfTag() throws Exception { Integer age = patient.getAge(); String excludeText = "Patient is atleast " + age; String htmlform = "<htmlform><excludeIf velocityTest=\"$patient.age >= " + age + "\">" + excludeText + "</excludeIf></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); Assert.assertEquals("<div class=\"htmlform\"></div>", session.getHtmlToDisplay()); }
ageWidget = new NumberFieldWidget(0d, 200d, false); ageErrorWidget = new ErrorWidget(); createWidgets(context, ageWidget, ageErrorWidget, existingPatient != null ? existingPatient.getAge() : null); ageWidget = new NumberFieldWidget(0d, 200d, false); ageErrorWidget = new ErrorWidget(); createWidgets(context, ageWidget, ageErrorWidget, existingPatient != null ? existingPatient.getAge() : null);
webServicePatient.setAge(patient.getAge()); PersonAttribute phoneNumberAttr = patient.getAttribute(MotechConstants.PERSON_ATTRIBUTE_PHONE_NUMBER); if (phoneNumberAttr != null) {