Skip to content

Commit 4319d55

Browse files
Merge branch 'main' into task/FTRS-1623-fix-address-multiline-and-not-available
2 parents 5127885 + 556d8f0 commit 4319d55

File tree

31 files changed

+796
-317
lines changed

31 files changed

+796
-317
lines changed

.github/actions/deploy-to-apim/action.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ inputs:
66
description: 'Name of the API to deploy'
77
required: true
88
workspace:
9-
description: 'Workspace identifier (e.g., FTRS-000)'
10-
required: true
9+
description: 'Workspace identifier (e.g., FTRS-000). If specified, a workspaced proxy will be deployed into the APIM environment'
10+
required: false
1111
environment:
12-
description: 'FTRS environment to deploy to (e.g., dev, test, prod)'
12+
description: ' The environment our target backend is deployed to. (e.g., dev, test, prod)'
1313
required: true
1414
apim_env:
15-
description: 'APIM environment to deploy the API Proxy into (e.g., internal-dev)'
15+
description: 'APIM environment to deploy the API Proxy into (e.g., internal-dev, internal-qa, int, ref, prod)'
1616
required: true
1717
access_token:
1818
description: 'Access Token for the Proxygen API'
@@ -42,19 +42,26 @@ runs:
4242
if: ${{ !contains(inputs.apim_env, 'sandbox') }}
4343
shell: bash
4444
run: |
45-
if [[ ! "${{ inputs.workspace }}" =~ ^ftrs-[0-9]+$ ]]; then
45+
# Skip validation if workspace is not provided or is 'default' (e.g., for int environment)
46+
if [ -z "${{ inputs.workspace }}" ] || [ "${{ inputs.workspace }}" == "default" ]; then
47+
echo "No workspace provided or default workspace - skipping validation (environment: ${{ inputs.environment }})"
48+
elif [[ ! "${{ inputs.workspace }}" =~ ^ftrs-[0-9]+$ ]]; then
4649
echo "Error: Workspace must be in format ftrs-#### (e.g., ftrs-1234, ftrs-001, ftrs-99999)"
4750
exit 1
51+
else
52+
echo "Workspace format validated: ${{ inputs.workspace }}"
4853
fi
49-
echo "Workspace format validated: ${{ inputs.workspace }}"
5054
5155
- name: Modify OAS Specification
5256
if: ${{ !contains(inputs.apim_env, 'sandbox') }}
5357
id: modify-spec
5458
shell: bash
5559
run: |
5660
export API_NAME="${{ inputs.api_name }}"
57-
export WORKSPACE="${{ inputs.workspace }}"
61+
# Only set WORKSPACE if it's not empty and not 'default'
62+
if [ -n "${{ inputs.workspace }}" ] && [ "${{ inputs.workspace }}" != "default" ]; then
63+
export WORKSPACE="${{ inputs.workspace }}"
64+
fi
5865
export PROXY_ENV="${{ inputs.apim_env }}"
5966
6067
chmod +x ./scripts/workflow/modify-oas-spec.sh
@@ -94,7 +101,10 @@ runs:
94101
shell: bash
95102
run: |
96103
export API_NAME="${{ inputs.api_name }}"
97-
export WORKSPACE="${{ inputs.workspace }}"
104+
# Only set WORKSPACE if it's not empty and not 'default'
105+
if [ -n "${{ inputs.workspace }}" ] && [ "${{ inputs.workspace }}" != "default" ]; then
106+
export WORKSPACE="${{ inputs.workspace }}"
107+
fi
98108
export PROXY_ENV="${{ inputs.apim_env }}"
99109
export ACCESS_TOKEN="${{ inputs.access_token }}"
100110
export PROXYGEN_URL="${{ inputs.proxygen_url }}"

.github/workflows/authenticate-and-deploy-to-apim.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ on:
1212
required: true
1313
type: string
1414
workspace:
15-
description: 'Workspace identifier (e.g., FTRS-000)'
16-
required: true
15+
description: 'Workspace identifier (e.g., FTRS-000). Deploys a workspaced proxy into the APIM environment if specified.'
16+
required: false
1717
type: string
1818
api_name:
1919
description: 'API name to deploy'
2020
required: true
2121
type: string
2222
apim_env:
23-
description: 'APIM environment to deploy to (e.g., internal-dev)'
23+
description: 'APIM environment to deploy to (e.g., internal-dev, internal-qa, int, ref, prod)'
2424
required: true
2525
type: string
2626
secrets:

.github/workflows/pipeline-deploy-application.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ jobs:
133133
secrets: inherit
134134

135135
deploy-proxy-to-apim:
136-
name: "Authenticate and Deploy ${{ matrix.api_name }} API to Proxygen in ${{ needs.metadata.outputs.environment }}"
137-
if: needs.metadata.outputs.environment == 'dev' && github.ref != 'refs/heads/main' # TODO: Update condition once further environment work is complete
136+
name: "Deploy ${{ matrix.api_name }} API to Proxygen"
138137
needs:
139138
- metadata
140139
- deploy-application-infrastructure
@@ -148,7 +147,7 @@ jobs:
148147
environment: ${{ needs.metadata.outputs.environment }}
149148
workspace: ${{ needs.metadata.outputs.workspace }}
150149
api_name: ${{ matrix.api_name }}
151-
apim_env: "internal-dev"
150+
apim_env: ${{ needs.metadata.outputs.environment == 'dev' && 'internal-dev' || needs.metadata.outputs.environment == 'test' && 'internal-qa' || needs.metadata.outputs.environment }}
152151
secrets:
153152
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
154153
AWS_REGION: ${{ vars.AWS_REGION }}
Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
from fhir.resources.R4B.operationoutcome import OperationOutcome, OperationOutcomeIssue
22
from pydantic import ValidationError
33

4+
OPERATION_OUTCOME_SYSTEM = "http://terminology.hl7.org/CodeSystem/operation-outcome"
5+
6+
FHIR_OPERATION_OUTCOME_CODES: dict[str, tuple[str, str]] = {
7+
"invalid": ("MSG_PARAM_INVALID", "Parameter content is invalid"),
8+
"not-found": ("MSG_NO_EXIST", "Resource does not exist"),
9+
"exception": ("MSG_ERROR_PARSING", "Error processing request"),
10+
"structure": ("MSG_BAD_SYNTAX", "Bad Syntax"),
11+
"required": ("MSG_RESOURCE_REQUIRED", "A resource is required"),
12+
"value": ("MSG_PARAM_INVALID", "Parameter content is invalid"),
13+
"processing": ("MSG_ERROR_PARSING", "Error processing request"),
14+
"duplicate": ("MSG_DUPLICATE_ID", "Duplicate Id for resource"),
15+
"informational": ("MSG_UPDATED", "Existing resource updated"),
16+
"success": ("MSG_UPDATED", "Existing resource updated"),
17+
}
18+
419

520
class OperationOutcomeException(Exception):
621
def __init__(self, outcome: dict) -> None:
@@ -18,21 +33,47 @@ class OperationOutcomeHandler:
1833
"""
1934

2035
@staticmethod
21-
def build(
36+
def _build_details(code: str, text: str) -> dict:
37+
fhir_code, display = FHIR_OPERATION_OUTCOME_CODES.get(
38+
code, ("MSG_ERROR_PARSING", "Error processing request")
39+
)
40+
return {
41+
"coding": [
42+
{
43+
"system": OPERATION_OUTCOME_SYSTEM,
44+
"code": fhir_code,
45+
"display": display,
46+
}
47+
],
48+
"text": text,
49+
}
50+
51+
@staticmethod
52+
def build( # noqa: PLR0913
2253
diagnostics: str,
2354
code: str = "invalid",
2455
severity: str = "error",
56+
details_text: str | None = None,
2557
details: dict | None = None,
58+
expression: list[str] | None = None,
2659
issues: list | None = None,
2760
) -> dict:
2861
if issues is None:
29-
issue_dict = {
62+
if details is None:
63+
details = OperationOutcomeHandler._build_details(
64+
code, details_text or diagnostics
65+
)
66+
67+
issue_dict: dict = {
3068
"severity": severity,
3169
"code": code,
70+
"details": details,
3271
"diagnostics": diagnostics,
3372
}
34-
if details:
35-
issue_dict["details"] = details
73+
74+
if expression:
75+
issue_dict["expression"] = expression
76+
3677
issues = [issue_dict]
3778

3879
fhir_issues = [OperationOutcomeIssue(**issue) for issue in issues]
@@ -48,42 +89,20 @@ def from_exception(
4889
"""
4990
Build an OperationOutcome from an exception.
5091
"""
51-
details = {
52-
"coding": [
53-
{
54-
"system": "http://terminology.hl7.org/CodeSystem/operation-outcome",
55-
"code": "exception",
56-
"display": "Exception",
57-
}
58-
],
59-
"text": f"An unexpected error occurred: {str(exc)}",
60-
}
61-
6292
return OperationOutcomeHandler.build(
6393
diagnostics=str(exc),
6494
code=code,
6595
severity=severity,
66-
details=details,
96+
details_text=f"An unexpected error occurred: {exc}",
6797
)
6898

6999
@staticmethod
70100
def from_validation_error(
71101
e: ValidationError,
72102
) -> dict:
73-
details = {
74-
"coding": [
75-
{
76-
"system": "http://terminology.hl7.org/CodeSystem/operation-outcome",
77-
"code": "invalid",
78-
"display": "Invalid Resource",
79-
}
80-
],
81-
"text": str(e),
82-
}
83-
84103
return OperationOutcomeHandler.build(
85104
diagnostics="Validation failed for resource.",
86105
code="invalid",
87106
severity="error",
88-
details=details,
107+
details_text=str(e),
89108
)

application/packages/python/ftrs_common/fhir/r4b/organisation_mapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class OrganizationMapper(FhirMapper):
3030
# --- FHIR Builders ---
3131
def _build_meta_profile(self) -> dict:
3232
return {
33-
"profile": ["https://fhir.nhs.uk/StructureDefinition/UKCore-Organization"]
33+
"profile": [
34+
"https://fhir.hl7.org.uk/StructureDefinition/UKCore-Organization"
35+
]
3436
}
3537

3638
def _build_identifier(self, ods_code: str) -> list[Identifier]:

0 commit comments

Comments
 (0)