{"v":[{"id":3149,"html_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236#issuecomment-3149","pull_request_url":"","issue_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236","user":{"id":3,"login":"connect-bot","login_name":"","source_id":0,"full_name":"","email":"connect-bot@noreply.www-s01.apinet.com","avatar_url":"https:\/\/www-s01.apinet.com\/codeforge\/avatars\/68a2723f7ad70dee2e1415be7488d84b","html_url":"https:\/\/www-s01.apinet.com\/codeforge\/connect-bot","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2026-10-01T08:49:35-05:00","restricted":false,"active":false,"prohibit_login":false,"location":"","pronouns":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"connect-bot"},"original_author":"","original_author_id":0,"body":"**Charles W.** _(via Connect)_\n<!-- connect:user=1 -->\n\nMessage from Cassandra: \r\n\"A start of care without a AO would only include the following: \r\n\r\n Other combinations could be: \r\nAO\/PHV\r\nAO\/PHV\/Change of Address\r\nAO\/PHV\r\nAO\/PHV\/Service Plan for Increase or Decrease\r\nAO\/PHV\/AR\r\nAO\/ Change of Address\r\n\r\n\r\nChange in tasks\/PHV\r\nChange in tasks\/AR\/PHV\r\n\r\nChange of Address\/AO\r\nChange of Address\/PHV\r\nChange of Address\/AR\r\nChange of Address\/AO\/PHV\r\nChange of Address\/AR\/AO\r\n\r\nPHV\/AR\r\n\r\nAR\/AO\r\n\r\nI believe I got them all, maybe some I include that they obviously overlap....Let me know if I am not clear.\"","assets":[{"id":10,"name":"photo-20261119-083815-1.png","size":53444,"download_count":4,"created_at":"2026-11-19T08:38:16-06:00","uuid":"8c13e2c3-a859-4c3a-a52e-e2e3316609fb","browser_download_url":"https:\/\/www-s01.apinet.com\/codeforge\/attachments\/8c13e2c3-a859-4c3a-a52e-e2e3316609fb","type":"attachment"}],"created_at":"2026-11-19T08:38:15-06:00","updated_at":"2026-11-19T08:38:16-06:00"},{"id":3150,"html_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236#issuecomment-3150","pull_request_url":"","issue_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236","user":{"id":1,"login":"charles","login_name":"","source_id":0,"full_name":"Charles Willgren","email":"charles@noreply.www-s01.apinet.com","avatar_url":"https:\/\/www-s01.apinet.com\/codeforge\/avatars\/d3c894f7297c5a18eb3f6ac837c335b11a00aa9cc0961323771632b1e2d61bb2","html_url":"https:\/\/www-s01.apinet.com\/codeforge\/charles","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2025-12-08T10:03:41-06:00","restricted":false,"active":false,"prohibit_login":false,"location":"","pronouns":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"charles"},"original_author":"","original_author_id":0,"body":"## Implementation plan\n\nThis plan tells how we will do this Action Item. It has seven phases. Each phase is one commit or a small set of commits, with its tests. No phase stops a visit that is in progress.\n\n### The main decision: one release for the visit types that combine\n\nToday, each visit type has its own release. A release pins one visit type, one interview and one version of each form. A visit pins one release.\n\nWe will make **one release for all the visit types that can combine**. We call these visit types the **family**. The family code is `CLIENT_VISIT` (D3). The family release pins:\n\n- the packet of each visit type in the family,\n- one interview for the family,\n- one version of each form that the family uses.\n\nWe use this design for three reasons:\n\n1. A visit pins one release, as it does today. When the supervisor adds a visit type, the visit uses the release that it already has. The visit does not read the active release again.\n2. Each form has one version in the release. Two visit types cannot pin two different versions of one form.\n3. Each question occurs one time in the family interview. Thus the system does not merge interviews during a visit. We merge them one time, when we write the family interview.\n\nWe compared the five interview files (`SOC_AO`, `AO`, `AR`, `ISP_COA`, `SV`):\n\n- They ask 313 different questions. 283 of these questions occur in two or more files.\n- 269 of the 283 questions are the same in each file. All 283 questions are in the same step in each file.\n- 14 questions are different. 7 of them get a different start value from the visit type. 6 have only a different help text. 1 has a different lookup.\n\nThus one interview for the family is possible.\n\n**The family:** SOC (new), AO, AR, PHV, ISP_COA, SPC_CHANGE, SPC_ADDED_TASKS.\n\nPHV, SPC_CHANGE and SPC_ADDED_TASKS do not need their own interview. All their forms are in the AR or AO interview. When these visit types join the family, the family interview asks their questions.\n\n**Not in the family:** SV, AE, PHONE_AO, PRE_INITIAL, INIT_TRANSFER, CHANGE_PROGRAM, PAY_RATE_INCREASE and TOKEN_INSTALL. Each of these keeps its own release, as today. Their visits have a list with one visit type.\n\n**The alternative that we do not use:** a release for each visit type, merged when the visit starts. Two releases can pin different versions of one form. Two interviews can word one question differently. Then a question can change on the screen when the supervisor adds a visit type.\n\n---\n\n### Phase 1 \u2014 The rules and the files (no database)\n\n1. Make `docs\/form-packets\/soc.json` from `soc-ao.json`. Remove `task_guide`, `things_may_not_do`, `employee_visit_plan` and `payroll_action`. Set Form 3040 to `require: {\"pages\":[1]}`.\n2. The family interview file (Phase 2) lists the visit types of the family. This list is the setting that we control. There is no screen for it.\n3. Write the pure file `code\/form_v2_combine_rules.inc.php`:\n   - `form_v2_combine_error($family, $types)` refuses an empty list, a visit type that is not in the family, and a visit type that occurs two times. It refuses SOC with a visit type other than AO.\n   - `form_v2_combine_change($types, $op, $type)` gives the new list for `add`, `remove` or `cancel`. It refuses to remove the last visit type. Only AO can be cancelled. When AO is the only visit type, a cancel gives \"abandon the visit\" (D1), not an empty list.\n   - `form_v2_combine_diff($before, $after)` gives the forms and pages that a change adds or removes. The screen shows this before the supervisor confirms.\n   - `form_v2_combine_title($types)` gives the name of the visit, for example \"Annual Reassessment + Attendant Orientation\".\n   - `form_v2_combine_visit_kind($types)` gives the one visit type that the paper shows (D2): SOC if the list has SOC, then AR, then AO.\n4. Write `scripts\/test-form-v2-combine-rules.php`. It must show that:\n   - SOC + AO merges to the same outputs as SOC_AO.\n   - Each of Cassandra's 12 combinations gives the forms and pages in the issue.\n   - When AO is cancelled from SPC_ADDED_TASKS + AO, only the Payroll Action Form goes.\n   - A cancel of AO when AO is the only visit type gives \"abandon the visit\".\n   - The rules refuse each incorrect list in step 3.\n\n### Phase 2 \u2014 One interview for the family\n\n1. Make `docs\/form-v2-interviews\/CLIENT_VISIT.json`. Start from `SOC_AO.json`: it has all the steps of `AO`, `AR` and `ISP_COA`. Add the questions that only the other files have.\n2. Add the fact `visit.types`: the list of visit types that are active in the visit. Conditions can read it. Add a start value that has a condition, if the interview format does not have one.\n3. Change the 7 questions that get their start value from the visit type:\n\n| Question | Today | In the family interview |\n|---|---|---|\n| Client Information Sheet, visit type | SOC: `soc`. AR: `ar`. | `soc` if the list has SOC, else `ar`. |\n| `visit.visit_kind` (used in the ISP limitations sentence) | One value for each file | `form_v2_combine_visit_kind()`: SOC, then AR, then AO (D2). |\n| ISP, new or ongoing schedule | SOC: `new`. AR: `ongoing`. | `new` if the list has SOC, else `ongoing`. |\n| Service start date | SOC and AO: always shown. AR and ISP_COA: shown only for a new schedule. | Always shown if the list has SOC. Else shown only for a new schedule. |\n| Form 3040, visit type for attendants A, B and C (3 questions) | AO or SV, from the file | AO if the list has AO, else SV. |\n\n4. Compare each form's \"visit type\" box with the paper. Do this before Phase 2 is complete (D2).\n5. For the 6 questions with a different help text, select one help text. For `shared.other_services.dahs_name`, select one lookup.\n6. Change the publish check (`form_v2_publish_check()`). It must validate the interview against each permitted combination of visit types, not against one set of forms. If one combination fails, the check stops the publish and names the combination.\n7. Do not delete the old interview files yet. Phase 7 retires them.\n\n### Phase 3 \u2014 The family release\n\n1. The release manifest gets `packets` (a list) in place of `packet`. A release with one visit type has a list with one item. Read the old `packet` key as a list with one item, so that old releases continue to operate.\n2. `form_v2_pipeline_run()` publishes the family interview, the packet of each visit type in the family, and all their forms in one release.\n3. Activation stays per agency. When the family release is active, the start screen offers its visit types in place of the old releases for SOC_AO, AO, AR and ISP_COA.\n4. **Pages come from the visit, not from the release.** Today `form_v2_release_pages()` reads the pages from the one packet in the manifest. After this phase, the pages come from the merged outputs of the visit's list. Change each place that narrows the pages: `form_v2_workflow_validation_ctx()`, `form_v2_release_runtime()` (through `form_v2_visit_runtime()`), `form_v2_signing_maps()` and `form_v2_release_pdf()`. Update `scripts\/test-form-v2-pages.php`.\n\n### Phase 4 \u2014 A visit with a list of visit types\n\n1. Add a migration for the table `form_v2_visit_type`: the visit, the agency, the visit type, the packet version, the status (`active`, `removed` or `cancelled`), the order, who added it and when, and who ended it and when.\n2. In the same migration, add one row for each visit that exists. Then all the code reads the list, and no code reads `form_v2_visit.packet_code` as the visit type.\n3. Change `form_v2_visit_plan()` and `form_v2_visit_prepare()` to accept a list. They merge the packets of the list with `form_packet_merge()`.\n4. The start screen lets the supervisor select one or more visit types of the family. It asks for a choice (for example, the Consent Form) before the visit starts, as today.\n5. The visit, the visit list and the visit history show all the visit types. They show a removed visit type as removed and a cancelled AO as cancelled.\n\n### Phase 5 \u2014 Add or remove a visit type during the visit\n\n1. Add the endpoint `backend\/formV2VisitTypes.php`. It is a POST with the CSRF token. It checks `client.visitsV2\/Conduct`, the client's scope and the writer token, as a save does.\n2. To add a visit type:\n   - Merge again with the release that the visit pinned.\n   - Ask for a new choice, if one is necessary.\n   - Seed only the questions that are new to the visit. Do not change an answer that the visit has.\n   - Show the forms and pages that the visit adds (`form_v2_combine_diff()`). The supervisor confirms.\n3. To remove a visit type, merge again without it. The visit keeps all the stored answers. If the supervisor adds the visit type again, the answers are there.\n4. **Correct `form_v2_visit_drop_hidden()`.** Today it deletes the answers to the questions that the visit does not show. After a remove, the questions of a removed form are not shown, so the function would delete their answers. Change it: delete only an answer that a `visible_if` condition hides, not an answer whose form left the visit.\n5. Each change increases the visit's revision. Thus the review candidate is not current. The next candidate uses `form_v2_candidate_carry()`, so the client signs again only the new forms and pages, and the forms whose answers changed.\n6. Record each change in `form_v2_visit_op` and in the audit: who, when, and which visit type.\n7. No office approval is necessary.\n\n### Phase 6 \u2014 Attendant presence at signing (#228)\n\n1. Before the review candidate is made, ask for each active attendant: \"Is attendant A present?\" Use the existing \"not here\" record (`form_v2_visit_signer`, `absent`).\n2. Replace the rules that read one `packet_code` (`FORM_V2_SIGN_ATTENDANT_MUST_SIGN`, `FORM_V2_SIGN_ATTENDANT_OPTIONAL`, `form_v2_sign_absence_error()`, `form_v2_sign_default_absent()`) with rules that read the visit's list.\n3. If an attendant is present, the attendant signs. The supervisor cannot mark a present attendant \"not here to sign\".\n4. If no attendant is present, and the list has AO with other visit types, the system tells the supervisor that the Attendant Orientation will be cancelled. When the supervisor confirms, the system cancels AO with Phase 5. It does not ask for a reason.\n5. If no attendant is present, and AO is the only visit type, the system tells the supervisor that the visit will be abandoned. The supervisor must confirm. Then the system abandons the visit (`form_v2_visit_abandon()`). If the supervisor does not confirm, nothing changes (D1).\n6. If no attendant is present, and the list has SPC_ADDED_TASKS, the Change in tasks continues. Its attendant lines stay unsigned. This does not stop the visit.\n7. Tests: add cases to `scripts\/test-form-v2-sign-rules.php` for AO, AO alone, SPC_ADDED_TASKS, AO with SPC_ADDED_TASKS, and a visit with two attendants where only one is present.\n\n### Phase 7 \u2014 Retire the old visit types, and the documents\n\n1. Activate the family release at each agency. Then no new visit starts on SOC_AO, AO, AR or ISP_COA as a single release.\n2. Visits that are in progress on an old release continue on it. Their pins do not change.\n3. Retire the old interview files and `soc-ao.json` when no visit in progress uses them. Look at all files that name `SOC_AO` (`grep -rl SOC_AO code scripts docs`).\n4. Update docs\/Forms.md, docs\/FormsV2Plan.md, docs\/UserChangelog.md and docs\/Changelog.md.\n\n---\n\n### Decisions (19 November 2026, Charles)\n\n- **D1. AO alone, with no attendant present.** The system warns the supervisor that the visit will be abandoned. The supervisor must confirm. Then the system abandons the visit. (Phase 6, step 5.)\n- **D2. What the paper shows for a combination.** `visit.visit_kind` is SOC if the list has SOC, then AR, then AO. We compare each form's \"visit type\" box with the paper before Phase 2 is complete.\n- **D3. Name of the family.** `CLIENT_VISIT`. Staff do not see this name.\n","assets":[],"created_at":"2026-11-19T09:06:34-06:00","updated_at":"2026-11-19T09:16:10-06:00"},{"id":3152,"html_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236#issuecomment-3152","pull_request_url":"","issue_url":"https:\/\/www-s01.apinet.com\/codeforge\/apiintl\/hhmanager\/issues\/236","user":{"id":1,"login":"charles","login_name":"","source_id":0,"full_name":"Charles Willgren","email":"charles@noreply.www-s01.apinet.com","avatar_url":"https:\/\/www-s01.apinet.com\/codeforge\/avatars\/d3c894f7297c5a18eb3f6ac837c335b11a00aa9cc0961323771632b1e2d61bb2","html_url":"https:\/\/www-s01.apinet.com\/codeforge\/charles","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2025-12-08T10:03:41-06:00","restricted":false,"active":false,"prohibit_login":false,"location":"","pronouns":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"charles"},"original_author":"","original_author_id":0,"body":"## Progress: Phases 1\u20136 built (2026-11-19)\n\nEverything is committed on `main`; nothing is pushed yet. Phase 7 is still open (see below).\n\n| Commit | Phase |\n|---|---|\n| `73b596e` | **1.** Combining rules (`code\/form_v2_combine_rules.inc.php`) and a new Start of Care packet (`soc.json`: SOC\/AO minus the orientation-only forms) |\n| `47cd43d` | **2.** One shared interview for the family `CLIENT_VISIT` (D3), checked against all 65 allowed combinations; conditions can read `visit.types`; `starts_as_if` |\n| `5401a9e` | **3.** One release that pins every member's packet; page narrowing follows the visit's types |\n| `d3c00ac` | **4.** A visit holds a list of visit types (`form_v2_visit_type`, migration `20261119_form-v2-visit-type.sql`, which backfills existing visits); several can be chosen at the start |\n| `45ccbf3` | **5.** Add, remove or cancel a visit type during the visit. A preview comes first, then a confirm; no answer is ever deleted; no office approval |\n| `a032d37` | **6.** Signing: attendant presence decides the orientation (with #235). With nobody present, AO is cancelled, or the visit is abandoned when AO is the only type (D1); a Change in tasks continues unsigned |\n| `4c9512f` | Docs: Forms.md \u00a79.3.1, FormsV2Plan, changelogs, DesignRationale |\n\nThe visit's kind follows D2: SOC, then AR, then AO.\n\n### Tested\n- All the forms test suites pass, including the database ones.\n- **Tried in a browser on dev:**\n  - Choosing Start of Care clears Annual Reassessment and keeps Attendant Orientation.\n  - An AR + AO visit plans and starts with the right forms.\n  - Removing AO previews 3040 page 2, Task Guide, Things Your Attendant May Not Do, Employee Visit Plan and Payroll Action Form; after confirming, the visit becomes an Annual Reassessment, with \"Attendant Orientation (AO): removed\" shown.\n- **Not yet tried in a browser:** the nobody-present signing flow (cancel the orientation, or abandon the visit). The rules have their own tests.\n\n### Still open (Phase 7)\n- [ ] **Production:**\n  - run the migration;\n  - activate the `CLIENT_VISIT` release for each agency on `\/admin\/form-v2-releases`.\n- [ ] **Retire `soc-ao.json` and the AO, AR and Change of Address interviews** once no visit in progress uses them. Until then, a change to one of them must also go into `CLIENT_VISIT.json`.\n- [ ] **Confirm with the customer:** in a Change in tasks visit, does each attendant start as SV or as AO? Each one starts as SV for now.","assets":[],"created_at":"2026-11-19T11:53:40-06:00","updated_at":"2026-11-19T11:53:40-06:00"}]}