<!-- BEGIN [% component.name %] -->
[% # PROCESS dumper.tt dump = patient;
# PROCESS dumper.tt dump = params;
# PROCESS dumper.tt dump = pds_query;
# PROCESS dumper.tt dump = pds_codes;
# PROCESS dumper.tt dump = c.query;
%]
<input type="hidden" name="pds_code"
value="[% pds.ErrorCode || params.pds_code # latter if _skip_pds employed %]" />
[% IF pds.size; # is_code_ref(pds_query).match('HASH')
pds_return_codes = config.patient_demographic_service.return_codes;
IF pds.ErrorCode.match('SMSP-0000');
fields = [
'last_name' 'first_name' 'middle_name' 'gender' 'dob' 'nhs_number'
];
USE format; zero_padded = format('%02d'); # ensure zero-padded for cmp
patient_dob = [ params.year, zero_padded(params.month), params.day ];
is_validated = 1;
%]
<div class="indent" id="pds">
<h4>PDS query
[% IF pds.demographics_verified %]
<span class="text-info">[patient details verified]</span>
[% ELSE %]
<span class="text-danger">[patient details unverified]</span>
[% END %]
</h4>
<p class="pds">
[% FOREACH field IN fields;
a = pds.${field} | lower; # PROCESS dumper.tt dump = a;
b = ( field == 'dob' )
? patient_dob.join('-')
: params.${field} | lower; # PROCESS dumper.tt dump = b;
%]
[% IF a != b # highlight it %]
<span class="pds">[% pds.item(field) || '[NULL]' %]</span>
<!-- | pds:[% a %]; form:[% b %] | -->
[% ELSIF pds.${field}; pds.${field}; ELSE; NEXT; END # skip if empty %]
[% ' :: ' IF loop.next # add separator unless end of array %]
[% END %]
[% IF pds.home_address;
' :: ' _ pds.home_address _ ', ' _ pds.post_code; END %]
</p>
[% IF NOT pds.demographics_verified %]
<span class="bg-danger strong">Patient details do not match PDS entry.
Please check your source.
</span>
[% END %]
</div>
[% ELSE; # PDS returned a not-OK error code:
error_code = pds.ErrorCode;
error_str = pds_return_codes.${error_code}; # empty for a PDS timeout
%]
<div class="indent">
<p class="bg-danger">PDS returned:
<span class="strong">[% error_code %] [[% error_str %]]</span>
[% IF error_code.match('DEMOG-000[17]') # no or multiple matches
OR error_code.match('SMSP-0001'); # message validation error %]
<span class="text-info strong">
PLEASE CHECK ALL FIELDS AND RESUBMIT
</span>
[% END %]
<button id="submit" name="submit"
class="btn btn-primary">Retry</button>
</p>
[% # allow PDS query override or no chance of registering if timeout or anon details:
message = error_code.match('timeout')
? 'patient demographic service appears to be off-line'
: 'PDS cannot find a match or returns multiple matches';
%]
<p class="text-info strong">If [% message %], skip repeat PDS lookup:
<input type="checkbox" name="_skip_pds" value="1" />
</p>
</div>
[% END %]
[% ELSE %]
<p class="bg-danger">PDS did not return expected format: [% pds %]</p>
<input type="hidden" name="_skip_pds" value="1" />[%# to break out of cycle %]
[% END %]
<!-- END [% component.name %] -->