Skip to content

Commit

Permalink
return composition id confirm registration endpoint in core (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil20 authored Nov 29, 2023
1 parent 1953fe1 commit 6366384
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/event-registration/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function eventRegistrationHandler(
const eventRegistrationIdentifiersResponse =
await createUniqueRegistrationNumberFromBundle(bundle)

fetch(CONFIRM_REGISTRATION_URL, {
await fetch(CONFIRM_REGISTRATION_URL, {
method: 'POST',
body: JSON.stringify(eventRegistrationIdentifiersResponse),
headers: request.headers
Expand Down
2 changes: 2 additions & 0 deletions src/api/event-registration/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import {
getCompositionId,
getTaskResource,
getTrackingIdFromTaskResource
} from '@countryconfig/utils'
Expand Down Expand Up @@ -39,6 +40,7 @@ export async function createUniqueRegistrationNumberFromBundle(
return {
trackingId,
registrationNumber: generateRegistrationNumber(trackingId),
compositionId: getCompositionId(bundle),
...(taskResource.code?.coding?.[0].code === 'BIRTH' && {
// Some countries desire to create multiple identifiers for citizens at the point of birth registration using external systems.
// OpenCRVS supports up to 3 additional, custom identifiers that can be created
Expand Down
6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export interface IApplicationConfigResponse {
config: IApplicationConfig
}

export function getCompositionId(resBody: fhir.Bundle) {
return resBody.entry
?.map((e) => e.resource)
.find((res) => res?.resourceType === 'Composition')?.id
}

export function getTaskResource(
bundle: fhir.Bundle & fhir.BundleEntry
): fhir.Task | undefined {
Expand Down

0 comments on commit 6366384

Please sign in to comment.