Skip to content

Commit

Permalink
Merge branch 'develop' into upgrade-apollo-to-4
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa authored Nov 25, 2024
2 parents 70e82f2 + 5e497eb commit 5b4417a
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Deploy UI-Kit Storybook to [opencrvs.pages.dev](https://opencrvs.pages.dev) to allow extending OpenCRVS using the component library
- Record audit action buttons are moved into action menu [#7390](https://github.com/opencrvs/opencrvs-core/issues/7390)
- Reoder the sytem user add/edit field for surname to be first, also change labels from `Last name` to `User's surname` and lastly remove the NID question from the form [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)
- Corrected the total amount displayed for _certification_ and _correction_ fees on the Performance Page, ensuring accurate fee tracking across certification and correction sequences. [#7793](https://github.com/opencrvs/opencrvs-core/issues/7793)
- Auth now allows registrar's token to be exchanged for a new token that strictly allows confirming or rejecting a specific record. Core now passes this token to country configuration instead of the registrar's token [#7728](https://github.com/opencrvs/opencrvs-core/issues/7728) [#7849](https://github.com/opencrvs/opencrvs-core/issues/7849)

## Bug fixes
Expand All @@ -36,6 +37,7 @@
- Only render units/postfix when field has a value [#7055](https://github.com/opencrvs/opencrvs-core/issues/7055)
- Only show items with values in review [#5192](https://github.com/opencrvs/opencrvs-core/pull/5192)
- Fix prefix text overlap issue in form text inputs
- Fix the event name displayed in email templates for death correction requests [#7703](https://github.com/opencrvs/opencrvs-core/issues/7703)

## 1.6.1 Release candidate

Expand Down
7 changes: 6 additions & 1 deletion packages/metrics/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export function fetchFHIR<T = any>(
}

export function fetchTaskHistory(taskId: string, authHeader: IAuthHeader) {
return fetchFHIR<fhir.Bundle>(`Task/${taskId}/_history`, authHeader)
// querying task history in descending order in case task history
// gets very big and we always need the latest history
return fetchFHIR<fhir.Bundle>(
`Task/${taskId}/_history?_sort=-meta.lastUpdated`,
authHeader
)
}

export const fetchLocation = async (
Expand Down
13 changes: 12 additions & 1 deletion packages/metrics/src/features/registration/fhirUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ function findAllPreviousTasks(historyResponseBundle: fhir.Bundle) {
return task as fhir.Task[]
}

export function getPaymentReconciliation(bundle: fhir.Bundle) {
export function getPaymentReconciliation(
bundle: fhir.Bundle,
task?: fhir.Task
) {
if (task) {
const paymentDetailsReference = task.extension?.find((x) =>
x.url.includes('paymentDetails')
)?.valueReference?.reference
return bundle.entry?.find((x) => x.fullUrl === paymentDetailsReference)
?.resource as fhir.PaymentReconciliation
}

return getResourceByType<fhir.PaymentReconciliation>(
bundle,
FHIR_RESOURCE_TYPE.PAYMENT_RECONCILIATION
Expand Down
4 changes: 2 additions & 2 deletions packages/metrics/src/features/registration/pointGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ export async function generatePaymentPoint(
authHeader: IAuthHeader,
paymentType: 'certification' | 'correction'
): Promise<IPaymentPoints> {
const reconciliation = getPaymentReconciliation(payload)
const composition = getComposition(payload)
const task = getTask(payload)
if (!task) {
throw new Error('Task not found')
}
const composition = getComposition(payload)
if (!composition) {
throw new Error('Composition not found')
}
const reconciliation = getPaymentReconciliation(payload, task)
if (!reconciliation) {
throw new Error('Payment reconciliation not found')
}
Expand Down
6 changes: 6 additions & 0 deletions packages/metrics/src/features/registration/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,12 @@ export const testDeathCertPayload = {
valueReference: {
reference: 'Practitioner/ec1f4476-182f-408f-9da2-aff0c9bd1f26'
}
},
{
url: 'http://opencrvs.org/specs/extension/paymentDetails',
valueReference: {
reference: 'urn:uuid:2aead0f3-55a4-4e7c-a7ac-720f36580f66'
}
}
],
lastModified: '2019-11-30T15:19:54.168Z',
Expand Down
61 changes: 59 additions & 2 deletions packages/workflow/src/records/fhir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,21 @@ export function createCertifiedTask(previousTask: SavedTask): SavedTask {
return createNewTaskResource(previousTask, [], 'CERTIFIED')
}

export function createIssuedTask(previousTask: SavedTask): SavedTask {
return createNewTaskResource(previousTask, [], 'ISSUED')
export function createIssuedTask(
previousTask: SavedTask,
paymentReconciliation?: BundleEntry<PaymentReconciliation>
): SavedTask {
const nextExtentions: Extension[] = paymentReconciliation?.fullUrl
? [
{
url: 'http://opencrvs.org/specs/extension/paymentDetails',
valueReference: {
reference: paymentReconciliation.fullUrl
}
}
]
: []
return createNewTaskResource(previousTask, nextExtentions, 'ISSUED')
}

export function createVerifyRecordTask(
Expand Down Expand Up @@ -1378,6 +1391,50 @@ export function toSavedBundle<T extends Resource>(
)
}
}
if (
isTask(entry.resource) &&
entry.resource.extension &&
entry.resource.extension.some(
(x) => x.url === 'http://opencrvs.org/specs/extension/paymentDetails'
)
) {
return {
...entry,
fullUrl: responseBundle.entry[index].response.location,
resource: {
...entry.resource,
id: urlReferenceToUUID(
responseBundle.entry[index].response.location
),
extension: entry.resource.extension.map((x: any) => {
if (
x.url ===
'http://opencrvs.org/specs/extension/paymentDetails' &&
x.valueReference &&
x.valueReference.reference &&
resourceBundle.entry.some(
(y) => y.fullUrl === x.valueReference.reference
)
) {
const newLocation = responseBundle.entry.find((y) =>
y.response.location.includes('PaymentReconciliation')
)?.response.location

if (newLocation) {
return {
...x,
valueReference: {
...x.valueReference,
reference: newLocation
}
}
}
}
return x
})
}
}
}

return {
...entry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const approveCorrectionRoute = createRoute({
practitionerContacts,
getAuthHeader(request),
{
event: 'BIRTH',
event: getEventType(record),
trackingId: getTrackingId(recordWithUpdatedValues)!,
userFullName: requestingPractitioner.name
}
Expand Down
3 changes: 2 additions & 1 deletion packages/workflow/src/records/handler/correction/reject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { createRoute } from '@workflow/states'
import { getToken } from '@workflow/utils/auth-utils'
import { validateRequest } from '@workflow/utils/index'
import { findActiveCorrectionRequest, sendNotification } from './utils'
import { getEventType } from '@workflow/features/registration/utils'

export const rejectCorrectionRoute = createRoute({
method: 'POST',
Expand Down Expand Up @@ -116,7 +117,7 @@ export const rejectCorrectionRoute = createRoute({
practitionerContacts,
getAuthHeader(request),
{
event: 'BIRTH',
event: getEventType(record),
trackingId: getTrackingId(recordWithCorrectionRejectedTask)!,
userFullName: requestingPractitioner.name,
reason: rejectionDetails.reason
Expand Down
14 changes: 9 additions & 5 deletions packages/workflow/src/records/state-transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,14 @@ export async function toIssued(
eventType: EVENT_TYPE,
certificateDetails: IssueInput
): Promise<IssuedRecord> {
const [paymentReconciliation] = createPaymentResources(
certificateDetails.payment
)
const previousTask = getTaskFromSavedBundle(record)
const taskWithoutPractitionerExtensions = createIssuedTask(previousTask)
const taskWithoutPractitionerExtensions = createIssuedTask(
previousTask,
paymentReconciliation
)

const [issuedTask, practitionerResourcesBundle] =
await withPractitionerDetails(taskWithoutPractitionerExtensions, token)
Expand All @@ -1035,15 +1041,13 @@ export async function toIssued(
record
)

const [paymentEntry] = createPaymentResources(certificateDetails.payment)

const documentReferenceEntry = createDocumentReferenceEntryForCertificate(
temporaryDocumentReferenceId,
temporaryRelatedPersonId,
eventType,
certificateDetails.hasShowedVerifiedDocument,
undefined,
paymentEntry.fullUrl
paymentReconciliation.fullUrl
)

const certificateSection: CompositionSection = {
Expand Down Expand Up @@ -1096,7 +1100,7 @@ export async function toIssued(
{ resource: compositionWithCertificateSection },
{ resource: issuedTask },
...relatedPersonEntries,
paymentEntry,
paymentReconciliation,
documentReferenceEntry
]
}
Expand Down

0 comments on commit 5b4417a

Please sign in to comment.