Skip to content

#13717 - Added additional missing fields for person#13792

Merged
raulbob merged 3 commits intodevelopmentfrom
bugfix-13717-external_message_missing_person_fields
Jan 26, 2026
Merged

#13717 - Added additional missing fields for person#13792
raulbob merged 3 commits intodevelopmentfrom
bugfix-13717-external_message_missing_person_fields

Conversation

@raulbob
Copy link
Copy Markdown
Contributor

@raulbob raulbob commented Jan 20, 2026

Fixes #13717

  • Added additional handling for missing person fields

Summary by CodeRabbit

  • New Features

    • External messages now capture and store person occupation.
    • Doctor declaration flow enriched to populate guardian name, guardian contact details, and occupation during processing.
  • System Updates

    • Database schema extended with new entities, versioning, and occupation support for external messages.
    • Infrastructure facade access rights expanded to include an additional system-level right.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Adds personOccupation support across API DTO, backend entity, persistence schema, and message processing; augments doctor-declaration processing to populate guardian details, third‑party contact details, and occupation mapping; expands CountryFacadeEjb access rights.

Changes

Cohort / File(s) Summary
API DTO
sormas-api/.../externalmessage/ExternalMessageDto.java
Adds PERSON_OCCUPATION constant, personOccupation field with @Size, and getter/setter.
Backend Entity
sormas-backend/.../externalmessage/ExternalMessage.java
Adds PERSON_OCCUPATION constant, personOccupation field, getter annotated with @Column(length = CHARACTER_LIMIT_DEFAULT), and setter.
Facade / Processing
sormas-api/.../externalmessage/processing/ExternalMessageProcessingFacade.java, sormas-backend/.../ExternalMessageFacadeEjb.java
Adds getOccupationTypeOther() to fetch OCCUPATION_TYPE "OTHER"; maps personOccupation between DTO and entity both ways.
UI Processing Flow
sormas-ui/.../doctordeclaration/DoctorDeclarationMessageProcessingFlow.java
Adds post-update callback to set guardian full name, add guardian email/phone as third‑party contact details, and set occupation type/details (uses getOccupationTypeOther()); integrates with existing notifier flow.
Schema / Migrations
sormas-backend/.../sql/sormas_schema.sql
Schema updates include externalmessage.personoccupation columns (and history), extensive multi-entity schema changes and versioning triggers across many tables.
Access Control
sormas-backend/.../infrastructure/country/CountryFacadeEjb.java
Expands @RightsAllowed on CountryFacadeEjb to include UserRight._SYSTEM alongside _INFRASTRUCTURE_VIEW.

Sequence Diagram(s)

sequenceDiagram
    participant Sender
    participant UI as DoctorDeclarationFlow
    participant FACADE as ExternalMessageProcessingFacade
    participant ENUM as CustomizableEnumFacade
    participant PERSON as PersonService
    participant DB as Database

    Sender->>UI: Submit doctor declaration (occupation, guardian, contacts)
    UI->>FACADE: Process external message
    FACADE->>ENUM: lookup OCCUPATION_TYPE "OTHER" (getOccupationTypeOther)
    ENUM-->>FACADE: OccupationType("OTHER")
    FACADE->>PERSON: Create/Update Person (set occupation type/details, guardian name)
    PERSON->>DB: Persist person and contact details
    DB-->>PERSON: Persisted
    PERSON-->>FACADE: Person updated
    FACADE->>DB: Create/Update Case referencing updated person
    DB-->>FACADE: Case created/updated
    FACADE-->>UI: Processing complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

Poem

A rabbit hops through messages at night,
I stitch occupations and guardians up tight,
Contacts and names in tidy rows,
Hopping data where it needs to go,
Case and person snug—what a sight! 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #13717: personOccupation field is added, but critical missing fields like country/address, tutor, hospitalization dates, symptoms, and diagnosis date are not addressed. Address remaining missing fields from issue #13717: country/address, tutor, hospitalization dates, symptoms, and date of diagnosis in the mapping logic.
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive CountryFacadeEjb rights annotation change appears unrelated to the person fields issue; sormas_schema.sql changes are extensive and may include unrelated alterations. Clarify whether CountryFacadeEjb rights change and schema modifications are intentional or should be separated into distinct PRs.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main objective: adding missing person fields for external message processing.
Description check ✅ Passed The description is minimal but adequately references the issue and explains the core change regarding missing person fields handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Copy link
Copy Markdown

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

🤖 Fix all issues with AI agents
In
`@sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/ExternalMessageProcessingFacade.java`:
- Around line 245-247: Replace the non-throwing call in getOccupationTypeOther()
that uses
customizableEnumFacade.getEnumValue(CustomizableEnumType.OCCUPATION_TYPE, null,
"OTHER") with the throwing variant used elsewhere (see how getDiseaseVariant
calls the facade) so that a missing "OTHER" occupation constant triggers
CustomEnumNotFoundException instead of returning null; update
getOccupationTypeOther() to call the same throwing signature on
customizableEnumFacade for OCCUPATION_TYPE/"OTHER".

In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/doctordeclaration/DoctorDeclarationMessageProcessingFlow.java`:
- Around line 385-419: Replace the null-unsafe contains() checks in
DoctorDeclarationMessageProcessingFlow with exact, null-safe equality checks:
for the email block use
externalMessage.getPersonGuardianEmail().equals(pc.getContactInformation())
inside the stream noneMatch (since externalMessage.getPersonGuardianEmail() is
already checked non-null/non-blank), and do the same for the phone block using
externalMessage.getPersonGuardianPhone().equals(pc.getContactInformation());
this prevents partial matches and avoids NPE when
PersonContactDetailDto.getContactInformation() is null.
- Around line 366-368: The code fetches PersonDto casePerson via
getExternalMessageProcessingFacade().getPersonByContext(PersonContext.CASE,
result.getUuid()) but only checks for null later, which risks NPE because
casePerson is used between lines 369–426; immediately after calling
getPersonByContext move the null check for casePerson (and early-return or
handle accordingly) so no subsequent code that references casePerson runs when
it's null, and then remove the delayed null check further down; keep doUpdate
handling and any subsequent logic intact.
🧹 Nitpick comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/doctordeclaration/DoctorDeclarationMessageProcessingFlow.java (1)

385-419: Consider extracting contact detail creation into a helper method.

The logic for adding guardian email (lines 385-401) and phone (lines 403-419) contact details is nearly identical. Extracting this into a helper method would reduce duplication and improve maintainability.

♻️ Example helper method
private boolean addGuardianContactDetailIfAbsent(
    PersonDto casePerson,
    String contactInfo,
    PersonContactDetailType type,
    String guardianName,
    String guardianRelationship) {
    
    if (contactInfo == null || contactInfo.isBlank()) {
        return false;
    }
    
    List<PersonContactDetailDto> contactDetails = casePerson.getPersonContactDetails();
    if (contactDetails.stream().noneMatch(pc -> contactInfo.equals(pc.getContactInformation()))) {
        PersonContactDetailDto pcd = new PersonContactDetailDto();
        pcd.setPerson(casePerson.toReference());
        pcd.setPrimaryContact(false);
        pcd.setPersonContactDetailType(type);
        pcd.setContactInformation(contactInfo);
        pcd.setThirdParty(true);
        pcd.setThirdPartyRole(guardianRelationship);
        pcd.setThirdPartyName(guardianName);
        contactDetails.add(pcd);
        return true;
    }
    return false;
}

@sormas-vitagroup
Copy link
Copy Markdown
Contributor

@sormas-vitagroup
Copy link
Copy Markdown
Contributor

@sormas-vitagroup
Copy link
Copy Markdown
Contributor

@raulbob raulbob merged commit e992b39 into development Jan 26, 2026
8 of 14 checks passed
@raulbob raulbob deleted the bugfix-13717-external_message_missing_person_fields branch January 26, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants