Skip to content
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

feat: allow supplying a comment with confirmRegistration #8197

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -571,6 +571,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 @@ -603,6 +603,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 @@ -740,6 +740,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 @@ -763,7 +763,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 @@ -774,7 +777,7 @@ export function createRegisterTask(previousTask: SavedTask): Task {
'REGISTERED'
)

const comments = previousTask?.note?.[0]?.text
const comments = comment ?? previousTask?.note?.[0]?.text
naftis marked this conversation as resolved.
Show resolved Hide resolved

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
Loading