nextgenhealthcare / connect

The swiss army knife of healthcare integration.
Other
915 stars 275 forks source link

[BUG] DefaultUserController.removePreference is broken #5965

Open joshmc82 opened 11 months ago

joshmc82 commented 11 months ago

reference code: https://github.com/nextgenhealthcare/connect/blob/047a7dd1229c5d3bffef158c9c5f04fa3827792e/server/src/com/mirth/connect/server/controllers/DefaultUserController.java#L613C46-L613C46

Is your feature request related to a problem? Please describe. The user_id/person_id parameter is not being correctly added to the parameterMap. It gets added with a key of "category" and instead should be added with a key of "person_id" in order to correctly pass to the db. This will currently throw an error. The query executed by the Postgres database is:

    <delete id='deletePreference' parameterType='java.util.Map'>
        DELETE FROM PERSON_PREFERENCE
        WHERE PERSON_ID = #{person_id}
        <if test='name != null'>
            AND NAME = #{name}
        </if>
    </delete>

This function is also not named in line with other similar functions. Others are named "getUserPreference", "setUserPreference" vs this one is "removePreference". Seems like the "User" is missing from the method name.

Describe your use case I am trying to write a plugin that will need to read/write/update/delete from the person_preference table.

Describe the solution you'd like At a minimum, the method should name the hashMap entry correctly (person_id). Ideally, the method would be renamed to be consistent with other CRUD operations in the same class.

Describe alternatives you've considered We ended up using the Update function to set the value to null/empty string to work around the hard SQL exception.