-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cac3148
commit 74c543f
Showing
7 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Concept-Mappers between Kids First and FHIR | ||
|
||
- `Group` | ||
- `Patient` | ||
- `FamilyMemberHistory` | ||
- `Condition` | ||
- `Observation` | ||
- `Specimen` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
def disease_onset(x): | ||
""" | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-onset.html | ||
""" | ||
pass | ||
|
||
def disease_tumor_stage(x): | ||
""" | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-tumor-stage.html | ||
""" | ||
pass | ||
|
||
def condition_code(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-condition-code.html | ||
""" | ||
pass | ||
|
||
def body_site(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-body-site.html | ||
""" | ||
|
||
|
||
condition = { | ||
'resourceType': 'Condition', | ||
'id': DIAGNOSIS.TARGET_SERVICE_ID | ||
'disease-onset': { | ||
'coding': [ | ||
{ | ||
'system': 'http://purl.obolibrary.org/obo/hp.owl', | ||
'code': 'HP:0410280' | ||
'display': 'Pediatric onset' | ||
} | ||
] | ||
}, | ||
'disease-tumor-stage': None, # disease_tumor_stage() | ||
'code': { | ||
'coding': None, # condition_code() | ||
'text': DIAGNOSIS.NAME | ||
}, | ||
'bodySite': None # body_site() | ||
'subject': { | ||
'reference': f'Patient/{PARTICIPANT.TARGET_SERVICE_ID}', | ||
'type': 'Patient' | ||
}, | ||
'onsetAge': DIAGNOSIS.EVENT_AGE_DAYS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
def pedigree_node_affected_status(x): | ||
""" | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-pedigree-affected-status.html | ||
""" | ||
if x == constants.COMMON.FALSE: | ||
return { | ||
'code': 'Affected', | ||
'display': 'Affected' | ||
} | ||
elif x == constants.COMMON.TRUE: | ||
return { | ||
'code': 'unaffected', | ||
'display': 'Unaffected' | ||
} | ||
elif x == constants.COMMON.UNKNOWN: | ||
return { | ||
'code': 'missing', | ||
'display': 'Missing' | ||
} | ||
else: | ||
raise Exception('Unknown FamilyMemberHistory pedigree-node-affected-status') | ||
|
||
def relationship(x): | ||
""" | ||
http://hl7.org/fhir/R4/v3/FamilyMember/vs.html | ||
""" | ||
coding = {"system": "http://terminology.hl7.org/CodeSystem/v3-RoleCode"} | ||
if x == constants.RELATIONSHIP.FATHER: | ||
return coding.update({ | ||
'code': 'FTH', | ||
'display': 'father' | ||
}) | ||
elif x == constants.RELATIONSHIP.MOTHER: | ||
return coding.update({ | ||
'code': 'MTH', | ||
'display': 'mother' | ||
}) | ||
else: | ||
raise Exception('Unknown FamilyMemberHistory relationship') | ||
|
||
def sex(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-administrative-gender.html | ||
""" | ||
if x == constants.GENDER.FEMALE: | ||
return 'female' | ||
elif x == constants.GENDER.MALE: | ||
return 'male' | ||
elif x == constants.COMMON.OTHER: | ||
return 'other' | ||
elif x == constants.COMMON.UNKNOWN: | ||
return 'unknown' | ||
else: | ||
raise Exception('Unknown FamilyMemberHistory sex') | ||
|
||
|
||
family_member_history = { | ||
'resourceType': 'FamilyMemberHistory', | ||
'id': FAMILY_RELATIONSHIP.TARGET_SERVICE_ID, | ||
'pedigree-node-affected-status': | ||
pedigree_node_affected_status(PARTICIPANT.IS_AFFECTED_UNDER_STUDY), | ||
'pedigree-node-family-identifier': [ | ||
{ | ||
'system': None, | ||
'value': FAMILY.ID | ||
} | ||
], | ||
'pedigree-node-individual': { | ||
'reference': f'Patient/{PARTICIPANT.TARGET_SERVICE_ID}', | ||
'type': 'Patient' | ||
}, | ||
'identifier': [ | ||
{ | ||
'system': None | ||
'value': FAMILY_RELATIONSHIP.ID | ||
} | ||
], | ||
'status': None, | ||
'patient': { | ||
'reference': f'Patient/{PARTICIPANT.TARGET_SERVICE_ID}', | ||
'type': 'Patient' | ||
}, | ||
'relationship': { | ||
"coding": [ | ||
relationship(FAMILY_RELATIONSHIP.RELATION_FROM_1_TO_2) | ||
] | ||
}, | ||
'sex': sex(PARTICIPANT.GENDER), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
def group_type(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-group-type.html | ||
""" | ||
if x in {constants.SPECIES.DOG}: | ||
return 'animal' | ||
elif x == constants.SPECIES.HUMAN: | ||
return 'person' | ||
else: | ||
raise Exception('Unknown Group type') | ||
|
||
def family_member_type(x): | ||
''' | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-family-member-type.html | ||
''' | ||
if x == constants.COMMON.TRUE: | ||
return { | ||
'code': 'proband', | ||
'display': 'Proband' | ||
} | ||
elif x == constants.COMMON.FALSE: | ||
return { | ||
'code': 'relative', | ||
'display': 'Relative' | ||
} | ||
else: | ||
raise Exception('Unknown Group family-member-type') | ||
|
||
|
||
group = 'Group': { | ||
'resourceType': 'Group', | ||
'id': FAMILY.TARGET_SERVICE_ID, | ||
'identifier': [ | ||
{ | ||
'system': None | ||
'value': FAMILY.ID | ||
} | ||
], | ||
'type': group_type(PARTICIPANT.SPECIES or constants.SPECIES.HUMAN), | ||
'actual': constants.COMMON.TRUE or constants.COMMON.FALSE, # defaults to True | ||
'member': [ | ||
{ | ||
'id': PARTICIPANT.ID, | ||
'family-member-type': { | ||
'coding': [ | ||
family_member_type(PARTICIPANT.IS_PROBAND) | ||
] | ||
}, | ||
# 'family-member-phenopacket': {}, | ||
'entity': { | ||
'reference': f'Patient/{PARTICIPANT.KF_ID}', | ||
'type': 'Patient' | ||
}, | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
def status(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-observation-status.html | ||
""" | ||
pass | ||
|
||
def interpretation(x): | ||
""" | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-phenotypic-feature-interpretation.html | ||
""" | ||
if x == constants.PHENOTYPE.OBSERVED.NO: | ||
return { | ||
'code': 'NEG', | ||
'display': 'Negative' | ||
} | ||
elif x == constants.PHENOTYPE.OBSERVED.YES: | ||
return { | ||
'code': 'POS', | ||
'display': 'Positive' | ||
} | ||
else: | ||
raise Exception('Unknown Observation interpretation') | ||
|
||
|
||
observation = { | ||
'id': PHENOTYPE.TARGET_SERVICE_ID, | ||
'phenotypic-feature-severity': None, | ||
'phenotypic-feature-modifier': None, | ||
'phenotypic-feature-onset': { | ||
'valueAge': PHENOTYPE.EVENT_AGE_DAYS | ||
}, | ||
'evidence': None, | ||
'identifier': [ | ||
{ | ||
'system': None, | ||
'value': PHENOTYPE.ID | ||
} | ||
], | ||
'status': 'registered', # defaults to 'registered' | ||
'code': { | ||
'text': PHENOTYPE.NAME | ||
}, | ||
'subject': { | ||
'reference': f'Patient/{PARTICIPANT.TARGET_SERVICE_ID}', | ||
'type': 'Patient' | ||
}, | ||
'interpretation': { | ||
'coding': [ | ||
interpretation(PHENOTYPE.OBSERVED) | ||
] | ||
}, | ||
'bodySite': None # body_site() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
def individual_texonomy(x): | ||
""" | ||
https://aehrc.github.io/fhir-phenopackets-ig/ValueSet-taxonomy.html | ||
""" | ||
if x == constants.SPECIES.DOG: | ||
return { | ||
'code': 'NCBITaxon_9615', | ||
'display': 'Canis lupus familiaris' | ||
} | ||
elif x == constants.SPECIES.HUMAN: | ||
return { | ||
'code': 'NCBITaxon_9606', | ||
'display': 'Homo sapiens' | ||
} | ||
else: | ||
raise Exception('Unknown Patient individual-taxonomy') | ||
|
||
def gender(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-administrative-gender.html | ||
""" | ||
if x == constants.GENDER.FEMALE: | ||
return 'female' | ||
elif x == constants.GENDER.MALE: | ||
return 'male' | ||
elif x == constants.COMMON.OTHER: | ||
return 'other' | ||
elif x == constants.COMMON.UNKNOWN: | ||
return 'unknown' | ||
else: | ||
raise Exception('Unknown Patient gender') | ||
|
||
|
||
patient = { | ||
'resourceType': 'Patient' | ||
'id': PARTICIPANT.TARGET_SERVICE_ID, | ||
'individual-age': { | ||
'valueAge': PARTICIPANT.ENROLLMENT_AGE_DAYS | ||
}, | ||
'individual-karyotypic-sex': None, | ||
'individual-taxonomy': { | ||
'coding': [ | ||
individual_texonomy(PARTICIPANT.SPECIES or constants.SPECIES.HUMAN) | ||
] | ||
}, | ||
'identifier': [ | ||
{ | ||
'system': None, | ||
'value': PARTICIPANT.ID | ||
} | ||
], | ||
'gender': gender(PARTICIPANT.GENDER), | ||
'birthDate': None | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
def status(x): | ||
""" | ||
http://hl7.org/fhir/R4/valueset-specimen-status.html | ||
""" | ||
if x == constants.COMMON.FALSE: | ||
return 'unavailable' | ||
elif x == constants.COMMON.TRUE: | ||
return 'available' | ||
else: | ||
raise Exception('Unknown Specimen status') | ||
|
||
def specimen_type(x): | ||
""" | ||
http://hl7.org/fhir/R4/v2/0487/index.html | ||
""" | ||
if x == constants.SPECIMEN.COMPOSITION.BLOOD: | ||
return { | ||
'coding': 'BLD', | ||
'display': 'Whole blood' | ||
} | ||
elif x == constants.SPECIMEN.COMPOSITION.SALIVA: | ||
return { | ||
'coding': 'SAL', | ||
'display': 'Saliva' | ||
} | ||
elif x == constants.SPECIMEN.COMPOSITION.TISSUE: | ||
return { | ||
'coding': 'TISS', | ||
'display': 'Tissue' | ||
} | ||
else: | ||
raise Exception('Unknown Specimen type') | ||
|
||
|
||
specimen = { | ||
'resourceType': 'Specimen', | ||
'id': BIOSPECIMEN.TARGET_SERVICE_ID, | ||
'biosample-individual-age-at-collection': None, | ||
'biosampe-histological-diagnosis': None, | ||
'biosample-tumor-progression': None, | ||
'biosample-tumor-grade': None, | ||
'biosample-control': True or False, # defaults to True | ||
'identifier': [ | ||
{ | ||
'system': None, | ||
'value': BIOSPECIMEN.ID | ||
} | ||
], | ||
'accessionIdentifier': [ | ||
{ | ||
'system': None, | ||
'value': BIOSPECIMEN.ID | ||
} | ||
], | ||
'status': status(BIOSPECIMEN.VISIBLE), | ||
'type': { | ||
'coding': [ | ||
specimen_type(BIOSPECIMEN.COMPOSITION) | ||
], | ||
'text': BIOSPECIMEN.COMPOSITION | ||
}, | ||
'subject': { | ||
'reference': f'Patient/{PARTICIPANT.TARGET_SERVICE_ID}', | ||
'type': 'Patient' | ||
} | ||
} |