2024-12-05 22:46:41 +00:00
|
|
|
import pytest
|
2025-01-10 21:20:33 +00:00
|
|
|
import pandas as pd
|
|
|
|
|
import numpy as np
|
|
|
|
|
from src.postprocessing_funcs import (
|
|
|
|
|
InvalidDateException,
|
|
|
|
|
yn_fixes,
|
|
|
|
|
convert_to_us_date_format,
|
|
|
|
|
)
|
2025-01-08 21:59:47 +00:00
|
|
|
|
2025-01-10 21:20:33 +00:00
|
|
|
|
|
|
|
|
class TestPostprocessingFuncs:
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def valid_dates(self):
|
|
|
|
|
return [
|
|
|
|
|
("2023-12-01", "12/01/2023"),
|
|
|
|
|
("2023-01-12", "01/12/2023"),
|
|
|
|
|
("2023-13-01", "01/13/2023"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def invalid_dates(self):
|
|
|
|
|
return ["2023-13-32", "2023-00-01", "2023-12-00", "2023-12-32", "2023-13-13"]
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def empty_dates(self):
|
|
|
|
|
return ["", "N/A", "null", "none"]
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def invalid_format_dates(self):
|
|
|
|
|
return ["2023/12/01", "12-01-2023", "2023.12.01"]
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def invalid_type_dates(self):
|
|
|
|
|
return [None]
|
|
|
|
|
|
|
|
|
|
def test_convert_to_us_date_format(
|
|
|
|
|
self,
|
|
|
|
|
valid_dates,
|
|
|
|
|
invalid_dates,
|
|
|
|
|
empty_dates,
|
|
|
|
|
invalid_format_dates,
|
|
|
|
|
invalid_type_dates,
|
|
|
|
|
):
|
|
|
|
|
for input_date, expected_output in valid_dates:
|
|
|
|
|
assert convert_to_us_date_format(input_date) == expected_output
|
|
|
|
|
|
|
|
|
|
for input_date in invalid_dates:
|
|
|
|
|
with pytest.raises(InvalidDateException):
|
|
|
|
|
convert_to_us_date_format(input_date)
|
|
|
|
|
|
|
|
|
|
for input_date in empty_dates:
|
|
|
|
|
with pytest.raises(InvalidDateException):
|
|
|
|
|
convert_to_us_date_format(input_date)
|
|
|
|
|
|
|
|
|
|
for input_date in invalid_format_dates:
|
|
|
|
|
with pytest.raises(InvalidDateException):
|
|
|
|
|
convert_to_us_date_format(input_date)
|
|
|
|
|
|
|
|
|
|
for input_date in invalid_type_dates:
|
|
|
|
|
with pytest.raises(TypeError):
|
|
|
|
|
convert_to_us_date_format(input_date)
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def sample_answer_dicts(self):
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
"FULL_SERVICE": "This is a test statement containing keyword 'Lease'",
|
|
|
|
|
"FULL_METHODOLOGY": "PMPM",
|
|
|
|
|
},
|
|
|
|
|
{"FULL_SERVICE": "unspecified", "FULL_METHODOLOGY": "valid"},
|
|
|
|
|
{
|
|
|
|
|
"FULL_SERVICE": "This is an example of clean dict",
|
|
|
|
|
"FULL_METHODOLOGY": "Will be effective for 30 days",
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def sample_df(self):
|
|
|
|
|
data = {
|
|
|
|
|
"FULL_SERVICE": ["Service A", "Service B", "Invalid Service"],
|
|
|
|
|
"FULL_METHODOLOGY": [
|
|
|
|
|
"Methodology X",
|
|
|
|
|
"Methodology Y",
|
|
|
|
|
"Invalid Methodology",
|
|
|
|
|
],
|
|
|
|
|
"LESSER": ["N", "Y", "N"],
|
|
|
|
|
"LESSER_RATE": [100, 200, 300],
|
|
|
|
|
"RATE_STANDARD": [150, 250, 350],
|
|
|
|
|
"DEFAULT_TERM": ["Outpatient", "Inpatient", "Invalid"],
|
|
|
|
|
"DEFAULT_RATE": ["AC", "BC", "Invalid"],
|
|
|
|
|
"IP_OP": ["OP", "IP", "OP"],
|
|
|
|
|
"PROV_TYPE_LEVEL_2": ["", "Type A", "Type B"],
|
|
|
|
|
"TERM_CLAUSE": [
|
|
|
|
|
"IL-4 Termination",
|
|
|
|
|
"bonus payment shall be effective",
|
|
|
|
|
"No term or termination",
|
|
|
|
|
],
|
|
|
|
|
"CONTRACT_AUTO_RENEWAL_IND": ["Y", "N", "Y"],
|
|
|
|
|
"CONTRACT_TERMINATION_DT": [np.nan, "2023-12-31", np.nan],
|
|
|
|
|
"PROV_GROUP_NPI": ["1234567890", "123", "N/A"],
|
|
|
|
|
"NETWORK_ACCESS_FEES_IND": ["Yes", "No", "Yes"],
|
|
|
|
|
"PAYER_NAME": ["Illini Health", "Superior HealthPlan", "Other Payer"],
|
|
|
|
|
"HEALTH_PLAN_STATE": ["IL", "TX", "CA"],
|
|
|
|
|
"NOTICE_PROVIDER_NAME": ["Superior HealthPlan", "Provider A", "Provider B"],
|
|
|
|
|
"NOTICE_PROVIDER_ADDRESS": ["Address A", "Address B", "Address C"],
|
|
|
|
|
"POLICIES_AND_PROCEDURES": ["Policy A", "Procedure B", "Invalid"],
|
|
|
|
|
"PROV_GROUP_TIN": ["12-3456789", "123456789", "N/A"],
|
|
|
|
|
"ADD_ON_REIMBURSEMENT_LANGUAGE": [
|
|
|
|
|
"in no event includ",
|
|
|
|
|
"forward payments",
|
|
|
|
|
"N/A",
|
|
|
|
|
],
|
|
|
|
|
"ADD_ON_REIMBURSEMENT_IND": ["Y", "N", "Y"],
|
|
|
|
|
"FLAT_FEE_STANDARD": ["$100", "$200", "$300"],
|
|
|
|
|
"CONTRACT_LOB": ["LOB A", "LOB B", "LOB C"],
|
|
|
|
|
"Parent Agreement Code": ["1234", "5678", "91011"],
|
|
|
|
|
"RATE_SHORT": ["$100", "$200", "$300"],
|
|
|
|
|
"DUMMY_COL(Y/N)": ["Yes", "No", ""],
|
|
|
|
|
}
|
|
|
|
|
return pd.DataFrame(data)
|
|
|
|
|
|
|
|
|
|
def test_yn_fixes(self, sample_df):
|
|
|
|
|
cleaned_df = yn_fixes(sample_df)
|
|
|
|
|
assert cleaned_df.loc[1, "ADD_ON_REIMBURSEMENT_LANGUAGE"] == ""
|
|
|
|
|
assert cleaned_df["DUMMY_COL(Y/N)"].tolist() == ["Y", "N", "N"]
|