// Create individual lab results
const { data: glucose } = await clinik.observations.create({
status: 'final',
code: { system: 'http://loinc.org', code: '2339-0', display: 'Glucose' },
patientId: 'pt_abc123',
category: 'laboratory',
valueQuantity: { value: 95, unit: 'mg/dL' },
interpretation: 'N',
referenceRange: {
low: { value: 70, unit: 'mg/dL' },
high: { value: 100, unit: 'mg/dL' },
},
});
const { data: creatinine } = await clinik.observations.create({
status: 'final',
code: { system: 'http://loinc.org', code: '2160-0', display: 'Creatinine' },
patientId: 'pt_abc123',
category: 'laboratory',
valueQuantity: { value: 1.1, unit: 'mg/dL' },
interpretation: 'N',
referenceRange: {
low: { value: 0.7, unit: 'mg/dL' },
high: { value: 1.3, unit: 'mg/dL' },
},
});
// Create the report linking them
const { data: report } = await clinik.labs.create({
status: 'final',
code: { system: 'http://loinc.org', code: '24323-8', display: 'CMP' },
patientId: 'pt_abc123',
category: 'LAB',
resultIds: [glucose.id!, creatinine.id!],
conclusion: 'All values within normal limits.',
});