Transitional medication safety is crucial, as miscommunication about medication changes can lead to significant risks. Unclear or incomplete documentation during care transitions can result in outdated or incorrect medication lists at discharge, potentially causing medication errors, adverse drug events, and inadequate patient education. These issues are exacerbated by extended hospital stays and multiple care events, making accurate medication recall challenging at discharge. Thus, we aimed to investigate how real-time documentation of in-hospital medication changes prevents undocumented medication changes at discharge and improves physician-pharmacist communication. We conducted a retrospective cohort study in a tertiary hospital. Two pharmacists reviewed medical records of patients admitted to the acute medical unit from April to June 2020. In-hospital medication discrepancies were determined by comparing preadmission and hospitalization medication lists and it was verified whether the physician's intent of medication changes was clarified by documentation. By a documentation rate of medication changes of 100% and <100%, respectively, fully documented (FD) and partially documented (PD) groups were defined. Any undocumented medication changes at discharge were considered a "documentation error at discharge". Pharmacists' survey was conducted to assess the impact of appropriate documentation on the pharmacists. After reviewing 400 medication records, patients were categorized into FD (61.3%) and PD (38.8%) groups. Documentation errors at discharge were significantly higher in the PD than in the FD group. Factors associated with documentation errors at discharge included belonging to the PD group, discharge from a non-hospitalist-managed ward, and having three or more intentional discrepancies. Pharmacists showed favorable attitudes towards physician's documentation. Appropriate documentation of in-hospital medication changes, facilitated by free-text communication, significantly decreased documentation errors at discharge. This analysis underlines the importance of communication between pharmacists and hospitalists in improving patient safety during transitions of care.