From 6366384f229bdb539719e811f13432fa6afbffdd Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:45:09 +0600 Subject: [PATCH] return composition id confirm registration endpoint in core (#797) --- src/api/event-registration/handler.ts | 2 +- src/api/event-registration/service.ts | 2 ++ src/utils/index.ts | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api/event-registration/handler.ts b/src/api/event-registration/handler.ts index 28a273cf3..f317482ec 100644 --- a/src/api/event-registration/handler.ts +++ b/src/api/event-registration/handler.ts @@ -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 diff --git a/src/api/event-registration/service.ts b/src/api/event-registration/service.ts index 03c5b4ed2..cab3a207f 100644 --- a/src/api/event-registration/service.ts +++ b/src/api/event-registration/service.ts @@ -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' @@ -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 diff --git a/src/utils/index.ts b/src/utils/index.ts index 338342596..96154be36 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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 {