We need answer user's request. Need produce final JSON only, no markdown. Need parse data and compute.

User Japanese: fictional measurement records. Need extract specified IDs in order: P1-0001, P1-0008, P1-0017, P1-0028, P1-0038, P1-0045. records array 6 objects keys id, code, value_mg integer. total_mg sum of 1st, 3rd, 6th (1-based) value_mg. missing is measurement value for ID=P1-9999 if absent null. Keys only records,total_mg,missing.

Need extract:
P1-0001: line0002 code 0d779aa92c4b value 411
P1-0008: line0009 code 6145b5511a6d value 869
P1-0017: line0018 code 7f33f46e3c72 value 191
P1-0028: line0029 code 1ce11754e79b value 633
P1-0038: line0039 code 75a4dd4130f3 value 686
P1-0045: line0046 code 73414e4bb5e3 value 366

records order as specified. total_mg = 1st (411) + 3rd (191) + 6th (366) = 968? 411+191=602; +366=968. missing null.

Need output JSON object only. Ensure integers not strings. No code fences.
