Skip to content

Commit aece092

Browse files
authored
Merge pull request #48 from NHSDigital/AMB-1743-complete-delete-endpoint
Amb 1743 complete delete endpoint
2 parents f3203a4 + fa32979 commit aece092

36 files changed

+829
-496
lines changed
File renamed without changes.

devtools/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test:
2+
python -m unittest
3+
4+
test-debug:
5+
./.venv/bin/pytest -s -v --color=yes -m debug
6+
7+
init:
8+
terraform init
9+
apply:
10+
terraform apply -auto-approve
11+
12+
13+
localstack:
14+
docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack:latest
15+
16+
.PHONY: test test-debug localstack apply init
File renamed without changes.
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ terraform {
1111
}
1212

1313
provider "aws" {
14-
region = "localhost"
14+
region = "us-east-1"
1515
skip_region_validation = true
1616

1717
endpoints {
@@ -21,7 +21,7 @@ provider "aws" {
2121
}
2222

2323
locals {
24-
short_prefix = "jaho3"
24+
short_prefix = "local"
2525
}
2626

2727
resource "aws_dynamodb_table" "test-dynamodb-table" {
@@ -33,21 +33,6 @@ resource "aws_dynamodb_table" "test-dynamodb-table" {
3333
name = "PK"
3434
type = "S"
3535
}
36-
attribute {
37-
name = "PatientPK"
38-
type = "S"
39-
}
40-
attribute {
41-
name = "PatientSK"
42-
type = "S"
43-
}
4436

45-
global_secondary_index {
46-
name = "PatientGSI"
47-
hash_key = "PatientPK"
48-
range_key = "PatientSK"
49-
projection_type = "INCLUDE"
50-
non_key_attributes = ["Event"]
51-
}
5237
}
5338

devtools/generate_data.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import copy
2+
import json
3+
import os
4+
import random
5+
import uuid
6+
from datetime import datetime
7+
8+
# generate reproducible random UUIDs
9+
rd = random.Random()
10+
rd.seed(0)
11+
12+
13+
def make_rand_id():
14+
return uuid.UUID(int=rd.getrandbits(128))
15+
16+
17+
patient_pool = [
18+
{"nhs_number": "9999999999", "dob": "1952-05-06"},
19+
{"nhs_number": "1111111111", "dob": "1987-02-23"},
20+
{"nhs_number": "1212233445", "dob": "1990-11-15"},
21+
]
22+
suppliers = [
23+
"https://supplierABC/ODSCode145", "https://supplierSDF/ODSCode123", "https://supplierXYZ/ODSCode735"
24+
]
25+
disease_type = ["covid", "flu", "mmr", "hpv", "polio"]
26+
vaccine_code = ["covidVaccine", "fluVaccine", "mmrVaccine", "hpvVaccine", "polioVaccine"]
27+
vaccine_procedure = ["vac_procedure-oral", "vac_procedure-injection", "vac_procedure-123"]
28+
local_patient_pool = [
29+
{"code": "ACME-Patient12345", "system": "https://supplierABC/identifiers/patient"},
30+
{"code": "ACME-Patient23455", "system": "https://supplierCSB/identifiers/patient"},
31+
{"code": "ACME-Patient35623", "system": "https://supplierXYZ/identifiers/patient"},
32+
]
33+
action_flag = ["flagA", "flagB"]
34+
35+
36+
def pick_rand(pool):
37+
idx = random.randint(0, len(pool) - 1)
38+
return pool[idx]
39+
40+
41+
def generate_immunisation(num):
42+
with open("sample_imms.json", "r") as template:
43+
imms = json.loads(template.read())
44+
45+
all_imms = []
46+
for _ in range(num):
47+
_imms = copy.deepcopy(imms)
48+
# ID
49+
_imms["id"] = str(make_rand_id())
50+
_imms["identifier"][0]["system"] = pick_rand(suppliers)
51+
_imms["identifier"][0]["value"] = str(make_rand_id())
52+
53+
all_imms.append(_imms)
54+
55+
return all_imms
56+
57+
58+
def write(_data, resource_type):
59+
path = "sample_data"
60+
if not os.path.exists(path):
61+
os.makedirs(path)
62+
63+
name = f"{datetime.today().strftime('%Y-%m-%dT%H:%M:%S')}_{resource_type}-{len(_data)}.json"
64+
with open(f"{path}/{name}", "w") as sample_file:
65+
json_events = json.dumps(_data, indent=2)
66+
sample_file.write(json_events)
67+
68+
69+
if __name__ == '__main__':
70+
imms = generate_immunisation(30)
71+
write(imms, resource_type="immunisation")
File renamed without changes.

0 commit comments

Comments
 (0)