Sort exports and add more debug info
Fix medications to only export nonarchived entries

Change-Id: I954b41c83d9d09274819069848f5a37df393a1f3
Signed-off-by: Jeremy Ho <jujaga@gmail.com>