Skip to content

Commit

Permalink
feat: enable online verification for death (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis authored Feb 28, 2025
1 parent bb4cd36 commit 0cf1fa5
Showing 1 changed file with 64 additions and 5 deletions.
69 changes: 64 additions & 5 deletions packages/mosip-api/src/routes/event-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export const reviewEventHandler = async (
father: false,
mother: false,
informant: false,
deceased: false,
spouse: false,
};

// @NOTE: Marriage not supported yet
Expand Down Expand Up @@ -136,11 +138,6 @@ export const reviewEventHandler = async (
composition,
request.body,
) as fhir3.Patient;
const father = findEntry(
"father-details",
composition,
request.body,
) as fhir3.Patient;

let motherNid;

Expand All @@ -164,6 +161,12 @@ export const reviewEventHandler = async (
verificationStatus.mother = result;
}

const father = findEntry(
"father-details",
composition,
request.body,
) as fhir3.Patient;

let fatherNid;

try {
Expand All @@ -186,5 +189,61 @@ export const reviewEventHandler = async (
verificationStatus.father = result;
}

let deceasedNid;

const deceased = findEntry(
"deceased-details",
composition,
request.body,
) as fhir3.Patient;

try {
deceasedNid = getPatientNationalId(deceased);
} catch (e) {
logger.info(
{ eventId },
"Couldn't find the deceased's NID. This is non-fatal - it likely wasn't submitted.",
);
}

if (deceasedNid) {
const result = await verifyAndUpdateRecord({
eventId,
event,
section: "deceased",
nid: deceasedNid,
token,
});
verificationStatus.deceased = result;
}

let spouseNid;

const spouse = findEntry(
"spouse-details",
composition,
request.body,
) as fhir3.Patient;

try {
spouseNid = getPatientNationalId(spouse);
} catch (e) {
logger.info(
{ eventId },
"Couldn't find the spouse's NID. This is non-fatal - it likely wasn't submitted.",
);
}

if (spouseNid) {
const result = await verifyAndUpdateRecord({
eventId,
event,
section: "spouse",
nid: spouseNid,
token,
});
verificationStatus.spouse = result;
}

return reply.code(202).send(verificationStatus);
};

0 comments on commit 0cf1fa5

Please sign in to comment.