Skip to content

[18.0][FIX] ni_patient, ni_observation: fixes from the P1 smoke test - #172

Merged
piruin merged 2 commits into
nirun-life:18.0from
wasud:18.0-fix-p1-smoke
Oct 21, 2026
Merged

piruin merged 2 commits into
nirun-life:18.0from
wasud:18.0-fix-p1-smoke

Conversation

@wasud

@wasud wasud commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Refs #141 · Found in the P1 smoke test (#137, #141), run as a clinician user (not admin)

Summary (TH)

แก้บั๊ก 2 ตัวที่เจอตอน smoke test ซึ่งเกิดตั้งแต่ 17.0: clinician เปิด encounter ไม่ได้ (Access Error จาก field ของ HR) และลำดับแถวในแท็บ Observation เพี้ยนหลังเปลี่ยนหมวด

Changes

Module Fix Version
ni_patient The encounter reads the participant's job_title and permit_no with sudo(). Since 17.0 reading a groups-restricted field through a record raises an access error (permit_no is HR-only; in 19.0 job_title is on hr.version), so a user without HR rights could not open any encounter. 16.0 showed both values to everyone who could read the encounter. 18.0.1.0.1
ni_observation The computed filtered_patient_observation_ids / filtered_encounter_observation_ids are sorted like the list's default_order (sequence,type_id). Since 17.0 the web client keeps the order of x2many values from an onchange, so after switching the category the rows came back in id order. 18.0.1.0.1

Decisions to review

  • sudo() for the two participant fields keeps the 16.0 behaviour: the practitioner's job title and permit number are part of the encounter (form and summary report). The alternative, reading from hr.employee.public, gives the job title but not the permit number, so non-HR users would see an empty permit number.

How tested

  • Fresh 18.0 DB without demo, ni_patient, ni_observation: 0 failed, 0 errors of 61 tests. New tests: test_ni_encounter_participant (non-HR user reads the participant fields) and test_observation_display_order (patient and encounter tabs follow the type order); both fail without the fix.
  • pre-commit clean on the changed files.
  • Smoke test in the browser as a clinician user with these commits: encounter form and discharge wizard on 17.0/18.0 (demo data), and the full P1 checklist on 19.0 (pilot DB upgraded 16→17→18→19), with 0 console errors. The recording goes on [MIG 19.0][P1-6] Data migration pilot: OpenUpgrade 16→17→18→19 on Phase 1 modules #141.

wasud added 2 commits October 21, 2026 14:54
Since 17.0 reading a field restricted by groups through a record raises an
access error. The encounter computes the participant's job title and permit
number from hr.employee, where permit_no is HR-only (and job_title moves to
hr.version in 19.0), so a clinician without HR rights could not open an
encounter at all. 16.0 did not check these reads, so the encounter showed
both values to everyone who could read it.

Read the two values with sudo() to keep that behaviour.

Found in the 19.0 smoke test as a clinician user.

Refs: nirun-life#137, nirun-life#141
The patient and encounter forms list the latest observations of one category
with default_order "sequence,type_id". Since 17.0 the web client keeps the
order of x2many values returned by an onchange, so after switching the
category the rows came back in record id order instead of type order.

Sort the computed records the same way as the list.

Found in the 19.0 smoke test.

Refs: nirun-life#139, nirun-life#141
@piruin
piruin merged commit 7c79069 into nirun-life:18.0 Oct 21, 2026
4 checks passed
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