Commit 9b47d9d
authored
Enhance facility name fetching for OH Rx (#24437)
* feat: Add prescription tracking support to UHD
- Add tracking attribute to UnifiedHealthData::Prescription model as array
- Update VistaPrescriptionAdapter to parse trackingInfo from VistA responses
- Add date formatting for shippedDate (VistA format to ISO 8601)
- Refactor adapter methods to eliminate MethodLength violation
- Update serializer to include tracking data in API responses
- Set is_trackable dynamically based on tracking data presence
- Update all related test files to use tracking array format
- Remove tracking_information attribute (no backwards compatibility needed)
Tracking objects include: prescriptionName, prescriptionNumber, ndcNumber,
prescriptionId, trackingNumber, shippedDate, carrier, otherPrescriptions
* feat: Add Oracle Health prescription tracking support
- Add tracking information parsing from FHIR MedicationDispense identifiers
- Extract tracking number, prescription number, carrier, shipped date from identifiers
- Add NDC number extraction from medicationCodeableConcept coding
- Set is_trackable dynamically based on tracking data presence
- Refactor build_prescription_attributes to eliminate MethodLength violation
- Add comprehensive test coverage for Oracle Health tracking scenarios
- Handle multiple MedicationDispense resources with tracking data
- Gracefully handle missing tracking data with empty arrays
Oracle Health tracking objects include: prescriptionName, prescriptionNumber,
ndcNumber, prescriptionId, trackingNumber, shippedDate, carrier, otherPrescriptions
* Fix NDC extraction to use individual dispense level
- Move NDC extraction from top-level MedicationRequest to individual MedicationDispense resources
- Update extract_ndc_number method to work with dispense parameter instead of resource
- Update corresponding spec tests to reflect new NDC extraction behavior
- Ensures FHIR compliance where each dispense can have its own medication coding
* Add VistA tracking specs
* Split adapter spec into EHR specific files
* feat: Enhanced facility name extraction for Oracle Health prescriptions
- Updated extract_facility_name to use 3-digit station number extraction from latest dispense
- Added 3-tier fallback strategy: Rails cache → Lighthouse API → station number
- Created FacilityNameCacheJob for hourly VHA facility name caching with 4-hour TTL
- Added comprehensive StatsD metrics for cache performance monitoring
- Updated prescription model to include type attribute
- Enhanced test coverage for facility name extraction scenarios
- Added periodic job scheduling at 37 minutes past hour
- Removed legacy fallbacks to encounter and performer for focused approach
Improves facility name resolution for Oracle Health prescriptions by using
VHA station numbers from dispense locations with intelligent caching strategy.
* rubocop
* Style updates
* Simplify facility name logic
* Fix prescription_id type in OracleHealthPrescriptionAdapter to maintain consistency
* remove unnecessary compact call
* rubocop
* Enhance facility name extraction by implementing cache fallback and API retrieval in OracleHealthPrescriptionAdapter
* Implement caching for facility name retrieval in fetch_facility_name_from_api method
* Fix facility name cache pagination and TTL
* Add explicit client load
* Normalize refill orders before building UHD payload
* Allow UHD facility cache fallback to full facility identifier
* rubocop
* Add CODEOWNERS entry for app/sidekiq/unified_health_data/facility_name_cache_job.rb
* Add CODEOWNERS entry for spec/sidekiq/unified_health_data/facility_name_cache_job_spec.rb
* Use Rails.cache.exist? to determine facility-name cache hits
Recognize explicit cache entries (including nil) by checking Rails.cache.exist?
instead of relying on the truthiness of Rails.cache.read. Update related
specs to stub Rails.cache.exist? (and provide a default) so tests reflect the
new cache-hit semantics.
* UnifiedHealthData: paginate Lighthouse facilities using response.links['next']
Replace manual page increment and batch-size stop logic with following the
response.links['next'] URL. Parse next link query params and request the
next page from the Lighthouse client. This ensures robust pagination
based on API-provided links.
Update specs to stub response.links by default and assert subsequent
pages are requested using the next link's query params.
* Improve var name
* UnifiedHealthData: adjust facility lookup logging levels and update specs
- Log invalid station extraction as error when station format can't be parsed
- Change Lighthouse "no facility" log from info to warn
- Escalate API failure logging from warn to error
- Update specs to expect the new logging behavior and stub logger calls
* Back model change out in favor of separate PR
* rubocop
* UnifiedHealthData: coerce labs_logging_date_range_days to integer in LabsRefreshJob
Call .to_i when reading Settings.mhv.uhd.labs_logging_date_range_days and update the spec to match so date arithmetic always uses an integer.
* Fix log level expectation1 parent 75dabd2 commit 9b47d9d
File tree
11 files changed
+751
-62
lines changed- .github
- app/sidekiq/unified_health_data
- lib
- unified_health_data
- adapters
- spec
- lib/unified_health_data
- adapters
- sidekiq/unified_health_data
11 files changed
+751
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
505 | 506 | | |
506 | 507 | | |
507 | 508 | | |
| |||
1893 | 1894 | | |
1894 | 1895 | | |
1895 | 1896 | | |
| 1897 | + | |
1896 | 1898 | | |
1897 | 1899 | | |
1898 | 1900 | | |
| |||
Lines changed: 108 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
Lines changed: 63 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
142 | 153 | | |
143 | 154 | | |
| 155 | + | |
| 156 | + | |
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
| |||
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
289 | 341 | | |
290 | 342 | | |
291 | 343 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | | - | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
282 | | - | |
283 | | - | |
| 283 | + | |
| 284 | + | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| |||
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
298 | 309 | | |
299 | 310 | | |
300 | 311 | | |
| |||
0 commit comments