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
85 changes: 85 additions & 0 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build NRL Project on Environment
run-name: Build NRL Project on ${{ inputs.environment || 'dev' }}
permissions:
id-token: write
contents: read
actions: write

on:
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
environment:
type: environment
description: "The environment to deploy changes to"
default: "dev"
required: true

jobs:
build:
name: Build - develop
runs-on: [self-hosted, ci]

steps:
- name: Git clone - develop
uses: actions/checkout@v4
with:
ref: develop

- name: Setup asdf cache
uses: actions/cache@v4
with:
path: ~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-

- name: Install asdf
uses: asdf-vm/actions/install@v3.0.2
with:
asdf_branch: v0.13.1

- name: Install zip
run: sudo apt-get install zip

- name: Setup Python environment
run: |
poetry install --no-root
source $(poetry env info --path)/bin/activate

- name: Run Linting
run: make lint

- name: Run Unit Tests
run: make test

- name: Build Project
run: make build

- name: Configure Management Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
role-session-name: github-actions-ci-${{ inputs.environment || 'dev' }}-${{ github.run_id }}

- name: Add S3 Permissions to Lambda
run: |
account=$(echo '${{ inputs.environment || 'dev' }}' | cut -d '-' -f1)
inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment || 'dev' }})
make get-s3-perms ENV=${account} TF_WORKSPACE_NAME=${inactive_stack}

- name: Save Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/*.zip
!dist/nrlf_permissions.zip

- name: Save NRLF Permissions cache
uses: actions/cache/save@v4
with:
key: ${{ github.run_id }}-nrlf-permissions
path: dist/nrlf_permissions.zip
2 changes: 1 addition & 1 deletion api/consumer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ components:
description: The status of this document reference.
docStatus:
type: string
pattern: "[^\\s]+(\\s[^\\s]+)*"
enum: ["entered-in-error", "amended", "preliminary", "final"]
description: The status of the underlying document.
type:
$ref: "#/components/schemas/CodeableConcept"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,47 @@ def test_create_document_reference_with_no_practiceSetting():
}


def test_create_document_reference_with_invalid_docStatus():
doc_ref = load_document_reference("Y05868-736253002-Valid")
doc_ref.docStatus = "invalid"

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 (docStatus: Input should be 'entered-in-error', 'amended', 'preliminary' or 'final')",
"expression": ["docStatus"],
},
],
}


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

Expand Down
2 changes: 1 addition & 1 deletion api/producer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ components:
description: The status of this document reference.
docStatus:
type: string
pattern: "[^\\s]+(\\s[^\\s]+)*"
enum: ["entered-in-error", "amended", "preliminary", "final"]
description: The status of the underlying document.
type:
$ref: "#/components/schemas/CodeableConcept"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,47 @@ def test_upsert_document_reference_with_no_practiceSetting():
}


def test_upsert_document_reference_with_invalid_docStatus():
doc_ref = load_document_reference("Y05868-736253002-Valid")
doc_ref.docStatus = "invalid"

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 (docStatus: Input should be 'entered-in-error', 'amended', 'preliminary' or 'final')",
"expression": ["docStatus"],
},
],
}


def test_upsert_document_reference_invalid_producer_id():
doc_ref = load_document_reference("Y05868-736253002-Valid")
doc_ref.id = "X26-99999-99999-999999"
Expand Down
9 changes: 3 additions & 6 deletions 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-12T13:19:56+00:00
# timestamp: 2024-12-13T11:19:30+00:00

from __future__ import annotations

Expand Down Expand Up @@ -669,11 +669,8 @@ class DocumentReference(BaseModel):
),
]
docStatus: Annotated[
Optional[str],
Field(
description="The status of the underlying document.",
pattern="[^\\s]+(\\s[^\\s]+)*",
),
Optional[Literal["entered-in-error", "amended", "preliminary", "final"]],
Field(description="The status of the underlying document."),
] = None
type: Annotated[
Optional[CodeableConcept],
Expand Down
Loading