Created
April 9, 2019 20:02
-
-
Save zindel/e58a32af4ee2baffa6e6d4de98bc29c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fhir = box() | |
fhir.resourceType = 'Condition' | |
# {"resourceType": "Condition"} | |
fhir.id = identifier.value(table='condition_occurrence', | |
code=condition.condition_occurrence_id) | |
fhir.verificationStatus = 'unknown' | |
fhir.clinicalStatus = 'inactive' if condition.end_date else 'inactive' | |
fhir.subject = identifier.ref(resource_type='Patient', | |
table='person', | |
code=condition.person_id) | |
extract_condition_category(fhir, condition) | |
with fhir.code.coding[0] as c: | |
c.system = vocabulary.guess_system(vocabulary_id=condition.condition_concept_vocabulary_id) | |
c.code = condition.condition_concept_code | |
c.display = condition.condition_concept_name | |
fhir.onsetDateTime = condition.start_date | |
if condition.end_date: | |
fhir.abatementDateTime = condition.end_date | |
# columns which we don't know how to map exactly | |
ext = lambda attr, type: extension.column(table='condition_concept_id', | |
column=attr, | |
value=getattr(condition, attr), | |
type=type) | |
columns = [ | |
('condition_source_value', 'String'), | |
('condition_source_concept_id', 'Integer'), | |
('condition_status_source_value', 'String'), | |
('condition_status_concept_id', 'Integer'), | |
] | |
for column, type in columns: | |
push(fhir.extension, ext(column, type)) | |
return unbox(fhir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment