Module: DaVinciDTRTestKit::NextQuestionTemplateQuestionnaires
- Defined in:
- lib/davinci_dtr_test_kit/full_ehr/v2.2.0/next_question_template_questionnaires.rb
Overview
Shared by the $next-question mock endpoint and the interaction wait test so that both agree on what counts as a usable $next-question response template: a single Questionnaire or a JSON array of Questionnaires. Entries that do not parse to a FHIR Questionnaire are silently discarded rather than treated as an error, since a template array may intentionally carry entries meant for other questionnaires in the workflow.
Instance Method Summary collapse
- #parse_template_questionnaire(questionnaire_json) ⇒ Object
- #questionnaires_from_template_value(value) ⇒ Object
Instance Method Details
#parse_template_questionnaire(questionnaire_json) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/davinci_dtr_test_kit/full_ehr/v2.2.0/next_question_template_questionnaires.rb', line 14 def parse_template_questionnaire(questionnaire_json) parsed = FHIR.from_contents(questionnaire_json.to_json) parsed if parsed.is_a?(FHIR::Questionnaire) rescue StandardError nil end |
#questionnaires_from_template_value(value) ⇒ Object
8 9 10 11 12 |
# File 'lib/davinci_dtr_test_kit/full_ehr/v2.2.0/next_question_template_questionnaires.rb', line 8 def questionnaires_from_template_value(value) parsed_json = JSON.parse(value) questionnaire_jsons = parsed_json.is_a?(Array) ? parsed_json : [parsed_json] questionnaire_jsons.filter_map { |questionnaire_json| parse_template_questionnaire(questionnaire_json) } end |