示例#1
0
文件: mixins.py 项目: dimagi/bhoma
 def _patient_wrapper(row):
     """
     The wrapper bolts the patient object onto the case, if we find
     it, otherwise does what the view would have done in the first
     place and adds an empty patient property
     """
     from bhoma.apps.patient.models import CPatient
     data = row.get('value')
     docid = row.get('id')
     doc = row.get('doc')
     if not data or data is None:
         return row
     if not isinstance(data, dict) or not docid:
         return row
     else:
         if 'rev' in data:
             data['_rev'] = data.pop('rev')
         case = cls.wrap(data)
         case.patient = None
         if doc == None:
             # there's (I think) a bug in couchdb causing these to come back empty
             try:
                 doc = CPatient.get_db().get(docid)
             except Exception, e:
                 pass
         if doc and doc.get("doc_type") == "CPatient":
             case.patient = CPatient.wrap(doc)
         return case
示例#2
0
文件: api_views.py 项目: dimagi/bhoma
 def wrapper_func(row):
     """
     Given a row of the view, get out a json representation of a patient row
     """
     patient = CPatient.wrap(row["doc"])
     return [patient.get_id,
             patient.formatted_id,
             patient.gender,
             patient.birthdate.strftime("%Y-%m-%d") if patient.birthdate else "",
             patient.current_clinic_display]