|
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 |
|
783 | 836 | its(:performed_ods_code) { should eq "B12345" } |
784 | 837 | its(:nhs_immunisations_api_primary_source) { should be false } |
785 | 838 |
|
786 | | - its(:notes) { should be_nil } |
| 839 | + its(:notes) do |
| 840 | + should include( |
| 841 | + "Reported dose number string: Dose sequence not recorded" |
| 842 | + ) |
| 843 | + end |
787 | 844 | end |
788 | 845 |
|
789 | 846 | context "with a record that is nasal flu, and is missing dose quantity (from real GP)" do |
|
980 | 1037 | its(:outcome) { should eq "administered" } |
981 | 1038 | its(:performed_ods_code) { should eq "B12345" } |
982 | 1039 |
|
983 | | - its(:notes) { should be_nil } |
| 1040 | + its(:notes) do |
| 1041 | + should include( |
| 1042 | + "Reported dose number string: Dose sequence not recorded" |
| 1043 | + ) |
| 1044 | + end |
984 | 1045 | end |
985 | 1046 | end |
986 | 1047 |
|
|
1070 | 1131 | its(:performed_ods_code) { should eq "R1L" } |
1071 | 1132 | its(:nhs_immunisations_api_primary_source) { should be true } |
1072 | 1133 |
|
1073 | | - its(:notes) { should be_nil } |
| 1134 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1074 | 1135 | end |
1075 | 1136 | end |
1076 | 1137 |
|
|
1115 | 1176 | its(:performed_ods_code) { should eq "R1L" } |
1116 | 1177 | its(:nhs_immunisations_api_primary_source) { should be true } |
1117 | 1178 |
|
1118 | | - its(:notes) { should be_nil } |
| 1179 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1119 | 1180 | end |
1120 | 1181 | end |
1121 | 1182 |
|
|
1164 | 1225 | its(:performed_ods_code) { should eq "R1L" } |
1165 | 1226 | its(:nhs_immunisations_api_primary_source) { should be true } |
1166 | 1227 |
|
1167 | | - its(:notes) { should be_nil } |
| 1228 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1168 | 1229 | end |
1169 | 1230 | end |
1170 | 1231 |
|
|
1213 | 1274 | its(:performed_ods_code) { should eq "R1L" } |
1214 | 1275 | its(:nhs_immunisations_api_primary_source) { should be true } |
1215 | 1276 |
|
1216 | | - its(:notes) { should be_nil } |
| 1277 | + its(:notes) { should include("Reported dose number string: Unknown") } |
1217 | 1278 | end |
1218 | 1279 | end |
1219 | 1280 | end |
|
0 commit comments