Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@
"code": "string"
}
]
},
{
"id": "DiagnosisComponent.clm_prod_type_cd_map",
"path": "DiagnosisComponent.clm_prod_type_cd_map",
"label": "Augmented Diagnosis Prod Type Code Map",
"min": 0,
"max": "*",
"type": [
{
"code": "string"
}
]
}

]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,11 @@
]
},
{
"id": "LineItemComponent.diagnosisRelatedLine",
"path": "LineItemComponent.diagnosisRelatedLine",
"id": "LineItemComponent.diagnosisSequence",
"path": "LineItemComponent.diagnosisSequence",
"label": "Corresponding diagnosis sequence number. Computed based upon resource generation.",
"min": 0,
"max": "1",
"max": "*",
"type": [
{
"code": "string"
Expand Down Expand Up @@ -1227,7 +1227,7 @@
"label": "Supporting Info Sequence Number",
"definition": "Pre-calculated sequence number for supportingInfo reference.",
"min": 0,
"max": "1",
"max": "*",
"type": [
{
"code": "string"
Expand Down Expand Up @@ -1262,4 +1262,4 @@
}
]
}
}
}
55 changes: 25 additions & 30 deletions apps/bfd-model-idr/augment_sample_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,46 +233,41 @@ class Diagnosis:
diagnosis_codes = [
Diagnosis(
CLM_DGNS_CD=x.get("CLM_DGNS_CD"),
CLM_PROD_TYPE_CD=x.get("CLM_PROD_TYPE_CD"),
CLM_POA_IND=x.get("CLM_POA_IND"),
CLM_DGNS_PRCDR_ICD_IND=x.get("CLM_DGNS_PRCDR_ICD_IND"),
ROW_NUM=x.get("CLM_VAL_SQNC_NUM"),
)
for x in cur_sample_data.get("diagnoses", [])
if x.get("CLM_PROD_TYPE_CD") == "D"
if x.get("CLM_PROD_TYPE_CD") in ["D", "P", "A", "R", "E"]
]

# of note, 1 and E appear to always be the same, so we only care about the E code.
clm_prod_type_cds = ["P", "A", "R", "E"]
# this loop ensures that 'rogue' (eg principal not present in main list) diagnoses are not missed.
for clm_prod_type_cd in clm_prod_type_cds:
code = [
x.get("CLM_DGNS_CD")
for x in cur_sample_data.get("diagnoses", [])
if x.get("CLM_PROD_TYPE_CD") == clm_prod_type_cd
]
if code and code[0] not in [x.CLM_DGNS_CD for x in diagnosis_codes]:
diagnosis = Diagnosis(
CLM_DGNS_CD=code,
CLM_PROD_TYPE_CD=clm_prod_type_cd,
CLM_DGNS_PRCDR_ICD_IND=diagnosis_codes[0].CLM_DGNS_PRCDR_ICD_IND,
ROW_NUM=str(len(diagnosis_codes) + 1),
)
diagnosis_codes.append(diagnosis)

for diagnosis_code in diagnosis_codes:
for clm_prod_type_cd in clm_prod_type_cds:
cur_code = [
x.get("CLM_DGNS_CD")
for x in cur_sample_data.get("diagnoses", [])
if x.get("CLM_PROD_TYPE_CD") == clm_prod_type_cd
]
if cur_code and cur_code[0] == diagnosis_code.CLM_DGNS_CD:
diagnosis_code.clm_prod_type_cd_map.append(clm_prod_type_cd)
if len(diagnosis_code.clm_prod_type_cd_map) == 0:
diagnosis_code.clm_prod_type_cd_map.append("D")
# Sort diagnoses keys
type_priority = {"P": 1, "A": 2, "R": 3, "E": 4}

# We need to preserve the list but sort it
diagnosis_codes.sort(key=lambda d: type_priority.get(d.CLM_PROD_TYPE_CD, 99))

# Assign sequential ROW_NUM
for idx, diag in enumerate(diagnosis_codes, start=1):
diag.ROW_NUM = str(idx)

cur_sample_data["diagnoses"] = [asdict(d) for d in diagnosis_codes]

# add diagnosisSequence where necessary
for item in cur_sample_data.get("lineItemComponents", []):
if "CLM_LINE_DGNS_CD" in item:
line_dgns_cd = item.get("CLM_LINE_DGNS_CD")
if match := next(
(
d
for d in diagnosis_codes
if line_dgns_cd == d.CLM_DGNS_CD and d.CLM_PROD_TYPE_CD == "D"
),
None,
):
item["diagnosisSequence"] = [int(match.ROW_NUM)]

filename = "out/temporary-sample.json"

with Path(filename).open("w") as f:
Expand Down
10 changes: 5 additions & 5 deletions apps/bfd-model-idr/maps/ExplanationOfBenefit-Base.map
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ uses "http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit" alias BFDEOB

imports "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper"
imports "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-SupportingInfo-Helper"
imports "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Item-Institutional-Helper"
imports "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Item-Helper"

group createEOBBase(source src: ExplanationOfBenefitBase, target tgt: BFDEOB){

Expand Down Expand Up @@ -524,8 +524,8 @@ group addInstitutionalAdjudicationElements(source src: ExplanationOfBenefitBase,
group addDiagnoses(source src: DiagnosisComponent, target tgt: BackboneElement){
src.ROW_NUM as rowNum -> tgt.sequence = rowNum "set sequence number";
src -> tgt.type = create('CodeableConcept') as tgtCC then{
src.clm_prod_type_cd_map as typeCode where (typeCode = "A" or typeCode = "P") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#HL7_DIAGTYPE','coding') "Add coding";
src.clm_prod_type_cd_map as typeCode where (typeCode = "1" or typeCode = "D" or typeCode = "E" or typeCode = "R") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#C4BB_DIAGTYPE','coding') "set coding";
src.CLM_PROD_TYPE_CD as typeCode where (typeCode = "A" or typeCode = "P") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#HL7_DIAGTYPE','coding') "Add coding";
src.CLM_PROD_TYPE_CD as typeCode where (typeCode = "1" or typeCode = "D" or typeCode = "E" or typeCode = "R") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#C4BB_DIAGTYPE','coding') "set coding";
} "Add types";
src.CLM_POA_IND as poaInd where (poaInd != ' ' and poaInd != '~' ) -> tgt.onAdmission = create('CodeableConcept') as tgtPOA,
tgtPOA.coding = create('Coding') as tgtCoding,
Expand All @@ -543,8 +543,8 @@ group addDiagnoses(source src: DiagnosisComponent, target tgt: BackboneElement){
group addDiagnosesProfessional(source src: DiagnosisComponent, target tgt: BackboneElement){
src.ROW_NUM as rowNum -> tgt.sequence = rowNum "set sequence number";
src -> tgt.type = create('CodeableConcept') as tgtCC then{
src.clm_prod_type_cd_map as typeCode where (typeCode = "A" or typeCode = "P") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#HL7_DIAGTYPE','coding') "Add coding";
src.clm_prod_type_cd_map as typeCode where (typeCode = "1" or typeCode = "D" or typeCode = "E" or typeCode = "R") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#C4BB_DIAGTYPE_PROF','coding') "set coding";
src.CLM_PROD_TYPE_CD as typeCode where (typeCode = "A" or typeCode = "P") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#HL7_DIAGTYPE','coding') "Add coding";
src.CLM_PROD_TYPE_CD as typeCode where (typeCode = "1" or typeCode = "D" or typeCode = "E" or typeCode = "R") -> tgtCC.coding = translate(typeCode,'https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper#C4BB_DIAGTYPE_PROF','coding') "set coding";
} "Add types";
src -> tgt.diagnosis = create('CodeableConcept') as tgtDiagnosis then {
src -> tgtDiagnosis.coding = create('Coding') as tgtCoding then {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
map "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Item-Institutional-Helper" = "BFD-ExplanationOfBenefit-Item-Institutional-Helper-Map"
map "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Item-Helper" = "BFD-ExplanationOfBenefit-Item-Helper-Map"
imports "https://bfd.cms.gov/MappingLanguage/Maps/ExplanationOfBenefit-Helper"

group addItem(source src: LineItemComponent, target tgt: BackboneElement){
Expand Down Expand Up @@ -110,7 +110,7 @@ group addItem(source src: LineItemComponent, target tgt: BackboneElement){
//In claims data, CLM_LINE_DGNS_CD refers to the diagnosis that supports the given claim line
//diagnosisRelatedLine is a computed value that is input "for FML purposes" to correspond to the sequence number
//present on the diagnosis in EoB.diagnosis that corresponds to the value in CLM_LINE_DGNS_CD.
src.diagnosisRelatedLine as claimLineDiagnosis -> tgt.diagnosisSequence = cast(claimLineDiagnosis,"positiveInt") "Add diagnosis sequence number";
src.diagnosisSequence as claimLineDiagnosis -> tgt.diagnosisSequence = cast(claimLineDiagnosis,"positiveInt") "Add diagnosis sequence number";
//Care team sequence is generated by the provider script.
src.careTeamSequence as careTeamSequence -> tgt.careTeamSequence = cast(careTeamSequence,"positiveInt") "Add reference to care team sequence.";
}
Expand Down
20 changes: 19 additions & 1 deletion apps/bfd-model-idr/sample-data/EOB-Base-Sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,25 @@
{"ROW_NUM":"33","CLM_FI_ACTN_CD":"1"}
],
"lineItemComponents":[
{"PRVDR_RNDRNG_PRVDR_NPI_NUM":"1942945159","CLM_LINE_ADD_ON_PYMT_AMT":"11.11","CLM_LINE_NON_EHR_RDCTN_AMT":"11.12","CLM_REV_CTR_TDAPA_AMT":"11.13","CLM_LINE_NUM":"1","CLM_LINE_ALOWD_CHRG_AMT":"9194.22","CLM_LINE_HCPCS_CD":"99213","CLM_REV_APC_HIPPS_CD":"","CLM_LINE_NDC_CD":"","CLM_LINE_NDC_QTY":"","CLM_LINE_SRVC_UNIT_QTY":"3.000","CLM_LINE_REV_CTR_CD":"0636","CLM_DDCTBL_COINSRNC_CD":"M","GEO_FAC_SSA_STATE_CD":"01","CLM_LINE_PRVDR_PMT_AMT":"11.15","CLM_LINE_SBMT_CHRG_AMT":"50.11"},
{
"CLM_LINE_DGNS_CD": "M48.062",
"PRVDR_RNDRNG_PRVDR_NPI_NUM": "1942945159",
"CLM_LINE_ADD_ON_PYMT_AMT": "11.11",
"CLM_LINE_NON_EHR_RDCTN_AMT": "11.12",
"CLM_REV_CTR_TDAPA_AMT": "11.13",
"CLM_LINE_NUM": "1",
"CLM_LINE_ALOWD_CHRG_AMT": "9194.22",
"CLM_LINE_HCPCS_CD": "99213",
"CLM_REV_APC_HIPPS_CD": "",
"CLM_LINE_NDC_CD": "",
"CLM_LINE_NDC_QTY": "",
"CLM_LINE_SRVC_UNIT_QTY": "3.000",
"CLM_LINE_REV_CTR_CD": "0636",
"CLM_DDCTBL_COINSRNC_CD": "M",
"GEO_FAC_SSA_STATE_CD": "01",
"CLM_LINE_PRVDR_PMT_AMT": "11.15",
"CLM_LINE_SBMT_CHRG_AMT": "50.11"
},
{"CLM_LINE_NUM":"2","CLM_LINE_HCPCS_CD":"99453","CLM_REV_APC_HIPPS_CD":"","CLM_LINE_NDC_CD":"","CLM_LINE_NDC_QTY":"","CLM_LINE_SRVC_UNIT_QTY":"3.000","CLM_LINE_REV_CTR_CD":"0771","HCPCS_1_MDFR_CD":"A2","CLM_LINE_NCVRD_CHRG_AMT":"0.10","CLM_LINE_PRVDR_PMT_AMT":"-91.0","CLM_LINE_BENE_PMT_AMT":"17.99","CLM_LINE_BENE_PD_AMT":"13.22","CLM_LINE_CVRD_PD_AMT":"11.14","CLM_LINE_BLOOD_DDCTBL_AMT":"17.11","CLM_LINE_MDCR_DDCTBL_AMT":"3.50"},
{"CLM_LINE_NUM":"3","CLM_LINE_HCPCS_CD":"","CLM_REV_APC_HIPPS_CD":"","CLM_LINE_NDC_CD":"","CLM_LINE_NDC_QTY":"2348.87","CLM_LINE_SRVC_UNIT_QTY":"","CLM_LINE_REV_CTR_CD":"0001","HCPCS_1_MDFR_CD":"99","CLM_LINE_NCVRD_CHRG_AMT":"","CLM_LINE_INSTNL_REV_CTR_DT":"2025-01-01","CLM_LINE_PRVDR_PMT_AMT":"14.11"},
{"CLM_LINE_NUM":"4","CLM_LINE_HCPCS_CD":"J2270","CLM_REV_APC_HIPPS_CD":"","CLM_LINE_NDC_CD":"00409189001","CLM_LINE_NDC_QTY":"1000.0","CLM_LINE_NDC_QTY_QLFYR_CD":"GR","CLM_LINE_SRVC_UNIT_QTY":"3.000","CLM_LINE_REV_CTR_CD":"0636","CLM_LINE_INSTNL_ADJSTD_AMT":"4.50","CLM_LINE_PRVDR_PMT_AMT":"11.11","CLM_LINE_INSTNL_RDCD_AMT":"11.11","CLM_LINE_INSTNL_MSP1_PD_AMT":"17.00","CLM_LINE_INSTNL_MSP2_PD_AMT":"14.21","CLM_LINE_INSTNL_RATE_AMT":"0.85","CLM_LINE_BLOOD_DDCTBL_AMT":"1234.0"}
Expand Down