CouchDB implementation of MoodGraph?

Background

See this video to get a 3 min intro to CouchDB.

I have decided to use one week for this. My project is to implement the server side of the following solution using CouchDB:

Overordnet systemskisse

 

To briefly summarize this system development process; I am doing my one-year master thesis on the creation of a self-reporting system for people who suffer from bipolar disorder, where the patient is prompted or notified on his or hers smartphone to input various self-reported data related to the disease at various times of the day. The data is then transmitted via a secure connection to a server. The server has a web interface where both patients and medical professionals involved in the therapeutical treatment of the patient  can view reports and analyze the data as it aggregates over time to discover patterns and guide the treatment.

I am as mentioned building the server side of the application using a standard Apache web server with PHP and MySQL, supported by the Symfony2 framework. As the work so far perhaps has been unnecessarily tedious and sometimes painful, this “spike” is introduced to figure out if CouchDB and the development of a Couch App is easier for this use case. So I fire up some jazz on Spotify and start my VM with Ubuntu (my dev env).

The documentation I follow is located here . My starting point is their wiki. I also start their IRC channel so that I can ask questions if needed. Further, I have a tendency of asking questions on Stackoverflow and I might do that for this work as well.

Installation

There is an installation guide in the wiki, and for my case the installation is done in Ubuntu. It is quite easy, just run the command:

sudo apt-get install couchdb -y

In my dev env it was already there. I don’t know what I have installed that installed it, but something is possibly depending on it.

Initial work

Then I went to http://localhost:5984/_utils/ to set up a database. For my use I created a database named “mood”. Then I click the security button, and I can see that there are some users I can set up here. Here my first question arises: Is it possible for me to port my design considering the structure when it comes to users and access control?

The model can be illustrated in this way in a model I created a few months ago:

modell

 

A user can have two different roles: It can be a patient or it can be a medical professional. A patient can log data concerning himself and view reports based on these data. A medical can have access to reading patient reports on specific patients he has been granted access to, but not other patients. I browsed the web but ended up asking at stackoverflow.

While waiting for input from the community I started browsing myself. I found Access Control Lists (ACLs) in the wiki. But this articles requires some prerequisites. Therefore I spend the rest of the day reading and watching videos on CouchDB.

Conclusion

Access Control Lists was a page concerning the wiki itself it seems. And what I have to conclude from readings in the wiki is that I will not use CouchDB for this case. It is not possible to give users read and write access to only parts of the database.

An update:

I could create it so that every patient has his own database. The doctors could be users of these databases, with only read abilities: http://wiki.apache.org/couchdb/PerDocumentAuthorization

CouchDB – a switch of platform from Symfony2?

I have been thinking alot about my architecture. As of today, I am using the Symfony2 framework - a PHP framework for web applications that serves the rendered pages using a collection of tools. The framework uses a package manager called Composer to make sure all dependencies of the application is met and one runs the composer command with the argument install in the folder of the application – makes it very comprehensible to deploy the application.

However, it has been a time consuming affair to build this application, and I have ended up generating javascript objects in php that I send to the browser (I set the parameters using a bundle named obHighChartsBundle). Hence, I am depending on this javascript to work on the client anyway, and I have not yet implemented functionality to update the data in the view without loading the page. I conclude from this that my application will not be particularly rich, and at the same time it will not be accessible for browsers that does not support JavaScript.

I now consider rebuilding the whole server side of the application using CouchDB and this post will investigate this my next blog post (or in a series of blog posts).

 

7th of May

A new overall systems diagram or drawing has been made:

Overordnet systemskisse

And the paper for the MEDICON conference is almost ready. It will not be posted on the blog, since I think that may violate the rules of the conference. If we are not accepted I will share it, and if we are I will provide a link to the publication.

 

Sunday 5th of May

I have been working on the Android app today. I have decided to divide the interaction of logging in the evening into three screens, or maybe two. The first logs the mood variations within the day and is depicted below:

logge humør mobil 0505

The activity has an analogue scale, but it translates it into the values of the NIMH Life Chart Manual section for graphing the  mood.

 

EDIT: later I commenced work on the second screen:

triggers og dagbok 0505

 

EDIT 2: I have also now, in the evening done some on the settings screen:

innstillinger 0505

Friday 19th of April

I have not been writing for a while, tried yesterday but my host was rebooting SQL servers so the site was down.

Today I have been discussing my thesis with various people, yesterday and days before I coded and worked on deployment of the server. I have also started writing a paper for the MEDICON conference.

Monday 1st of April 2012

from WORKLOG.md

01.04.2012

- The report now shows empty days as well. Before only the graph did
- The report had a severe bug. I am only testing with one user. The first day was determined based on the set of all
day entities in the collection of days irrespective of what user had logged it. So it would have shown reports based on
the first date of the first user who started logging!
- Major refactoring was done and more is to be done. Namely, the User entity now has a function called “getDaysWithNulls()”
which returns all the days logged but with empty days where nothing is logged.

Wednesday 27th or March

Today from worklog:

 

-Removed static path to trigger icon for the getObObjectFrom() method and used helper from assetic.
-added mood levels to day reports
-added triggers to graph labels and plotted them in the graph
-added access control for reports based on who the user has access to, but must be tested more