File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -939,7 +939,15 @@ def validate_school_urn
939
939
940
940
def validate_session_id
941
941
if session_id . present?
942
- if session_id . to_i . nil?
942
+ if uuid . present? &&
943
+ VaccinationRecord . find_by (
944
+ uuid : uuid . to_s
945
+ ) &.sourced_from_nhs_immunisations_api?
946
+ errors . add (
947
+ session_id . header ,
948
+ "A session ID cannot be provided for this record; this record was sourced from an external source."
949
+ )
950
+ elsif session_id . to_i . nil?
943
951
errors . add (
944
952
session_id . header ,
945
953
"The session ID is not recognised. Download the offline spreadsheet " \
Original file line number Diff line number Diff line change 794
794
end
795
795
end
796
796
797
+ context "vaccination in a session, but UUID matches a record sourced from NHS immunisations API" do
798
+ let ( :data ) do
799
+ {
800
+ "VACCINATED" => "Y" ,
801
+ "PROGRAMME" => "Flu" ,
802
+ "SESSION_ID" => 1 ,
803
+ "DATE_OF_VACCINATION" => "#{ AcademicYear . current } 0901" ,
804
+ "UUID" => "12345678-1234-1234-1234-123456789abc"
805
+ }
806
+ end
807
+
808
+ before do
809
+ create (
810
+ :vaccination_record ,
811
+ programme : create ( :programme , :flu ) ,
812
+ uuid : "12345678-1234-1234-1234-123456789abc" ,
813
+ source : :nhs_immunisations_api
814
+ )
815
+ end
816
+
817
+ it "has errors" do
818
+ expect ( immunisation_import_row ) . to be_invalid
819
+ expect ( immunisation_import_row . errors [ "SESSION_ID" ] ) . to eq (
820
+ [
821
+ "A session ID cannot be provided for this record; " \
822
+ "this record was sourced from an external source."
823
+ ]
824
+ )
825
+ end
826
+ end
827
+
797
828
context "with valid fields for Flu" do
798
829
let ( :programmes ) { [ create ( :programme , :flu ) ] }
799
830
You can’t perform that action at this time.
0 commit comments