Vitals Interpretation for FHIR (#4528)
commit75655508136578dbac176bc3e06b75c28fa4302e
authorStephen Nielson <stephen@nielson.org>
Sun, 25 Jul 2021 20:04:21 +0000 (25 16:04 -0400)
committerGitHub <noreply@github.com>
Sun, 25 Jul 2021 20:04:21 +0000 (25 13:04 -0700)
treef0cd74eab9bda5e19869a3c69230a9475df62359
parentf7fdf04f1e11e8f0d315834c3513bb1a9de91c0b
Vitals Interpretation for FHIR (#4528)

* Vitals Interpretation for FHIR #4527

This is a work in progress that will add clinician interpretations to the vital signs.  This current commit adds the interpretation value to the vital signs observations.  I'm currently mocking the values at the service level which provides a working example in FHIR for interpretation.  I'm still toying around with the database structure but the current implementation mocks things up nicely.  I add an interpretation_code and interpretation_text for every vital signs measurement.

I intended to overhaul the entire vitals_form but it is used in > 144 places with about half of those in the clinical decision rules.  So I'm taking this secondary step where we will have a vital_form_details table that will contain the interpretation and auxiliary data for each vitals_form.

I massively overhauled the vitals form UX in order to make the code less redundant and so I could easily add in the interpretation dropdown. I also reworked all of the metric / usa conversion codes on the vitals form to remove magic numbers.

The saving of the interpretation values is still not complete as well as the vital_form_details table implementation.  Overall though, I'm pretty pleased with how things turned out.

* Form Vital Details, Refactored FormVitals,new list

Added a Form Vital Details concept to OpenEMR represented in the form_vital_details table and FormVitalDetails class.
This allows interpretations of the vitals to be stored for each vital and any additional information on a per column basis could be stored here.  While it'd be nice to breakup the form_vitals table itself and make it a vertical instead of horizontal representation, the form is used in many places that would be a pretty large overhaul at this point.  Future work of centeralizing all database interactions via the VitalsService would simplify this, but for now we will leverage the details representation.

Modified FormVitals to be populated via the vitals service as part of the initial work to centralize the DB interactions into the vitals service.

Refactored the FormVitals and C_FormVitals to be psr4 compliant.

Added a new list_options for the vitals-interpretations.

Did additional cleanup work on the form vitals.

* Initial ideas on abstracting unit measurements out

* Moved FormVitals, updated templates

Got the metric and usa values to finally display correctly.  Moved the
FormVitals class per @brady.miller's suggestion.

Cleaned up some general code.

* Vitals Form fixes, refactoring, finished saving

Per @brady.miller's suggestion, removed the composer addition and moved the form model classes into the main src folder.

Fixed vitals form unit tests.

Got vital forms + form details saving.  Centralized the saving logic into the VitalsService.

Removed unused / deprecated code in vitals sql.

Added a method to ORDataObject to grab a model's data to be saved.

* Fixing forms record creation

Moved the creation of the forms record into the service so we can handle
the saving of the interpretations.

* Standard API implement vitals interpretation save.

Consolidated vitals save from encounters to use vitals service instead
of hitting the database directly.

This made it so that vitals interpretations now save to the database.

* Fix style changes

* Cleanup todo and sql select

* Remove old comment, and unused number search field

* Fix code review issues.

* Remove unused metrics sql from rebase

Not sure how the metrics stuff snuck in from the rebase, but its removed
now.

* Fix list service get option bug.

Had a bug where if you used the list service to get a list option with
an option id it would return a random one due to the order of the AND
clause.  Fixed that bug.

* Fix reporting when using FHIR and USA measurements.

* More fixes for USA measurements.

* Fix php error

Not sure why this fails the CI engine but we will fix it.

* Hide the interpretation column on trend report.

* Fix form user setting, import.

Per code review fix the form user setting which was NOT being set.  Fix
the import

* Fix new form temperature metric reading.

Reading for a new temperature of F 0 comes out at -17 C which we need to
avoid displaying.

* Vitals Remove foreign keys, fix new install lists.

Removed the foreign key constraints on the form_vital_details table due
to collation problems for database upgrades.  See #4520 for details on
what is happening and why we removed the keys.

Also code reviews showed we aren't installing the interpretation values
in a new database install.

* Vitals user and groupname populated on save.

I noticed the form_vitals user & groupname are not populated whereas the
forms was.  This appears to be a bug in master branch, glad we have it
working now.

* Fix template escaping, add escape modifiers.

Made it so we can handle smarty xla and xlt as modifiers instead of
function calls.  Added in all the code review template escapes here.

* Escape table name with back quotes

* Fix code comments and header

* Remove FQN for FormVitals class

* Style fixes

* Use escape table name instead of escape_custom

* minor fixes

1. array reference fix that was duplicating first 2 vital output when
there were details (high, low etc.) assigned.
2. html escaping
3. hide uuid from output report
35 files changed:
_rest_routes.inc.php
interface/forms/CAMOS/content_parser.php
interface/forms/vitals/C_FormVitals.class.php
interface/forms/vitals/new.php
interface/forms/vitals/report.php
interface/forms/vitals/save.php
interface/forms/vitals/templates/vitals/general_new.html
interface/forms/vitals/templates/vitals/vitals_historical_values.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_interpretation_selector.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_javascript_functions.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_notes.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_temp_method.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_textbox.tpl [new file with mode: 0644]
interface/forms/vitals/templates/vitals/vitals_textbox_conversion.tpl [new file with mode: 0644]
interface/forms/vitals/view.php
interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php
library/classes/Controller.class.php
library/smarty/plugins/modifier.xla.php [new file with mode: 0644]
library/smarty/plugins/modifier.xlt.php [new file with mode: 0644]
sql/6_0_0-to-6_1_0_upgrade.sql
sql/database.sql
src/Common/Database/QueryUtils.php
src/Common/Forms/FormVitalDetails.php [new file with mode: 0644]
src/Common/Forms/FormVitals.php [moved from interface/forms/vitals/FormVitals.class.php with 67% similarity]
src/Common/ORDataObject/ORDataObject.php
src/Common/Utils/MeasurementUtils.php [new file with mode: 0644]
src/Events/Services/ServiceSaveEvent.php [new file with mode: 0644]
src/Services/EncounterService.php
src/Services/FHIR/FhirCodeSystemConstants.php
src/Services/FHIR/Observation/FhirObservationVitalsService.php
src/Services/ListService.php
src/Services/Search/NumberSearchField.php [new file with mode: 0644]
src/Services/VitalsService.php
tests/Tests/Services/EncounterServiceTest.php
tests/Tests/Unit/Common/Forms/FormVitalsTest.php [new file with mode: 0644]