Repository navigation
[18.0][FIX] ni_patient, ni_observation: fixes from the P1 smoke test - #172
Merged
Merged
Conversation
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
This was referenced Oct 21, 2026
piruin
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ni_patientjob_titleandpermit_nowithsudo(). Since 17.0 reading a groups-restricted field through a record raises an access error (permit_nois HR-only; in 19.0job_titleis onhr.version), so a user without HR rights could not open any encounter. 16.0 showed both values to everyone who could read the encounter.ni_observationfiltered_patient_observation_ids/filtered_encounter_observation_idsare sorted like the list'sdefault_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.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 fromhr.employee.public, gives the job title but not the permit number, so non-HR users would see an empty permit number.How tested
ni_patient, ni_observation: 0 failed, 0 errors of 61 tests. New tests:test_ni_encounter_participant(non-HR user reads the participant fields) andtest_observation_display_order(patient and encounter tabs follow the type order); both fail without the fix.pre-commitclean on the changed files.