Skip to content

Commit 96a3122

Browse files
authored
Merge branch 'master' into dependabot/pip/ack_backend/pip-minor-patch-c8bd5c726d
2 parents d017182 + 537339e commit 96a3122

22 files changed

+186
-108
lines changed

backend/src/fhir_service.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@
2929
logging.basicConfig(level="INFO")
3030
logger = logging.getLogger()
3131

32-
def get_service_url(
33-
service_env: str = os.getenv("IMMUNIZATION_ENV"),
34-
service_base_path: str = os.getenv("IMMUNIZATION_BASE_PATH"),
35-
):
32+
def get_service_url(service_env: str = os.getenv("IMMUNIZATION_ENV"), service_base_path: str = os.getenv("IMMUNIZATION_BASE_PATH")
33+
) -> str:
34+
35+
if not service_base_path:
36+
service_base_path = "immunisation-fhir-api/FHIR/R4"
37+
3638
non_prod = ["internal-dev", "int", "sandbox"]
3739
if service_env in non_prod:
3840
subdomain = f"{service_env}."
3941
elif service_env == "prod":
4042
subdomain = ""
4143
else:
4244
subdomain = "internal-dev."
45+
4346
return f"https://{subdomain}api.service.nhs.uk/{service_base_path}"
4447

4548

@@ -366,7 +369,7 @@ def search_immunizations(
366369
BundleEntry(
367370
resource=Immunization.parse_obj(imms),
368371
search=BundleEntrySearch(mode="match"),
369-
fullUrl=f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{imms['id']}",
372+
fullUrl=f"{get_service_url()}/Immunization/{imms['id']}",
370373
)
371374
for imms in resources_filtered_for_search
372375
]

backend/tests/test_fhir_service.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import uuid
33
import datetime
44
import unittest
5-
from unittest.mock import MagicMock
5+
import os
6+
from unittest.mock import MagicMock, patch
67
from copy import deepcopy
78
from unittest.mock import create_autospec, patch
89
from decimal import Decimal
@@ -54,22 +55,22 @@ def tearDown(self):
5455
def test_get_service_url(self):
5556
"""it should create service url"""
5657
env = "int"
57-
base_path = "my-base-path"
58+
base_path = "immunisation-fhir-api/FHIR/R4"
5859
url = get_service_url(env, base_path)
5960
self.assertEqual(url, f"https://{env}.api.service.nhs.uk/{base_path}")
6061
# default should be internal-dev
6162
env = "it-does-not-exist"
62-
base_path = "my-base-path"
63+
base_path = "immunisation-fhir-api/FHIR/R4"
6364
url = get_service_url(env, base_path)
6465
self.assertEqual(url, f"https://internal-dev.api.service.nhs.uk/{base_path}")
6566
# prod should not have a subdomain
6667
env = "prod"
67-
base_path = "my-base-path"
68+
base_path = "immunisation-fhir-api/FHIR/R4"
6869
url = get_service_url(env, base_path)
6970
self.assertEqual(url, f"https://api.service.nhs.uk/{base_path}")
7071
# any other env should fall back to internal-dev (like pr-xx or per-user)
7172
env = "pr-42"
72-
base_path = "my-base-path"
73+
base_path = "immunisation-fhir-api/FHIR/R4"
7374
url = get_service_url(env, base_path)
7475
self.assertEqual(url, f"https://internal-dev.api.service.nhs.uk/{base_path}")
7576

@@ -772,6 +773,8 @@ class TestSearchImmunizations(unittest.TestCase):
772773
MOCK_SUPPLIER_SYSTEM_NAME = "Test"
773774

774775
def setUp(self):
776+
os.environ["IMMUNIZATION_ENV"] = "internal-dev"
777+
os.environ["IMMUNIZATION_BASE_PATH"] = "immunisation-fhir-api/FHIR/R4"
775778
self.authoriser = create_autospec(Authoriser)
776779
self.imms_repo = create_autospec(ImmunizationRepository)
777780
self.validator = create_autospec(ImmunizationValidator)
@@ -1083,7 +1086,6 @@ def test_matches_contain_fullUrl(self):
10831086
"""All matches must have a fullUrl consisting of their id.
10841087
See http://hl7.org/fhir/R4B/bundle-definitions.html#Bundle.entry.fullUrl.
10851088
Tested because fhir.resources validation doesn't check this as mandatory."""
1086-
10871089
imms_ids = ["imms-1", "imms-2"]
10881090
imms_list = [create_covid_19_immunization_dict(imms_id) for imms_id in imms_ids]
10891091
self.imms_repo.find_immunizations.return_value = imms_list
@@ -1100,14 +1102,13 @@ def test_matches_contain_fullUrl(self):
11001102
for i, entry in enumerate(entries):
11011103
self.assertEqual(
11021104
entry.fullUrl,
1103-
f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{imms_ids[i]}",
1105+
f"https://internal-dev.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/Immunization/{imms_ids[i]}",
11041106
)
11051107

11061108
def test_patient_contains_fullUrl(self):
11071109
"""Patient must have a fullUrl consisting of its id.
11081110
See http://hl7.org/fhir/R4B/bundle-definitions.html#Bundle.entry.fullUrl.
11091111
Tested because fhir.resources validation doesn't check this as mandatory."""
1110-
11111112
imms_ids = ["imms-1", "imms-2"]
11121113
imms_list = [create_covid_19_immunization_dict(imms_id) for imms_id in imms_ids]
11131114
self.imms_repo.find_immunizations.return_value = imms_list

config/dev/permissions_config.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22
{
33
"supplier": "DPSFULL",
44
"permissions": [
5+
"3IN1.CRUDS",
56
"COVID19.CRUDS",
67
"FLU.CRUDS",
7-
"MMR.CRUDS",
8-
"RSV.CRUDS",
98
"HPV.CRUDS",
109
"MENACWY.CRUDS",
11-
"3IN1.CRUDS"
10+
"MMR.CRUDS",
11+
"RSV.CRUDS"
1212
],
1313
"ods_codes": ["DPSFULL"]
1414
},
1515
{
1616
"supplier": "DPSREDUCED",
1717
"permissions": [
18+
"3IN1.CRUDS",
1819
"COVID19.CRUDS",
1920
"FLU.CRUDS",
20-
"MMR.CRUDS",
21-
"RSV.CRUDS",
2221
"HPV.CRUDS",
2322
"MENACWY.CRUDS",
24-
"3IN1.CRUDS"
23+
"MMR.CRUDS",
24+
"RSV.CRUDS"
2525
],
2626
"ods_codes": ["DPSREDUCED"]
2727
},
2828
{
2929
"supplier": "MAVIS",
3030
"permissions": [
31-
"HPV.CRUDS",
3231
"3IN1.CRUDS",
32+
"FLU.CRUDS",
33+
"HPV.CRUDS",
3334
"MENACWY.CRUDS",
34-
"MMR.CRUDS",
35-
"FLU.CRUDS"
35+
"MMR.CRUDS"
3636
],
3737
"ods_codes": ["V0V8L"]
3838
},
@@ -48,39 +48,39 @@
4848
},
4949
{
5050
"supplier": "RAVS",
51-
"permissions": ["RSV.CRUDS", "MMR.CRUDS"],
51+
"permissions": ["MMR.CRUDS", "RSV.CRUDS"],
5252
"ods_codes": ["X26", "X8E5B"]
5353
},
5454
{
5555
"supplier": "EMIS",
5656
"permissions": [
57-
"RSV.CRUDS",
58-
"MMR.CRUDS",
59-
"HPV.CRUDS",
6057
"3IN1.CRUDS",
61-
"MENACWY.CRUDS"
58+
"HPV.CRUDS",
59+
"MENACWY.CRUDS",
60+
"MMR.CRUDS",
61+
"RSV.CRUDS"
6262
],
6363
"ods_codes": ["YGM41", "YGJ"]
6464
},
6565
{
6666
"supplier": "TPP",
6767
"permissions": [
68-
"RSV.CRUDS",
69-
"MMR.CRUDS",
70-
"HPV.CRUDS",
7168
"3IN1.CRUDS",
72-
"MENACWY.CRUDS"
69+
"HPV.CRUDS",
70+
"MENACWY.CRUDS",
71+
"MMR.CRUDS",
72+
"RSV.CRUDS"
7373
],
7474
"ods_codes": ["YGA"]
7575
},
7676
{
7777
"supplier": "MEDICUS",
7878
"permissions": [
79-
"RSV.CRUDS",
80-
"MMR.CRUDS",
81-
"HPV.CRUDS",
8279
"3IN1.CRUDS",
83-
"MENACWY.CRUDS"
80+
"HPV.CRUDS",
81+
"MENACWY.CRUDS",
82+
"MMR.CRUDS",
83+
"RSV.CRUDS"
8484
],
8585
"ods_codes": ["YGMYW"]
8686
},
@@ -131,25 +131,25 @@
131131
{
132132
"supplier": "Test_App",
133133
"permissions": [
134+
"3IN1.CRUDS",
134135
"COVID19.CRUDS",
135136
"FLU.CRUDS",
136-
"MMR.CRUDS",
137-
"RSV.CRUDS",
138137
"HPV.CRUDS",
139138
"MENACWY.CRUDS",
140-
"3IN1.CRUDS"
139+
"MMR.CRUDS",
140+
"RSV.CRUDS"
141141
]
142142
},
143143
{
144144
"supplier": "Postman_Auth",
145145
"permissions": [
146+
"3IN1.CRUDS",
146147
"COVID19.CRUDS",
147148
"FLU.CRUDS",
148-
"MMR.CRUDS",
149-
"RSV.CRUDS",
150149
"HPV.CRUDS",
151150
"MENACWY.CRUDS",
152-
"3IN1.CRUDS"
151+
"MMR.CRUDS",
152+
"RSV.CRUDS"
153153
]
154154
}
155155
]

config/preprod/permissions_config.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,100 @@
22
{
33
"supplier": "DPSFULL",
44
"permissions": [
5+
"3IN1.CRUDS",
56
"COVID19.CRUDS",
67
"FLU.CRUDS",
7-
"MMR.CRUDS",
8-
"RSV.CRUDS",
98
"HPV.CRUDS",
109
"MENACWY.CRUDS",
11-
"3IN1.CRUDS"
10+
"MMR.CRUDS",
11+
"RSV.CRUDS"
1212
],
1313
"ods_codes": ["DPSFULL"]
1414
},
1515
{
1616
"supplier": "DPSREDUCED",
1717
"permissions": [
18+
"3IN1.CRUDS",
1819
"COVID19.CRUDS",
1920
"FLU.CRUDS",
20-
"MMR.CRUDS",
21-
"RSV.CRUDS",
2221
"HPV.CRUDS",
2322
"MENACWY.CRUDS",
24-
"3IN1.CRUDS"
23+
"MMR.CRUDS",
24+
"RSV.CRUDS"
2525
],
2626
"ods_codes": ["DPSREDUCED"]
2727
},
2828
{
2929
"supplier": "MAVIS",
3030
"permissions": [
31-
"HPV.CRUDS",
3231
"3IN1.CRUDS",
32+
"FLU.CRUDS",
33+
"HPV.CRUDS",
3334
"MENACWY.CRUDS",
34-
"MMR.CRUDS",
35-
"FLU.CRUDS"
35+
"MMR.CRUDS"
3636
],
3737
"ods_codes": ["V0V8L"]
3838
},
3939
{
4040
"supplier": "RAVS",
41-
"permissions": ["RSV.CRUDS", "MMR.CRUDS"],
41+
"permissions": ["MMR.CRUDS", "RSV.CRUDS"],
4242
"ods_codes": ["X26", "X8E5B"]
4343
},
4444
{
4545
"supplier": "EMIS",
4646
"permissions": [
47-
"RSV.CRUDS",
48-
"MMR.CRUDS",
49-
"HPV.CRUDS",
5047
"3IN1.CRUDS",
51-
"MENACWY.CRUDS"
48+
"HPV.CRUDS",
49+
"MENACWY.CRUDS",
50+
"MMR.CRUDS",
51+
"RSV.CRUDS"
5252
],
5353
"ods_codes": ["YGM41", "YGJ"]
5454
},
5555
{
5656
"supplier": "TPP",
5757
"permissions": [
58-
"RSV.CRUDS",
59-
"MMR.CRUDS",
60-
"HPV.CRUDS",
6158
"3IN1.CRUDS",
62-
"MENACWY.CRUDS"
59+
"HPV.CRUDS",
60+
"MENACWY.CRUDS",
61+
"MMR.CRUDS",
62+
"RSV.CRUDS"
6363
],
6464
"ods_codes": ["YGA"]
6565
},
6666
{
6767
"supplier": "MEDICUS",
6868
"permissions": [
69-
"RSV.CRUDS",
70-
"MMR.CRUDS",
71-
"HPV.CRUDS",
7269
"3IN1.CRUDS",
73-
"MENACWY.CRUDS"
70+
"HPV.CRUDS",
71+
"MENACWY.CRUDS",
72+
"MMR.CRUDS",
73+
"RSV.CRUDS"
7474
],
7575
"ods_codes": ["YGMYW"]
7676
},
7777
{
7878
"supplier": "Test_App",
7979
"permissions": [
80+
"3IN1.CRUDS",
8081
"COVID19.CRUDS",
8182
"FLU.CRUDS",
82-
"MMR.CRUDS",
83-
"RSV.CRUDS",
8483
"HPV.CRUDS",
8584
"MENACWY.CRUDS",
86-
"3IN1.CRUDS"
85+
"MMR.CRUDS",
86+
"RSV.CRUDS"
8787
]
8888
},
8989
{
9090
"supplier": "Postman_Auth",
9191
"permissions": [
92+
"3IN1.CRUDS",
9293
"COVID19.CRUDS",
9394
"FLU.CRUDS",
94-
"MMR.CRUDS",
95-
"RSV.CRUDS",
9695
"HPV.CRUDS",
9796
"MENACWY.CRUDS",
98-
"3IN1.CRUDS"
97+
"MMR.CRUDS",
98+
"RSV.CRUDS"
9999
]
100100
},
101101
{

0 commit comments

Comments
 (0)