Is there any way how to recognize whether a document was modified?

If the user makes some changes and then tries to close a document, then the ‘Notes’ client will show the save dialog. Do you know how this feature works and how to recognize a modified document by a code? It would be good to know exactly what was changed but it is not necessary.