Beispiel #1
0
    def get_all_rows(self):
        """
        Rows to appear in the "Subjects" sheet of export_table().

        CdiscOdmExportWriter will render this using the odm_export.xml template to combine subjects into a single
        ODM XML document.

        The values are also used to register new subjects if the web service is enabled.
        """
        audit_log_id_ref = {'id': 0}  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
        query = self._build_query().case_type(CC_SUBJECT_CASE_TYPE).start(0).size(SIZE_LIMIT)
        rows = []
        for result in query.scroll():
            case = CommCareCase.wrap(result)
            if not self.is_subject_selected(case):
                continue
            subject = Subject.wrap(case, audit_log_id_ref)
            row = [
                'SS_' + subject.subject_key,  # OpenClinica prefixes subject key with "SS_" to make the OID
                subject.study_subject_id,
                subject.enrollment_date,
                subject.sex,
                subject.dob,
                subject.get_export_data(),
            ]
            rows.append(row)
        return rows
Beispiel #2
0
 def subject_rows(self):
     audit_log_id = 0  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
     for case in self.get_subject_cases():
         subject = Subject(getattr(case, CC_SUBJECT_KEY), getattr(case, CC_STUDY_SUBJECT_ID), self.domain)
         for form in originals_first(case.get_forms()):
             updates = form.form['case'].get('update', {})
             if updates:
                 for question, answer in updates.iteritems():
                     item = get_question_item(self.domain, form.xmlns, question)
                     if item is None:
                         # This is a CommCare-only question or form
                         continue
                     audit_log_id += 1
                     subject.add_item(item, form, question, oc_format_date(answer), audit_log_id)
                 subject.close_form(form)
         yield subject
Beispiel #3
0
 def rows(self):
     audit_log_id_ref = {'id': 0}  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
     for res in self.es_results['hits'].get('hits', []):
         case = CommCareCase.wrap(res['_source'])
         if not self.is_subject_selected(case):
             continue
         subject = Subject.wrap(case, audit_log_id_ref)
         row = [
             subject.subject_key,  # What OpenClinica refers to as Person ID; i.e. OID with the "SS_" prefix
             subject.study_subject_id,
             subject.enrollment_date,
             subject.sex,
             subject.dob,
             subject.get_report_events(),
         ]
         yield row
Beispiel #4
0
 def subject_rows(self):
     audit_log_id_ref = {'id': 0}  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
     for case in self.get_study_subject_cases():
         subject = Subject(getattr(case, CC_SUBJECT_KEY), getattr(case, CC_STUDY_SUBJECT_ID), self.domain)
         subject.enrollment_date = getattr(case, CC_ENROLLMENT_DATE, None)
         subject.sex = getattr(case, CC_SEX, None)
         subject.dob = getattr(case, CC_DOB, None)
         for form in originals_first(case.get_forms()):
             # Pass audit log ID by reference to increment it for each audit log
             subject.add_data(form.form, form, audit_log_id_ref)
         yield subject
Beispiel #5
0
 def rows(self):
     audit_log_id_ref = {'id': 0}  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
     query = self._build_query().case_type(CC_SUBJECT_CASE_TYPE)
     for result in query.scroll():
         case = CommCareCase.wrap(result)
         if not self.is_subject_selected(case):
             continue
         subject = Subject.wrap(case, audit_log_id_ref)
         row = [
             subject.subject_key,  # What OpenClinica refers to as Person ID; i.e. OID with the "SS_" prefix
             subject.study_subject_id,
             subject.enrollment_date,
             subject.sex,
             subject.dob,
             subject.get_report_events(),
         ]
         yield row
Beispiel #6
0
    def get_all_rows(self):
        """
        Rows to appear in the "Subjects" sheet of export_table().

        CdiscOdmExportWriter will render this using the odm_export.xml template to combine subjects into a single
        ODM XML document.
        """
        audit_log_id_ref = {'id': 0}  # To exclude audit logs, set `custom.openclinica.const.AUDIT_LOGS = False`
        query = self._build_query().start(0).size(SIZE_LIMIT)
        for result in query.scroll():
            case = CommCareCase.wrap(result)
            if not self.is_subject_selected(case):
                continue
            subject = Subject.wrap(case, audit_log_id_ref)
            row = [
                'SS_' + subject.subject_key,  # OpenClinica prefixes subject key with "SS_" to make the OID
                subject.study_subject_id,
                subject.get_export_data(),
            ]
            yield row