Skip to content

Commit

Permalink
feat: allow supplying a comment with confirmRegistration (#8197)
Browse files Browse the repository at this point in the history
* feat: allow supplying a comment with confirmRegistration

* trigger e2e

* chore: update changelog

---------

Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>
  • Loading branch information
naftis and rikukissa authored Jan 6, 2025
1 parent 967dd79 commit 066ecda
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

### New features

- Misc new feature
- Allow configuring the default search criteria for record search [#6924](https://github.com/opencrvs/opencrvs-core/issues/6924)
- Add checks to validate client and server are always on the same version. This prevents browsers with a cached or outdated client versions from making potentially invalid requests to the backend [#6695](https://github.com/opencrvs/opencrvs-core/issues/6695)
- Two new statuses of record are added: `Validated` and `Correction Requested` for advanced search parameters [#6365](https://github.com/opencrvs/opencrvs-core/issues/6365)
Expand All @@ -24,6 +23,7 @@
- **Template Selection Dropdown**: Updated print workflow to include a dropdown menu for template selection when issuing a certificate.
- Auth now allows exchanging user's token for a new record-specific token [#7728](https://github.com/opencrvs/opencrvs-core/issues/7728)
- A new GraphQL mutation `upsertRegistrationIdentifier` is added to allow updating the patient identifiers of a registration record such as NID [#8034](https://github.com/opencrvs/opencrvs-core/pull/8034)
- Updated GraphQL mutation `confirmRegistration` to allow adding a `comment` for record audit [#8197](https://github.com/opencrvs/opencrvs-core/pull/8197)
- Introduced a new customisable UI component: Banner [#8276](https://github.com/opencrvs/opencrvs-core/issues/8276)

### Improvements
Expand Down
5 changes: 1 addition & 4 deletions packages/gateway/src/features/registration/root-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,7 @@ export const resolvers: GQLResolver = {
}

try {
const taskEntry = await confirmRegistration(id, authHeader, {
registrationNumber: details.registrationNumber,
identifiers: details.identifiers
})
const taskEntry = await confirmRegistration(id, authHeader, details)

return taskEntry.resource.id
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/src/features/registration/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ input IdentifierInput {
input ConfirmRegistrationInput {
registrationNumber: String!
identifiers: [IdentifierInput!]
comment: String # For record audit
}

input RejectRegistrationInput {
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/src/graphql/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export interface GQLReinstated {
export interface GQLConfirmRegistrationInput {
registrationNumber: string
identifiers?: Array<GQLIdentifierInput>
comment?: string
}

export interface GQLRejectRegistrationInput {
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ type Reinstated {
input ConfirmRegistrationInput {
registrationNumber: String!
identifiers: [IdentifierInput!]
comment: String
}

input RejectRegistrationInput {
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/src/workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export async function confirmRegistration(
details: {
registrationNumber: string
identifiers?: IdentifierInput[]
comment?: string
}
) {
const res: ReadyForReviewRecord = await createRequest(
Expand Down
6 changes: 4 additions & 2 deletions packages/workflow/src/features/registration/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { SupportedPatientIdentifierCode } from '@opencrvs/commons/types'
export interface EventRegistrationPayload {
trackingId: string
registrationNumber: string
error: string
error?: string
comment?: string
identifiers?: {
type: SupportedPatientIdentifierCode
value: string
Expand All @@ -38,7 +39,7 @@ export async function markEventAsRegisteredCallbackHandler(
) {
const token = getToken(request)
const compositionId = request.params.id
const { registrationNumber, error, identifiers } =
const { registrationNumber, error, comment, identifiers } =
request.payload as EventRegistrationPayload

if (error) {
Expand All @@ -60,6 +61,7 @@ export async function markEventAsRegisteredCallbackHandler(
savedRecord,
registrationNumber,
token,
comment,
identifiers
)
const event = getEventType(bundle)
Expand Down
7 changes: 5 additions & 2 deletions packages/workflow/src/records/fhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,10 @@ export function createWaitingForValidationTask(
}
}

export function createRegisterTask(previousTask: SavedTask): Task {
export function createRegisterTask(
previousTask: SavedTask,
comment?: string
): Task {
const timeLoggedMSExtension = previousTask.extension.find(
(e) => e.url === 'http://opencrvs.org/specs/extension/timeLoggedMS'
)!
Expand All @@ -779,7 +782,7 @@ export function createRegisterTask(previousTask: SavedTask): Task {
'REGISTERED'
)

const comments = previousTask?.note?.[0]?.text
const comments = comment ?? previousTask?.note?.[0]?.text

return {
...registeredTask,
Expand Down
7 changes: 5 additions & 2 deletions packages/workflow/src/records/state-transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,14 @@ export async function toRegistered(
record: WaitingForValidationRecord,
registrationNumber: EventRegistrationPayload['registrationNumber'],
token: string,
comment?: string,
identifiers?: EventRegistrationPayload['identifiers']
): Promise<RegisteredRecord> {
const previousTask = getTaskFromSavedBundle(record)
const registeredTaskWithoutPractitionerExtensions =
createRegisterTask(previousTask)
const registeredTaskWithoutPractitionerExtensions = createRegisterTask(
previousTask,
comment
)

const [registeredTask, practitionerResourcesBundle] =
await withPractitionerDetails(
Expand Down

0 comments on commit 066ecda

Please sign in to comment.