|
546 | 546 | end |
547 | 547 | end |
548 | 548 |
|
| 549 | + describe "the parsed performed_ods_code value" do |
| 550 | + subject { record.performed_ods_code } |
| 551 | + |
| 552 | + before do |
| 553 | + allow( |
| 554 | + fhir_immunization |
| 555 | + .performer |
| 556 | + .find { it.actor&.type == "Organization" } |
| 557 | + .actor |
| 558 | + .identifier |
| 559 | + ).to receive(:value).and_return(ods_code) |
| 560 | + end |
| 561 | + |
| 562 | + let(:fixture_file_name) { "fhir/flu/fhir_record_full.json" } |
| 563 | + |
| 564 | + context "when the org performer ODS code is a real code" do |
| 565 | + let(:ods_code) { "B0C4P" } |
| 566 | + |
| 567 | + it { should eq "B0C4P" } |
| 568 | + end |
| 569 | + |
| 570 | + context "when the org performer ODS code is a placeholder" do |
| 571 | + let(:ods_code) { FHIRMapper::Location::UNKNOWN_IDENTIFIER } |
| 572 | + |
| 573 | + it { should be_nil } |
| 574 | + end |
| 575 | + end |
| 576 | + |
| 577 | + describe "the parsed batch_expiry value" do |
| 578 | + subject { record.batch_expiry } |
| 579 | + |
| 580 | + let(:fixture_file_name) { "fhir/flu/fhir_record_full.json" } |
| 581 | + |
| 582 | + before do |
| 583 | + allow(fhir_immunization).to receive(:expirationDate).and_return( |
| 584 | + expiration_date |
| 585 | + ) |
| 586 | + end |
| 587 | + |
| 588 | + context "when the expiry date is realistic" do |
| 589 | + let(:expiration_date) { "2026-07-02" } |
| 590 | + |
| 591 | + it { should eq Date.new(2026, 7, 2) } |
| 592 | + end |
| 593 | + |
| 594 | + context "when the expiry date is after 2100" do |
| 595 | + let(:expiration_date) { "9999-12-31" } |
| 596 | + |
| 597 | + it { should be_nil } |
| 598 | + end |
| 599 | + |
| 600 | + context "when the expiry date is before 1900" do |
| 601 | + let(:expiration_date) { "1899-12-31" } |
| 602 | + |
| 603 | + it { should be_nil } |
| 604 | + end |
| 605 | + |
| 606 | + context "when the expiry date is nil" do |
| 607 | + let(:expiration_date) { nil } |
| 608 | + |
| 609 | + it { should be_nil } |
| 610 | + end |
| 611 | + end |
| 612 | + |
549 | 613 | context "with a full fhir record" do |
550 | 614 | let(:fixture_file_name) { "fhir/flu/fhir_record_full.json" } |
551 | 615 |
|
|
740 | 804 | its(:delivery_method) { should eq "intramuscular" } |
741 | 805 | its(:delivery_site) { should eq "left_arm_upper_position" } |
742 | 806 | its(:full_dose) { should be true } |
743 | | - its(:location_name) { should eq "X99999" } |
| 807 | + |
| 808 | + its(:location_name) { should eq "Unknown" } |
| 809 | + |
744 | 810 | its(:outcome) { should eq "administered" } |
745 | 811 | its(:performed_ods_code) { should eq "B0C4P" } |
746 | 812 | its(:nhs_immunisations_api_primary_source) { should be true } |
|
907 | 973 | its(:nhs_immunisations_api_primary_source) { should be true } |
908 | 974 |
|
909 | 975 | its(:location) { should be_nil } |
910 | | - its(:location_name) { should eq "X99999" } |
| 976 | + |
| 977 | + its(:location_name) { should eq "Unknown" } |
911 | 978 |
|
912 | 979 | its(:notes) { should be_nil } |
913 | 980 | end |
|
0 commit comments