Package: pfb-fhir
Table of ContentsAbout The ProjectBuilt WithGetting StartedPrerequisitesInstallationUsageRoadmapContributingLicenseContactAcknowledgmentspfb_fhirAbout The ProjectRender a PFB graph from FHIR dataBuilt Withpydanticfastavropypfb[gen3]flatten_jsonfhirclientr4syntheaSpecial thanksKyle Ellrott(OHSU)NHGRI Genomic Data Science Analysis, Visualization and Informatics Lab-spaceAnVILNCPI FHIR Working Group, Robert Carroll (VUMC), Allison Heath (CHOP)Center for Translational Data Science (UChicago)gen3ncpi-fhir-pfb-prototypeBrian O'Connor (Broad), Ann Van (Nimbus Informatics)GA4GHcohort-rep-hackathonsyntheaGetting StartedInstallation:# clone 
git clone https://github.com/bmeg/pfb_fhir
cd pfb_fhirTo get a local copy up and running follow these simple example steps.# use virtual env
python3 -m venv venv
source venv/bin/activate

# install dependencies  
pip install -r requirements.txt

# install this package
pip install -e .UsageSee help for a list of commands, examine configuration examples in fixtures:$ pfb_fhir --help
Usage: pfb_fhir [OPTIONS] COMMAND [ARGS]...

  Render FHIR Data in PFB.

Options:
  -l, --log-level [NOTSET|DEBUG|INFO|WARNING|ERROR|CRITICAL]
  --output_path TEXT              Output path for working files and output.
                                  Read from PFB_FHIR_OUTPUT_PATH [default:
                                  ./DATA]

  --config_path TEXT              Path to config file. Read from
                                  PFB_FHIR_CONFIG_PATH [default:
                                  ./config.yaml]

  --help                          Show this message and exit.

Commands:
  version    Print the version.
  transform  Transform FHIR resources from directory.
  inspect    Inspect a PFB.
  visualize  Create a simple visualization.
  config     Print the config.
  demo       Download Test data and create example PFB and figure.Environmental variables and their defaultsPFB_FHIR_CONFIG_PATH./config.yamlPFB_FHIR_OUTPUT_PATHDATA/PFB_FHIR_CACHE_PATHcache/DemosSeveral demonstration datasets are available:anvilRead 1000G data from AnVIL.dbgapRead open access data from dbGAP's FHIR service.kfRead synthetic clinical data created by kids first.ncpiRead examples from ncpi ImplementationGuide.syntheaRead synthetic clinical data created by synthea.genomic-reportingRead oncology example from ImplementationGuide.For example:# run the demo
pfb_fhir demo dbgap

# view the image
open DEMO/dbgap/output/dbgap.pfb.avro.png 

# inspect the pfb
pfb_fhir inspect --pfb_path  DEMO/dbgap/output/dbgap.pfb.avro

# use gen3's pfb utility
cat DEMO/dbgap/output/dbgap.pfb.avro | pfb show stats 

# or native avro tools
java -jar avro-tools-1.11.0.jar getschema DEMO/dbgap/output/dbgap.pfb.avro | \
jq '.fields[] | select(.name == "object") | .type[] | .name 'Using the PFBTerra# run the demo
pfb_fhir demo synthea

# upload that PFB to google storage
gsutil cp DEMO/synthea/output/synthea.pfb.avro $GOOGLE_BUCKET

# Sign the url so terra can read it.
gsutil signurl -u  $GOOGLE_BUCKET/synthea.pfb.avro

# Or, grant access
# gsutil acl ch -u AllUsers:R  $GOOGLE_BUCKET/synthea.pfb.avro

# url encode the signed url
 
open 'https://app.terra.bio/#import-data?format=PFB&url=https:....'Gen3The easiest way to see the resulting schema in gen3 is to use theData Dictionary Development workflowUse the intermediate file located at <PFB_FHIR_OUTPUT_PATH>//output/dump-ordered.json e.g. DEMO/ncpi/output/dump-ordered.jsonContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestDistribution# update pypi

export TWINE_USERNAME=  #  the username to use for authentication to the repository.
export TWINE_PASSWORD=  # the password to use for authentication to the repository.

rm -r dist/
python3  setup.py sdist bdist_wheel
twine upload dist/*LicenseDistributed under the Apache License. SeeLICENSEfor more information.ContactBrian Walsh -@bpwalsh- walsbr AT ohsu DOT eduAcknowledgmentsNIH-NCPIAnVILncpi-fhir-pfb-prototypegen3Roadmap✅ config.yaml driven map of FHIR resource to PFB node,✅ Parse FHIR resources, retrieve and cache FHIR profile (schema) elements,✅ Recursively match with FHIR profiles (schemas)✅ Flatten for export✅ write to PFB✅ test cases for protected/ resources - ResearchSubject, Patient, Specimen, Task, DocumentReference✅ networkx based visualization✅ pfb cli✅ demo with public data✅ update README with Terra import examples✅ update README with gen3 import examples✅ update to new release of pypfb0.5.18✅ include kids first✅ simplify✅ add genomic reportingexamples✅ pypiDistributionTest with dockerdocker build -t pfb_fhir .

# typical run command
docker run -v $(pwd)/cache:/app/pfb_fhir/cache -v $(pwd)/DEMO:/app/pfb_fhir/DEMO pfb_fhir demo ncpiUpdate pypiexport TWINE_USERNAME=  #  the username to use for authentication to the repository.
export TWINE_PASSWORD=  # the password to use for authentication to the repository.

rm -r dist/
python3  setup.py sdist bdist_wheel
twine upload dist/*Known Issuessimplify- could do a better job of making resulting nodes more "data frame friendly"config.yaml- currently there is no way of expressing a reference found in a FHIR extension.