openemr icon indicating copy to clipboard operation
openemr copied to clipboard

date_end for create patient insurance is not persisted

Open dmtrs opened this issue 1 year ago • 1 comments

Describe the bug

REST API call to create patient insurance has date_end validation but is not persisting the field. When passing date_end the information is not persisted.

To Reproduce

A call to /patient/{uuid}/insurance with body:

{
  "date": "2024-09-01",
  "date_end": "2026-09-01",
  "provider": "1",
  "patientUUID": "9ccf578d-17df-4e80-a054-52212d9ffae8",
  "policy_number": "123",
  "subscriber_DOB": "1980-01-01",
  "subscriber_sex": "UNK",
  "subscriber_city": "Test",
  "subscriber_fname": "Foo",
  "subscriber_lname": "Bar",
  "subscriber_state": "AL",
  "accept_assignment": "TRUE",
  "subscriber_street": "Test",
  "subscriber_postal_code": "1111",
  "subscriber_relationship": "self"
}

Returns:

{
    "data": {
        "id": 4,
        "uuid": "9cd1742b-c7e0-4a67-a4e1-c6c01087128d",
        "type": "primary",
        "provider": "1",
        "plan_name": "",
        "policy_number": "123",
        "group_number": "",
        "subscriber_lname": "Bar",
        "subscriber_mname": "",
        "subscriber_fname": "Foo",
        "subscriber_relationship": "self",
        "subscriber_ss": "",
        "subscriber_DOB": "1980-01-01",
        "subscriber_street": "Test",
        "subscriber_postal_code": "1111",
        "subscriber_city": "Test",
        "subscriber_state": "AL",
        "subscriber_country": "",
        "subscriber_phone": "",
        "subscriber_employer": "",
        "subscriber_employer_street": "",
        "subscriber_employer_postal_code": "",
        "subscriber_employer_state": "",
        "subscriber_employer_country": "",
        "subscriber_employer_city": "",
        "copay": "",
        "date": "2024-09-01",
        "pid": 9,
        "subscriber_sex": "UNK",
        "accept_assignment": "TRUE",
        "policy_type": "",
        "subscriber_street_line_2": null,
        "subscriber_employer_street_line_2": null,
        "date_end": null
    }
}

Expected behavior

The date_end should have value "2026-09-01" . null is currently returned

Client configuration

  • Browser: REST API call
  • OpenEMR version: 7

dmtrs avatar Aug 21 '24 09:08 dmtrs

@dmtrs I think the challenge arises in the fact that OpenEMR's internal data model treats a 'current' policy as having no date_end. As the policy you are saving is considered 'current' and 'active' the date_end is set to NULL otherwise the policy would be treated as expired. It'd be nice to actually store dates in the future but it would require quite a bit of refactoring to deal with the insurance business logic in the system for having an actual end date in the future instead of a 'null' date.

I'll leave this open in case anyone wants to actually tackle the internal logic, but it's not going to be an easy fix and will need some heavy testing.

adunsulag avatar Sep 02 '24 14:09 adunsulag