Exploring the Connection between Medical Problems and Encounters: Seeking Guidance

Hello everyone,

I hope you’re all doing well. I’ve got a question regarding our data management in the context of medical problems and encounters. We’ve been working with the APIs for medical problems and encounters to handle our data effectively. However, we’ve hit a bit of a roadblock when it comes to establishing a meaningful connection between these two essential aspects of our system.

Digging a bit into the API for medical problems, we find this query in the ConditionService and we found the following query:

        $sql = "SELECT lists.*,
        lists.pid AS patient_id,
        lists.title,
        encounter.uuid as encounter_uuid,
        patient.puuid,
        patient.patient_uuid,
        condition_ids.condition_uuid,
        verification.title as verification_title
        ,provider.provider_id
        ,provider.provider_npi
        ,provider.provider_uuid
        ,provider.provider_username
    FROM lists
        INNER JOIN (
            SELECT lists.uuid AS condition_uuid FROM lists
        ) condition_ids ON lists.uuid = condition_ids.condition_uuid
        LEFT JOIN list_options as verification ON verification.option_id = lists.verification and verification.list_id = 'condition-verification'
        RIGHT JOIN (
            SELECT
                patient_data.uuid AS puuid
                ,patient_data.pid
                ,patient_data.uuid AS patient_uuid
            FROM patient_data
        ) patient ON patient.pid = lists.pid
        LEFT JOIN issue_encounter as issue ON issue.list_id =lists.id
        LEFT JOIN form_encounter as encounter ON encounter.encounter =issue.encounter
        LEFT JOIN (
                select 
                   id AS provider_id
                   ,uuid AS provider_uuid
                   ,npi AS provider_npi
                    ,username as provider_username
                FROM users
            ) provider ON lists.user = provider.provider_username";

Here we can see the relation between the medical problems (hosted on the lists table) and the encounters through the table issue_encounter.

Our question is the following: Is there a viable approach to establish a relationship between medical problems and encounters using the existing resources at hand, particularly the “issue_encounter” table? We believe that tapping into this untapped potential could unlock the synergy between medical data and encounter information, enhancing our data management and analysis capabilities.

Please don’t hesitate to share your thoughts, suggestions, or potential solutions. Your collective knowledge might just lead us to that “aha” moment we’re seeking.

Thank you for your time and valuable contributions.

Hello @Cardo_Devel and welcome to the OpenEMR forum-- and the community!

Let me start by saying I am not a dev! I am a User Interface Support kinda guy, but it appears that what you’re trying to do from a programmatic point of view already exists in OpenEMR. I can’t discuss the coding side of it all but let me show you what is available from the user interface POV and you can see if this is what you’re talking about (pictures taken from the OpenEMR 7.1 public demo).

Issues (medical problems, etc) can be associated with the encounters in which they are addressed.
When a new encounter is created, the patient’s issues appear in a list window (lower right in the next pic) and one or more of them can be selected to associate with that encounter.
ne1

Once associated, the issue can be pulled up for editing in the patient’s ‘Issues’ screen
ne2

ne4

Admittedly, documentation is OpenEMR’s weak spot, but here is a description of the topic as it pertains to Immunizations, shown on an older version of OpenEMR. Especially see section 1.2 Associating Issues with Encounters.

https://www.open-emr.org/wiki/index.php/Issues_%26_Immunizations

The screen controls discussed may be rearranged in later versions of the EMR but they will all be present and function the same.

Best- Harley

@Cardo_Devel is mostly doing API work it sounds like. However, as @htuck has explained, medical problems ie issues are connected directly to the encounter view the issue_encounter table. You can rely on the table to perform the linkage you are wanting to do. Hopefully that answers your question.