Skip to content

Conversation

@snehar-nd
Copy link

πŸ“‹ Description

JIRA ID:
AMM-1963

βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch release-3.4.1

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

Comment @coderabbitai help to get the list of available commands and usage tips.

} else {
if (frequency.equalsIgnoreCase("Single Dose") || frequency.equalsIgnoreCase("Stat Dose")||
frequency.equalsIgnoreCase("Single Dose Before Food") || frequency.equalsIgnoreCase("Single Dose After Food")) {
frequency.equalsIgnoreCase("Single Dose Before Food") || frequency.equalsIgnoreCase("Single Dose After Food")) {
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be typo with extra space between Before and Food. πŸ€”

Copy link
Member

Choose a reason for hiding this comment

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

@snehar-nd didn't follow this fix.
The fix is to introduce a space?

Copy link
Member

Choose a reason for hiding this comment

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

This is basically a dose and frequency multiplier.
Gave this to AI, got bacK:

public static double getQtyForOneDay(String form, String dose, String frequency) {
    if (form == null || dose == null || frequency == null) return 0d;

    String f = form.trim().toLowerCase();
    String d = dose.trim().toLowerCase();
    String freq = frequency.trim().toLowerCase();

    // dose multiplier for tablets (capsules treated as 1 per administration in original code)
    double doseMultiplier;
    if (f.contains("tablet")) {
        switch (d) {
            case "half tab":           doseMultiplier = 0.5; break;
            case "one tab":            doseMultiplier = 1.0; break;
            case "one & half tab":     doseMultiplier = 1.5; break;
            case "one & half tablet":  doseMultiplier = 1.5; break; // tolerate small wording variants
            case "two tabs":           doseMultiplier = 2.0; break;
            default:                   doseMultiplier = 0.0; // unknown dose
        }
    } else if (f.contains("capsule")) {
        // original code always used integer counts for capsule (1 per administration)
        doseMultiplier = 1.0;
    } else {
        return 0d; // unknown form
    }

    // frequency -> administrations per day
    double freqMultiplier;
    if (freq.contains("once in a week") || freq.contains("once a week") || freq.contains("weekly")) {
        freqMultiplier = 1.0 / 7.0;
    } else if (freq.contains("four") || freq.contains("qid") || freq.contains("four times")) {
        freqMultiplier = 4.0;
    } else if (freq.contains("thrice") || freq.contains("tid")) {
        freqMultiplier = 3.0;
    } else if (freq.contains("twice") || freq.contains("bd")) {
        freqMultiplier = 2.0;
    } else if (freq.contains("once daily") || freq.contains("od") || (freq.contains("once") && freq.contains("daily"))) {
        freqMultiplier = 1.0;
    } else if (freq.contains("single dose") || freq.contains("stat dose") || freq.contains("single dose before") || freq.contains("single dose after")) {
        freqMultiplier = 1.0;
    } else if (freq.contains("sos")) {
        freqMultiplier = 1.0;
    } else {
        // unknown frequency -> 0 (safer than making a guess)
        return 0d;
    }

    return doseMultiplier * freqMultiplier;
}

Copy link
Author

Choose a reason for hiding this comment

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

That was a quick fix for the issue, I will implement quality code here.

* fix: anc care issue

* fix: alignment
@sonarqubecloud
Copy link

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.

4 participants