mikee6290
11/22/2023, 4:39 PMmikee6290
11/28/2023, 5:06 PMrahul1
11/28/2023, 9:23 PMcacheTime parameter to define how long the client caches before refetching from the servermikee6290
12/08/2023, 11:17 AMmikee6290
12/08/2023, 11:19 AMmikee6290
12/11/2023, 12:35 PMmikee6290
12/11/2023, 2:42 PMrahul1
12/12/2023, 5:49 AMreadResource or searchResourcesrahul1
12/12/2023, 5:49 AMmikee6290
12/12/2023, 11:07 AMmikee6290
12/12/2023, 11:11 AMmikee6290
12/13/2023, 10:37 AMmikee6290
12/13/2023, 10:38 AMrahul1
12/13/2023, 9:43 PMrahul1
12/13/2023, 9:50 PMreadResource('Observation', id), the client will automatically read from the cache, even if you don't call getCached. You should be able to confirm this using the networking tab
I just ran the code below as a single TS file (not in a react component) as was able to confirm that the Observation could be read from cache
ts
const observations = await medplum.searchResources('Observation')
console.log(observations[0].id)
console.log(medplum.getCached('Observation', observations[0].id))mikee6290
12/14/2023, 11:13 AMrahul1
12/15/2023, 7:38 PMts
const patientId = 'f04fde56-88cf-4713-a11a-cbe8ee9f2242'
const observations = await medplum.searchResources('Observation', `subject=Patient/${patientId}`)
console.log(observations.length)
console.log(observations[0].id)
console.log(medplum.getCached('Observation', observations[0].id))
output:
ts
20
5abb4492-e1f0-442a-940e-7c214052f926
{
resourceType: 'Observation',
id: '5abb4492-e1f0-442a-940e-7c214052f926',
meta: {
profile: [
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-head-circumference'
],
versionId: '6ba2ad0e-add2-4d06-b398-f02c17e45d4e',
lastUpdated: '2023-08-17T18:10:32.454Z',
author: {
reference: 'Practitioner/996a2c29-5aaa-4810-bd6f-5f2935e90239',
display: 'Rahul Agarwal'
},
project: '70721083-1dde-413a-bd2a-419771a8718e',
compartment: [ [Object], [Object] ]
},
status: 'final',
category: [ { coding: [Array] } ],
code: { coding: [ [Object] ], text: 'Head Circumference' },
subject: { reference: 'Patient/f04fde56-88cf-4713-a11a-cbe8ee9f2242' },
effectiveDateTime: '2020-11-18T16:19:31-08:00',
valueQuantity: {
value: 51.2,
unit: 'cm',
system: 'http://unitsofmeasure.org',
code: 'cm'
}
}