Skip to content

Conversation

@ShivangMishra
Copy link

@ShivangMishra ShivangMishra commented Sep 3, 2025

Summary by CodeRabbit

  • New Features
    • Added support for a new QR data type in concepts, enabling storage and handling of QR values across applicable workflows (e.g., forms and encounters).
  • Chores
    • Expanded data type catalog to include QR without affecting existing filters or media/multi-select behavior.

@coderabbitai
Copy link

coderabbitai bot commented Sep 3, 2025

Walkthrough

A new enum constant, QR, was added to ConceptDataType in avni-server-data/src/main/java/org/avni/server/domain/ConceptDataType.java. No changes were made to existing static lists or other declarations.

Changes

Cohort / File(s) Summary
Domain enum update
avni-server-data/src/main/java/org/avni/server/domain/ConceptDataType.java
Added enum constant QR to ConceptDataType; no changes to dateTypes, dashboardFilterSupportedTypes, mediaDataTypes, or multiSelectTypes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

I twitch my ears at a shiny new star—QR!
Hopping through enums, near and far,
A tidy nibble, a concise delight,
One more type to scan just right.
Carrot high-five—ship it, bright! 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in 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 ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
avni-server-data/src/main/java/org/avni/server/domain/ConceptDataType.java (2)

32-35: Confirm whether QR should be filterable and/or multi-select

  • If QR values are intended to be queryable (e.g., exact/contains search), consider adding QR to dashboardFilterSupportedTypes.
  • Multi-select: please confirm product intent; default assumption is single-value, so no change to multiSelectTypes.

If filterable, apply:

-    public static final List<ConceptDataType> dashboardFilterSupportedTypes = Arrays.asList(Numeric, Text, Notes, Coded, Date, DateTime, Time, Id, Location);
+    public static final List<ConceptDataType> dashboardFilterSupportedTypes = Arrays.asList(Numeric, Text, Notes, Coded, Date, DateTime, Time, Id, Location, QR);

36-56: Add minimal tests for QR helpers

Add tests to lock expected behavior:

  • matches(QR, "QR") → true; matches("QR", Numeric, Text) → false
  • dateType("QR") → false
  • isMedia("QR") → false

I can draft a small JUnit test class targeting ConceptDataType for these assertions—want me to add it?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bdb5e67 and 6b30f2f.

📒 Files selected for processing (1)
  • avni-server-data/src/main/java/org/avni/server/domain/ConceptDataType.java (1 hunks)

Comment on lines +28 to +29
Encounter,
QR;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Added QR enum: verify persistence and switch/if handling before merge

  • Ensure all JPA mappings for this enum use EnumType.STRING, not ORDINAL, to avoid data corruption when adding new constants.
  • Audit switch/if logic that branches on ConceptDataType and add case QR where needed (validators, serializers, UI mapping endpoints).

Run:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Check for ORDINAL usage (should be none):"
rg -nP --glob '!.git/**' --glob '!**/target/**' '@Enumerated\s*\(\s*EnumType\.ORDINAL\s*\)' -C3 || true

echo "2) List all places ConceptDataType is persisted/used near @Enumerated:"
rg -nP --glob '!.git/**' --glob '!**/target/**' -C3 'ConceptDataType|@Enumerated' || true

echo "3) Find switch statements on ConceptDataType:"
rg -nP --glob '!.git/**' --glob '!**/target/**' -C3 '(?s)switch\s*\(\s*[^)]*\bConceptDataType\b[^)]*\)' || true

echo "4) Verify case QR is handled:"
rg -nP --glob '!.git/**' --glob '!**/target/**' -C2 '\bcase\s+QR\b' || true

Length of output: 188368


Handle newly added QR in ConceptDataType

  • Confirmed no use of @Enumerated(EnumType.ORDINAL); ConceptDataType is persisted as a String.
  • No case QR in any switch(ConceptDataType.valueOf(...))—add QR handling in all such switches (RequestUtils, ObservationService, ViewGenService, ConceptService, etc.).
  • Audit all if (ConceptDataType.X.toString().equals(...)) branches (ImportController, FormController, serializers, UI mapping) and insert corresponding QR logic.
🤖 Prompt for AI Agents
avni-server-data/src/main/java/org/avni/server/domain/ConceptDataType.java lines
28-29: The enum now includes QR but the codebase lacks handling for it; confirm
persistence is String (no DB migration), then add explicit QR branches where
ConceptDataType is used: update every switch(ConceptDataType.valueOf(...)) to
include a case QR and implement the intended behavior (RequestUtils,
ObservationService, ViewGenService, ConceptService, etc.), and audit all
string-equality checks like if (ConceptDataType.X.toString().equals(...)) across
ImportController, FormController, serializers and UI mapping to add
corresponding QR logic or fallbacks; ensure tests and
serialization/deserialization handle QR and add unit tests for new branch
coverage.

@ombhardwajj
Copy link
Member

This closes avniproject/avni-product#1712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants