Skip to main content

FHIR to BFF

Mapping status

This table documents the experimental FHIR R4 JSON Bundle mapping introduced in v0.33 and the mCODE 4.0 profile-aware mapping added for v0.34. Its current coverage reflects the attributed generic and official mCODE fixtures and may be refined as additional implementations are evaluated.

The route resolves Bundle references, groups resources by Patient, creates one Beacon individuals record per Patient, and can emit first-class biosamples plus source-derived datasets and cohorts.

Patient​

FHIR sourceBFF targetBehavior
Patient.id, fallback Patient.identifier[].valueidA stable identifier is required
Patient.gendersexSupported FHIR administrative gender values use Beacon-compatible NCIT defaults; unsupported or absent values use unknown sex
Patient.birthDateinfo.phenopacket.dateOfBirthA full date becomes a UTC midnight timestamp for later PXF conversion
Patient.deceasedDateTimeinfo.phenopacket.vitalStatusSets DECEASED and retains timeOfDeath.timestamp
Patient.deceasedBooleaninfo.phenopacket.vitalStatus.statusMaps to DECEASED or ALIVE
US Core ethnicity extensionethnicityUses the extension coding and display/text when present
patient-birthPlace extensiongeographicOriginTwo- or three-letter country values use ISO3166-1:; other values use a source-derived FHIR term

Conditions And Phenotypic Features​

FHIR sourceBFF targetBehavior
Condition.codediseases[].diseaseCodeFirst usable coding is retained as an ontology term; text is the fallback
Condition.onsetDateTimediseases[].ageOfOnsetBecomes age when Patient.birthDate is available, otherwise a timestamp
Condition.abatementDateTimediseases[].resolutionBecomes age when possible, otherwise a timestamp
refuted or entered-in-error Condition.verificationStatusdiseases[].excludedSets true
mCODE primary cancer Condition.stage[].summarydiseases[].stageUses the coded summary; a resolvable stage-assessment Observation is the fallback
HPO coding in Observation.code or Observation.valueCodeableConceptphenotypicFeatures[].featureTypeRecognized by the HP: CURIE prefix
Observation.valueBoolean=false for an HPO featurephenotypicFeatures[].excludedSets true; other cases set false
HPO Observation effective datephenotypicFeatures[].onsetBecomes age when possible, otherwise a timestamp

Measurements​

FHIR sourceBFF targetBehavior
Observation.codemeasures[].assayCodeMaps the assay coding or text
Observation.component[]additional measures[]Each component with a usable code and value becomes a separate measure
valueQuantitymeasurementValue.quantityNumeric value and coded/display unit are retained
referenceRange[].low/highmeasurementValue.quantity.referenceRangeRetained when both bounds are numeric
valueCodeableConceptmeasurementValueRetained as a categorical ontology term
valueInteger, valueDecimalmeasurementValue.quantityNumeric value is retained with a not-available unit fallback when no unit exists
valueBoolean, valueString, valueCode, valueDateTime, valueDatemeasurementValueRetained as a source-derived FHIR term
Observation.effectiveDateTime, period start, or issuedmeasures[].dateDate component is retained
Observation.methodmeasures[].procedure.procedureCodeRetained when coded or labeled

An Observation with specimen.reference is not added to the individual's measures. It is mapped to the matching biosample's measurements instead.

Procedures And Treatments​

FHIR sourceBFF targetBehavior
Procedure.codeinterventionsOrProcedures[].procedureCodeCoding or text is retained
Procedure.performedDateTime, fallback period startinterventionsOrProcedures[].dateOfProcedureDate component is retained
first Procedure.bodySiteinterventionsOrProcedures[].bodySiteCoding or text is retained
medication code or resolvable medicationReferencetreatments[].treatmentCodeSupports MedicationRequest, MedicationAdministration, and MedicationStatement, including contained Medication resources
first applicable dosage routetreatments[].routeOfAdministrationCoding or text is retained
authored/effective starttreatments[].ageOfOnsetBecomes age when Patient.birthDate is available

Specimens And Biosamples​

FHIR sourceBFF biosample targetBehavior
Specimen.ididRequired for first-class biosample output
resolved PatientindividualIdUses the owning Patient id
Specimen.statusbiosampleStatusRetained as a source-derived FHIR term
Specimen.typesampleOriginTypeCoding or text is retained; missing values use the Beacon ontology-term default
Specimen.collection.collectedDateTimecollectionDateDate component is retained
Specimen.collection.bodySitesampleOriginDetailCoding or text is retained
Specimen.collection.methodobtentionProcedure.procedureCodeCoding or text is retained
Specimen.note[].textnotesMultiple notes are joined with newlines
linked Observation resourcesmeasurements[]Uses the same measurement mapping and requires a resolvable Observation.specimen reference
FHIR specimen status

Specimen.status comes from the required FHIR R4 SpecimenStatus value set. Convert-Pheno therefore retains it as a source-derived term, for example FHIR:SpecimenStatus.available with the canonical display Available. It does not infer an NCIT or other cross-ontology equivalent that is absent from the source record.

The semantic biosample representation is also retained under individuals[].info.phenopacket.biosamples. This is deliberate: it allows the fhir2pxf pipeline to preserve specimen data while the pipeline's primary BFF view carries individuals between stages.

Study Metadata​

FHIR sourceBFF entity metadataBehavior
first ResearchStudy.id or identifierdataset idFalls back to the first Bundle id or a generated source id
ResearchStudy.title, fallback namedataset nameFalls back to the dataset id
ResearchStudy.descriptiondataset descriptionRetained when scalar
first Group.id or identifiercohort idUsed for the source-derived cohort
Group.namecohort nameFalls back to the cohort id
Group.quantity, fallback member countcohort sizeRetained as a number

Explicit derived_entity_overrides supplied through a programmatic request take precedence over this source-derived metadata.

Terminology And Provenance​

Known coding-system URIs map to stable prefixes including HP, LOINC, SNOMEDCT, RxNorm, UCUM, NCIT, and ICD-10 variants. Existing CURIE codes are retained. Whitespace in identifiers is replaced with _ for API-safe identifiers.

Unknown coding systems receive a prefix derived from the system URI, and uncoded text receives a FHIR: source identifier. These values preserve source identity and are not evidence of ontology resolution.

By default, raw Patient and patient-scoped resources are copied under info.fhir; biosamples retain their source Specimen and linked Observations. --no-source-info removes those copies while retaining mapped BFF fields and semantic Phenopacket biosample data.

mCODE is detected from canonical meta.profile URLs. Detected profile names, the mCODE canonical URL, and the supported version 4.0.0 are recorded under info.fhir.profiles.mcode. This annotation is emitted only when mCODE profiles are present.

Current Boundaries​

The current profile does not read FHIR XML, Bulk Data NDJSON, or live FHIR server endpoints. Resources without an implemented first-class mapping remain in provenance. Beyond the documented mCODE stage rule, arbitrary extensions, profile-specific slices, encounter-level grouping, and terminology-server expansion are outside the current mapper.

See the FHIR R4 guide for input constraints, commands, interface availability, and memory behavior.