Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create additional config for notification display fields and refactor #334

Conversation

MatthewErispe
Copy link
Collaborator

@MatthewErispe MatthewErispe commented Oct 15, 2024

…e and kafka partition key

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new fields for Kafka key generation and notification display in configuration files.
  • Improvements

    • Streamlined the process for generating Kafka partition keys, enhancing performance and maintainability.
    • Updated patient name construction logic for better readability.
  • Bug Fixes

    • Removed outdated fields from JSON configurations to prevent confusion and improve organization.

These changes aim to enhance the overall functionality and clarity of the application, benefiting user experience and system performance.

@rcrichton
Copy link
Member

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request involve significant modifications to several classes and configuration files related to Kafka partition key generation and notification display. A new method generateKafkaPartitionKey has been introduced in the Main class, which encapsulates the logic for generating partition keys from DemographicData. Configuration classes have been updated to include new fields for Kafka key generation and notification display, replacing the previous nameValidationFields. Additionally, several JSON configuration files have been restructured to reflect these changes, ensuring consistency across the application.

Changes

File Change Summary
JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java Added method private static @NotNull String generateKafkaPartitionKey(final DemographicData patientRecord). Updated apacheReadCSV to use this new method. Modified logging to reflect new method output.
JeMPI_Apps/JeMPI_EM_Scala/src/main/scala/org/jembi/jempi/em/config/Config.scala Updated Config case class: removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay.
JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/FieldsConfig.java Replaced nameValidationFields with fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay. Updated constructor to initialize new fields.
JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/JsonConfig.java Replaced nameValidationFields with fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay, annotated with @JsonProperty.
JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/NameFieldsForKafkaKeyGen.java Renamed record from NameValidationFields to NameFieldsForKafkaKeyGen and updated field name accordingly.
JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/ConfigurationModel.java Replaced nameValidationFields with fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay.
JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/backend/LinkerDWH.java Refactored patientName method to construct display name using FIELDS_CONFIG.nameFieldsForNotificationDisplay.
devops/linux/docker/data-config/config-reference-auto-generate-fields.json Removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay with relevant fields.
devops/linux/docker/data-config/config-reference-link-d-validate-dp-match-dp.json Removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay.
devops/linux/docker/data-config/config-reference-link-d.json Removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay.
devops/linux/docker/data-config/config-reference-link-dp-minimal.json Removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay.
devops/linux/docker/data-config/config-reference-link-dp.json Removed nameValidationFields, added fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay. Added aux_auto_update_enabled in auxGoldenRecordFields.

Possibly related PRs

Suggested reviewers

  • NyashaMuusha
  • martino-jembi

Poem

In fields where data hops and plays,
A key for Kafka now displays.
With names that sound so sweet and clear,
Our code now sings, oh what a cheer!
From fields of old, new paths we weave,
In every byte, a tale to believe! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (6)
devops/linux/docker/data-config/config-reference-link-d.json (1)

116-122: LGTM! Consider adding a comment for clarity.

The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay arrays aligns well with the PR objectives. These changes provide clear configuration for Kafka key generation and notification display fields, which enhances the flexibility and maintainability of the system.

Consider adding a brief comment above each new array to explain their purpose. For example:

  // Fields used to generate Kafka partition keys
  "fieldsForKafkaKeyGen": [
    "given_name",
    "family_name"
  ],
  // Fields to be displayed in notifications
  "nameFieldsForNotificationDisplay": [
    "given_name",
    "family_name"
  ],

This would improve the self-documentation of the configuration file.

devops/linux/docker/data-config/config-reference-link-dp.json (2)

177-183: LGTM! Consider adding comments for clarity.

The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay aligns well with the PR objectives. These new fields provide a clear separation of concerns for Kafka key generation and notification display, which is a good practice.

Consider adding brief comments to explain the purpose of these fields:

 {
+  // Fields used to generate the Kafka partition key
   "fieldsForKafkaKeyGen": [
     "given_name",
     "family_name"
   ],
+  // Fields used to display names in notifications
   "nameFieldsForNotificationDisplay": [
     "given_name",
     "family_name"
   ],
 }

This would enhance the configuration's self-documentation and make it easier for other developers to understand the purpose of these fields.


Line range hint 1-220: Overall structure maintains integrity while adding new functionality.

The changes to this configuration file are well-structured and maintain the integrity of the existing configuration. The additions of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay enhance the file's functionality without disrupting the existing fields or rules.

Key observations:

  1. The new fields are logically placed within the file structure.
  2. Existing configurations, including the complex linking rules, remain unchanged, minimizing the risk of unintended side effects.
  3. The changes align with the PR objectives of creating a configuration for notification display fields and refactoring related to the Kafka partition key.

As the configuration grows, consider splitting it into separate files for different concerns (e.g., Kafka configuration, notification configuration, linking rules) to improve maintainability. This could be a future refactoring task if the configuration continues to expand.

devops/linux/docker/data-config/config-reference-link-d-validate-dp-match-dp.json (1)

225-231: LGTM! Consider adding inline comments for clarity.

The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay improves the configuration's flexibility and aligns with the PR objectives. The separation of concerns between Kafka key generation and notification display is a good practice.

Consider adding inline comments to explain the purpose of these new fields, especially how they relate to the removed nameValidationFields. This would improve maintainability. For example:

"fieldsForKafkaKeyGen": [
  // Fields used to generate Kafka partition keys
  "given_name",
  "family_name"
],
"nameFieldsForNotificationDisplay": [
  // Fields used for displaying names in notifications
  "given_name",
  "family_name"
]
JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java (1)

186-208: LGTM: Well-structured partition key generation method.

The generateKafkaPartitionKey method is well-implemented and aligns with the PR objectives. It encapsulates the logic for generating Kafka partition keys, uses configurable fields, and ensures a non-null return value. The use of the Soundex algorithm for phonetic matching is a good approach.

A minor suggestion for improvement:

Consider moving the logging statement to a debug level to avoid potential performance issues in production:

-LOGGER.info("Using Kafka topic/partition: {}", partitionKeyStr);
+LOGGER.debug("Using Kafka topic/partition: {}", partitionKeyStr);

This change would reduce log verbosity in production while still providing valuable information during development and debugging.

JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/backend/LinkerDWH.java (1)

98-107: Approve refactoring of patientName method with a suggestion for improvement

The refactoring of the patientName method is a good improvement. It now uses a more flexible approach by leveraging the FIELDS_CONFIG.nameFieldsForNotificationDisplay configuration, which allows for easier maintenance and customization of the patient name display.

To improve readability, consider extracting the stream operation into a separate method. This would make the patientName method more concise and easier to understand at a glance. For example:

 private static String patientName(final Interaction interaction) {
     var patientRecord = interaction.demographicData();
-    String patientDisplayName = FIELDS_CONFIG.nameFieldsForNotificationDisplay.stream()
-                                                                    .map(fieldName -> patientRecord.fields.stream()
-                                                                                                          .filter(field -> fieldName.equals(
-                                                                                                                field.ccTag()))
-                                                                                                          .map(DemographicData.DemographicField::value)
-                                                                                                          .findFirst()
-                                                                                                          .orElse(""))
-                                                                    .collect(Collectors.joining(" "))
-                                                                    .trim();
-    return patientDisplayName;
+    return buildPatientDisplayName(patientRecord);
 }
+
+ private static String buildPatientDisplayName(DemographicData patientRecord) {
+    return FIELDS_CONFIG.nameFieldsForNotificationDisplay.stream()
+        .map(fieldName -> patientRecord.fields.stream()
+            .filter(field -> fieldName.equals(field.ccTag()))
+            .map(DemographicData.DemographicField::value)
+            .findFirst()
+            .orElse(""))
+        .collect(Collectors.joining(" "))
+        .trim();
+ }

This change would make the patientName method more concise while moving the complex stream operation to a dedicated method with a descriptive name.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fc2ac46 and af276c0.

📒 Files selected for processing (12)
  • JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java (3 hunks)
  • JeMPI_Apps/JeMPI_EM_Scala/src/main/scala/org/jembi/jempi/em/config/Config.scala (1 hunks)
  • JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/FieldsConfig.java (2 hunks)
  • JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/JsonConfig.java (1 hunks)
  • JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/NameFieldsForKafkaKeyGen.java (1 hunks)
  • JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/ConfigurationModel.java (1 hunks)
  • JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/backend/LinkerDWH.java (1 hunks)
  • devops/linux/docker/data-config/config-reference-auto-generate-fields.json (1 hunks)
  • devops/linux/docker/data-config/config-reference-link-d-validate-dp-match-dp.json (1 hunks)
  • devops/linux/docker/data-config/config-reference-link-d.json (1 hunks)
  • devops/linux/docker/data-config/config-reference-link-dp-minimal.json (1 hunks)
  • devops/linux/docker/data-config/config-reference-link-dp.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (18)
JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/NameFieldsForKafkaKeyGen.java (1)

7-9: LGTM! Renaming improves clarity but verify usage.

The renaming of the record from NameValidationFields to NameFieldsForKafkaKeyGen and its field from nameValidationFields to nameFieldsForKafkaKeyGen improves clarity about the purpose of this configuration. This change aligns well with the PR objective of creating a configuration for Kafka key generation.

To ensure that this change doesn't break existing code, please verify all usages of this record across the codebase. Run the following script to find all occurrences:

Make sure to update all references to use the new names.

✅ Verification successful

Verified: Renaming does not impact other parts of the codebase.

The renaming of the record NameFieldsForKafkaKeyGen and its field nameFieldsForKafkaKeyGen is localized to NameFieldsForKafkaKeyGen.java with no references found elsewhere. This change enhances clarity without affecting other components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of the old and new record names

echo "Searching for old record name 'NameValidationFields':"
rg --type java "NameValidationFields"

echo "\nSearching for new record name 'NameFieldsForKafkaKeyGen':"
rg --type java "NameFieldsForKafkaKeyGen"

echo "\nSearching for old field name 'nameValidationFields':"
rg --type java "nameValidationFields"

echo "\nSearching for new field name 'nameFieldsForKafkaKeyGen':"
rg --type java "nameFieldsForKafkaKeyGen"

Length of output: 979

JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/input/JsonConfig.java (1)

22-23: LGTM! New fields added as per PR objectives.

The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay aligns with the PR objectives. The fields are properly annotated with @JsonProperty for correct JSON serialization/deserialization.

To ensure that the removal of nameValidationFields doesn't break existing functionality, please run the following script:

Consider adding Javadoc comments to describe the purpose and expected content of these new fields. This will help other developers understand their usage. For example:

/**
 * List of field names used for generating Kafka partition keys.
 */
@JsonProperty("fieldsForKafkaKeyGen") List<String> fieldsForKafkaKeyGen,

/**
 * List of name fields to be displayed in notifications.
 */
@JsonProperty("nameFieldsForNotificationDisplay") List<String> nameFieldsForNotificationDisplay,
✅ Verification successful

Changes Verified Successfully

The removal of nameValidationFields was confirmed as it is no longer used in the codebase. No remaining references were found in any files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of the removed field 'nameValidationFields'

# Test: Search for 'nameValidationFields' usage in Java files
rg --type java 'nameValidationFields'

# Test: Search for 'nameValidationFields' in JSON config files
rg --type json 'nameValidationFields'

Length of output: 75


Script:

#!/bin/bash
# Description: Comprehensive search for any usage of the removed field 'nameValidationFields'

# Search for 'nameValidationFields' in all files
rg 'nameValidationFields' 

# If rg is not available, use fd combined with grep as a fallback
if ! command -v rg &> /dev/null
then
    echo "rg not found, using fd and grep as fallback."
    fd --type f | xargs grep -i 'nameValidationFields'
fi

Length of output: 41

JeMPI_Apps/JeMPI_EM_Scala/src/main/scala/org/jembi/jempi/em/config/Config.scala (1)

64-70: Review of changes to the Config case class

The modifications to the Config case class align with the PR objectives and introduce new configuration options for Kafka key generation and notification display. However, there are a few points to consider:

  1. The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay fields is consistent with the PR summary and objectives.

  2. The removal of nameValidationFields might impact existing code that relies on this field. Ensure that all references to this field have been updated or removed throughout the codebase.

  3. Both new fields are of type Option[List[String]], which allows for flexibility in configuration. However, consider if default values or documentation for these fields are needed to guide users on their proper usage.

To ensure that the removal of nameValidationFields doesn't cause issues, please run the following script to check for any remaining references:

Would you like assistance in updating the documentation or adding comments to explain the usage of these new fields?

✅ Verification successful

Verified Removal of nameValidationFields

The removal of nameValidationFields does not have any remaining references in Scala or JSON files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to nameValidationFields

# Search for nameValidationFields in Scala files
echo "Searching for nameValidationFields in Scala files:"
rg --type scala 'nameValidationFields'

# Search for nameValidationFields in JSON configuration files
echo "Searching for nameValidationFields in JSON files:"
rg --type json 'nameValidationFields'

Length of output: 296

JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/models/ConfigurationModel.java (1)

19-20: LGTM! Consider verifying impact and updating documentation.

The addition of fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay aligns well with the PR objectives. This change improves the separation of concerns by having distinct fields for Kafka key generation and notification display.

Please ensure that all parts of the codebase that previously used nameValidationFields have been updated to use the new fields appropriately. Run the following script to verify:

Consider updating any relevant documentation or comments to reflect these configuration changes, ensuring that developers understand the purpose and usage of these new fields.

✅ Verification successful

Verified! All references to nameValidationFields have been successfully removed and the new fields are correctly implemented throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of nameValidationFields and verify the usage of new fields

# Search for any remaining usage of nameValidationFields
echo "Checking for remaining usage of nameValidationFields:"
rg "nameValidationFields" --type java

# Verify the usage of new fields
echo "Verifying usage of new fields:"
rg "fieldsForKafkaKeyGen|nameFieldsForNotificationDisplay" --type java

Length of output: 2258

devops/linux/docker/data-config/config-reference-auto-generate-fields.json (1)

138-144: LGTM! New configuration fields added as expected.

The changes align well with the PR objectives. Two new fields have been added:

  1. fieldsForKafkaKeyGen: This appears to be used for generating Kafka partition keys.
  2. nameFieldsForNotificationDisplay: This seems to be used for displaying names in notifications.

Both fields include "given_name" and "family_name", which are appropriate for these purposes.

To ensure these changes are properly integrated, please run the following script to verify the usage of these new fields in the application code:

This script will help ensure that:

  1. The new fields are being used in the application code.
  2. There are no leftover references to the old nameValidationFields.
✅ Verification successful

Verified! The new configuration fields are correctly integrated into the application code, and the old nameValidationFields has been successfully removed with no remaining references.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new configuration fields in the application code.

# Test 1: Search for usage of fieldsForKafkaKeyGen
echo "Searching for fieldsForKafkaKeyGen usage:"
rg --type java --type scala 'fieldsForKafkaKeyGen'

# Test 2: Search for usage of nameFieldsForNotificationDisplay
echo "Searching for nameFieldsForNotificationDisplay usage:"
rg --type java --type scala 'nameFieldsForNotificationDisplay'

# Test 3: Search for any remaining usage of the old nameValidationFields
echo "Searching for any remaining usage of nameValidationFields:"
rg --type java --type scala 'nameValidationFields'

Length of output: 2758

devops/linux/docker/data-config/config-reference-link-dp-minimal.json (4)

192-198: Summary of changes and their impact.

The changes in this configuration file are well-structured and align with the PR objectives:

  1. Added fieldsForKafkaKeyGen for specifying fields used in Kafka partition key generation.
  2. Added nameFieldsForNotificationDisplay for specifying fields used in notification displays.
  3. Removed the previous nameValidationFields, replacing its functionality with more specific configurations.

These changes improve the clarity and specificity of the configuration, allowing for more fine-grained control over Kafka key generation and notification displays. The rest of the configuration file remains unchanged, maintaining the existing functionality for other aspects of the system.

To ensure a smooth transition, please make sure to:

  1. Update any code that previously used nameValidationFields to now use the appropriate new field.
  2. Update documentation to reflect these new configuration options.
  3. Consider adding comments in the JSON file to explain the purpose of these new fields for future maintainers.

192-198: Verify the impact of removing nameValidationFields.

The nameValidationFields has been removed and replaced with more specific fields: fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay. This change improves the clarity of the configuration. However, please ensure that all previous uses of nameValidationFields in the codebase have been updated to use these new fields.

Run the following script to check for any remaining uses of nameValidationFields:

#!/bin/bash
# Search for any remaining uses of nameValidationFields in the codebase
rg --type-add 'config:*.{json,yaml,yml}' --type config --type java --type scala 'nameValidationFields'

If any results are found, they may need to be updated to use the new fields.


192-195: New configuration for Kafka key generation added.

The addition of fieldsForKafkaKeyGen aligns with the PR objective of creating a configuration flag for the Kafka key. This new field specifies which demographic fields should be used for generating the Kafka partition key.

To ensure consistency, let's verify if these fields exist in the demographicFields section:

✅ Verification successful

Kafka key generation fields are valid.

All fields specified in fieldsForKafkaKeyGen are present in demographicFields.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the fields used for Kafka key generation exist in demographicFields
jq '.demographicFields[] | select(.fieldName == "given_name" or .fieldName == "family_name")' devops/linux/docker/data-config/config-reference-link-dp-minimal.json

Length of output: 752


196-198: New configuration for notification display fields added.

The addition of nameFieldsForNotificationDisplay addresses the PR objective of creating a configuration related to notification display fields. This new field specifies which name fields should be used for displaying notifications.

Let's verify if these fields exist in the demographicFields section:

devops/linux/docker/data-config/config-reference-link-d-validate-dp-match-dp.json (2)

Line range hint 1-283: Summary: Configuration changes align with PR objectives

The modifications to this configuration file successfully implement the creation of a Kafka key generation config and refactor the notification display fields. These changes improve the configuration's flexibility and clarity while maintaining consistency with the existing structure.

Key points:

  1. Addition of fieldsForKafkaKeyGen for Kafka partition key generation.
  2. Introduction of nameFieldsForNotificationDisplay for notification-specific name fields.
  3. Removal of the previous nameValidationFields array.
  4. Core functionality and rules remain unchanged.

The changes appear to be well-thought-out and aligned with the PR objectives. Ensure that the verification steps are completed to confirm there are no unintended side effects in other parts of the system.


Line range hint 1-283: Verify system-wide impact of configuration changes

The changes to this configuration file are focused and maintain consistency with the existing structure. The separation of Kafka key generation and notification display fields improves flexibility without disrupting the core functionality defined in the rules section.

To ensure these changes don't cause issues elsewhere in the system, please run the following verification:

This script will help identify any code or configuration that might need to be updated to use the new fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay instead of the old nameValidationFields.

JeMPI_Apps/JeMPI_LibShared/src/main/java/org/jembi/jempi/shared/config/FieldsConfig.java (3)

93-96: LGTM: Proper initialization of fieldsForKafkaKeyGen

The initialization of fieldsForKafkaKeyGen is well-implemented:

  • It correctly handles the case where jsonConfig.fieldsForKafkaKeyGen() might be null.
  • Using List.copyOf() ensures immutability of the list, which is a good practice.
  • The code is concise and readable.

97-99: LGTM: Consistent and proper initialization of nameFieldsForNotificationDisplay

The initialization of nameFieldsForNotificationDisplay is well-implemented and consistent with the initialization of fieldsForKafkaKeyGen:

  • It correctly handles the case where jsonConfig.nameFieldsForNotificationDisplay() might be null.
  • Using List.copyOf() ensures immutability of the list, which is a good practice.
  • The code is concise and readable.
  • The implementation maintains consistency with the initialization of fieldsForKafkaKeyGen, which is good for code maintainability.

Line range hint 1-150: Overall assessment: Well-implemented changes with a minor suggestion

The changes in this file align well with the PR objectives to create additional configuration for notification display fields and refactor. The new fields fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay are correctly implemented and initialized, with proper null checks and immutability considerations.

There's a minor suggestion to improve encapsulation by making these fields private and adding getter methods. Otherwise, the changes are well-structured, consistent, and achieve the intended goals of the PR.

JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java (3)

18-18: LGTM: Import of @NotNull annotation.

The addition of the @NotNull annotation import is a good practice for improving code clarity and enabling better static analysis. This can help catch potential null pointer exceptions early in the development process.


157-157: LGTM: Refactored partition key generation.

The extraction of partition key generation logic into a separate method generateKafkaPartitionKey improves code readability and maintainability. This change aligns well with the Single Responsibility Principle and the PR objectives.


Line range hint 1-324: Overall assessment: Well-executed refactoring with improved configurability.

The changes in this PR successfully refactor the Kafka partition key generation logic, improving code organization and maintainability. The introduction of FIELDS_CONFIG.fieldsForKafkaKeyGen enhances the configurability of the key generation process, aligning well with the PR objectives.

Key improvements:

  1. Separation of concerns by extracting partition key generation into a dedicated method.
  2. Increased flexibility through configurable fields for key generation.
  3. Consistent use of the Soundex algorithm for phonetic matching.
  4. Proper null-safety considerations with the @NotNull annotation.

These changes contribute to a more robust and maintainable codebase without introducing apparent bugs or security issues.

JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/backend/LinkerDWH.java (1)

98-107: Verify the impact of patientName method changes

While the refactoring of the patientName method is an improvement in terms of flexibility and maintainability, it's important to note that the behavior of the method has changed. The method now uses a configurable list of fields (FIELDS_CONFIG.nameFieldsForNotificationDisplay) to construct the patient name, which might result in different output compared to the previous implementation that specifically used given name and family name.

Please ensure that:

  1. The FIELDS_CONFIG.nameFieldsForNotificationDisplay is correctly configured to include all necessary name fields.
  2. The new implementation produces the expected output for various test cases, including edge cases (e.g., missing fields, non-standard name formats).
  3. Any downstream code or systems that rely on the output of this method are compatible with the potentially changed format of the patient name.

To assist with verification, you can run the following script to check the usage of patientName method and the configuration of nameFieldsForNotificationDisplay:

This will help identify all places where the patientName method is used and where the nameFieldsForNotificationDisplay configuration is set or modified.

✅ Verification successful

Impact of patientName Method Changes Verified

The refactoring of the patientName method in LinkerDWH.java is confined to this class, and the configuration for nameFieldsForNotificationDisplay is appropriately managed in FieldsConfig.java. This limits the scope of changes and reduces potential side effects.

Please ensure that:

  1. The nameFieldsForNotificationDisplay includes all necessary fields required for accurate patient name construction.
  2. Comprehensive tests are conducted within LinkerDWH.java to validate the new implementation across different scenarios, including edge cases.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check usage of patientName method
echo "Usage of patientName method:"
rg "patientName\(" --type java

# Check configuration of nameFieldsForNotificationDisplay
echo "\nConfiguration of nameFieldsForNotificationDisplay:"
rg "nameFieldsForNotificationDisplay" --type java

Length of output: 2035

Comment on lines +116 to +119
"fieldsForKafkaKeyGen": [
"given_name",
"family_name"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

fieldsForKafkaKeyGen Configuration Defined but Not Utilized.

The fieldsForKafkaKeyGen is defined in Config.scala but is not currently used in any method related to Kafka partition key generation. Please ensure that this configuration is properly integrated into the Kafka partition key generation logic.

  • File: JeMPI_Apps/JeMPI_EM_Scala/src/main/scala/org/jembi/jempi/em/config/Config.scala
  • Configuration: fieldsForKafkaKeyGen
🔗 Analysis chain

Verify usage of new Kafka key generation fields.

The new fieldsForKafkaKeyGen configuration aligns with the PR objective of creating a config flag for the Kafka key. To ensure proper implementation:

Run the following script to verify the usage of these fields in the codebase:

Ensure that the generateKafkaPartitionKey method in the Main class properly utilizes these configured fields for generating Kafka partition keys.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of fieldsForKafkaKeyGen in the codebase

# Test: Search for references to fieldsForKafkaKeyGen
# Expect: At least one occurrence in code that generates Kafka partition keys
rg --type-add 'scala:*.scala' --type scala 'fieldsForKafkaKeyGen'

# Test: Search for the new generateKafkaPartitionKey method
# Expect: Method implementation using the new configuration
ast-grep --lang scala --pattern $'def generateKafkaPartitionKey($_, $_) {
  $$$
}'

Length of output: 292


Script:

#!/bin/bash
# Description: Verify the existence and usage of generateKafkaPartitionKey method

# Test 1: Search for the definition of generateKafkaPartitionKey in the codebase
ast-grep --lang scala --pattern $'def generateKafkaPartitionKey($_, $_) {
  $$$
}'

# Test 2: Find all usages of fieldsForKafkaKeyGen in the codebase
rg --type-add 'scala:*.scala' --type scala 'fieldsForKafkaKeyGen'

Length of output: 292

Comment on lines +34 to +35
public final List<String> fieldsForKafkaKeyGen;
public final List<String> nameFieldsForNotificationDisplay;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving encapsulation for new fields.

The new fields fieldsForKafkaKeyGen and nameFieldsForNotificationDisplay are correctly declared as final, which is good for immutability. However, they are also declared as public, which might violate encapsulation principles.

Consider making these fields private and adding getter methods:

-   public final List<String> fieldsForKafkaKeyGen;
-   public final List<String> nameFieldsForNotificationDisplay;
+   private final List<String> fieldsForKafkaKeyGen;
+   private final List<String> nameFieldsForNotificationDisplay;

+   public List<String> getFieldsForKafkaKeyGen() {
+       return Collections.unmodifiableList(fieldsForKafkaKeyGen);
+   }

+   public List<String> getNameFieldsForNotificationDisplay() {
+       return Collections.unmodifiableList(nameFieldsForNotificationDisplay);
+   }

This change would improve encapsulation while still allowing read access to these fields.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public final List<String> fieldsForKafkaKeyGen;
public final List<String> nameFieldsForNotificationDisplay;
private final List<String> fieldsForKafkaKeyGen;
private final List<String> nameFieldsForNotificationDisplay;
public List<String> getFieldsForKafkaKeyGen() {
return Collections.unmodifiableList(fieldsForKafkaKeyGen);
}
public List<String> getNameFieldsForNotificationDisplay() {
return Collections.unmodifiableList(nameFieldsForNotificationDisplay);
}

Copy link
Collaborator

@sushantpatil1214 sushantpatil1214 left a comment

Choose a reason for hiding this comment

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

LGTM

@MatthewErispe MatthewErispe merged commit 77380ae into CU-86c083kqv_Create-Config-Flag-for-Kafka-Key Oct 15, 2024
1 check passed
@MatthewErispe MatthewErispe deleted the create-additional-config-for-notification-diplay-fields branch October 15, 2024 09:48
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.

3 participants