Skip to content

Commit

Permalink
Handle non mandatory facility address and recipient address in certif…
Browse files Browse the repository at this point in the history
…icate-api

* facility address

(cherry picked from commit 5fb2ad9)

* Revert "facility address"

This reverts commit d3e7947.

* helper function values update

(cherry picked from commit 967bbf1)

* recipient address

* facility address

(cherry picked from commit 5fb2ad9)

Co-authored-by: Vishwajeet <[email protected]>
  • Loading branch information
vishwajeet-eGov and vishi24 authored Jun 30, 2022
1 parent ab2504b commit b188b1f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/certificate_api/src/services/certificate_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const prepareDataForVaccineCertificateTemplate = (certificateRaw, dataURL, doseT
identity: formatId(credentialSubject.id),
nationality: credentialSubject.nationality,
beneficiaryId: credentialSubject.refId,
recipientAddress: formatRecipientAddress(credentialSubject.address),
recipientAddress: credentialSubject.address ? formatRecipientAddress(credentialSubject.address) : "",
vaccine: evidence[0].vaccine,
vaccinationDate: formatDate(evidence[0].date),
vaccineBatch: evidence[0].batch,
Expand All @@ -61,7 +61,7 @@ const prepareDataForVaccineCertificateTemplate = (certificateRaw, dataURL, doseT
vaccineManufacturer: evidence[0].manufacturer,
vaccineValidDays: `after ${getVaccineValidDays(evidence[0].effectiveStart, evidence[0].effectiveUntil)} days`,
vaccinatedBy: evidence[0].verifier.name,
vaccinatedAt: formatFacilityAddress(evidence[0]),
vaccinatedAt: evidence[0].facility.name ? evidence[0].facility.address.district ? formatFacilityAddress(evidence[0]) : evidence[0].facility.name : "" ,
qrCode: dataURL,
dose: evidence[0].dose,
totalDoses: evidence[0].totalDoses,
Expand All @@ -81,6 +81,7 @@ function getVaccineDetails(doseToVaccinationDetailsMap) {
let vaxEvents = [];
for (let [key, value] of doseToVaccinationDetailsMap) {
let vaxEventMap = {
dose: value.dose || "",
doseType: (value.dose <= value.totalDoses) ?
("Primary Dose " + value.dose) :
("Booster Dose " + (value.dose - value.totalDoses)),
Expand All @@ -91,6 +92,7 @@ function getVaccineDetails(doseToVaccinationDetailsMap) {
countryOfVax: value.vaccinatedCountry || "",
validity: value.validity || "",
vaxType: value.vaxType || "",
vaxEvent: value || "" ,
};
vaxEvents.push(vaxEventMap);
}
Expand All @@ -107,6 +109,7 @@ function fetchVaccinationDetailsFromCert(evidence) {
batch: evidence.batch,
manufacturer: evidence.manufacturer,
vaccinatedCountry: evidence.facility.address.addressCountry,
evidence: evidence,
};
return vaccineDetails;
}
Expand Down

0 comments on commit b188b1f

Please sign in to comment.