Features / Farmer profile

Add/Edit farmer (IE profile)

Creates or edits a farmer record ("IE", Individual Entrepreneur): identity, Aadhaar, mobile, family, education, designation and current member category. New farmers are saved locally first and synced to the server later.

FactsheetFarmer profile
Who uses it
Cadre user (can save)HAN user (Health & Nutrition, role.ap.gov.han: read-only)
How you get here
New: "+" button on the Farmer list. Edit: Farmer hub, Profile tile (only if the profile switch is on).
Tables
ie, ie_flat_entity, ierolemap
APIs
7 calls today, 7 App Service operations
Offline
Works offline. The record is saved to the local ie table, then copied to sync tables and pushed by the background sync queue; the photo is queued separately.

Screens

ScreenWhat it doesSource
Add / Edit FarmerForm for the farmer profile.app/src/main/java/org/platformcommons/urvi/view/ie/AddIeFragment.kt
Farmer view modelValidation helpers, duplicate checks and save.app/src/main/java/org/platformcommons/urvi/view/ie/IeViewModel.kt

What it captures

FieldTypeRequiredValidationOptions from
Farmer statusSwitch (Active / Inactive)NoEdit only. Switching to Inactive asks for confirmation. An inactive farmer has all other fields disabled.LIFE_STATUS codes
Select ReasonDropdownIf the status was changed in this sessionOnce a reason is saved and the status is unchanged, the reason, free text and switch are locked.Local reference files: Active reasons (Returned from seasonal migration, Wrongly marked inactive, Other) or Inactive reasons (Member died, Migrated to another village, Left/removed from SHG, Age limit exceeded for SHG, Other)
Write the reasonTextIf "Other" is pickedMaximum 100 characters. Stored instead of a reason code.User input
Village / VO / HabitationDropdowns (read-only)NoPre-filled from the work node chosen at setup.Work nodes in local database
PhotoImage pickerNoCompressed to JPEG quality 80, width 100 px, uploaded as the profile picture.Camera / gallery
NameText with autocompleteYesMaximum 100 characters; special characters are blocked (letters, digits and spaces only).Autocomplete from existing local names
Farmer Aadhaar NumberNumberYesExactly 12 digits (only check: fewer than 12 is an error). Masked when editing; focusing the field clears it for re-entry. If another local farmer has the same Aadhaar, a warning lets the user save anyway.User input
Mobile NumberNumberYesExactly 10 digits, first digit 6, 7, 8 or 9.User input
GenderDropdownYesChanging away from Female resets SHG to "Non-SHG".Reference data genderdata
Select SHGDropdownNoVisible only for Female. Assigning an SHG to a non-female farmer is blocked.Distinct SHGs of existing local farmers, "Non-SHG" first
AgeNumberYes18 to 110 inclusive; 0 is rejected; maximum 3 digits.User input
Highest qualificationDropdownIf ActiveCleared when the farmer is Inactive.Reference data educationalQualificationData
Social categoryDropdownIf ActiveCleared when the farmer is Inactive.Reference data socialCategoryData
DesignationCheckbox gridIf editing an active farmer (at least one)Cadre sub-roles are picked in the next field.ieRole list: Cadre, Member, Leader, Lead Farmer, EYP, VOA, VO-OB, MS Member, MS Office bearer, HSCM, Farmer
Cadre DesignationDropdownIf "Cadre" is tickedAppended to the designation list.FMT L1/L2/L3, FMT DMMT, FMT MT, Farmer Scientist, Trainee ICRP, H&N ICRP, CDF, CDI, L3(iCRP), L3, L1, L2, Mentor, Master Trainer, NFA, AMMT, Model Maker/DMMT
Current Member CategoryRadio (Farmer / C4 (Non-Agri) / C5 (POP))If ActiveC4 = non-agricultural member, C5 = POP member; both are blocked from most farm modules. Picking a value different from the saved one resets the category-set date (gapStartDate) to now. May be locked (see rules).Fixed list
Marital statusDropdownIf visibleVisible only for Female. "Married" shows the spouse block; anything else shows the father block.Reference data maritalstatus
Spouse name / Aadhaar / mobileText (100) / Number (12) / Number (10)If Married: name Yes, Aadhaar Yes, mobile NoAadhaar must be 12 digits. Mobile, if entered, must be 10 digits starting 6-9.User input
Father's name / Aadhaar / mobileText (100) / Number (12) / Number (10)If not Married: name Yes, Aadhaar No, mobile NoAadhaar, if entered, must be 12 digits. Mobile, if entered, must be 10 digits starting 6-9. Stored in the same columns as spouse details.User input

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
The user is a HAN userEvery field is disabled and Save does nothing.
The admin switch for adding/editing farmers is offThe screen shows "Farmer Add/Edit is not enabled by admin", disables the form and hides Save.
Adding a new farmer and the profile consent config is onA blocking consent dialog asks the farmer to agree to share Aadhaar, phone and profile data; Cancel leaves the screen.
A new farmer is savedDefaults are written: new local UUID, occupation "Farming", address "Not Available", pincode "000000", SHG "Non-SHG" if none, category date = now, category "N-A" if empty.
A new farmer has the same full name, mobile and gender as an existing local farmerSave is blocked: "We found another farmer with the same details".
The Aadhaar already exists on another local farmerA warning is shown, but the user can save anyway.
Editing, multiple category edits are disallowed by admin, a category is set, and the farmer is a Farmer whose land is not authenticatedThe category stays editable.
Editing, multiple category edits are disallowed, and the category is already frozenThe category radios are disabled.
The category-set date is later than the admin "last mandatory category update date", or the member is a Farmer with authenticated landThe category counts as frozen.
Editing a Farmer who has any active landThe category radios are disabled.
Multiple category edits are disallowedHelper text explains: category freezes only after land is authenticated; for C4/C5 once Submit is pressed.
Editing and nothing changedNothing is synced; only a new photo (if any) is saved.
Editing and something changedA PATCH is queued that reuses server ids for contacts, identifiers, family, education and address, removes deleted designations and adds new ones.
Marital status is Married at sync timeThe family person is sent as SPOUSE; otherwise as FATHER.

API contracts

Each call opens to its use case, headers, request and response bodies, and errors.

Today: callUseReplaced by
GET /ctld/api/ierolemap/v1?criteria=isActive=true AND iE.id in (...)Download farmer role maps for a chunk of farmers.
POST /ptld/api/customworknode/v1/worknodeietag/urviCreate the full server-side farmer (IE) from the flat record; also used as get-or-create when a farmer is opened.
POST /ptld/api/customworknode/v1/worknodeietag/urvi/ieCreate a new farmer.
PATCH /ptld/api/customworknode/v1/worknodeietag/urvi/ieUpdate a farmer profile or farming category / gap start date.
PUT /ctld/api/ie/v1/iconpicUpload a farmer profile photo.
POST /ctld/api/ierolemap/v1Assign a role to a farmer.
DELETE /ctld/api/ierolemap/v1?iERoleMapId=Remove a farmer role.
App Service v2: operationUse
GET /configTyped config bundle (ETag)
GET /farmers/snapshotCursor-paged hydrated farmer snapshot
GET /farmers/{farmerId}One hydrated farmer (get-or-create)
POST /sync/batchApply an ordered batch of offline mutations
POST /filesCreate a file upload (resumable or single-shot)
PATCH /files/{fileId}Append a chunk to a resumable upload
HEAD /files/{fileId}Current offset of a resumable upload

Behaviour notes

  • Village, VO, Habitation and SHG travel as URL parameters on the create call (WorkNodeId, WorkNodeAliasIdHabitation, voAlias, voName, shgAliasId, shgName); SHG is also sent inside addressLine2 JSON.
  • Aadhaar is sent Base64-encoded in the identifier list; category is sent as "<KAP 2021-22 category>/<current category>", for example "N-A/Farmer".
  • Privacy farmer, spouse and father Aadhaar are stored unencrypted in the local ie table; Base64 on the wire is not encryption.
  • Privacy a hard-coded static request header is sent on farmer create/patch; it looks like a leftover shared secret and should be reviewed (value intentionally not shown).
  • Possible bug · unverified father details are saved into the spouse columns; if marital status later changes, the meaning of the stored data silently flips.
  • Possible bug · unverified spouse Aadhaar is mandatory but father Aadhaar is optional, and family details are captured only for women.
  • Possible bug · unverified the category is stored as its display label (including Telugu text), so switching app language changes the stored value.
  • Possible bug · unverified the age field shows its error while still focused because of an operator-precedence mistake (final save check is correct).
  • Possible bug · unverified photo height uses integer division, giving 0 or 100 px, so photos come out tiny or distorted.
  • Possible bug · unverified the land check reads the saved category, not the value just picked on the radio, so fresh changes are not seen.
  • Possible bug · unverified the duplicate check runs on the main thread (risk of freezes on low-end phones).

Improve in the rewrite

  • Model the IE as a typed object: category as a code enum, separate spouse and father, and store codes not labels.
  • Encrypt Aadhaar at rest and remove the static header.
  • Capture family details for all genders with consistent Aadhaar rules.
  • Show inline field errors instead of one toast at a time, and a clear "Category locked because..." message.