Skip to content

Commit 5c621d0

Browse files
committed
NPA-3899 Add More Examples to Sandbox
1 parent 93247b7 commit 5c621d0

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

sandbox/api/app.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
VALIDATE_RELATIONSHIP_INCLUDE_009,
2424
VALIDATE_RELATIONSHIP_INCLUDE_025,
2525
INTERNAL_SERVER_ERROR_EXAMPLE,
26+
CONSENT__ADULT_CONSENTING_EXAMPLE,
27+
CONSENT__MIXED_EXAMPLE,
28+
CONSENT__MOTHER_CHILD_EXAMPLE,
29+
CONSENT_PERFORMER,
2630
)
2731

2832
app = Flask(__name__)
@@ -122,8 +126,30 @@ def get_consent() -> Union[dict, tuple]:
122126
Union[dict, tuple]: Response for GET /Consent
123127
"""
124128
try:
125-
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)
126-
129+
performer_identifier = remove_system(request.args.get("performer:identifier"))
130+
status = request.args.get("status")
131+
_include = request.args.get("_include")
132+
133+
if (
134+
performer_identifier == "9000000017"
135+
and status == "active"
136+
and _include == CONSENT_PERFORMER
137+
):
138+
return generate_response_from_example(
139+
CONSENT__ADULT_CONSENTING_EXAMPLE, 200
140+
)
141+
elif (
142+
performer_identifier == "9000000016"
143+
and status == "active"
144+
and _include == CONSENT_PERFORMER
145+
):
146+
return generate_response_from_example(CONSENT__MIXED_EXAMPLE, 200)
147+
elif (
148+
performer_identifier == "9000000015"
149+
and status == "active"
150+
and _include == CONSENT_PERFORMER
151+
):
152+
return generate_response_from_example(CONSENT__MOTHER_CHILD_EXAMPLE, 200)
127153
# else:
128154
# logger.error(e)
129155
# return generate_response(load_json_file(ERROR_RESPONSE), 400)

sandbox/api/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,12 @@
2828
PATIENT_IDENTIFIERS = ["9000000017", "9000000033"]
2929
RELATED_IDENTIFIERS = ["9000000009", "9000000025"]
3030

31+
CONSENT_PERFORMER = "Consent:performer"
32+
3133
# Example files
34+
## Common examples
3235
INTERNAL_SERVER_ERROR_EXAMPLE = "./api/examples/errors/internal-server-error.yaml"
36+
## Consent examples
37+
CONSENT__ADULT_CONSENTING_EXAMPLE = "./api/examples/GET_Consent/adults-consenting.yaml"
38+
CONSENT__MIXED_EXAMPLE = "./api/examples/GET_Consent/mixed.yaml"
39+
CONSENT__MOTHER_CHILD_EXAMPLE = "./api/examples/GET_Consent/mother-child.yaml"

0 commit comments

Comments
 (0)