-
Notifications
You must be signed in to change notification settings - Fork 68
ENG-454 Inbound XCPD includes custodian #4012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ref eng-454 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
WalkthroughThe changes update internal logic to add a custodian object in a response constructor, refactor a Lambda handler to use a wrapper for error capturing, broaden accepted content types in a mock gateway Express middleware, and update a script path in a package configuration. No public API signatures are changed. Changes
Sequence Diagram(s)sequenceDiagram
participant API Gateway
participant Lambda Handler
participant capture.wrapHandler
participant Analytics
participant Processor
API Gateway->>capture.wrapHandler: Invoke handler(event)
activate capture.wrapHandler
capture.wrapHandler->>Lambda Handler: Execute async handler logic
activate Lambda Handler
Lambda Handler->>Processor: Process inbound patient discovery request
Processor-->>Lambda Handler: Return response
Lambda Handler->>Analytics: Emit analytics event (conditional)
Lambda Handler-->>capture.wrapHandler: Return API response
deactivate Lambda Handler
capture.wrapHandler-->>API Gateway: Return API response
deactivate capture.wrapHandler
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error code ERR_SSL_WRONG_VERSION_NUMBER ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)<
8000
/h3>
@coderabbitai pause to pause the reviews on a PR.@coderabbitai resume to resume the paused reviews.@coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full review to do a full review from scratch and review all the files again.@coderabbitai summary to regenerate the summary of the PR.@coderabbitai generate docstrings to generate docstrings for this PR.@coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.@coderabbitai resolve resolve all the CodeRabbit review comments.@coderabbitai configuration to show the current CodeRabbit configuration for the repository.@coderabbitai help to get help.@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summary to generate the high-level summary at a specific location in the PR description.@coderabbitai anywhere in the PR title to generate the title automatically..coderabbit.yaml file to the root of your repository.# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json |
.coderabbit.yaml
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts (1)
73-79
:⚠️ Potential issueLambda response body must be a string
APIGatewayProxyResult.body
expects a string.
On the empty-body path we currently pass an object, which will be serialised to
[object Object]
and break consumers.-function buildResponse(status: number, body: unknown) { +function buildResponse(status: number, body: unknown) { return { statusCode: status, headers: { "Content-Type": "application/soap+xml" }, - body, + body: typeof body === "string" ? body : JSON.stringify(body), }; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts
(1 hunks)packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts
(3 hunks)packages/utils/package.json
(1 hunks)packages/utils/src/saml/mock-ihe-gateway.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: - Use the Onion Pattern to organize a package's code in layers - Try to use immutable code and avoid sharing state across different functions, objects, and systems - Try...
**/*.ts
: - Use the Onion Pattern to organize a package's code in layers
- Try to use immutable code and avoid sharing state across different functions, objects, and systems
- Try to build code that's idempotent whenever possible
- Prefer functional programming style functions: small, deterministic, 1 input, 1 output
- Minimize coupling / dependencies
- Avoid modifying objects received as parameter
- Only add comments to code to explain why something was done, not how it works
- Naming
- classes, enums:
PascalCase
- constants, variables, functions:
camelCase
- file names:
kebab-case
- table and column names:
snake_case
- Use meaningful names, so whoever is reading the code understands what it means
- Don’t use negative names, like
notEnabled
, preferisDisabled
- For numeric values, if the type doesn’t convey the unit, add the unit to the name
- Typescript
- Use types
- Prefer
const
instead oflet
- Avoid
any
and casting fromany
to other types- Type predicates: only applicable to narrow down the type, not to force a complete type conversion
- Prefer deconstructing parameters for functions instead of multiple parameters that might be of
the same type- Don’t use
null
inside the app, only on code interacting with external interfaces/services,
like DB and HTTP; convert toundefined
before sending inwards into the code- Use
async/await
instead of.then()
- Use the strict equality operator
===
, don’t use abstract equality operator==
- When calling a Promise-returning function asynchronously (i.e., not awaiting), use
.catch()
to
handle errors (seeprocessAsyncError
andemptyFunction
depending on the case)- Date and Time
- Always use
buildDayjs()
to createdayjs
instances- Prefer
dayjs.duration(...)
to create duration consts and keep them asduration
- Prefer Nullish Coalesce (??) than the OR operator (||) to provide a default value
- Avoid creating arrow functions
- Use truthy syntax instead of
in
- i.e.,if (data.link)
notif ('link' in data)
- Error handling
- Pass the original error as the new one’s
cause
so the stack trace is persisted- Error messages should have a static message - add dynamic data to MetriportError's
additionalInfo
prop- Avoid sending multiple events to Sentry for a single error
- Global constants and variables
- Move literals to constants declared after imports when possible (avoid magic numbers)
- Avoid shared, global objects
- Avoid using
console.log
andconsole.error
in packages other than utils, infra and shared,
and try to useout().log
instead- Avoid multi-line logs
- don't send objects as a second parameter to
console.log()
orout().log()
- don't create multi-line strings when using
JSON.stringify()
- Use
eslint
to enforce code style- Use
prettier
to format code- max column length is 100 chars
- multi-line comments use
/** */
- scripts: top-level comments go after the import
packages/utils/src/saml/mock-ihe-gateway.ts
packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts
packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/utils/package.json (1)
24-28
: Confirm new script path works end-to-end
mock-ihe-gateway
now points tosrc/saml/mock-ihe-gateway
.
Make sure:
- The target file exists and is executable when run with
ts-node
(no missing.ts
extension or path typos).- Any docs / CI jobs referencing the old location are updated.
No code change needed if both are true.
packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts (1)
154-169
: Verify custodian XML structure against ITI-55 schema
custodian → assignedCustodian → assignedEntity
does not match the HL7 v3 sample
(custodian/assignedCustodian/representedCustodianOrganization
).
If the element hierarchy is wrong the responding gateway may reject the message.Please cross-check with the spec and adjust the nesting / element names (e.g. move
assignedEntity
insideassignedCustodian
, or rename to
representedCustodianOrganization
) and add a contract test.packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts (1)
27-71
: Wrapped handler looks goodSwitching to
capture.wrapHandler
improves observability without altering the
business logic. Signature remains compatible with API Gateway events.
Dependencies
none
Description
Inbound XCPD includes custodian.
Testing
Release Plan
Summary by CodeRabbit