-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from Crown-Commercial-Service/merge-uat-into-…
…preproduction Merge uat into main
- Loading branch information
Showing
14 changed files
with
256 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Nhs | ||
class Address | ||
def initialize(result) | ||
super() | ||
@result = result | ||
end | ||
|
||
def build_response | ||
{ | ||
streetAddress: street_address, | ||
locality: locality, | ||
region: region, | ||
postalCode: postal_code, | ||
countryName: country_name | ||
} | ||
end | ||
|
||
def street_address | ||
"#{exists_or_null(@result['Organisation']['GeoLoc']['Location']['AddrLn1'])}#{street_address_two}#{street_address_three}" | ||
end | ||
|
||
def street_address_two | ||
", #{exists_or_null(@result['Organisation']['GeoLoc']['Location']['AddrLn2'])}" if exists_or_null(@result['Organisation']['GeoLoc']['Location']['AddrLn2']).present? | ||
end | ||
|
||
def street_address_three | ||
", #{exists_or_null(@result['Organisation']['GeoLoc']['Location']['AddrLn3'])}" if exists_or_null(@result['Organisation']['GeoLoc']['Location']['AddrLn3']).present? | ||
end | ||
|
||
def locality | ||
exists_or_null(@result['Organisation']['GeoLoc']['Location']['Town']) | ||
end | ||
|
||
def region | ||
exists_or_null(@result['Organisation']['GeoLoc']['Location']['County']) | ||
end | ||
|
||
def postal_code | ||
exists_or_null(@result['Organisation']['GeoLoc']['Location']['PostCode']) | ||
end | ||
|
||
def country_name | ||
exists_or_null(@result['Organisation']['GeoLoc']['Location']['Country']) | ||
end | ||
|
||
private | ||
|
||
def exists_or_null(api_param) | ||
api_param.present? ? api_param : '' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Nhs | ||
class Contact | ||
def initialize(result) | ||
super() | ||
@result = result | ||
end | ||
|
||
def build_response | ||
{ | ||
name: '', | ||
email: '', | ||
telephone: exists_or_null(telephone).to_s, | ||
faxNumber: exists_or_null(fax).to_s, | ||
uri: exists_or_null(uri).to_s | ||
} | ||
end | ||
|
||
def telephone | ||
get_contact_value(@result['Organisation']['Contacts']['Contact'], 'tel') if @result['Organisation']['Contacts'].present? | ||
end | ||
|
||
def fax | ||
get_contact_value(@result['Organisation']['Contacts']['Contact'], 'fax') if @result['Organisation']['Contacts'].present? | ||
end | ||
|
||
def uri | ||
get_contact_value(@result['Organisation']['Contacts']['Contact'], 'http') if @result['Organisation']['Contacts'].present? | ||
end | ||
|
||
private | ||
|
||
def get_contact_value(contacts, type) | ||
return '' if contacts.blank? | ||
|
||
contacts.each do |contact| | ||
return contact['value'] if contact['type'] == type.to_s | ||
end | ||
'' | ||
end | ||
|
||
def exists_or_null(api_param) | ||
api_param.present? ? api_param : '' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Nhs | ||
class Indentifier | ||
def initialize(result) | ||
super() | ||
@result = result | ||
end | ||
|
||
def build_response | ||
{ | ||
scheme: 'GB-NHS', | ||
id: organisation_code, | ||
legalName: legal_name, | ||
uri: "https://directory.spineservices.nhs.uk/ORD/2-0-0/organisations/#{organisation_code}" | ||
} | ||
end | ||
|
||
def organisation_code | ||
exists_or_null(@result['Organisation']['OrgId']['extension']) | ||
end | ||
|
||
def legal_name | ||
exists_or_null(@result['Organisation']['Name']) | ||
end | ||
|
||
private | ||
|
||
def exists_or_null(api_param) | ||
api_param.present? ? api_param : '' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Nhs | ||
class Search | ||
def initialize(organisation_code) | ||
super() | ||
@organisation_code = organisation_code | ||
@company_number = nil | ||
@error = nil | ||
@result = [] | ||
@additional_indentifers_list = [] | ||
end | ||
|
||
def fetch_results | ||
conn = Common::ApiHelper.faraday_new(url: 'https://directory.spineservices.nhs.uk') | ||
resp = conn.get("/ORD/2-0-0/organisations/#{@organisation_code}") | ||
logging(resp) | ||
@result = ActiveSupport::JSON.decode(resp.body) if resp.status == 200 | ||
|
||
if resp.status == 200 && @result.key?('Organisation') && @result['Organisation']['Status'] == 'Active' | ||
build_response | ||
else | ||
false | ||
end | ||
end | ||
|
||
def build_response | ||
{ | ||
name: name, | ||
identifier: Nhs::Indentifier.new(@result).build_response, | ||
additionalIdentifiers: [], | ||
address: Nhs::Address.new(@result).build_response, | ||
contactPoint: Nhs::Contact.new(@result).build_response | ||
} | ||
end | ||
|
||
def name | ||
exists_or_null(@result['Organisation']['Name']) | ||
end | ||
|
||
private | ||
|
||
def exists_or_null(api_param) | ||
api_param.present? ? api_param : '' | ||
rescue StandardError => e | ||
ApiLogging::Logger.info(e) | ||
end | ||
|
||
def logging(resp) | ||
ApiLogging::Logger.api_status_error('NHS API| method:fetch_results', resp) | ||
# ApiLogging::Logger.info(resp.headers['X-RateLimit-Remain']) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"Organisation": { | ||
"Name": "Testing NHS Regsitry", | ||
"Date": [ | ||
{ | ||
"Type": "Operational", | ||
"Start": "1999-11-11", | ||
"End": "2011-12-12" | ||
} | ||
], | ||
"OrgId": { | ||
"root": "4.14.444.4.414484.4.4.4.4.4.14.44", | ||
"assigningAuthorityName": "HDIDI", | ||
"extension": "A23" | ||
}, | ||
"Status": "Active", | ||
"LastChangeDate": "2020-10-10", | ||
"orgRecordClass": "RCX", | ||
"refOnly": true, | ||
"GeoLoc": { | ||
"Location": { | ||
"AddrLn1": "ADDRESS LINE ONE", | ||
"AddrLn2": "ADDRESS LINE TWO", | ||
"Town": "TOWN", | ||
"County": "COUNTY", | ||
"PostCode": "AB1 2CD", | ||
"Country": "UNITED KINGDOM" | ||
} | ||
}, | ||
"Roles": { | ||
"Role": [ | ||
{ | ||
"id": "RO999", | ||
"uniqueRoleId": 37777, | ||
"primaryRole": true, | ||
"Date": [ | ||
{ | ||
"Type": "Operational", | ||
"Start": "1999-11-11", | ||
"End": "2011-12-12" | ||
} | ||
], | ||
"Status": "Active" | ||
} | ||
] | ||
} | ||
} | ||
} |