@@ -202,32 +202,50 @@ export const internalAttrListToScopes = (
202202 return scopes
203203}
204204
205+ /**
206+ * This is derived from the MyInfo API v4.
207+ * @see https://public.cloud.myinfo.gov.sg/myinfo/api/myinfo-kyc-v4.0.html#childrenbirthrecords
208+ */
209+ interface MyInfoChildVaccinationRequirement {
210+ requirement : { code : string ; desc : string }
211+ fulfilled : { value : boolean }
212+ }
213+
205214/**
206215 * Converts whatever preschool vaccination data
207216 * we get directly from MyInfo to out internal representation.
208217 *
209- * NOTE: As of the time of writing this, there is only one possible
210- * vaccination status code. So the array input doesn't matter
211- * and we can just output a single enum. However, if this changes
212- * in the future, we need to support multiple vaccination statuses.
218+ * NOTE (Support for only one vaccination requirement code): As of the time of writing this,
219+ * there is only one possible vaccination requirement status code (which is 1M3D).
220+ * So the array input doesn't matter and we can just output a single enum.
221+ * However, if this changes in the future, we need to support multiple vaccination statuses.
222+ *
223+ * NOTE (Missing data is treated as not fulfilled):
224+ * All children should have the vaccination requirement 1M3D.
225+ * The official National Immunisation Registry (NIR), synced with MyInfo, must be used to mark the 1M3D requirement as fulfilled.
226+ * Hence, if the vaccination requirement is not present in MyInfo, we enforce the not fulfilled status by default.
227+ * This is instead of unknown returned previously before this PR change, which allowed the respondent to edit the value.
213228 *
214229 * @param vaccinationRequirement The preschool child records vaccination requirements.
215- * @returns Vaccination status of the child. Unknown status should be treated as missing data .
230+ * @returns Vaccination status of the child. Missing data should be treated as not fulfilled for the reason noted below .
216231 */
217232const requirementToVaccinationEnum = (
218- vaccinationRequirement :
219- | undefined
220- | {
221- requirement : { code : string ; desc : string }
222- fulfilled : { value : boolean }
223- } [ ] ,
233+ vaccinationRequirement : undefined | MyInfoChildVaccinationRequirement [ ] ,
224234) : MyInfoChildVaxxStatus => {
225235 if ( vaccinationRequirement === undefined || ! vaccinationRequirement . length ) {
226- return MyInfoChildVaxxStatus . Unknown
236+ return MyInfoChildVaxxStatus . ONEM3D_NOT_FULFILLED
237+ }
238+ const oneM3DVaccinationRequirement = vaccinationRequirement . find (
239+ ( req ) => req ?. requirement ?. code === '1M3D' ,
240+ )
241+ if ( ! oneM3DVaccinationRequirement ) {
242+ return MyInfoChildVaxxStatus . ONEM3D_NOT_FULFILLED
227243 }
228- return vaccinationRequirement . some ( ( req ) => req ?. requirement ?. code === '1M3D' )
229- ? MyInfoChildVaxxStatus . ONEM3D
230- : MyInfoChildVaxxStatus . Unknown
244+
245+ const isOneM3DFulfilled = oneM3DVaccinationRequirement . fulfilled . value
246+ return isOneM3DFulfilled
247+ ? MyInfoChildVaxxStatus . ONEM3D_FULFILLED
248+ : MyInfoChildVaxxStatus . ONEM3D_NOT_FULFILLED
231249}
232250
233251const MyInfoChildAttributesSorted = Object . values ( MyInfoChildAttributes ) . sort ( )
0 commit comments