Skip to main content

An adapter for transfer DigitalTWIN Clinic Description to FHIR

Project description

Digitaltwins on FHIR

Usage

  • Setup and connect to FHIR server
from digitaltwins_on_fhir.core import Adapter

adapter = Adapter("http://localhost:8080/fhir/")

Load data to FHIR server

Primary measurements

  • Load FHIR bundle
 await adapter.loader().load_fhir_bundle('./dataset/dataset-fhir-bundles')
  • Load DigitalTWIN Clinical Description (primary measurements)
measurements = adapter.loader().load_sparc_dataset_primary_measurements()
with open('./dataset/measurements.json', 'r') as file:
    data = json.load(file)

await measurements.add_measurements_description(data).generate_resources()
  • Add Practitioner (researcher) to FHIR server
from digitaltwins_on_fhir.core.resource import Identifier, Code, HumanName, Practitioner

await measurements.add_practitioner(researcher=Practitioner(
  active=True,
  identifier=[
    Identifier(use=Code("official"), system="sparc.org",
               value='sparc-d557ac68-f365-0718-c945-8722ec')],
  name=[HumanName(use="usual", text="Xiaoming Li", family="Li", given=["Xiaoming"])],
  gender="male"
))

Workflow

Search

References in Task (workflow tool process) resource

  • owner: Patient reference
  • for: PlanDefinition (workflow) reference
  • focus: ActivityDefinition (workflow tool) reference
  • basedOn: ResearchSubject reference
  • requester (Optional): Practitioner (researcher) reference
  • references in input
    • ImagingStudy
    • Observation
  • references in output
    • Observation
Example
  • Find a specific workflow process
    • If known: patient, dataset, workflow tool and workflow uuids
client = adapter.async_client

# Step 1: find the patient
patient = await client.resources("Patient").search(
                                    identifier="patient-xxxx").first()
# Step 2: find the dataset
dataset = await client.resources("ResearchStudy").search(
                                    identifier="dataset-xxxx").first()
# Step 3: find the workflow tool
workflow_tool = await client.resources("ActivityDefinition").search(
                                    identifier="workflow-tool-xxxx").first()
# Step 4: find the research subject
research_subject = await client.resources("ResearchSubject").search(
                                    patient=patient.to_reference().reference,
                                    study=dataset.to_reference().reference).first()
# Step 5: find workflow
workflow = await client.resources("PlanDefinition").search(
                                    identifier="sparc-workflow-uuid-001").first()
workflow_tool_process = await client.resources("Task").search(
                                    subject=workflow.to_reference(),
                                    focus=workflow_tool.to_reference(),
                                    based_on=research_subject.to_reference(),
                                    owner=patient.to_reference()).first()
  • Find all input resources of the workflow tool process
inputs = workflow_tool_process.get("input")
for i in inputs:
    input_reference = i.get("valueReference")
    input_resource = await input_reference.to_resource()
  • Find the input data comes from with dataset
    • Assume we don't know the dataset and patient uuids at this stage
composition = await client.resources("Composition").search(
                                    title="primary measurements", 
                                    entry=input_reference).first()
dataset = await composition.get("subject").to_resource()
  • Find all output resources of the workflow tool process
outputs = workflow_tool_process.get("output")
for output in outputs:
    output_reference = output.get("valueReference")
    output_resource = await output_reference.to_resource()

References in PlanDefinition (workflow) resource

  • action
    • definition_canonical: ActivityDefinition (workflow tool) reference
Example
  • If known workflow uuid
    • Find all related workflow tools
      workflow = await client.resources("PlanDefinition").search(
                                          identifier="sparc-workflow-uuid-001").first()
      actions = workflow.get("action")
      
      for a in actions:
          if a.get("definitionCanonical") is None:
              continue
          resource_type, _id = a.get("definitionCanonical").split("/")
          workflow_tool = await client.reference(resource_type, _id).to_resource()
      
    • Find all related workflow processes
      workflow_tool_processes = await client.resources("Task").search(
                                          subject=workflow.to_reference()).fetch_all()
      

Reference in resource

  • Patient
    • generalPractitioner: [ Practitioner reference ]
  • ResearchSubject
    • individual(patient): Patient reference
    • study: ResearchStudy reference
    • consent: Consent reference
  • ResearchStudy
    • principalInvestigator: Practitioner reference
  • Composition - primary measurements
    • author: [ Patient reference, Practitioner reference ]
    • subject: ResearchStudy reference
    • entry: [ Observation reference, ImagingStudy reference]
  • ImagingStudy
    • subject: Patient reference
    • endpoint: [ Endpoint Reference ]
    • referrer: Practitioner reference
  • Observation - primary measurements
    • subject: Patient reference
  • PlanDefinition:
    • action.definitionCanonical: ActivityDefinition reference string
  • ActivityDefinition:
    • participant: [ software uuid, model uuid]
  • Task:
    • owner: patient reference
    • for(subject): workflow reference
    • focus: workflow tool reference
    • basedOn: research subject reference
    • requester (Optional): practitioner reference
    • input: [ Observation reference, ImagingStudy reference ]
    • output: [ Observation reference, ImagingStudy reference ]
  • Composition - workflow tool result
    • author: Patient reference
    • subject: Task (workflow tool process) reference
    • section:
      • entry: Observations
      • focus: ActivityDefinition (workflow tool) reference
  • Observation - workflow tool result
    • focus: [ActivityDefinition reference]

DigitalTWIN on FHIR Diagram

DigitalTWIN on FHIR

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

digitaltwins_on_fhir-1.2.3.tar.gz (66.9 kB view details)

Uploaded Source

Built Distribution

digitaltwins_on_fhir-1.2.3-py3-none-any.whl (85.0 kB view details)

Uploaded Python 3

File details

Details for the file digitaltwins_on_fhir-1.2.3.tar.gz.

File metadata

  • Download URL: digitaltwins_on_fhir-1.2.3.tar.gz
  • Upload date:
  • Size: 66.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for digitaltwins_on_fhir-1.2.3.tar.gz
Algorithm Hash digest
SHA256 838e40ac4b27bbc8e030762e5ba086d5b5cac9a436bf8f7acb5314c740600024
MD5 2af6264179f231233cfbfb4d3bb280c3
BLAKE2b-256 b6a852bd4bb77eabd48e5354ee55e2bf3c9c475e431a2f665d48cc81a41cc808

See more details on using hashes here.

File details

Details for the file digitaltwins_on_fhir-1.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for digitaltwins_on_fhir-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 390d0eb502d5111d356c598e7a4c6fcc9d3eac777690563ea104bf1dfebc45f8
MD5 53510b9f7c5a013c852437329039e35e
BLAKE2b-256 0f0d2a2c7ea9e677b6e807a48fddb2587a5c10e2d3074aae731d8f7de5c94cc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page