Jim Fiorato
04/29/2025, 9:45 PMpartOf reference. It is possible that both will be created at the same time, so I want to commit them both as part of the same transaction. I understand that Placeholder IDs using `BatchEntry`'s fullUrl and a reference that uses the urn:uuid string can handle this.
However, with the FHIR types, the type enforcement requires a Reference<ResourceType>. How can I set the partOf attribute on the Organization to the Placeholder ID?
So, basically something like:
const entries: BundleEntry[] = []
const parentOrgPlaceholderId = `urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a`
const parentOrg: Organization = {
resourceType: 'Organization',
name: 'Parent Org'
}
entries.push({
parentOrg,
fullUrl: parentOrgPlaceholderId,
request: {
url: parentOrg.resourceType,
method: 'POST'
})
const childOrg: Organization = {{
resourceType: 'Organization',
name: 'Parent Org'
partOf: ??????? <-- This requires a Reference<Organization> type I want to use { reference: parentOrgPlaceholderId }
}
entries.push({
childOrg,
request: {
url: childOrg.resourceType,
method: 'POST'
})
await medplumClient.executeBatch({
resourceType: 'Bundle',
type: 'transaction',
entry: entries
})Jim Fiorato
04/29/2025, 10:28 PMcreateReference function:
export function createReferenceWithPlaceholder<T extends Resource>(
resource: T,
overrideReference?: string
): Reference<T> & { reference: string } {
const reference =
overrideReference ?? getReferenceString(resource) ?? 'undefined/undefined'
const display = getDisplayString(resource)
return display === reference ? { reference } : { reference, display }
}Ian Plunkett
04/29/2025, 10:37 PM