adding display value to answer options
Proposed Changes
- adding display field to asnwer_options
Associated Issue
- Link to issue here, explain how the proposed solution will solve the reported issue/ feature request.
Architecture changes
- Remove this section if not used
Merge Checklist
- [ ] Tests added/fixed
- [ ] Update docs in
/docs - [ ] Linting Complete
- [ ] Any other necessary step
Only PR's with test cases included and passing lint and test pipelines will be reviewed
@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins
Summary by CodeRabbit
-
New Features
- Answer options now support optional user-facing display labels.
- Option values may be string, integer, or coded entries with stricter validation.
-
Tests
- Test questionnaires updated to include display labels for choice options.
-
Chores
- Questionnaire fixtures refreshed to add display labels across multiple choice questions.
📝 Walkthrough
Walkthrough
Adds an optional display field to answer options, narrows value to str | int | Coding with updated trimming/validation, and enforces uniform types across answer options; tests and JSON fixtures are updated to include display values.
Changes
| Cohort / File(s) | Summary |
|---|---|
Questionnaire modelcare/emr/resources/questionnaire/spec.py |
Added `AnswerOption.display: str |
Tests (add displays to options)care/emr/tests/test_questionnaire_api.py |
Updated test questionnaire definitions to include display alongside value for repeated choice questions. |
Fixtures (add displays to options)data/questionnaire_fixtures.json |
Added display keys to multiple choice answer options across several questions; display values mirror labels/codes. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant QuestionnaireModel
participant AnswerOptionValidator
participant QuestionValidator
Client->>QuestionnaireModel: create Question with answer_options
Note right of QuestionnaireModel: For each AnswerOption
QuestionnaireModel->>AnswerOptionValidator: validate_value_field(value)
alt value is string
AnswerOptionValidator-->>QuestionnaireModel: trimmed string
else value is int or Coding
AnswerOptionValidator-->>QuestionnaireModel: accepted value
end
QuestionnaireModel->>QuestionValidator: validate_choice_and_group_questions(options)
alt multiple options with mixed types
QuestionValidator-->>QuestionnaireModel: raise ValueError (lists types)
else uniform types
QuestionValidator-->>QuestionnaireModel: OK
end
QuestionnaireModel-->>Client: creation result / error
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Poem
New displays drift in beside each value, polite,
Validators tidy strings and scold the vague, not quite.
Options must agree — no mingle or surprise,
Tests and fixtures updated, everything in its place (mostly). 🧹
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
prafful/feat/adding-display-value-to-answer-options
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreor@coderabbit ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
Project coverage is 51.21%. Comparing base (
529a684) to head (182329c).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| care/emr/resources/questionnaire/spec.py | 57.14% | 3 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #3082 +/- ##
===========================================
- Coverage 51.21% 51.21% -0.01%
===========================================
Files 251 251
Lines 11383 11387 +4
Branches 1282 1283 +1
===========================================
+ Hits 5830 5832 +2
- Misses 5532 5534 +2
Partials 21 21
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.