Skip to content

Vb/counselling#264

Merged
vishwab1 merged 18 commits into
PSMRI:vb/counsellingfrom
sehjotsinghunthinkable:vb/counselling
Jul 3, 2026
Merged

Vb/counselling#264
vishwab1 merged 18 commits into
PSMRI:vb/counsellingfrom
sehjotsinghunthinkable:vb/counselling

Conversation

@sehjotsinghunthinkable

Copy link
Copy Markdown

📋 Description

JIRA ID: https://support.piramalfoundation.org/jira/browse/STOP-253?jql=project%20%3D%20%2212201%22

  • New feature (non-breaking change which adds functionality)

sehjotsinghunthinkable and others added 18 commits June 22, 2026 12:20
… a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.
* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.
…cessed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support
…iciaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.
…iciaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.
Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields
This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

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.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3189f5e-05bc-4c77-b144-ebfc13f9b390

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@vishwab1
vishwab1 merged commit 82286d2 into PSMRI:vb/counselling Jul 3, 2026
1 check passed
vishwab1 added a commit that referenced this pull request Jul 13, 2026
vishwab1 added a commit that referenced this pull request Jul 23, 2026
* feat(linting): commitlint ,Commitzen, Husky configuration

* feat: added new register api for stoptb

* feat: added new register api for stoptb

* feat: added new api for nurse

* fix: populate workingDistrictId from blockId in getUserDetail when district is null

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: align Stop TB APIs with BRD — village scoping + correct field names

- StopTBGeneralExamination: rewrite with BRD-correct fields (pallorId+pallor
  string pairs, pulseRate, randomBloodSugar, oedema, beneficiaryRegID,
  keyPopulationRiskFactorIds, hivStatusId — no more boolean clinical signs)
- StopTBRegistration: add villageId + villageName from i_bendemographics.districtBranchID
- StopTBRegistrationDto: add villageId + villageName for worklist requests
- StopTBRegistrationRepo: scope registrar worklist by psmId + villageId
- BenFlowStatusRepo: scope nurse worklist by psmId + villageId
- StopTBGeneralExaminationRepo: rename findByBeneficiaryRegID
- StopTBServiceImpl: extract village from demographics on registration,
  set on both tb_stoptb_registration and i_ben_flow_outreach flow record,
  fix all BRD field names throughout, add toJsonString for array fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: replace tb_stoptb_registration with BenFlowStatus for registrar worklist and add beneficiary details endpoint

- getRegistrarWorklist now queries i_ben_flow_outreach by villageID + visitCategory instead of tb_stoptb_registration
- add getRegistrarWorklist query to BenFlowStatusRepo
- add getBeneficiaryDetails endpoint that proxies TM-API quickSearchNew and merges otherFields into flat response object

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: worklist chnges

* fix: use JwtToken header for getBeneficiaryDetails TM-API call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use okhttp User-Agent pattern for TM-API call in getBeneficiaryDetails

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: look up 12-digit beneficiaryID from BenFlowStatus for TM-API quickSearchNew

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: redesign Stop TB worklist to return full beneficiary data in getBeneficiaryData style

- saveRegistration: forward full payload to TM-API without stripping Stop TB/anthropometry
  fields — they land in ExtraFields via checkExtraFields; enrich BenFlowStatus with benName,
  dob, gender, phone, district extracted from registration payload
- getRegistrarWorklist: returns getBeneficiaryData-style response — BenFlowStatus fields +
  db_identity detail (community, education, fatherName, motherName) + otherFields parsed for
  anthropometry and Stop TB details (personFrom, caseFindingType, tuId, weight, height, bmi, temp)
- getNurseWorklist: same rich response + generalExamination, tbScreening, generalOpd attached
  if already saved (null if not yet captured)
- Remove getRegistration and getBeneficiaryDetails endpoints — worklist covers both
- Add otherFields (ExtraFields column) mapping to RMNCHMBeneficiarydetail entity
- BenFlowStatusRepo worklist queries scoped to psmId + villageId only (visitCategory column
  not guaranteed to exist in i_ben_flow_outreach table)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use mapping table two-step lookup to fetch beneficiary details in Stop TB worklist

getDetailByBenRegID queries i_beneficiarydetails.beneficiaryRegID which is unpopulated;
correct path is i_beneficiarymapping → BenDetailsId → i_beneficiarydetails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: use OutputResponse for all StopTBController endpoints to match AMRIT standard format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add Stop TB worklist path and anthropometry to getBeneficiaryData

- Add providerServiceMapID to GetBenRequestHandler for Stop TB filtering
- Add getAddressesByBenRegIds repo query to fetch addresses by benRegId list
- Add Stop TB path in getBenData: filter by providerServiceMapID+villageID via BenFlowStatus
- Parse i_beneficiarydetails.ExtraFields to include anthropometry (weight/height/bmi/temperatureValue) in response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use JOIN query for getAddressesByBenRegIds and accept villageId alias

- Replace subquery with JOIN to fix Hibernate 6 multi-valued binding error
- Add setVillageId setter as alias for villageID in GetBenRequestHandler

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: switch getAddressesByBenRegIds to native SQL to avoid Hibernate 6 IN binding issue

JPQL IN with collection param throws multi-valued binding error in Hibernate 6 — native query bypasses this.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use per-row mapping lookup for Stop TB worklist to avoid Hibernate IN binding issue

Replace bulk native query with per-row findByBenRegIdFromMapping + getAddressById calls
— same pattern as existing FLW code, avoids Object[] mapping error from native SELECT *.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add stopTBDetails block (personFrom, caseFindingType, isMobileAvailable, tuId, tuName) to getBeneficiaryData response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add occupation, economicStatus, residentialArea to stopTBDetails in worklist response

- occupation read from i_beneficiarydetails (already stored by Identity-API)
- economicStatus and residentialArea promoted to top-level in registration payload so Identity-API saves them in ExtraFields; read back in worklist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add demographics block with address, occupation, economicStatus, residentialArea to worklist response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Revert "feat: add demographics block with address, occupation, economicStatus, residentialArea to worklist response"

This reverts commit 3695522d5139363e8eba335d6142cb5526af7ec0.

* feat: use tb-prefixed keys for economicStatus and residentialArea to ensure ExtraFields storage

Identity-API ignores unknown processing of economicStatus/residentialArea to DB columns silently;
using tbEconomicStatus/tbResidentialArea as keys ensures they land in ExtraFields and are returned in worklist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: move occupation, economicStatus, residentialArea into beneficiaryDetails object

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: read economicStatus and residentialArea directly from ExtraFields (not tb-prefixed keys)

Mobile sends these as top-level fields to TM-API; Identity-API saves them in ExtraFields as-is

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add Diagnostics module and Yes/No ID fields across Stop TB nurse flow

- Add StopTBDiagnostics entity, repo, service, and controller (save/get/getAll)
- Add village-scoped getAll (villageID optional) to GeneralExamination, TBScreening, GeneralOpd, Diagnostics via BenFlowStatus subquery
- Fix TBScreening visitDate to accept user-provided date; preserve on update (not editable once submitted)
- Fix referralToHWCNeeded to trust mobile-computed value instead of server recalculating
- Fix chiefComplaint to support multi-select (JSON array)
- Add Yes/No boolean ID counterpart fields to TBScreening (14 fields), GeneralExamination (referralToHWCNeededId), Registration (isMobileAvailableId), and Diagnostics (6 fields)
- Add getTimestamp helper to StopTBServiceImpl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: accept array of objects in all 4 Stop TB nurse save APIs

generalExamination, tbScreening, generalOpd, and diagnostics save
endpoints now take List<Map> instead of a single Map, allowing bulk
save in one request. Each item is processed within the same transaction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix supervisor name

* fix supervisor name

* fix supervisor name

* add update date on get ben api

* add update date on get ben api

* feat: return updateDate and updatedBy in all Stop TB getAll APIs

- Add lastModDate + modifiedBy fields to TBScreening, TBSuspected,
  TBConfirmedCase, MalariaFollowUp entities (columns already exist in DB)
- Set modifiedBy in all save methods across StopTB, TBSuspected,
  TBConfirmed, MalariaFollowUp services
- Return updateDate/updatedBy in all 8 getAll API responses so mobile
  app can detect and refresh stale local records
- Fix TBConfirmedCase save duplicate bug — now looks up existing record
  by benId before inserting new entity
- Add updateDate to getBeneficiaryData response from i_beneficiarydetails

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: resolve compile errors — move resultMap.put after initialization, add Map import

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add chest xray, sputum, NAAT reason fields to StopTB diagnostics

Added isReferredForDigitalChestXray, reasonForDenialChestXray,
reasonNotConductedChestXray, isReferredForSputumCollection,
reasonForDenialSputum, sputumSubmittedAt, reasonNotConductedNaat
and their *Other variants to domain, save, and get map.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(stoptb): add local-to-central sync fields for Stop TB mobile flow

- Add vanID, parkingPlaceID, visitCode, processed, vanSerialNo to all
  Stop TB entities (TBScreening, GeneralExamination, GeneralOpd,
  Diagnostics, TBSuspected, TBConfirmedCase)
- Add updateVanSerialNo() to all 6 repos for MMU DataSync pattern
- Add CampConfigService to read camp:vanID from Redis (set by MMU login)
- Stamp vanID + processed='N' on every save in StopTBServiceImpl,
  TBSuspectedServiceImpl, TBConfirmedCaseServiceImpl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: make vanID stamping conditional — skip gracefully when camp not configured

When FLW-API is used without a Stop TB camp setup (no MMU login, no
camp:vanID in Redis), getVanID() now returns null instead of throwing.
All save methods guard with vanID != null before stamping, so regular
FLW/ASHA usage is completely unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(stoptb): add stoptb.enforce.vanid flag to fail loudly when camp not configured

CampConfigService.getVanID() previously returned null silently whenever
camp:vanID was missing from Redis, letting Stop TB records save with
vanID=NULL — these then never sync to central since the fetch query
filters on vanID IS NOT NULL. When stoptb.enforce.vanid=true, the save
now throws immediately so the error surfaces to the user instead of
being discovered later as an un-synced record.

* fix(stoptb): correct symptomatic/asymptomatic save and retrieve mapping

Frontend sends a single "symptomatic" Yes/No value, but the DB has two
separate columns (symptomatic, asymptomatic) with swapped semantics.
Yes now stores asymptomatic=Yes (symptomatic=null), No stores
symptomatic=Yes (asymptomatic=null). Retrieval derives the response
"symptomatic" value back from whichever column is Yes, so it always
echoes the original input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix sync issue

* feat(counselling): implement dynamic form management for TB counselling

Introduces dynamic form definition management with versioning and
response lifecycle support (draft, submit, complete, and bulk sync)
for the TB counselling module.

Includes:
- Dynamic form and response APIs
- QuestionType and ValidationType enums
- TbCounsellingFormSeeder for initial form setup
- JWT-based audit stamping (createdBy/updatedBy)
- SecurityWhitelistConfig for endpoint-level authentication control

* feat(stoptb): add per-visit history to General Examination, TB Screening, OPD, Suspected, Confirmed

Every Stop TB clinical save previously upserted by beneficiaryRegID/benId
alone, so a beneficiary's second camp visit silently overwrote their first
- no history was ever kept. Adds a new tb_stoptb_visit table (mirrors MMU's
t_benvisitdetail visitNo pattern, scoped entirely to Stop TB's own schema)
and a getOrCreateVisitForToday() helper that infers "new visit" purely from
the save date, with no mobile change required.

- New TBStopVisit entity/repo/service: visitNo counting, role-handoff flags
  reserved for future Doctor/Counsellor screens, full sync field set
  (processed/vanSerialNo/SyncedDate/Syncedby/SyncFailureReason) matching the
  existing AMRIT-wide DataSyncRepository convention.
- StopTBGeneralExamination/TBScreening/StopTBGeneralOpd/TBSuspected/
  TBConfirmedCase now upsert keyed by (beneficiaryRegID, visitCode) instead
  of beneficiaryRegID alone. Reused the existing dormant visitCode column on
  4 of 6 tables rather than adding a new one.
- Fixed 4 read methods (getNurseWorklist, getGeneralExamination,
  getNurseTBScreening, getGeneralOpd) that would have thrown
  NonUniqueResultException once a beneficiary had more than one visit row -
  switched to findLatestBy... + PageRequest.of(0,1).
- StopTBDiagnostics deliberately excluded: liquid culture results arrive
  40-45 days after the original encounter and must update the same row,
  which visit-keying would have broken.

Requires DB migration (not included): CREATE TABLE tb_stoptb_visit, plus
ALTER TABLE tb_suspected/tb_confirmed_cases ADD COLUMN visitCode BIGINT.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Merge remote-tracking branch 'origin/vb/stoptb' into vb/stoptb

* chore(local-env): update local datasource/redis/jwt config and add dynamic form schema SQL

Adds manual DDL/seed script for the dynamic form tables since ddl-auto
wasn't creating them in local runs, and syncs local properties with
the values needed to run submitBulk locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(local-env): keep backup copy of common_local.properties

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* token chnges

* Vb/counselling (#254)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

---------

Co-authored-by: Sehjot Singh Pannu <sehjot.singh@unthinkable.co>

* Vb/counselling (#255)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Vb/counselling (#256)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

---------

Co-authored-by: Sehjot Singh Pannu <sehjot.singh@unthinkable.co>

* fix(user-service): handle empty result from getDistrictByBlockId fallback

Native query result must be mapped to List<Object[]>, not a bare Object[];
the previous signature caused getUserDetail() to silently skip the
workingDistrictId fallback for block-only users.

* Vb/counselling (#257)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>

* fix(dynamic-form): default processed to N via @Builder.Default

Lombok @Builder ignores field initializers, so FormResponse,
QuestionResponse, and SectionResponse were inserting NULL into the
processed column instead of the intended "N" default, causing
"Column 'processed' cannot be null" on submitBulk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#258)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#259)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#261)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(stoptb): dual-write clinical data to AMRIT standard tables via t_benvisitdetail

- Replace tb_stoptb_visit with t_benvisitdetail (MMU-compatible visitCode formula)
- Dual-write exam data to t_phy_anthropometry, t_phy_vitals, t_Phy_GeneralExam, t_benreferdetails
- Dual-write OPD data to t_benchiefcomplaint, t_prescription, t_prescribeddrug
- Add 6 new JPA entities and repos for standard tables (db_iemr schema)
- Update TBSuspectedServiceImpl and TBConfirmedCaseServiceImpl to use BenVisitDetail
- Fix vanID/parkingPlaceID not being stored in t_form_response, t_section_response, t_question_response
- Delete orphaned TBStopVisit entity and TBStopVisitRepo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): getBeneficiaryData reads anthropometry/vitals from standard tables

- getBeneficiaryData now reads height/weight/bmi from t_phy_anthropometry
  and temperature/pulse/BP/RBS from t_phy_vitals (latest row per beneficiary)
- Fallback to otherFields if exam not yet saved for the beneficiary
- Stop TB specific fields (personFrom, caseFindingType etc.) still from otherFields
- Add findByBeneficiaryRegIDOrderByCreatedDateDesc and findByBenVisitID
  to BenAnthropometryRepo and BenPhysicalVitalRepo
- Add StopTB_Future_Roadmap.md for future HWC integration and edit support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(compile): rename variable 'a' to 'anthro' to avoid conflict with outer loop variable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): set CreatedDate on t_benvisitdetail insert to prevent NOT NULL constraint violation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(anc-pnc): guard CreatedDate on BenVisitDetail insert for ANC and PNC flows

If mobile does not send createdDate, ModelMapper leaves it null and MySQL
rejects the insert with NOT NULL constraint. Set server timestamp as fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docker): set TZ=Asia/Kolkata to prevent UTC/IST date mismatch

Without explicit timezone, Docker defaults to UTC. This causes LocalDate.now()
in getOrCreateVisitForToday() to use UTC date, so evening IST registrations
appear as next-day July 1 in DB and visit lookups fail after UTC midnight.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): handle ISO 8601 Z suffix in parseDob to fix beneficiary age display

Timestamp.valueOf() throws on "yyyy-MM-dd HH:mm:ss.SSSZ" format because the
trailing Z is not a valid nanosecond value. Strip Z before parsing so mobile
DOB like "1987-07-01T00:00:00.000Z" is correctly stored in i_ben_flow_outreach.ben_dob.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): fallback to i_ben_flow_outreach.ben_dob when i_beneficiarydetails.dob is null

Identity-API mapper (@Mapping source=dto.dob) is commented out, causing dob to be
null for all mobile registrations. Fall back to ben_dob from i_ben_flow_outreach
so getBeneficiaryData returns correct DOB and mobile shows correct age.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use saveAndFlush to prevent FK violation in t_benchiefcomplaint

save() leaves VisitCode UPDATE pending in JPA session — t_benchiefcomplaint
INSERT runs before the UPDATE reaches DB, causing FK constraint failure and
full transaction rollback. saveAndFlush forces the UPDATE to DB immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#262)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

* Add optional villageId and providerServiceMapId filters to getCompletedBeneficiaries

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#263)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

* Add optional villageId and providerServiceMapId filters to getCompletedBeneficiaries

* Removing section f from seeder

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Vb/counselling (#264)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

* Add optional villageId and providerServiceMapId filters to getCompletedBeneficiaries

* Removing section f from seeder

* Removing already existing check in /complete api

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): compute age from benDetailsRMNCH_OBJ.dob instead of benDetailsOBJ.dob

benDetailsOBJ.dob (i_beneficiarydetails) is null for Stop TB mobile
registrations, which is why c22b3fd2 added a fallback that fills
benDetailsRMNCH_OBJ.dob from i_ben_flow_outreach. The age calculation
block still read the original, still-null benDetailsOBJ.dob, so dob
came back correct but age/ageFull stayed 0/"". Point it at the
already-corrected benDetailsRMNCH_OBJ.dob instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* field missing

* fix(stoptb): scope Suspected/Confirmed getAll by facility+village instead of userId

Nurse and Counsellor are different logins hitting the same
/tb/suspected/getAll and /tb/confirmed/getAll endpoints, but both queries
filtered by the calling user's own userId. So a Counsellor pulling data
after a Nurse creates a Suspected/Confirmed record saw none of it - only
rows tied to their own login.

Adds an optional providerServiceMapID(+villageID)-scoped query path on
both endpoints, joined through the already-populated BenFlowStatus table
(same pattern as StopTBDiagnosticsRepo), so any role at the same
facility/village sees the same worklist. The old userId-based path is
kept as the fallback when the new fields aren't sent, so already-deployed
app builds are unaffected.

* fix(stoptb): drop date filter from facility-scoped Suspected query

visitDate isn't the right dimension for a facility worklist - an
unresolved Suspected case from months ago is still actionable, and
filtering it out by date would hide it from the Counsellor, working
against the visibility fix in the previous commit. Also matches
StopTBDiagnosticsRepo's facility-scoped query, which never date-filters.
Old ashaId-based fallback path is untouched and still date-filters as
before.

* fix(stoptb): join facility-scoped query on beneficiaryID, not beneficiaryRegID

TBSuspected.benId / TBConfirmedCase.benId store the person-level
beneficiary_id (e.g. 907797933607), not beneficiaryRegID (e.g. 35137) -
confirmed by querying i_ben_flow_outreach directly. The facility-scoped
query added in the previous two commits joined against
BenFlowStatus.beneficiaryRegID, so it never matched anything and always
returned empty. Switched the join to BenFlowStatus.beneficiaryID, which
is the correct corresponding column.

* Add debug logging, RMNCH pinCode field, and GPS fallback pinCode mapping

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Vb/counselling (#269)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

* Add optional villageId and providerServiceMapId filters to getCompletedBeneficiaries

* Removing section f from seeder

* Removing already existing check in /complete api

* Add a CHECKBOX question type and a TB_COUNSELLING_V2 seeder with a GENERAL_INFO consent gate ahead of the counselling sections.

* Seed single-checkbox questions for Sections A-D and point the Counselled lookup at TB_COUNSELLING_V2 instead of the retired V1 form

* Mark form/section status REFUSED when TB2_GI_Q1=NO on /complete, split getCompletedBeneficiaries into completed/refused lists, and extract FormResponseStatus enum

* Resolved conflicts

* fix(stoptb): getBeneficiaryData reads anthropometry/vitals from standard tables

- getBeneficiaryData now reads height/weight/bmi from t_phy_anthropometry
  and temperature/pulse/BP/RBS from t_phy_vitals (latest row per beneficiary)
- Fallback to otherFields if exam not yet saved for the beneficiary
- Stop TB specific fields (personFrom, caseFindingType etc.) still from otherFields
- Add findByBeneficiaryRegIDOrderByCreatedDateDesc and findByBenVisitID
  to BenAnthropometryRepo and BenPhysicalVitalRepo
- Add StopTB_Future_Roadmap.md for future HWC integration and edit support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(compile): rename variable 'a' to 'anthro' to avoid conflict with outer loop variable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): set CreatedDate on t_benvisitdetail insert to prevent NOT NULL constraint violation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(anc-pnc): guard CreatedDate on BenVisitDetail insert for ANC and PNC flows

If mobile does not send createdDate, ModelMapper leaves it null and MySQL
rejects the insert with NOT NULL constraint. Set server timestamp as fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docker): set TZ=Asia/Kolkata to prevent UTC/IST date mismatch

Without explicit timezone, Docker defaults to UTC. This causes LocalDate.now()
in getOrCreateVisitForToday() to use UTC date, so evening IST registrations
appear as next-day July 1 in DB and visit lookups fail after UTC midnight.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): handle ISO 8601 Z suffix in parseDob to fix beneficiary age display

Timestamp.valueOf() throws on "yyyy-MM-dd HH:mm:ss.SSSZ" format because the
trailing Z is not a valid nanosecond value. Strip Z before parsing so mobile
DOB like "1987-07-01T00:00:00.000Z" is correctly stored in i_ben_flow_outreach.ben_dob.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): fallback to i_ben_flow_outreach.ben_dob when i_beneficiarydetails.dob is null

Identity-API mapper (@Mapping source=dto.dob) is commented out, causing dob to be
null for all mobile registrations. Fall back to ben_dob from i_ben_flow_outreach
so getBeneficiaryData returns correct DOB and mobile shows correct age.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use saveAndFlush to prevent FK violation in t_benchiefcomplaint

save() leaves VisitCode UPDATE pending in JPA session — t_benchiefcomplaint
INSERT runs before the UPDATE reaches DB, causing FK constraint failure and
full transaction rollback. saveAndFlush forces the UPDATE to DB immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): compute age from benDetailsRMNCH_OBJ.dob instead of benDetailsOBJ.dob

benDetailsOBJ.dob (i_beneficiarydetails) is null for Stop TB mobile
registrations, which is why c22b3fd2 added a fallback that fills
benDetailsRMNCH_OBJ.dob from i_ben_flow_outreach. The age calculation
block still read the original, still-null benDetailsOBJ.dob, so dob
came back correct but age/ageFull stayed 0/"". Point it at the
already-corrected benDetailsRMNCH_OBJ.dob instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(stoptb): scope Suspected/Confirmed getAll by facility+village instead of userId

Nurse and Counsellor are different logins hitting the same
/tb/suspected/getAll and /tb/confirmed/getAll endpoints, but both queries
filtered by the calling user's own userId. So a Counsellor pulling data
after a Nurse creates a Suspected/Confirmed record saw none of it - only
rows tied to their own login.

Adds an optional providerServiceMapID(+villageID)-scoped query path on
both endpoints, joined through the already-populated BenFlowStatus table
(same pattern as StopTBDiagnosticsRepo), so any role at the same
facility/village sees the same worklist. The old userId-based path is
kept as the fallback when the new fields aren't sent, so already-deployed
app builds are unaffected.

* fix(stoptb): drop date filter from facility-scoped Suspected query

visitDate isn't the right dimension for a facility worklist - an
unresolved Suspected case from months ago is still actionable, and
filtering it out by date would hide it from the Counsellor, working
against the visibility fix in the previous commit. Also matches
StopTBDiagnosticsRepo's facility-scoped query, which never date-filters.
Old ashaId-based fallback path is untouched and still date-filters as
before.

* fix(stoptb): join facility-scoped query on beneficiaryID, not beneficiaryRegID

TBSuspected.benId / TBConfirmedCase.benId store the person-level
beneficiary_id (e.g. 907797933607), not beneficiaryRegID (e.g. 35137) -
confirmed by querying i_ben_flow_outreach directly. The facility-scoped
query added in the previous two commits joined against
BenFlowStatus.beneficiaryRegID, so it never matched anything and always
returned empty. Switched the join to BenFlowStatus.beneficiaryID, which
is the correct corresponding column.

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: vishwab1 <vishwanath@navadhiti.com>

* fix(counselling): remove duplicate findCounselledBenIds method and import left over from PR #269 merge

The duplicate interface method was a compile error that cascaded into
hundreds of unrelated Lombok symbol errors across the module.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Vb/counselling (#270)

* Enforced mandatory validation for "Reason for Refusal in section e in file TbCounsellingFormSeeder

* Added counselled flag to confirmed cases response, indicating whether a beneficiary has completed the TB Counselling form. Implemented using a single bulk query to avoid N+1 lookups against FormResponse.

* Align `/complete` and `/submitBulk` form response editing behavior

* Updated `/complete` to resolve `FormResponse` using `beneficiaryId` and `formUuid` from the request body, removing the dependency on `responseId` as a query parameter.
* Updated `/submitBulk` section editing to match `/complete` behavior by performing in-place `SectionResponse` upserts and per-question delete-and-reinsert operations, instead of deleting and recreating the entire section.

* Add van/sync tracking fields (vanID, parkingPlaceID, vanSerialNo, processed, syncedDate, syncedBy, syncFailureReason) to domain entities for offline mobile data collection support

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(dynamic-form): add Hindi localization fields and completed beneficiaries endpoint

- Added `sectionName_hindi`, `questionText_hindi`, and `optionValue_hindi` fields to the FormSection, SectionQuestion, and QuestionOption entities to support Hindi localization.
- Added `GET /dynamicForm/response/getCompletedBeneficiaries?formType=` endpoint to return beneficiary IDs with `COMPLETE` status for the specified form type.

* feat(beneficiary): expose GPS coordinates in getBeneficiaryData response

Add gpsLatitude, gpsLongitude, digipin, gpsTimestamp, and isGpsUnavailable
fields to RMNCHBeneficiaryDetailsRmnch and RMNCHHouseHoldDetails entities,
mapping to the columns written by Identity-API's /syncDataToAmrit endpoint.

Enable serializeNulls on the Gson builder in BeneficiaryServiceImpl so GPS
keys are always present in householdDetails and beneficiaryDetails — null
for web-registered records, real values for mobile-registered ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Revert "Committed 82b00ccf with only the three files:"

This reverts commit 3040a08077d82d27dfd86f29f0fbdd4dc094ec56.

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

* Committed 82b00ccf with only the three files:
  - BeneficiaryServiceImpl.java — serializeNulls() + GPS fallback from address
  - RMNCHBeneficiaryDetailsRmnch.java — gpsLatitude, gpsLongitude, digipin, gpsTimestamp, isGpsUnavailable fields
  - RMNCHHouseHoldDetails.java — gpsLatitude, gpsLongitude fields

# Conflicts:
#	src/main/java/com/iemr/flw/domain/identity/RMNCHMBeneficiaryaddress.java

* Updated isMandatory field in Section C, so changed in TbCounsellingFormSeeder

* Add optional villageId and providerServiceMapId filters to getCompletedBeneficiaries

* Removing section f from seeder

* Removing already existing check in /complete api

* Add a CHECKBOX question type and a TB_COUNSELLING_V2 seeder with a GENERAL_INFO consent gate ahead of the counselling sections.

* Seed single-checkbox questions for Sections A-D and point the Counselled lookup at TB_COUNSELLING_V2 instead of the retired V1 form

* Mark form/section status REFUSED when TB2_GI_Q1=NO on /complete, split getCompletedBeneficiaries into completed/refused lists, and extract FormResponseStatus enum

* Resolved conflicts

* fix(stoptb): getBeneficiaryData reads anthropometry/vitals from standard tables

- getBeneficiaryData now reads height/weight/bmi from t_phy_anthropometry
  and temperature/pulse/BP/RBS from t_phy_vitals (latest row per beneficiary)
- Fallback to otherFields if exam not yet saved for the beneficiary
- Stop TB specific fields (personFrom, caseFindingType etc.) still from otherFields
- Add findByBeneficiaryRegIDOrderByCreatedDateDesc and findByBenVisitID
  to BenAnthropometryRepo and BenPhysicalVitalRepo
- Add StopTB_Future_Roadmap.md for future HWC integration and edit support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(compile): rename variable 'a' to 'anthro' to avoid conflict with outer loop variable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): set CreatedDate on t_benvisitdetail insert to prevent NOT NULL constraint violation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(anc-pnc): guard CreatedDate on BenVisitDetail insert for ANC and PNC flows

If mobile does not send createdDate, ModelMapper leaves it null and MySQL
rejects the insert with NOT NULL constraint. Set server timestamp as fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(docker): set TZ=Asia/Kolkata to prevent UTC/IST date mismatch

Without explicit timezone, Docker defaults to UTC. This causes LocalDate.now()
in getOrCreateVisitForToday() to use UTC date, so evening IST registrations
appear as next-day July 1 in DB and visit lookups fail after UTC midnight.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): handle ISO 8601 Z suffix in parseDob to fix beneficiary age display

Timestamp.valueOf() throws on "yyyy-MM-dd HH:mm:ss.SSSZ" format because the
trailing Z is not a valid nanosecond value. Strip Z before parsing so mobile
DOB like "1987-07-01T00:00:00.000Z" is correctly stored in i_ben_flow_outreach.ben_dob.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): fallback to i_ben_flow_outreach.ben_dob when i_beneficiarydetails.dob is null

Identity-API mapper (@Mapping source=dto.dob) is commented out, causing dob to be
null for all mobile registrations. Fall back to ben_dob from i_ben_flow_outreach
so getBeneficiaryData returns correct DOB and mobile shows correct age.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use saveAndFlush to prevent FK violation in t_benchiefcomplaint

save() leaves VisitCode UPDATE pending in JPA session — t_benchiefcomplaint
INSERT runs before the UPDATE reaches DB, causing FK constraint failure and
full transaction rollback. saveAndFlush forces the UPDATE to DB immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(stoptb): compute age from benDetailsRMNCH_OBJ.dob instead of benDetailsOBJ.dob

benDetailsOBJ.dob (i_beneficiarydetails) is null for Stop TB mobile
registrations, which is why c22b3fd2 added a fallback that fills
benDetailsRMNCH_OBJ.dob from i_ben_flow_outreach. The age calculation
block still read the original, still-null benDetailsOBJ.dob, so dob
came back correct but age/ageFull stayed 0/"". Point it at the
already-corrected benDetailsRMNCH_OBJ.dob instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(stoptb): scope Suspected/Confirmed getAll by …
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