ValueSet Converters
Tools for converting value sets in different formats. Such as converting
extensional value sets in CSV format to JSON format able to be uploaded to a
FHIR server.
Set up / installation
- You must have Python3 installed.
- Run to clone repo:
git clone https://github.com/HOT-Ecosystem/ValueSet-Converters.git
- Change directory:
cd ValueSet-Converters
- Make & use virtual environment:
virtualenv env; source env/bin/activate
- Run to install dependencies:
pip install -r requirements.txt
- To use the "VSAC to OMOP/FHIR JSON" tool, which fetches from Google Sheets,
you'll need the following:
3.a. Access to this
google sheet.
3.b. Placecredentials.json
andtoken.json
inside theenv/
directory.
These can be obtained from Joe (will upload them to a Google Drive folder
later). - Create an
env/.env
file based onenv/.env.example
, replacingVSAC_API_KEY
with your own VSAC API key as
shown in your profile. More instructions on getting an API key can be found in
"Step 1" on this page.
Tools
First, cd
into the directory where this repository was cloned.
1. CSV to FHIR JSON
First, convert your CSV to have column names like the example below. Then can
run these commands.
Syntax
python3 -m value_set_csv_to_fhir_json path/to/FILE.csv
Example
python3 -m value_set_csv_to_fhir_json examples/1/input/n3cLikeExtensionalValueSetExample.csv
Before:
valueSet.id,valueSet.name,valueSet.description,valueSet.status,valueSet.codeSystem,valueSet.codeSystemVersion,concept.code,concept.display
1,bear family,A family of bears.,draft,http://loinc.org,2.36,1234,mama bear
1,bear family,A family of bears.,draft,http://loinc.org,2.36,1235,papa bear
1,bear family,A family of bears.,draft,http://loinc.org,2.36,1236,baby bear
After:
{
"resourceType": "ValueSet",
"id": 1,
"meta": {
"profile": [
"http://hl7.org/fhir/StructureDefinition/shareablevalueset"
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n\t\t\t<p>A family of bears.</p>\n\t\t</div>"
},
"name": "bear family",
"title": "bear family",
"status": "draft",
"description": "A family of bears.",
"compose": {
"include": [
{
"system": "http://loinc.org",
"version": 2.36,
"concept": [
{
"code": 1234,
"display": "mama bear"
},
{
"code": 1235,
"display": "papa bear"
},
{
"code": 1236,
"display": "baby bear"
}
]
}
]
}
}
2. VSAC to OMOP/FHIR JSON
This will fetch from the following google sheet:
https://docs.google.com/spreadsheets/d/1jzGrVELQz5L4B_-DqPflPIcpBaTfJOUTrVJT5nS_j18/edit#gid=1335629675
Syntax
- With default options:
python3 -m value_set_vsac_to_json
- Choosing an output format:
python3 -m value_set_vsac_to_json -f omop
Options:
Short flag | Long flag | Options | Default | Description |
---|---|---|---|---|
-f |
--format |
['omop', 'fhir'] |
'omop' | Output format. |
GitHub - HOT-Ecosystem/ValueSet-Converters at pythonawesome.com
Various converters to convert value sets from CSV to JSON, etc. - GitHub - HOT-Ecosystem/ValueSet-Converters at pythonawesome.com