As part of the OpenMRS ID Platform Improvements project, I propose that we allow applications to store “free-form” data on user objects in OpenMRS ID.
The idea is that external, future applications should be able to store user-related data in the Dashboard without requiring us to implement schema changes. For example, OpenMRS Atlas could, using the REST API, store information about the clinic or implementation a person belongs to. That data could be used by the Dashboard, the wiki, or any other application to build a more comprehensive profile out of that person’s OpenMRS ID.
Technically, I think this can be done by used Mixed attributes in Mongoose, which is a schema-less type that stores any object. The user schema could be something like this:
username: <String>
firstName: <String>
lastName: <String>
....
locked: <Boolean>
externalInformation: <Mixed>
So, in my example, Atlas might store data in user.externalInformation.atlas
, which in turn might be an array of Atlas locations associated with the user. The point is that we don’t have to care what it is, if it’s valid JSON/BSON we can store it!
Here are a couple SO questions about doing the same thing:
- http://stackoverflow.com/questions/10403450/how-to-allow-free-form-json-data-within-mongoose-documents
- http://stackoverflow.com/questions/5370846/how-do-you-use-mongoose-without-defining-a-schema
If we do this at the schema-level, then the REST API just needs a sensible way to represent information contained in externalInformation
as REST resources.
@plypy: you know way more about Mongoose than I do Do you think my proposal is something that’d be feasible?