Skip to content

Commit 1733a36

Browse files
committed
[NRL-1051] WIP some more renaming
1 parent 6dffea4 commit 1733a36

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ build-layers: ./layer/*
6666
./scripts/build-lambda-layer.sh $${layer} $(DIST_PATH); \
6767
done
6868

69-
build-api-packages: ./api/consumer/* ./api/producer/* ./api/mhds-recipient/*
69+
build-api-packages: ./api/consumer/* ./api/producer/*
7070
@echo "Building API packages"
7171
@mkdir -p $(DIST_PATH)
7272
for api in $^; do \

api/mhds-recipient/processTransaction/process_transaction.py renamed to api/producer/processTransaction/process_transaction_bundle.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,14 @@ def handler(
284284
Returns:
285285
Response: The response indicating the result of the operation.
286286
"""
287-
if not body.meta.profile[0].endswith(
288-
"profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.UnContained.Comprehensive.ProvideBundle"
287+
# TODO - Add logging
288+
# TODO - Add profile for NRLF too
289+
if (
290+
body.meta
291+
and body.meta.profile
292+
and not body.meta.profile[0].endswith(
293+
"profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.UnContained.Comprehensive.ProvideBundle"
294+
)
289295
):
290296
return SpineErrorResponse.BAD_REQUEST(
291297
diagnostics="Only IHE.MHD.UnContained.Comprehensive.ProvideBundle profiles are supported",
@@ -299,13 +305,13 @@ def handler(
299305
)
300306

301307
if body.entry is None:
302-
return SpineErrorResponse.BAD_REQUEST(
303-
diagnostics="The bundle must contain at least one entry", expression="entry"
308+
# TODO - Log that there was not entry
309+
return Response.from_resource(
310+
resource=Bundle(resourceType="Bundle", type="transaction-response")
304311
)
305312

306313
document_references: list[DocumentReference] = []
307314

308-
# TODO - Handle this better
309315
issues: list[BaseModel] = []
310316

311317
for entry in body.entry:
@@ -320,6 +326,17 @@ def handler(
320326
)
321327
)
322328

329+
if entry.request.method != "POST":
330+
issues.append(
331+
OperationOutcomeIssue(
332+
severity="error",
333+
code="exception",
334+
diagnostics="Only create using POST method is supported",
335+
expression=[ExpressionItem("entry.request.method")],
336+
details=SpineErrorConcept.from_code("BAD_REQUEST"),
337+
)
338+
)
339+
323340
document_references.append(DocumentReference.model_validate(entry.resource))
324341

325342
if issues:
@@ -335,4 +352,8 @@ def handler(
335352
except OperationOutcomeError as e:
336353
responses.append(e.response)
337354

338-
return NRLResponse.BUNDLE_CREATED(responses)
355+
return Response.from_resource(
356+
resource=Bundle(
357+
resourceType="Bundle", type="transaction-response", entry=responses
358+
)
359+
)

terraform/infrastructure/api_gateway.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module "producer__gateway" {
3434
method_upsertDocumentReference = "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:${local.aws_account_id}:function:${substr("${local.prefix}--api--producer--upsertDocumentReference", 0, 64)}/invocations"
3535
method_deleteDocumentReference = "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:${local.aws_account_id}:function:${substr("${local.prefix}--api--producer--deleteDocumentReference", 0, 64)}/invocations"
3636
method_status = "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:${local.aws_account_id}:function:${substr("${local.prefix}--api--producer--status", 0, 64)}/invocations"
37-
method_mhdsProcessTransation = "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:${local.aws_account_id}:function:${substr("${local.prefix}--api--mhdsRecipient--processTransaction", 0, 64)}/invocations"
37+
method_processTransation = "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:${local.aws_account_id}:function:${substr("${local.prefix}--api--producer--processTransaction", 0, 64)}/invocations"
3838
}
3939

4040
kms_key_id = module.kms__cloudwatch.kms_arn

terraform/infrastructure/lambda.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ module "producer__status" {
384384

385385
module "mhdsReceiver__processTransactionBundle" {
386386
source = "./modules/lambda"
387-
parent_path = "api/mhds-recipient"
387+
parent_path = "api/producer"
388388
name = "processTransaction"
389389
region = local.region
390390
prefix = local.prefix
391391
layers = [module.nrlf.layer_arn, module.third_party.layer_arn, module.nrlf_permissions.layer_arn]
392-
api_gateway_source_arn = ["arn:aws:execute-api:${local.region}:${local.aws_account_id}:${module.producer__gateway.api_gateway_id}/*/GET/_status"]
392+
api_gateway_source_arn = ["arn:aws:execute-api:${local.region}:${local.aws_account_id}:${module.producer__gateway.api_gateway_id}/*/POST/"]
393393
kms_key_id = module.kms__cloudwatch.kms_arn
394394
environment_variables = {
395395
PREFIX = "${local.prefix}--"

0 commit comments

Comments
 (0)