Skip to content

Commit 2feeeaf

Browse files
committed
AMB-1739 use a rand functions instead of overwriting uuid4()
1 parent cd64693 commit 2feeeaf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

devtools/generate_data.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
import uuid
66
from datetime import datetime
77

8-
# we want to generate random UUIDs but, we want to make them reproducible
9-
# see: https://stackoverflow.com/a/56757552/3943054
8+
# generate reproducible random UUIDs
109
rd = random.Random()
1110
rd.seed(0)
12-
uuid.uuid4 = lambda: uuid.UUID(int=rd.getrandbits(128))
11+
12+
13+
def make_rand_id():
14+
return uuid.UUID(int=rd.getrandbits(128))
15+
1316

1417
patient_pool = [
1518
{"nhs_number": "9999999999", "dob": "1952-05-06"},
@@ -43,9 +46,9 @@ def generate_immunisation(num):
4346
for _ in range(num):
4447
_imms = copy.deepcopy(imms)
4548
# ID
46-
_imms["id"] = str(uuid.uuid4())
49+
_imms["id"] = str(make_rand_id())
4750
_imms["identifier"][0]["system"] = pick_rand(suppliers)
48-
_imms["identifier"][0]["value"] = str(uuid.uuid4())
51+
_imms["identifier"][0]["value"] = str(make_rand_id())
4952

5053
all_imms.append(_imms)
5154

0 commit comments

Comments
 (0)