Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #714 (assigned defect)

Opened 4 months ago

Last modified 3 months ago

PersonAttributeType with a format of java.Util.Date

Reported by: bwolfe Assigned to: bwolfe (accepted)
Priority: critical Milestone: OpenMRS 1.4
Component: OpenMRS Code Base Keywords:
Cc: jarbaugh

Description

In order to store a date as a Person Attribute, you need to choose the format of java.util.Date. When doing this, a javascript calendar picker appears for the user to choose a date and save to the person. When viewing this patient again, no input box and no date appears as options. (as reported by James: https://listserv.iupui.edu/cgi-bin/wa-iupui.exe?A2=ind0804&L=openmrs-implement-l&D=1&T=0&O=D&P=11865 )

Attachments

dateattribute.patch (9.4 kB) - added by bwolfe on 06/05/08 10:00:14.
dateAttributable2.patch (9.2 kB) - added by jacobb on 07/09/08 15:19:57.
Fixed empty and invalid date errors.

Change History

04/30/08 07:59:46 changed by bwolfe

This appears to be a problem with converting from the stored string to a Date object in the dateField.tag file. The fix would be to covert to/from a Date object in the PersonAttribute.java file in the hydrateObject() method.

To replicate:

  • Create a Person Attribute Type with a format of java.util.Date
  • View the main long patient edit form for a current patient
  • Choose a date for the new person attribute and save the patient
  • View the patient again, nothing appears next to that person attribute now.

File to look at:

  • newPatientForm.jsp
  • NewPatientFormController.java
  • patientForm.jsp
  • PatientFormController.java
  • dateField.tag
  • fieldGen/date.jsp

04/30/08 08:06:10 changed by bwolfe

Proposed solution:

Looking at line 451 in newPatientForm.jsp, its calling hydrateObject() on the PersonAttribute. We could add a check for format==java.util.Date, and convert to a date object on return from there. This is where it gets tricky. The user viewing the page might be using a different locale than the user that saved the date last. So, we need to store the dates in a common format. When an attribute is saved to a person in NewPatientFormController and PatientFormController, the value is set/saved with the format of the current user. This needs to be changes so that when a java.util.Date attribute is saved, it converts to the right string format. Then, when using hydrateObject to convert that string to a date object, that same "right string format" is used again.

Of course, an easy solution would be to create an org.openmrs.Date object that is "Attributable", (see Attributable.java), we could do all of this within that object. But thats kind of an ugly solution.

05/26/08 14:30:14 changed by arbaughj

  • priority changed from minor to critical.
  • milestone changed from OpenMRS Someday to OpenMRS 1.4.

06/05/08 10:00:14 changed by bwolfe

  • attachment dateattribute.patch added.

06/05/08 10:04:39 changed by bwolfe

  • owner changed from somebody to bwolfe.
  • status changed from new to assigned.

I attached a patch that will give you this functionality, James. You have to use the org.openmrs.util.AttributableDate format for your person attribute type. Dates are stored in a yyyyMMdd format. You can try this out now by applying to the current trunk code. After the 1.3 release I will apply this to trunk.

(When #802 is completed it should be easier to pick date as the attribute type 'format')

07/09/08 15:19:57 changed by jacobb

  • attachment dateAttributable2.patch added.

Fixed empty and invalid date errors.