Skip to content

Commit

Permalink
Refactor save service response object (#3018)
Browse files Browse the repository at this point in the history
* pull out saveFhirMetadata into it's own function

* Use PersistenceResponse instead of Nextjs response

* console log error messages

* Do not close pool when done with mssql

https://www.npmjs.com/package/mssql#advanced-pool-management:~:text=Also%20notice%20that,of%20the%20script.

* increase sqlserver timeout to 30 s

* don't return anything from save ecr data query

* set pool min to 1

* Rename PersistenceResponse to SaveResponse

* update the rest of the types to match save response

* update comments to describe save response

* Do not return error in return statement, instead just log

* update tests

* deconstruct Service Response object

* update console error logs to log object rather than string

* fix tests

* Update response message to remove ecrID

* Update containers/ecr-viewer/src/app/api/save-fhir-data/save-fhir-data-service.ts

Co-authored-by: Mary McGrath <[email protected]>

---------

Co-authored-by: Mary McGrath <[email protected]>
  • Loading branch information
BobanL and mcmcgrath13 authored Dec 11, 2024
1 parent 89f3e8d commit 2c516ff
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 148 deletions.
10 changes: 8 additions & 2 deletions containers/ecr-viewer/src/app/api/save-fhir-data/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ export async function POST(request: NextRequest) {
}

if (requestBody.metadata) {
return saveWithMetadata(
const { message, status } = await saveWithMetadata(
fhirBundle,
ecrId,
saveSource,
requestBody.metadata,
);
return NextResponse.json({ message }, { status });
} else {
return saveFhirData(fhirBundle, ecrId, saveSource);
const { message, status } = await saveFhirData(
fhirBundle,
ecrId,
saveSource,
);
return NextResponse.json({ message }, { status });
}
}
Loading

0 comments on commit 2c516ff

Please sign in to comment.