Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,36 @@ def test_create_document_reference_invalid_body():
"diagnostics": "Request body could not be parsed (status: Field required)",
"expression": ["status"],
},
{
"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 (type: Field required)",
"expression": ["type"],
},
{
"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 (category: Field required)",
"expression": ["category"],
},
{
"severity": "error",
"code": "invalid",
Expand Down
89 changes: 71 additions & 18 deletions api/producer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1354,12 +1354,12 @@ components:
enum: ["entered-in-error", "amended", "preliminary", "final"]
description: The status of the underlying document.
type:
$ref: "#/components/schemas/CodeableConcept"
$ref: "#/components/schemas/NRLCodeableConcept"
description: Specifies the particular kind of document referenced (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.
category:
type: array
items:
$ref: "#/components/schemas/CodeableConcept"
$ref: "#/components/schemas/NRLCodeableConcept"
description: A categorization for the type of document referenced – helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.
subject:
$ref: "#/components/schemas/Reference"
Expand All @@ -1386,7 +1386,7 @@ components:
description: Relationships that this document has with other document references that already exist.
description:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: Human–readable description of the source document.
securityLabel:
type: array
Expand All @@ -1408,6 +1408,8 @@ components:
- content
- author
- context
- type
- category
Bundle:
type: object
properties:
Expand Down Expand Up @@ -1607,7 +1609,7 @@ components:
$ref: "#/components/schemas/CodeableConcept"
description: The kind of facility where the patient was seen.
practiceSetting:
$ref: "#/components/schemas/CodeableConcept"
$ref: "#/components/schemas/NRLCodeableConcept"
description: This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.
sourcePatientInfo:
$ref: "#/components/schemas/Reference"
Expand Down Expand Up @@ -1693,7 +1695,7 @@ components:
description: The calculated hash of the data using SHA–1. Represented using base64.
title:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A label or set of text to display in place of the data.
creation:
type: string
Expand All @@ -1716,8 +1718,29 @@ components:
description: A reference to a code defined by a terminology system.
text:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A human language representation of the concept as seen/selected/uttered by the user who entered the data and/or which represents the intended meaning of the user.
NRLCodeableConcept:
type: object
properties:
id:
type: string
pattern: "[A-Za-z0-9\\-\\.]{1,64}"
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
coding:
type: array
items:
$ref: "#/components/schemas/NRLCoding"
description: A reference to a code defined by a terminology system.
minItems: 1
maxItems: 1
text:
type: string
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A human language representation of the concept as seen/selected/uttered by the user who entered the data and/or which represents the intended meaning of the user.
required:
- coding

Coding:
type: object
properties:
Expand All @@ -1727,23 +1750,53 @@ components:
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
system:
type: string
pattern: \S*
pattern: \S+
description: The identification of the code system that defines the meaning of the symbol in the code.
version:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: The version of the code system which was used when choosing this code. Note that a well–maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured, and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.
code:
type: string
pattern: "[^\\s]+(\\s[^\\s]+)*"
description: A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post–coordination).
display:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A representation of the meaning of the code in the system, following the rules of the system.
userSelected:
type: boolean
description: Indicates that this coding was chosen by a user directly – e.g. off a pick list of available items (codes or displays).
NRLCoding:
type: object
properties:
id:
type: string
pattern: "[A-Za-z0-9\\-\\.]{1,64}"
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
system:
type: string
pattern: \S+
description: The identification of the code system that defines the meaning of the symbol in the code.
version:
type: string
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: The version of the code system which was used when choosing this code. Note that a well–maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured, and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.
code:
type: string
pattern: "[^\\s]+(\\s[^\\s]+)*"
description: A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post–coordination).
display:
type: string
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A representation of the meaning of the code in the system, following the rules of the system.
userSelected:
type: boolean
description: Indicates that this coding was chosen by a user directly – e.g. off a pick list of available items (codes or displays).
required:
- system
- code
- display
Extension:
type: object
properties:
Expand Down Expand Up @@ -1842,11 +1895,11 @@ components:
description: A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.
system:
type: string
pattern: \S*
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: Establishes the namespace for the value – that is, a URL that describes a set values that are unique.
value:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: The portion of the identifier typically relevant to the user and which is unique within the context of the system.
period:
$ref: "#/components/schemas/Period"
Expand Down Expand Up @@ -1885,11 +1938,11 @@ components:
description: How the value should be understood and represented &ndash; whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
unit:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A human&ndash;readable form of the unit.
system:
type: string
pattern: \S*
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: The identification of the system that provides the coded form of the unit.
code:
type: string
Expand All @@ -1904,11 +1957,11 @@ components:
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
reference:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
type:
type: string
pattern: \S*
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: |-
The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
Expand All @@ -1917,7 +1970,7 @@ components:
description: An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
display:
type: string
pattern: "[ \\r\\n\\t\\S]+"
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: Plain text narrative that identifies the resource in addition to the resource reference.
Signature:
type: object
Expand Down Expand Up @@ -1975,13 +2028,13 @@ components:
description: When the resource last changed &ndash; e.g. when the version changed.
source:
type: string
pattern: \S*
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A uri that identifies the source system of the resource. This provides a minimal amount of [Provenance](provenance.html#) information that can be used to track or differentiate the source of information in the resource. The source may identify another FHIR server, document, message, database, etc.
profile:
type: array
items:
type: string
pattern: \S*
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
description: A list of profiles (references to [StructureDefinition](structuredefinition.html#) resources) that this resource claims to conform to. The URL is a reference to [StructureDefinition.url](structuredefinition&ndash;definitions.html#StructureDefinition.url).
security:
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_create_document_reference_no_body():
}


def test_create_document_reference_invalid_body():
def test_update_document_reference_invalid_body():
event = create_test_api_gateway_event(
headers=create_headers(),
path_parameters={"id": "Y05868-99999-99999-999999"},
Expand Down Expand Up @@ -246,6 +246,36 @@ def test_create_document_reference_invalid_body():
"diagnostics": "Request body could not be parsed (status: Field required)",
"expression": ["status"],
},
{
"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 (type: Field required)",
"expression": ["type"],
},
{
"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 (category: Field required)",
"expression": ["category"],
},
{
"severity": "error",
"code": "invalid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,36 @@ def test_upsert_document_reference_invalid_body():
"diagnostics": "Request body could not be parsed (status: Field required)",
"expression": ["status"],
},
{
"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 (type: Field required)",
"expression": ["type"],
},
{
"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 (category: Field required)",
"expression": ["category"],
},
{
"severity": "error",
"code": "invalid",
Expand Down
2 changes: 1 addition & 1 deletion layer/nrlf/consumer/fhir/r4/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: swagger.yaml
# timestamp: 2024-12-13T11:19:30+00:00
# timestamp: 2025-01-27T09:26:33+00:00

from __future__ import annotations

Expand Down
25 changes: 1 addition & 24 deletions layer/nrlf/core/dynamodb/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from nrlf.core.constants import PointerTypes
from nrlf.core.dynamodb.model import DocumentPointer, DynamoDBModel
from nrlf.core.utils import create_fhir_instant
from nrlf.producer.fhir.r4.model import DocumentReference
from nrlf.tests.data import load_document_reference, load_document_reference_json
from nrlf.tests.data import load_document_reference


def test_dynamodb_model_init():
Expand Down Expand Up @@ -159,28 +158,6 @@ def test_document_pointer_from_document_reference_invalid():
assert str(error.value) == "'NoneType' object has no attribute 'coding'"


def test_document_pointer_from_document_reference_multiple_types():
doc_ref_data = load_document_reference_json("Y05868-736253002-Valid")
doc_ref = DocumentReference.model_validate(
{
**doc_ref_data,
"type": {
"coding": [
{"system": "http://snomed.info/sct", "code": "123456789"},
{"system": "http://snomed.info/sct", "code": "987654321"},
]
},
}
)

with pytest.raises(ValueError) as error:
DocumentPointer.from_document_reference(doc_ref)

assert (
str(error.value) == "DocumentReference.type.coding must have exactly one item"
)


def test_document_pointer_extract_custodian_suffix_no_suffix():
values = {"custodian": "X26", "custodian_suffix": None}

Expand Down
Loading