File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ def initialize(vaccination_record)
1818 def fhir_record
1919 immunisation = FHIR ::Immunization . new ( id : nhs_immunisations_api_id )
2020
21- if performed_by_user . present?
22- immunisation . contained << performed_by_user . fhir_practitioner (
23- reference_id : "Practitioner1"
24- )
21+ if performed_by . present?
22+ immunisation . contained << FHIRMapper :: User . new (
23+ performed_by
24+ ) . fhir_practitioner ( reference_id : "Practitioner1" )
2525 end
2626
2727 immunisation . contained << patient . fhir_record ( reference_id : "Patient1" )
@@ -44,10 +44,12 @@ def fhir_record
4444 immunisation . site = fhir_site
4545 immunisation . route = fhir_route
4646 immunisation . doseQuantity = fhir_dose_quantity
47- immunisation . performer = [
48- fhir_user_performer ( reference_id : "Practitioner1" ) ,
49- fhir_org_performer
50- ]
47+ if performed_by . present?
48+ immunisation . performer << fhir_user_performer (
49+ reference_id : "Practitioner1"
50+ )
51+ end
52+ immunisation . performer << fhir_org_performer
5153 immunisation . reasonCode = [ fhir_reason_code ]
5254 immunisation . protocolApplied = [ fhir_protocol_applied ]
5355
Original file line number Diff line number Diff line change 6262 end
6363
6464 describe "contained performing practitioner" do
65- subject { immunisation_fhir . contained . find { it . id == "Practitioner1" } }
65+ subject ( :contained_practitioner ) do
66+ immunisation_fhir . contained . find { it . id == "Practitioner1" }
67+ end
6668
6769 it { should eq user . fhir_practitioner ( reference_id : "Practitioner1" ) }
70+
71+ context "when the performing professional is not a local user" do
72+ subject ( :name ) { contained_practitioner . name . first }
73+
74+ before do
75+ vaccination_record . update (
76+ performed_by_user : nil ,
77+ performed_by_given_name : "John" ,
78+ performed_by_family_name : "Howie"
79+ )
80+ end
81+
82+ its ( :given ) { should eq [ "John" ] }
83+ its ( :family ) { should eq "Howie" }
84+ end
85+
86+ context "when the performing professional is missing" do
87+ before { vaccination_record . update ( performed_by_user : nil ) }
88+
89+ it { should be_nil }
90+ end
6891 end
6992
7093 describe "performing practitioner" do
You can’t perform that action at this time.
0 commit comments