Skip to content

Commit

Permalink
Merge pull request #34 from NHSDigital/NHSECheck/IgnoreURLS
Browse files Browse the repository at this point in the history
Tweak url prefix detection / ignores
  • Loading branch information
ryma2fhir authored Nov 17, 2023
2 parents 6f3e5da + 863a332 commit a5e77dd
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions QualityControlChecker/QualityControlChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
parentDir = os.path.basename(parent)

'''Creates main variables for use with UKCore and NHSE assets'''
ukcoreVar = {'project':'UKCore','urlPrefix': 'https://fhir.hl7.org.uk/','codesystemPrefix':[],'org':'HL7 UK', 'email':'[email protected]'}
nhseVar = {'project':'England','urlPrefix': 'https://fhir.nhs.uk/England/', 'codesystemPrefix':['https://ord.nhs.uk/'],'org':'NHS England', 'email':'[email protected]'}
ukcoreVar = {'project':'UKCore','urlPrefix': 'https://fhir.hl7.org.uk/','ignoreURLPrefix':['http://hl7.org/fhir/5.0/'],'org':'HL7 UK', 'email':'[email protected]'}
nhseVar = {'project':'England','urlPrefix': 'https://fhir.nhs.uk/England/', 'ignoreURLPrefix':['http://hl7.org/fhir/5.0/','https://ord.nhs.uk/'],'org':'NHS England', 'email':'[email protected]'}
mainVar = {}
if 'ukcore' in parentDir.lower():
mainVar = ukcoreVar
Expand Down Expand Up @@ -99,20 +99,17 @@
fileName = '-'.join(fileName.split('-')[1:])
if not fileName == elements['id']:
warnings.append("\t\t"+elements['id']+" - the 'id' is incorrect")
if not elements['url'].startswith('http://hl7.org/fhir/5.0/'): #passes any R5 extensions
'''Check all url's unless they starts with one in the ignore list'''
uriCheck=True
for elem in mainVar['ignoreURLPrefix']:
if elements['url'].startswith(elem):
uriCheck=False
break
if uriCheck == True:
if not fileName == elements['url'].split('/')[-1]:
warnings.append("\t\t"+elements['url']+" - The 'url' element is incorrect")
if not elements['url'].startswith(mainVar['urlPrefix']+assets[path]):
if path == 'codesystems':
uriCheck = False
for elem in mainVar['codesystemPrefix']:
if elements['url'].startswith(elem+assets[path]):
uriCheck = True
break
if uriCheck == False:
warnings.append("\t\t"+elements['url']+" - The 'url' element prefix is not one of :"+str(mainVar['urlPrefix'])+", "+", ".join(mainVar['codesystemPrefix']))
else:
warnings.append("\t\t"+elements['url']+" - The 'url' element prefix is incorrect")
warnings.append("\t\t"+elements['url']+" - The 'url' element prefix is incorrect")
if not ''.join(fileName.split('-')) == elements['name'].split('/')[-1]:
warnings.append("\t\t"+elements['name']+" - The 'name' element is incorrect")
if not fileName.replace('-','') == elements['title'].replace(' ',''):
Expand Down

0 comments on commit a5e77dd

Please sign in to comment.