FHIR Extensions¶
A FHIR extension provides a way to add custom data elements to existing FHIR resources, enabling the representation of information that is not defined in the core FHIR specification. They allow for flexibility and extensibility within FHIR while maintaining interoperability.
The vocuabulary Observation includes a summary of these extensions
In [2]:
Copied!
# extensions with ranges
combined_extension_range_counts = df[['research_study_identifiers', 'path', 'extension_url', 'low', 'high', 'url']]
combined_extension_range_counts = combined_extension_range_counts[combined_extension_range_counts['extension_url'] != '']
combined_extension_range_counts = combined_extension_range_counts[combined_extension_range_counts['low'] != '']
combined_extension_range_counts
# extensions with ranges
combined_extension_range_counts = df[['research_study_identifiers', 'path', 'extension_url', 'low', 'high', 'url']]
combined_extension_range_counts = combined_extension_range_counts[combined_extension_range_counts['extension_url'] != '']
combined_extension_range_counts = combined_extension_range_counts[combined_extension_range_counts['low'] != '']
combined_extension_range_counts
Out[2]:
| Loading ITables v2.5.2 from the internet... (need help?) |
In [3]:
Copied!
# extensions with codes
combined_extension_code_counts = df[['research_study_identifiers', 'path', 'extension_url', 'display', 'url', 'count']]
combined_extension_code_counts = combined_extension_code_counts[combined_extension_code_counts['extension_url'] != '']
combined_extension_code_counts = combined_extension_code_counts[combined_extension_code_counts['display'] != '']
combined_extension_code_counts
# extensions with codes
combined_extension_code_counts = df[['research_study_identifiers', 'path', 'extension_url', 'display', 'url', 'count']]
combined_extension_code_counts = combined_extension_code_counts[combined_extension_code_counts['extension_url'] != '']
combined_extension_code_counts = combined_extension_code_counts[combined_extension_code_counts['display'] != '']
combined_extension_code_counts
Out[3]:
| Loading ITables v2.5.2 from the internet... (need help?) |
In [4]:
Copied!
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Create heatmap for each extension
# Get unique extensions
extension_urls = combined_extension_code_counts['extension_url'].unique()
combined_extension_code_counts = combined_extension_code_counts.infer_objects(copy=False)
for extension_url in extension_urls:
# Filter data for the current extension
filtered_data = combined_extension_code_counts[combined_extension_code_counts['extension_url'] == extension_url]
# Pivot the filtered data for the heatmap
heatmap_data = filtered_data.pivot_table(index='research_study_identifiers',
columns=['display'],
values='count',
fill_value=0.0)
# Create the heatmap
plt.figure(figsize=(12, 10)) # Adjust figsize as needed
# sns.heatmap(heatmap_data, annot=True, annot_kws={"size": 6}, fmt=".0f", cmap='viridis', cbar=False)
# Create a mask to identify zero values
mask = heatmap_data == 0
# Custom function to format annotations
def heatmap_annot(val, **kwargs):
if val == 0: # Hide annotations for zero values
return ""
else:
return f"{val:.0f}" # Format non-zero values as integers
# Generate heatmap with the custom annotation function
ax = sns.heatmap(heatmap_data, annot=True, fmt=".0f", cmap='viridis',
cbar_kws={'extend': 'both', 'extendrect': True},
vmin=0, # Set minimum value for color scale
vmax=heatmap_data.max().max() / 2, # Adjust maximum value
annot_kws={"size": 6}) # Reduce font size
# Apply the custom annotation function to each cell
for text in ax.texts:
text.set_text(heatmap_annot(float(text.get_text())))
plt.title(f'Heatmap for Path: {extension_url}') # Set title with path name
plt.xlabel('Display')
plt.ylabel('Research Study Identifiers')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Create heatmap for each extension
# Get unique extensions
extension_urls = combined_extension_code_counts['extension_url'].unique()
combined_extension_code_counts = combined_extension_code_counts.infer_objects(copy=False)
for extension_url in extension_urls:
# Filter data for the current extension
filtered_data = combined_extension_code_counts[combined_extension_code_counts['extension_url'] == extension_url]
# Pivot the filtered data for the heatmap
heatmap_data = filtered_data.pivot_table(index='research_study_identifiers',
columns=['display'],
values='count',
fill_value=0.0)
# Create the heatmap
plt.figure(figsize=(12, 10)) # Adjust figsize as needed
# sns.heatmap(heatmap_data, annot=True, annot_kws={"size": 6}, fmt=".0f", cmap='viridis', cbar=False)
# Create a mask to identify zero values
mask = heatmap_data == 0
# Custom function to format annotations
def heatmap_annot(val, **kwargs):
if val == 0: # Hide annotations for zero values
return ""
else:
return f"{val:.0f}" # Format non-zero values as integers
# Generate heatmap with the custom annotation function
ax = sns.heatmap(heatmap_data, annot=True, fmt=".0f", cmap='viridis',
cbar_kws={'extend': 'both', 'extendrect': True},
vmin=0, # Set minimum value for color scale
vmax=heatmap_data.max().max() / 2, # Adjust maximum value
annot_kws={"size": 6}) # Reduce font size
# Apply the custom annotation function to each cell
for text in ax.texts:
text.set_text(heatmap_annot(float(text.get_text())))
plt.title(f'Heatmap for Path: {extension_url}') # Set title with path name
plt.xlabel('Display')
plt.ylabel('Research Study Identifiers')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()