> For the complete documentation index, see [llms.txt](https://docs.rhinofcp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rhinofcp.com/tutorials-recipes-and-demos/harmonizing-complex-rwd-to-a-custom-data-model.md).

# Harmonizing Complex RWD to a Custom Data Model

The goal of this project is to demonstrate, end to end, that Rhino Federated Computing's Data Harmonization Engine (DHE) can transform a complex, multimodal real-world oncology dataset into a standardized target schema entirely at the data source. Using the publicly accessible [AACR GENIE BPC BrCa v1.0-public release](https://www.aacr.org/professionals/research/aacr-project-genie/bpc/early-onset-brca/) — twelve source files spanning patient demographics, cancer diagnoses, treatment regimens, imaging, pathology, tumor markers, and somatic variant calls — the project produces a complete, field-level mapping to the [GENIE Data Model (GDM v1.0.1)](https://www.aacr.org/professionals/research/aacr-project-genie/aacr-project-genie-data-model/), covering 11 output tables across the Core GENIE and Extended GDM layers.&#x20;

<div data-with-frame="true"><figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2FyLCSLCEpv6rTb9s83qKP%2FScreenshot%202026-08-11%20at%209.59.31%E2%80%AFAM.png?alt=media&amp;token=3fea45fd-41f2-44e6-861a-8661d7c89643" alt=""><figcaption></figcaption></figure></div>

Beyond the harmonized output itself, the project aims to establish a reusable reference pattern: a documented lineage from source to staging to target, a controlled-vocabulary mapping layer, and a phased execution plan that separates Code Object pre-processing from DHE syntactic mapping, and an auditable specification a partner site can inspect and re-run. In doing so, it shows how any GENIE-contributing center can conform local clinico-genomic data to a shared model in place — making the data federation-ready for multi-institutional cohort discovery and analysis without ever moving patient records across institutional boundaries.

## Overview

The figure below represents and overview of the process involved in transforming the real-world data into the custom data model:

While the process could be run end-to-end by an AI agent, having a human in the loop with subject matter expertise is recommended to ensure that the output is of high quality. The four components visible in the diagram are reference below in their own isolated section.&#x20;

### Create Custom Data Model in Rhino

1. Create a new Rhino project for the data transformation
2. Generate Rhino Data Schema Objects to reflect the custom data model (GENIE data model)
3. In Claude, upload the [data dictionary](https://github.com/AACR-Project-GENIE/GENIE-data-model/tree/main/GDM_v1.0.1) representing the GENIE data model and an example [Rhino Data Schema](https://docs.rhinofcp.com/data-schemas/what-is-a-data-schema) with the following prompt:

{% prompt description="Build Custom Data Model on the Rhino FCP" %}

```markdown
Generate a Rhino Data Schema object for each table in the data model described in the attached data dictionary. Requirements for each field per the data model (incl. permissible values) should be specified in the Description field of each column. 

You may explore the following page and related pages to understand Data Schema objects: https://docs.rhinohealth.com/hc/en-us/articles/12382860751517-What-is-a-Data-Schema
```

{% endprompt %}

4. Create a Data Schema for each target table by uploading the generated CSVs into your project.

<div data-with-frame="true"><figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2FUWu1cciDmsPfQzxpNAQq%2FScreenshot%202026-08-11%20at%208.54.08%E2%80%AFAM.png?alt=media&amp;token=0237a325-8081-4db3-89a1-f5866301d556" alt=""><figcaption></figcaption></figure></div>

4. Create Custom Vocabularies for the code sets required by the custom data model

<div data-with-frame="true"><figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2F5Z9VKNRKC6N5wrmsCH76%2FScreenshot%202026-08-11%20at%208.53.37%E2%80%AFAM.png?alt=media&amp;token=1b506b36-f700-4cff-84a1-8b8172b91a03" alt=""><figcaption></figcaption></figure></div>

### &#x20;Register Source Data

1. Register source data (BrCa BPC) on Rhino client by creating Datasets
2. Export auto-generated Rhino Data Schema Objects (CSVs) from the Rhino platform and save them locally.
3. Enhance data schemas by incorporating information from the data dictionary (GENIE BPC Analytic Data Guide BrCa v1.0-public)
4. Upload the data dictionary to Claude with the following prompt:

{% prompt description="Ingest Source Data Dictionary" %}

```markdown
Generate a CSV that extracts all of the information about tables and columns in the PDF.

Columns:
Filename | Dataset | Variable Name | Field Label | Provenance | Data Format | Values | Description | Preferred
Example:
patient_level_dataset.csv | PATIENT CHARACTERISTICS DATASET | institution | Institution | Character | Statistical Coordinator Center | DFCI = Dana Farber Cancer Institute, MSK = Memorial Sloan Kettering Cancer Center, VICC = Vanderbilt Ingram Cancer Center | Indicates the patient’s internal institution of cancer care. Corresponds to variable [center] in AACR Project GENIE data. | NA

Important Considerations:
The 'provenance' variable will be extracted from variable name per the color coding described on pages 6 using the following values:
Orange: AACR Project GENIE Tier 1 data.
Green: Institutional tumor registry.
Blue: Institutional EHR.
Purple: Statistical Coordinating Center.

The 'preferred' variable will be extracted from color coding also and you may have to make some inferences on which variable is preferred. For example, stage at diagnosis is captured from the tumor registry and also curated from the EHR, but a derived variable combining the two sources is also provided. In this case, the tumor registry and curated stage at diagnosis are shown with gray shading and the composite derived variable is preferred for analysis.
```

{% endprompt %}

5. Upload the auto-generated Rhino Data Schema objects (CSVs) into Claude with the following prompt:

{% prompt description="Enrich Rhino FCP Data Schemas With Source Data Context" %}

```markdown
Use the CSV generated above to enrich the Rhino platform's data schema objects. Each description section in the Rhino schemas objects should incorporate all relevant information from the generated CSV including provenance, values, description, and preferred status.
Take an adversarial approach to check your work and ensure that no information is inadvertently missed and not copied from the generated CSV to the updated Rhino schemas.
```

{% endprompt %}

6. Re-register the source data by creating Datasets while selecting the updated enriched Data Schema objects.&#x20;

### Generate Semantic Mappings

1. Paste the following prompt into Claude or another LLM connected to the Rhino MCP:

{% prompt description="Identify and Generate Required Semantic Mappings" %}

```markdown
Complete the following multi-step process:
1. Generate an Markdown file listing all of the datasets and columns and column descriptions from the available source Datasets in the project. 

2. Generate a Markdown file listing of all the datasets and columns and column descriptions from the available Data Schemas related to tables from the GENIE Data Model, as identified using the naming convention 'GDM - [Table Name] v1'

3. Generate a Markdown file name and descriptions of all of the Custom Vocabularies in the project.

4. Using the Markdown files, identify the GENIE data model columns that are to be created by translating source dataset columns into the Custom Vocabularies. Recommend semantic mappings to be created on the Rhino platform. 

Only create semantic mappings when source values are in a different format/vocabulary than the target and need fuzzy/LLM-based translation. If the source column is already coded in the exact same standard as the target vocabulary, there's nothing to "map" — it's a pass-through or, at most, a formatting fix.

If there are fewer than 6 unique values and the translation to the Custom Vocabulary is straightforward and not dependent on subject matter expertise (e.g. gender, units), use a Custom Mapping transformation type in a Syntactic Mapping rather than a Semantic Mapping. 

5. Create the recommended semantic mappings in the project (one per vocabulary/field combination)
```

{% endprompt %}

<div data-with-frame="true"><figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2F6q6sYunjryLgMfER0AyB%2FScreenshot%202026-08-11%20at%208.53.15%E2%80%AFAM.png?alt=media&amp;token=e0a76ad8-f6f4-4515-9a2c-f51e6a31adae" alt=""><figcaption></figcaption></figure></div>

### Generate and Execute Syntactic Mappings&#x20;

1. Paste the following prompt into Claude or another LLM connected to the Rhino MCP:

{% prompt description="Identify and Generate Required Syntactic Mappings" %}

```markdown
1. For the source Datasets in the project, create a plan to transform them into the Custom Data Model. 

Note that Python Code Objects are needed wherever a transformation goes beyond the operations Rhino's declarative syntactic mapping is built for. Several steps in this plan require row-level restructuring (e.g., pivoting wide drug-slot columns into one row per administration), multi-dataset joins that merge fields from different source tables into a single target row, or conditional logic and free-text parsing that can't be expressed as a fixed value lookup. Since a syntactic mapping assumes a stable one-row-in, one-row-out shape with a finite set of source values per column, any transformation that multiplies rows, merges tables, or applies procedural logic must be computed upstream in a Python Code Object, producing an already-correctly-shaped intermediate dataset that the syntactic mapping can then simply rename and vocabulary-map.

2. Create any Python Code Objects required to generate any staging tables necessary.

3. Run the Code Objects created above to create the staging tables necessary.

4. Generate the recommended syntactic mappings to the target data model and run the autogeneration to populate the mapping with the desired transformations

```

{% endprompt %}

<div data-with-frame="true"><figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2Fi0K3EcuSwoVuPQf9ScW4%2FScreenshot%202026-08-11%20at%208.52.57%E2%80%AFAM.png?alt=media&amp;token=66f0d461-3fe6-4f10-ba02-8fcd2916b00a" alt=""><figcaption></figcaption></figure></div>

2. Review the newly created syntactic mappings on the Rhino dashboard for accuracy and click 'Save' if all of the transformations appear accurate.&#x20;
3. Navigate to the 'Code' page and click 'Run' on the newly created Data Harmonization Code Object. <br>

<figure><img src="https://2949362692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FydySyCBmy6F7NnGn4bPa%2Fuploads%2FtZvF8kqr0hSm8s30ej7x%2FScreenshot%202026-08-11%20at%2010.04.41%E2%80%AFAM.png?alt=media&amp;token=cad9362b-e77f-46be-a891-7e1941cb4196" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rhinofcp.com/tutorials-recipes-and-demos/harmonizing-complex-rwd-to-a-custom-data-model.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
