Skip to content

MHV / Add interpretation to mobile response#27587

Merged
mdewey merged 10 commits intomasterfrom
mhv/add-interpretation-to-mobile-response
Apr 16, 2026
Merged

MHV / Add interpretation to mobile response#27587
mdewey merged 10 commits intomasterfrom
mhv/add-interpretation-to-mobile-response

Conversation

@liztownd
Copy link
Copy Markdown
Contributor

@liztownd liztownd commented Apr 6, 2026

Summary

  • This work is behind a feature toggle (flipper): YES/NO NO
  • (Summarize the changes that have been made to the platform)
    • Add interpretation map to labs adapter (moving from web FE) to return a human-readable string to FE (both web + mobile)
    • Add interpretation field to observations for Mobile response
    • Update Mobile docs to reflect current state of Lab&Test data structure
    • Update tests
  • (If bug, how to reproduce)
  • (What is the solution, why is this the solution?)
    • For consistency we don't want to map the code (i.e. "N") to a human readable string (i.e. "Normal") in the FE of both the web + mobile app we're moving the mapping logic to the BE
    • Also for consistency, we want the same data displayed in the app (which is currently missing the interpretation field)
  • (Which team do you work for, does your team own the maintenance of this component?)
    • MHV Medical Records
  • (If introducing a flipper, what is the success criteria being targeted?)

Related issue(s)

Testing done

  • New code is covered by unit tests
  • Describe what the old behavior was prior to the change
    • Missing field in Mobile
    • Mapping happened only in the web FE
  • Describe the steps required to verify your changes are working as expected. Exclusively stating 'Specs run' is NOT acceptable as appropriate testing
    • You can drop a byebug in and verify that the interpretation field is present and in the correct format (i.e. "Normal" vs. "N")
  • If this work is behind a flipper:
    • Tests need to be written for both the flipper on and flipper off scenarios. Docs.
    • What is the testing plan for rolling out the feature?

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)
lib/unified_health_data/labs adapter
related tests
modules/mobile/docs (to update the expected response)
related tests

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves lab observation interpretation mapping into the UHD labs adapter so API consumers receive a human-readable interpretation string, and updates Mobile Labs & Tests documentation accordingly.

Changes:

  • Add INTERPRETATION_MAP and update extract_interpretation to return mapped display strings (with fallback).
  • Update adapter specs to assert mapped interpretation values (e.g., High instead of H).
  • Update Mobile Labs & Tests V1 OpenAPI schema/docs to reflect the current Labs & Tests response structure and include interpretation on observations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
lib/unified_health_data/adapters/lab_or_test_adapter.rb Adds interpretation mapping and changes interpretation extraction behavior returned to consumers.
spec/lib/unified_health_data/adapters/lab_or_test_adapter_spec.rb Updates unit tests for the new mapped interpretation behavior.
modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml Updates the documented response schema for Mobile Labs & Tests V1 (including interpretation).
modules/mobile/docs/openapi.json Updates generated OpenAPI output to match the updated Labs & Tests V1 schema.
Comments suppressed due to low confidence (2)

spec/lib/unified_health_data/adapters/lab_or_test_adapter_spec.rb:2863

  • extract_interpretation now maps HL7 v3 codes via INTERPRETATION_MAP and falls back when the HL7 code is present but unmapped. There’s no spec covering the case where an HL7 v3 coding exists but the code is not in the map; add a unit test to assert it returns CodeableConcept text/coding display in that scenario.
      it 'falls back to interpretation text when no HL7 v3 coding is present' do
        obs = {
          'code' => { 'text' => 'LDL' },
          'interpretation' => [
            {
              'coding' => [
                {
                  'system' => 'https://fhir.cerner.com/some-id/codeSet/52',
                  'code' => '212',
                  'display' => 'NA',
                  'userSelected' => true
                }
              ],
              'text' => 'N/A'
            }
          ]
        }
        result = adapter.send(:extract_interpretation, obs)
        expect(result).to eq('N/A')
      end

modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml:168

  • The Labs & Tests mobile controllers render UnifiedHealthData::LabOrTestSerializer.new(labs) without supplying meta, which (with JSONAPI::Serializer) typically produces a top-level { data: [...] } without a meta.pagination object. This schema requires meta with pagination; either update the controller/serializer options to actually include pagination metadata, or relax the schema (and openapi.json) so meta isn’t required for this response.
  meta:
    type: object
    additionalProperties: false
    required:
      - pagination
    properties:
      pagination:
        type: object
        additionalProperties: false
        required:
          - currentPage
          - perPage
          - totalPages
          - totalEntries
        properties:

Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb Outdated
Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb Outdated
Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb Outdated
Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb Outdated
Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb
Comment thread modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml Outdated
Comment thread modules/mobile/docs/openapi.json Outdated
Comment thread modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread lib/unified_health_data/adapters/lab_or_test_adapter.rb
Comment thread modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml Outdated
Comment thread modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml
@GovNapoleon GovNapoleon self-requested a review April 14, 2026 23:32
@liztownd liztownd marked this pull request as ready for review April 15, 2026 13:47
@liztownd liztownd requested review from a team as code owners April 15, 2026 13:47
@liztownd liztownd requested a review from mdewey April 15, 2026 13:47
@nichia nichia requested a review from Copilot April 15, 2026 14:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread modules/mobile/docs/schemas/v1/LabsAndTestsV1.yml
Comment thread modules/mobile/docs/openapi.json
@mdewey mdewey merged commit c330aa1 into master Apr 16, 2026
42 of 43 checks passed
@mdewey mdewey deleted the mhv/add-interpretation-to-mobile-response branch April 16, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants