def post_demographics_questionnaire(self,
                                        participant_id,
                                        questionnaire_id,
                                        cabor_signature_string=False,
                                        time=TIME_1,
                                        **kwargs):
        """POSTs answers to the demographics questionnaire for the participant"""
        answers = {
            'code_answers': [],
            'string_answers': [],
            'date_answers': [('dateOfBirth', kwargs.get('dateOfBirth'))]
        }
        if cabor_signature_string:
            answers['string_answers'].append(
                ('CABoRSignature', kwargs.get('CABoRSignature')))
        else:
            answers['uri_answers'] = [('CABoRSignature',
                                       kwargs.get('CABoRSignature'))]

        for link_id in self.code_link_ids:
            if link_id in kwargs:
                concept = Concept(PPI_SYSTEM, kwargs[link_id])
                answers['code_answers'].append((link_id, concept))

        for link_id in self.string_link_ids:
            code = kwargs.get(link_id)
            answers['string_answers'].append((link_id, code))

        response_data = make_questionnaire_response_json(
            participant_id, questionnaire_id, **answers)

        with FakeClock(time):
            url = 'Participant/%s/QuestionnaireResponse' % participant_id
            return self.send_post(url, request_data=response_data)
Example #2
0
 def _submit_empty_questionnaire_response(self,
                                          participant_id,
                                          questionnaire_id,
                                          time=TIME_1):
     qr = make_questionnaire_response_json(participant_id, questionnaire_id)
     with FakeClock(time):
         self.send_post(
             'Participant/%s/QuestionnaireResponse' % participant_id, qr)
    def submit_questionnaire_response(self,
                                      participant_id,
                                      questionnaire_id,
                                      race_code,
                                      gender_code,
                                      first_name,
                                      middle_name,
                                      last_name,
                                      zip_code,
                                      state_code,
                                      street_address,
                                      street_address2,
                                      city,
                                      sex_code,
                                      login_phone_number,
                                      sexual_orientation_code,
                                      phone_number,
                                      recontact_method_code,
                                      language_code,
                                      education_code,
                                      income_code,
                                      date_of_birth,
                                      cabor_signature_uri,
                                      time=TIME_1):
        code_answers = []
        _add_code_answer(code_answers, "race", race_code)
        _add_code_answer(code_answers, "genderIdentity", gender_code)
        _add_code_answer(code_answers, "state", state_code)
        _add_code_answer(code_answers, "sex", sex_code)
        _add_code_answer(code_answers, "sexualOrientation",
                         sexual_orientation_code)
        _add_code_answer(code_answers, "recontactMethod",
                         recontact_method_code)
        _add_code_answer(code_answers, "language", language_code)
        _add_code_answer(code_answers, "education", education_code)
        _add_code_answer(code_answers, "income", income_code)

        qr = make_questionnaire_response_json(
            participant_id,
            questionnaire_id,
            code_answers=code_answers,
            string_answers=[("firstName", first_name),
                            ("middleName", middle_name),
                            ("lastName", last_name),
                            ("streetAddress", street_address),
                            ("streetAddress2", street_address2),
                            ("city", city), ("phoneNumber", phone_number),
                            ("loginPhoneNumber", login_phone_number),
                            ("zipCode", zip_code)],
            date_answers=[("dateOfBirth", date_of_birth)],
            uri_answers=[("CABoRSignature", cabor_signature_uri)])
        with FakeClock(time):
            self.send_post(
                'Participant/%s/QuestionnaireResponse' % participant_id, qr)
Example #4
0
 def _submit_consent_questionnaire_response(self,
                                            participant_id,
                                            questionnaire_id,
                                            ehr_consent_answer,
                                            time=TIME_1):
     code_answers = []
     _add_code_answer(code_answers, "ehrConsent", ehr_consent_answer)
     qr = make_questionnaire_response_json(participant_id,
                                           questionnaire_id,
                                           code_answers=code_answers)
     with FakeClock(time):
         self.send_post(
             'Participant/%s/QuestionnaireResponse' % participant_id, qr)