|
3118 | 3118 | end |
3119 | 3119 | end |
3120 | 3120 | end |
3121 | | - end |
3122 | 3121 |
|
3123 | | - describe '#parse_labs' do |
3124 | | - context 'with multiple records with mixed statuses' do |
3125 | | - it 'filters records and returns only those with allowed statuses' do |
3126 | | - records = [ |
3127 | | - { |
3128 | | - 'resource' => { |
3129 | | - 'resourceType' => 'DiagnosticReport', |
3130 | | - 'id' => '1', |
3131 | | - 'status' => 'final', |
3132 | | - 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
3133 | | - 'code' => { 'text' => 'Test 1' }, |
3134 | | - 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
3135 | | - 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data1' }] |
3136 | | - } |
3137 | | - }, |
3138 | | - { |
3139 | | - 'resource' => { |
3140 | | - 'resourceType' => 'DiagnosticReport', |
3141 | | - 'id' => '2', |
3142 | | - 'status' => 'preliminary', |
3143 | | - 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
3144 | | - 'code' => { 'text' => 'Test 2' }, |
3145 | | - 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
3146 | | - 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data2' }] |
3147 | | - } |
3148 | | - }, |
3149 | | - { |
3150 | | - 'resource' => { |
3151 | | - 'resourceType' => 'DiagnosticReport', |
3152 | | - 'id' => '3', |
3153 | | - 'status' => 'amended', |
3154 | | - 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
3155 | | - 'code' => { 'text' => 'Test 3' }, |
3156 | | - 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
3157 | | - 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data3' }] |
3158 | | - } |
3159 | | - }, |
3160 | | - { |
3161 | | - 'resource' => { |
3162 | | - 'resourceType' => 'DiagnosticReport', |
3163 | | - 'id' => '4', |
3164 | | - 'status' => 'cancelled', |
3165 | | - 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
3166 | | - 'code' => { 'text' => 'Test 4' }, |
3167 | | - 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
3168 | | - 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data4' }] |
| 3122 | + describe '#parse_labs with filtering' do |
| 3123 | + context 'with multiple records with mixed statuses' do |
| 3124 | + it 'filters records and returns only those with allowed statuses' do |
| 3125 | + records = [ |
| 3126 | + { |
| 3127 | + 'resource' => { |
| 3128 | + 'resourceType' => 'DiagnosticReport', |
| 3129 | + 'id' => '1', |
| 3130 | + 'status' => 'final', |
| 3131 | + 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
| 3132 | + 'code' => { 'text' => 'Test 1' }, |
| 3133 | + 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
| 3134 | + 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data1' }] |
| 3135 | + } |
| 3136 | + }, |
| 3137 | + { |
| 3138 | + 'resource' => { |
| 3139 | + 'resourceType' => 'DiagnosticReport', |
| 3140 | + 'id' => '2', |
| 3141 | + 'status' => 'preliminary', |
| 3142 | + 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
| 3143 | + 'code' => { 'text' => 'Test 2' }, |
| 3144 | + 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
| 3145 | + 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data2' }] |
| 3146 | + } |
| 3147 | + }, |
| 3148 | + { |
| 3149 | + 'resource' => { |
| 3150 | + 'resourceType' => 'DiagnosticReport', |
| 3151 | + 'id' => '3', |
| 3152 | + 'status' => 'amended', |
| 3153 | + 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
| 3154 | + 'code' => { 'text' => 'Test 3' }, |
| 3155 | + 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
| 3156 | + 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data3' }] |
| 3157 | + } |
| 3158 | + }, |
| 3159 | + { |
| 3160 | + 'resource' => { |
| 3161 | + 'resourceType' => 'DiagnosticReport', |
| 3162 | + 'id' => '4', |
| 3163 | + 'status' => 'cancelled', |
| 3164 | + 'category' => [{ 'coding' => [{ 'code' => 'CH' }] }], |
| 3165 | + 'code' => { 'text' => 'Test 4' }, |
| 3166 | + 'effectiveDateTime' => '2025-01-01T00:00:00.000Z', |
| 3167 | + 'presentedForm' => [{ 'contentType' => 'text/plain', 'data' => 'data4' }] |
| 3168 | + } |
3169 | 3169 | } |
3170 | | - } |
3171 | | - ] |
| 3170 | + ] |
3172 | 3171 |
|
3173 | | - result = adapter.send(:parse_labs, records) |
| 3172 | + result = adapter.send(:parse_labs, records) |
3174 | 3173 |
|
3175 | | - expect(result.size).to eq(2) |
3176 | | - expect(result.map(&:id)).to contain_exactly('1', '3') |
3177 | | - expect(result.map(&:status)).to contain_exactly('final', 'amended') |
| 3174 | + expect(result.size).to eq(2) |
| 3175 | + expect(result.map(&:id)).to contain_exactly('1', '3') |
| 3176 | + expect(result.map(&:status)).to contain_exactly('final', 'amended') |
| 3177 | + end |
3178 | 3178 | end |
3179 | 3179 | end |
3180 | 3180 | end |
|
0 commit comments