Skip to content
111 changes: 54 additions & 57 deletions api/consumer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,34 +333,28 @@ paths:
code: urn:ihe:pcc:handp:2008
display: History and Physical Specification
context:
encounter:
- identifier:
value: Encounter/4409815415
event:
- coding:
- system: http://snomed.info/sct
code: "305625009"
display: Seen by mental health counselor
code: "445627002"
display: Assessment using adult early warning scoring system
period:
start: "2022-12-20T09:00:41+11:00"
end: "2022-12-20T09:45:41+11:00"
facilityType:
coding:
- system: http://snomed.info/sct
code: "390826005"
display: Mental health caregiver support
code: "82242000"
display: Children's hospital
practiceSetting:
coding:
- system: http://snomed.info/sct
code: "390826005"
display: Mental health caregiver support
sourcePatientInfo:
identifier:
value: Patient/4409815415
code: "788002001"
display: Adult mental health service
related:
- identifier:
system: https://fhir.nhs.uk/Id/ods-organization-code
value: MENTAL HEALTH OUTREACH
system: https://fhir.nhs.uk/Id/nhsSpineASID
value: "200000000610"
headers:
X-Correlation-Id:
$ref: "#/components/headers/CorrelationId"
Expand Down Expand Up @@ -466,29 +460,28 @@ paths:
code: urn:ihe:pcc:cm:2008
display: Care Management
context:
encounter:
- identifier:
value: Encounter/4409815415
event:
- coding:
- system: http://snomed.info/sct
code: "861421000000109"
display: End of life care coordination summary
period:
start: "2022-12-21T09:00:41+11:00"
end: "2022-12-21T10:45:41+11:00"
facilityType:
coding:
- system: http://snomed.info/sct
code: "14866005"
display: Hospital outpatient mental health center
sourcePatientInfo:
identifier:
value: Patient/4409815415
related:
- identifier:
system: https://fhir.nhs.uk/Id/ods-organization-code
value: TRAFFORD GENERAL HOSPITAL
- event:
- coding:
system: http://snomed.info/sct
code: "445627002"
display: Assessment using adult early warning scoring system
- period:
start: "2022-12-20T09:00:41+11:00"
end: "2022-12-20T09:45:41+11:00"
- facilityType:
- coding:
system: http://snomed.info/sct
code: "82242000"
display: Children's hospital
- practiceSetting:
- coding:
system: http://snomed.info/sct
code: "788002001"
display: Adult mental health service
- related:
- identifier:
system: https://fhir.nhs.uk/Id/nhsSpineASID
value: "200000000610"
headers:
X-Correlation-Id:
$ref: "#/components/headers/CorrelationId"
Expand Down Expand Up @@ -579,26 +572,28 @@ paths:
code: urn:ihe:pcc:handp:2008
display: History and Physical Specification
context:
encounter:
- identifier:
value: Encounter/4409815415
event:
- coding:
- system: http://snomed.info/sct
code: "702779007"
display: Emergency health care plan agreed
period:
start: "2022-12-20T09:00:41+11:00"
end: "2022-12-20T09:45:41+11:00"
facilityType:
coding:
- system: http://snomed.info/sct
code: "453121000124107"
display: Emergency department healthcare professional
related:
- identifier:
system: https://fhir.nhs.uk/Id/ods-organization-code
value: EMERGENCY DEPT PRIMARY CARE STREAMING
- event:
- coding:
system: http://snomed.info/sct
code: "445627002"
display: Assessment using adult early warning scoring system
- period:
start: "2022-12-20T09:00:41+11:00"
end: "2022-12-20T09:45:41+11:00"
- facilityType:
- coding:
system: http://snomed.info/sct
code: "82242000"
display: Children's hospital
- practiceSetting:
- coding:
system: http://snomed.info/sct
code: "788002001"
display: Adult mental health service
- related:
- identifier:
system: https://fhir.nhs.uk/Id/nhsSpineASID
value: "200000000610"
headers:
X-Correlation-Id:
$ref: "#/components/headers/CorrelationId"
Expand Down Expand Up @@ -1057,6 +1052,8 @@ components:
items:
$ref: "#/components/schemas/Reference"
description: Related identifiers or resources associated with the DocumentReference.
required:
- practiceSetting
DocumentReferenceContent:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,21 @@ def test_create_document_reference_invalid_body():
"diagnostics": "Request body could not be parsed (content: Field required)",
"expression": ["content"],
},
{
"severity": "error",
"code": "invalid",
"details": {
"coding": [
{
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
"code": "MESSAGE_NOT_WELL_FORMED",
"display": "Message not well formed",
}
]
},
"diagnostics": "Request body could not be parsed (context: Field required)",
"expression": ["context"],
},
],
}

Expand Down Expand Up @@ -355,6 +370,47 @@ def test_create_document_reference_with_no_custodian():
}


def test_create_document_reference_with_no_practiceSetting():
doc_ref = load_document_reference("Y05868-736253002-Valid")
doc_ref.context.practiceSetting = None

event = create_test_api_gateway_event(
headers=create_headers(),
body=doc_ref.model_dump_json(exclude_none=True),
)

result = handler(event, create_mock_context())
body = result.pop("body")

assert result == {
"statusCode": "400",
"headers": default_response_headers(),
"isBase64Encoded": False,
}

parsed_body = json.loads(body)
assert parsed_body == {
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"details": {
"coding": [
{
"code": "MESSAGE_NOT_WELL_FORMED",
"display": "Message not well formed",
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
}
],
},
"diagnostics": "Request body could not be parsed (context.practiceSetting: Field required)",
"expression": ["context.practiceSetting"],
},
],
}


def test_create_document_reference_invalid_custodian_id():
doc_ref = load_document_reference("Y05868-736253002-Valid")

Expand Down
Loading