|
504 | 504 | end |
505 | 505 | end |
506 | 506 |
|
507 | | - describe "the parsed dose_sequence value" do |
| 507 | + describe "dose sequence parsing" do |
508 | 508 | subject { record.dose_sequence } |
509 | 509 |
|
510 | 510 | let(:fixture_file_name) { "fhir/flu/fhir_record_full.json" } |
| 511 | + let(:dose_number_positive_int) { nil } |
| 512 | + let(:dose_number_string) { nil } |
511 | 513 |
|
512 | 514 | before do |
513 | | - allow(fhir_immunization.protocolApplied.sole).to receive( |
514 | | - :doseNumberPositiveInt |
515 | | - ).and_return(dose_number) |
| 515 | + allow(fhir_immunization.protocolApplied.sole).to receive_messages( |
| 516 | + doseNumberPositiveInt: dose_number_positive_int, |
| 517 | + doseNumberString: dose_number_string |
| 518 | + ) |
516 | 519 | end |
517 | 520 |
|
518 | | - context "when doseNumberPositiveInt is nil" do |
519 | | - let(:dose_number) { nil } |
520 | | - |
| 521 | + context "when both fields are nil" do |
521 | 522 | it { should be_nil } |
522 | 523 |
|
523 | | - it "does not include a dose sequence note" do |
524 | | - expect(record.notes.to_s).not_to include("Reported dose sequence") |
| 524 | + it "does not include any dose notes" do |
| 525 | + expect(record.notes.to_s).not_to include("Reported dose number") |
| 526 | + expect(record.notes.to_s).not_to include( |
| 527 | + "Reported dose number string" |
| 528 | + ) |
525 | 529 | end |
526 | 530 | end |
527 | 531 |
|
528 | | - context "when doseNumberPositiveInt is less than the maximum dose sequence for flu" do |
529 | | - let(:dose_number) { 1 } |
| 532 | + context "when doseNumberPositiveInt is within the maximum dose sequence for flu" do |
| 533 | + let(:dose_number_positive_int) { 1 } |
530 | 534 |
|
531 | 535 | it { should eq 1 } |
532 | 536 |
|
533 | 537 | it "does not include a dose sequence note" do |
534 | | - expect(record.notes.to_s).not_to include("Reported dose sequence") |
| 538 | + expect(record.notes.to_s).not_to include("Reported dose number") |
535 | 539 | end |
536 | 540 | end |
537 | 541 |
|
538 | 542 | context "when doseNumberPositiveInt exceeds the maximum dose sequence for flu" do |
539 | | - let(:dose_number) { 3 } |
| 543 | + let(:dose_number_positive_int) { 3 } |
540 | 544 |
|
541 | 545 | it { should be_nil } |
542 | 546 |
|
543 | 547 | it "records the out-of-range dose sequence in notes" do |
544 | | - expect(record.notes.to_s).to include("Reported dose sequence: 3") |
| 548 | + expect(record.notes.to_s).to include("Reported dose number: 3") |
| 549 | + end |
| 550 | + end |
| 551 | + |
| 552 | + context "when doseNumberPositiveInt is present and doseNumberString is also present" do |
| 553 | + let(:dose_number_positive_int) { 2 } |
| 554 | + let(:dose_number_string) { "first" } |
| 555 | + |
| 556 | + it { should eq 2 } |
| 557 | + |
| 558 | + it "does not include a dose number string note" do |
| 559 | + expect(record.notes.to_s).not_to include( |
| 560 | + "Reported dose number string" |
| 561 | + ) |
| 562 | + end |
| 563 | + end |
| 564 | + |
| 565 | + context "when doseNumberString is an integer string" do |
| 566 | + let(:dose_number_string) { "1" } |
| 567 | + |
| 568 | + it { should eq 1 } |
| 569 | + |
| 570 | + it "does not include a dose number string note" do |
| 571 | + expect(record.notes.to_s).not_to include( |
| 572 | + "Reported dose number string" |
| 573 | + ) |
| 574 | + end |
| 575 | + end |
| 576 | + |
| 577 | + context "when doseNumberString is a non-integer string" do |
| 578 | + let(:dose_number_string) { "first" } |
| 579 | + |
| 580 | + it { should be_nil } |
| 581 | + |
| 582 | + it "appends the value to notes" do |
| 583 | + expect(record.notes.to_s).to include( |
| 584 | + "Reported dose number string: first" |
| 585 | + ) |
| 586 | + end |
| 587 | + end |
| 588 | + |
| 589 | + context "when doseNumberString is blank" do |
| 590 | + let(:dose_number_string) { "" } |
| 591 | + |
| 592 | + it { should be_nil } |
| 593 | + |
| 594 | + it "does not include a dose number string note" do |
| 595 | + expect(record.notes.to_s).not_to include( |
| 596 | + "Reported dose number string" |
| 597 | + ) |
545 | 598 | end |
546 | 599 | end |
547 | 600 | end |
|
849 | 902 | its(:performed_ods_code) { should eq "B12345" } |
850 | 903 | its(:nhs_immunisations_api_primary_source) { should be false } |
851 | 904 |
|
852 | | - its(:notes) { should be_nil } |
| 905 | + its(:notes) do |
| 906 | + should include( |
| 907 | + "Reported dose number string: Dose sequence not recorded" |
| 908 | + ) |
| 909 | + end |
853 | 910 | end |
854 | 911 |
|
855 | 912 | context "with a record that is nasal flu, and is missing dose quantity (from real GP)" do |
|
1047 | 1104 | its(:outcome) { should eq "administered" } |
1048 | 1105 | its(:performed_ods_code) { should eq "B12345" } |
1049 | 1106 |
|
1050 | | - its(:notes) { should be_nil } |
| 1107 | + its(:notes) do |
| 1108 | + should include( |
| 1109 | + "Reported dose number string: Dose sequence not recorded" |
| 1110 | + ) |
| 1111 | + end |
1051 | 1112 | end |
1052 | 1113 | end |
1053 | 1114 |
|
|
1137 | 1198 | its(:performed_ods_code) { should eq "R1L" } |
1138 | 1199 | its(:nhs_immunisations_api_primary_source) { should be true } |
1139 | 1200 |
|
1140 | | - its(:notes) { should be_nil } |
| 1201 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1141 | 1202 | end |
1142 | 1203 | end |
1143 | 1204 |
|
|
1182 | 1243 | its(:performed_ods_code) { should eq "R1L" } |
1183 | 1244 | its(:nhs_immunisations_api_primary_source) { should be true } |
1184 | 1245 |
|
1185 | | - its(:notes) { should be_nil } |
| 1246 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1186 | 1247 | end |
1187 | 1248 | end |
1188 | 1249 |
|
|
1231 | 1292 | its(:performed_ods_code) { should eq "R1L" } |
1232 | 1293 | its(:nhs_immunisations_api_primary_source) { should be true } |
1233 | 1294 |
|
1234 | | - its(:notes) { should be_nil } |
| 1295 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1235 | 1296 | end |
1236 | 1297 | end |
1237 | 1298 |
|
|
1280 | 1341 | its(:performed_ods_code) { should eq "R1L" } |
1281 | 1342 | its(:nhs_immunisations_api_primary_source) { should be true } |
1282 | 1343 |
|
1283 | | - its(:notes) { should be_nil } |
| 1344 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1284 | 1345 | end |
1285 | 1346 | end |
1286 | 1347 | end |
|
0 commit comments