According to the CMS State Operations Manual (SOM) Tag K221, locks on patient sleeping room doors are not permitted unless the key-locking device that restricts access from the corridor does not restrict egress from the patient room, or the locking arrangement is permitted for patient clinical, security, or safety needs in accordance with 18.2.2.2.5 or 19.2.2.2.5. 18.2.2.2, 19.2.2.2, NFPA 101 (2012) TIA 12-4.
HFM Magazine has another great resource for this question: https://www.hfmmagazine.com/articles/5011-a-new-tool-for-compliant-locking-arrangements