Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Patient Address Initial Support #5396

Conversation

adunsulag
Copy link
Sponsor Member

Fixes #5367

Added a new data type for LBF to support Address List data type.

Addresses can be added with multiple addresses supported. Initial
framework for saving addresses is here as well s retrieving them.

Rolled out the initial contact and contact address classes that can
be used to support Patients. Decided to leverage the ORM classes
for Contact and ContactAddress to quickly persist and model
the data.

This is a WIP draft for people to be able to see what I'm proposing. It currently doesn't fetch the address information from the database but we're super close to being able to do that.

I'll get back to this once we make it through the clinical quality measures stuff.

Added a new data type for LBF to support Address List data type.

Addresses can be added with multiple addresses supported.  Initial
framework for saving addresses is here as well s retrieving them.

Rolled out the initial contact and contact address classes that can
be used to support Patients.  Decided to leverage the ORM classes
for Contact and ContactAddress to quickly persist and model
the data.
@adunsulag
Copy link
Sponsor Member Author

@psoas This is what I've currently done. I was nearly finished with it but things got busy with the Clinical Quality Measures stuff. My hope is to wrap this up next week. I wanted to push this out there so that you and others can have a chance to see it and what its doing. It's probably a half a day to a day away from being finished and we'll be able to then bring it in.

@@ -61,7 +63,8 @@
"46" => xl("List box w/comment"),
"51" => xl("Patient"),
"52" => xl("Previous Names"),
"53" => xl("Patient Encounters List")
"53" => xl("Patient Encounters List"),
"54" => xl("Address List")
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2DV-2

@bradymiller
Copy link
Sponsor Member

@adunsulag , Just did a quick review. Nice stuff!! Will do another review when out of draft.

Implemented the multiple address save for contact and contact address.

Removed the duplicate code in ORDataObject to populate the object and
instead call the populateArray object.  This make sit possible to
overload the object and define custom behavior there.

Moved the Address, Contact, and ContactAddress class into our src folder
so we can follow normal PSR4 namespacing.

Fixed the primary key problem with the contact table in the database.
@adunsulag
Copy link
Sponsor Member Author

Got the addresses saving and reloading now. Still need to do a bunch more testing and adding in some of the items identified in #5367. I'm also keen on potentially bringing in @mdsupport's PR here #4862 so we can keep things idempotent with transactions.

Was hoping to finish this yesterday, but we have more pressing issues with the schematron fixes for CCDA, so I'll circle back around on this when I'm done with that.

Made it so the address widget re-uses the lbf widget display code for
each of the address element codes.

Refactored the tables into divs to be mobile friendly.

Added in the date start and end dates so we can support previous
addresses.

Added the address use and address type selectors so people can identify
what kind of address it is.

Exposed the option js functions into the global window under the oeUI
container so we can have our add button on the state, country, use, and
type selector widgets.
Implemented the saving of the address list lbf template in the new
patient and the existing patient demographics page.

Added a new lbf field called additional_addresses to be displayed in the
contacts group layout.

Added the district field to support counties / districts in addresses.
Added the use and type FHIR data fields.
Also added a period start and period end to the addresses so we can
track the time period an address was in use.  New addresses default to a
current date of today with an empty end date.

Added new list options for address-uses and address-types to support the
new FHIR options.  The option_id is the FHIR key name.

Migrated some of the date formatting into the DateFormatterUtils object
so we can leverage them inside our objects without having to include the
formatter.inc.php file.

Added the address_list datatype to the restricted lbf fields so users
can't remove the datatype since we have to have it for USCDI support.

Refactored all of the styles of the address list widget to be responsive
and mobile friendly using bootstrap classes and styles.

Made the js functions of addresses consistent in naming conventions with
our other js functions.

Implemented the archiving / deactivating of the address list items.  Had
to switch from the BINARY(1) data type to a char value.  The
ORDataObject has a bug in that you can't save a value with a numeric 0
as its treated as empty.  I didn't want to try and change the logic and
mess up the other classes that extend ORDataObject, so in the interest
of time I switched isPrimary and status to be char fields that we key
off of.

Renamed the contact table fields to be consistent with fire naming
conventions per @mdsupport's recommendation.

Changed up the js events to be added in javacsript and not using inline
onclick events.  This simplifies the debugging immensely.
@adunsulag adunsulag marked this pull request as ready for review June 17, 2022 04:32
@adunsulag
Copy link
Sponsor Member Author

@bradymiller This is ready for a deeper review. I will do some more extensive testing, but I've tested on fresh databases and existing databases and it appears to be working. Its a lot of code but when you get a chance to review it, I'd appreciate it. I'll fix the sql merge conflict tomorrow.

`priority` INT(11) NULL,
`type` VARCHAR(255) NULL COMMENT 'FK to list_options.option_id for list_id address-types',
`use` VARCHAR(255) NULL COMMENT 'FK to list_options.option_id for list_id address-uses',
`notes` TEXT(255) NULL,
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text should be bare

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k removed the null on the text column

@bradymiller
Copy link
Sponsor Member

@adunsulag , Looks great! Just noted a couple issues.

@sjpadgett
Copy link
Sponsor Member

Pretty nice, Seems to test well for me. I'm adding the addresses array for generator address and about half done.

@adunsulag adunsulag changed the title WIP Multiple Patient Address Initial Support Multiple Patient Address Initial Support Jun 17, 2022
@adunsulag
Copy link
Sponsor Member Author

@bradymiller @stephenwaite @sjpadgett Does anyone know what is up with the display mode column format of the LBF forms. It doesn't seem to follow the same 4 column layout when displaying the data compared to when editing it.

Look for example here on the display
image

Versus here on the edit
image

The previous address is configured to have the label as 4 columns and the edit widget to have 4 columns. The intent is to shove the previous addresses onto its own completely new line.

@adunsulag
Copy link
Sponsor Member Author

@sjpadgett That'd be awesome if you already have it taken care of in CCDA. I plan on opening another PR to add the previous address support to FHIR once I've got this merged in.

Had the close button not working when it was a new address, was only
working on existing address so had to fix that.

Also made the labels the same on the display as on the edit.

Removed unused code in the formatting.inc.php
@sjpadgett
Copy link
Sponsor Member

<addr use="HP">
    <streetAddressLine>1357, Amber Dr</streetAddressLine>
    <city>Beaverton</city>
    <state>OR</state>
    <postalCode>97006</postalCode>
    <country>USA</country>
</addr>
<addr use="H">
    <streetAddressLine>100 Test Dr</streetAddressLine>
    <streetAddressLine>Room 2</streetAddressLine>
    <city>Orlando</city>
    <state>FL</state>
    <postalCode>33520</postalCode>
    <country>USA</country>
    <useablePeriod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="IVL_TS">
        <low value="20170629"/>
        <high value="20220601"/>
    </useablePeriod>
</addr>

Fixes openemr#5501 Immunization reason code column mispelling.
Fixes openemr#5502 for multiple previous address support in FHIR.

Changed contact_address notes datatype to tinytext for review.

Added indexes to patient_history and contact_address to speed up
patient service search.

Added to api patient service the ability to include the patient
addresses. Had to refactor the queries as we were excluding any
previous names and previous addresses that didn't match the search
criteria.

Added to the /api/patient endpoint an address array of the patient data.
This includes both the main patient address and their additional address
information.  Eventually we can drop the inline address information in the
standard api.

Made the patient address search work on both the main address and additional
address information the patient has.

Made the DateFormatterUtils::dateStringToDateTime have support for times.
@adunsulag
Copy link
Sponsor Member Author

@bradymiller so my last commit was dependent on this branch, so I just pushed it together as I wasn't sure if we were ready to bring this in yet or not. I added in the fixes for the TinyText that @sjpadgett suggested.

I also implemented the FHIR api support for multiple addresses. I tested this against my local inferno on both a fresh db install and an existing db and that appears to be working. Didn't test the bulk export but I figure if the standard API is working the bulk will work also.

Discovered a bug in the immunization api so I fixed that as part of this commit also.

@@ -922,3 +922,11 @@ UPDATE `list_options` SET `activity` = '1' WHERE `list_id` = 'race' AND `title`
UPDATE `list_options` SET `activity` = '1' WHERE `list_id` = 'race' AND `title` = 'Korean';
UPDATE `list_options` SET `activity` = '1' WHERE `list_id` = 'race' AND `title` = 'Asian Indian';
#Endif

#IfNotIndex patient_history idx_pid
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix (looks like it got inverted :) ):

#IfNotIndex patient_history pid_idx

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know I just stared at this over and over again and couldn't figure out what you were saying, had to copy and paste the line and then my eyes saw the difference, lol.

ALTER TABLE patient_history ADD INDEX `pid_idx` (`pid`);
#EndIf

#IfNotIndex contact_address
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix:

#IfNotIndex contact_address contact_address_idx

@@ -16,7 +16,10 @@

namespace OpenEMR\Services;

use MongoDB\Driver\Query;
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this class being used here?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, removing.

@bradymiller
Copy link
Sponsor Member

@adunsulag , Just noted 3 issues above. Also looks like it's failing the ci tests. When sorted out, then ready to bring into codebase :)

2DV

@sjpadgett
Copy link
Sponsor Member

@adunsulag I thought I saw an issue with col for previous address rendering miscount between edit and view but can't find it!
Anyway a couple years ago I put in an edit option in layouts of Span Entire Row but didn't follow through.
I will now:
image

No idea why they didn't show up the first time I ran the style checker,
but oh well.  This will eventually work lol.
@adunsulag adunsulag merged commit 1bd7ee3 into openemr:master Jun 18, 2022
@adunsulag adunsulag deleted the openemr-fix-5367-patient-previous-address branch April 5, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support patient previous addresses
5 participants