Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zavoraad authored Dec 16, 2024
1 parent e703233 commit 701b938
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions dbignite/writer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ This can be done in either the Dataframe creation step or lambda encoder.
from pyspark.sql.functions import *
data.createOrReplaceTempView("claims")
df = spark.sql("""
SELECT array(map('code', prcdr_cd1, 'system', 'http://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets')) as codeset_prcdr,
SELECT map('code', prcdr_cd1, 'system', 'http://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets') as codeset_prcdr,
map('code', dx_cd1, 'system', 'http://terminology.hl7.org/CodeSystem/icd9cm') as codeset_dx
from claims
""")
Expand All @@ -156,16 +156,29 @@ df.show(truncate=False)
"""

maps = [
Mapping('codeset_prcdr', 'Claim.extension.coding'),
Mapping('codeset_dx', 'Claim.extension.coding')]
Mapping('codeset_prcdr', 'Claim.extension'),
Mapping('codeset_dx', 'Claim.extension')]

em = FhirEncoderManager(override_encoders ={
"Claim.extension.coding":
FhirEncoder(False, False, lambda x: x[0] )})
"Claim.extension":
FhirEncoder(False, False, lambda x: x )})

m = MappingManager(maps, df.schema, em)
b = Bundle(m)
b.df_to_fhir(df).map(lambda x: json.loads(x)).foreach(lambda x: print(json.dumps(x, indent=4)))

"""
"extension": [
{
"code": "PRCDR11",
"system": "http://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets"
},
{
"code": "DX11",
"system": "http://terminology.hl7.org/CodeSystem/icd9cm"
}
]
"""
```

```python
Expand Down

0 comments on commit 701b938

Please sign in to comment.