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: enable online verification for death #64

Merged
merged 1 commit into from
Feb 28, 2025
Merged
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
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);
};