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
| Screen | What it does | Source |
|---|---|---|
| Add / Edit Farmer | Form for the farmer profile. | app/src/main/java/org/platformcommons/urvi/view/ie/AddIeFragment.kt |
| Farmer view model | Validation helpers, duplicate checks and save. | app/src/main/java/org/platformcommons/urvi/view/ie/IeViewModel.kt |
What it captures
| Field | Type | Required | Validation | Options from |
|---|---|---|---|---|
| Farmer status | Switch (Active / Inactive) | No | Edit only. Switching to Inactive asks for confirmation. An inactive farmer has all other fields disabled. | LIFE_STATUS codes |
| Select Reason | Dropdown | If the status was changed in this session | Once 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 reason | Text | If "Other" is picked | Maximum 100 characters. Stored instead of a reason code. | User input |
| Village / VO / Habitation | Dropdowns (read-only) | No | Pre-filled from the work node chosen at setup. | Work nodes in local database |
| Photo | Image picker | No | Compressed to JPEG quality 80, width 100 px, uploaded as the profile picture. | Camera / gallery |
| Name | Text with autocomplete | Yes | Maximum 100 characters; special characters are blocked (letters, digits and spaces only). | Autocomplete from existing local names |
| Farmer Aadhaar Number | Number | Yes | Exactly 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 Number | Number | Yes | Exactly 10 digits, first digit 6, 7, 8 or 9. | User input |
| Gender | Dropdown | Yes | Changing away from Female resets SHG to "Non-SHG". | Reference data genderdata |
| Select SHG | Dropdown | No | Visible only for Female. Assigning an SHG to a non-female farmer is blocked. | Distinct SHGs of existing local farmers, "Non-SHG" first |
| Age | Number | Yes | 18 to 110 inclusive; 0 is rejected; maximum 3 digits. | User input |
| Highest qualification | Dropdown | If Active | Cleared when the farmer is Inactive. | Reference data educationalQualificationData |
| Social category | Dropdown | If Active | Cleared when the farmer is Inactive. | Reference data socialCategoryData |
| Designation | Checkbox grid | If 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 Designation | Dropdown | If "Cadre" is ticked | Appended 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 Category | Radio (Farmer / C4 (Non-Agri) / C5 (POP)) | If Active | C4 = 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 status | Dropdown | If visible | Visible only for Female. "Married" shows the spouse block; anything else shows the father block. | Reference data maritalstatus |
| Spouse name / Aadhaar / mobile | Text (100) / Number (12) / Number (10) | If Married: name Yes, Aadhaar Yes, mobile No | Aadhaar must be 12 digits. Mobile, if entered, must be 10 digits starting 6-9. | User input |
| Father's name / Aadhaar / mobile | Text (100) / Number (12) / Number (10) | If not Married: name Yes, Aadhaar No, mobile No | Aadhaar, 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.
| When | Then |
|---|---|
| The user is a HAN user | Every field is disabled and Save does nothing. |
| The admin switch for adding/editing farmers is off | The 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 on | A blocking consent dialog asks the farmer to agree to share Aadhaar, phone and profile data; Cancel leaves the screen. |
| A new farmer is saved | Defaults 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 farmer | Save is blocked: "We found another farmer with the same details". |
| The Aadhaar already exists on another local farmer | A 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 authenticated | The category stays editable. |
| Editing, multiple category edits are disallowed, and the category is already frozen | The 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 land | The category counts as frozen. |
| Editing a Farmer who has any active land | The category radios are disabled. |
| Multiple category edits are disallowed | Helper text explains: category freezes only after land is authenticated; for C4/C5 once Submit is pressed. |
| Editing and nothing changed | Nothing is synced; only a new photo (if any) is saved. |
| Editing and something changed | A 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 time | The 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: call | Use | Replaced 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/urvi | Create 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/ie | Create a new farmer. | |
PATCH /ptld/api/customworknode/v1/worknodeietag/urvi/ie | Update a farmer profile or farming category / gap start date. | |
PUT /ctld/api/ie/v1/iconpic | Upload a farmer profile photo. | |
POST /ctld/api/ierolemap/v1 | Assign a role to a farmer. | |
DELETE /ctld/api/ierolemap/v1?iERoleMapId= | Remove a farmer role. |
| App Service v2: operation | Use |
|---|---|
GET /config | Typed config bundle (ETag) |
GET /farmers/snapshot | Cursor-paged hydrated farmer snapshot |
GET /farmers/{farmerId} | One hydrated farmer (get-or-create) |
POST /sync/batch | Apply an ordered batch of offline mutations |
POST /files | Create 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.