 )
     BEGIN
 
+        -- all observations for a patient by NHS number
         select
             o.patient_id, o.effective_date, o.original_code, o.original_term, o.original_code_scheme,
             ov.result_value, ov.result_value_units, ov.result_date, ov.result_text,
             pr.title as 'Clincian Title', pr.first_name as 'Clinician First Name', pr.last_name as 'Clinician Last Name'
         from
             pcr.observation o
-            left join
+        left join
             pcr.observation_value ov on o.id = ov.observation_id and ov.patient_id = o.patient_id
-            left join
+        left join
             pcr.practitioner pr on pr.id = o.effective_practitioner_id
-            join
+        join
             pcr.patient p on p.id = o.patient_id
         where
             p.nhs_number = _nhsno;

)
    BEGIN

        select
            i.patient_id, i.effective_date, i.original_code, i.original_term, i.original_code_scheme,
            pr.title as 'Clincian Title', pr.first_name as 'Clinician First Name', pr.last_name as 'Clinician Last Name'
        from
            pcr.immunisation i
            left join
            pcr.practitioner pr on pr.id = i.effective_practitioner_id
            join
            pcr.patient p on p.id = i.patient_id
        where
            p.nhs_number = _nhsno;

)
    BEGIN

        -- all PCR data tables counts
        select
            count(*) as 'Count', '' 'pcr.allergy' from pcr.allergy a
            join pcr.organisation org on org.id = a.owning_organisation_id
