3

My application working in a multi-users environment for medical records. One of the important parts of the application is writing the medical records, doctors should always review the current written data then adding or correcting any information's as needed.

I were aware about the situation when 2 doctors (A,B) viewing the data at same time, one of them will make changes and hit save (A).

the other doctor (B) still editing the old data & he don't know about the changes applied by doctor (A).

When doctor (B) hit save, the application will compare the Version column in the database, application then return an error message ("Data has been changed by another user !!!").

My Question in this case: What choices should be available within my solution.

I'm seeking an professional solution or idea from your experiences.

My application using: Java Swing for end user client & MySQL database.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • possible duplicate of [how to handle form editing in a Multi-user environment?](http://stackoverflow.com/questions/11557537/how-to-handle-form-editing-in-a-multi-user-environment) – Ascalonian Apr 07 '15 at 11:57
  • There is no duplicate, i can easily use the optimistic approach & it's implemented successfully in my application, the mentioned post asking about how to solve the problem. My question about: what options should be given to doctor (B)? imagine you are working on record & after writing & editing when try to save your changes, the system detect data changes & discarding your changes, are you happy with this case? so, what would you like the application to do for you in such a situation like this? that's my question. – user3822563 Apr 07 '15 at 12:03
  • 3
    This is not meant as an insult; but well: a person that is developing a real world medical system ... should really be able to at least outline potential solutions himself. Sure, it is always better to discuss ideas with experienced programmers; but relying on stackoverflow to tell you how to **design** your medical application; wow. And you know - we are not the **users** of your applications. Turn to your **users** and understand what **they** would like to see in this situation. Requirements come from users; not from stackoverlow. – GhostCat Apr 07 '15 at 12:03
  • I think pessimistic write in query can help you – Nimesh Apr 07 '15 at 12:04
  • Sire, please i'm asking about the choices, ex. 1. Discarding the changes for doctor (B). 2. Viewing a page with tow versions & let doctor (B) choose what to keep. 3. Ignore the message & overwrite the doctor (A) changes. ...etc what you preferred? – user3822563 Apr 07 '15 at 12:06
  • @Naman: pessimistic is a very good approach, but lets say that doctor (A) hit edit and left the computer for a cup of tee, the record will still locked until the expiration time reached. which mean doctor (B) will still in hold until doctor (A) lock is released. if there is a configuration to be done in MySQL server to apply this approach i will prefer this solution, taking in considerations: 1. doctor (B) will be get immediate message that record is editing by another user. 2. My Transactions will not suffer from (Lock wait time exception). – user3822563 Apr 07 '15 at 12:11
  • @Jägermeister, I'm pretty sure that if more people developing real world medical systems would ask for suggestions on design best practises on Stack Overflow, end users of these systems would be happier. This is a Q&A site and the question is a good one -- and maybe also worth asking on the [UX site](http://ux.stackexchange.com). Additionally, you _do not_ want to let users design how updates on stale data should be displayed (because [they can't tell](http://uxmyths.com/post/746610684/myth-21-people-can-tell-you-what-they-want)); that's the job of professional software and UX designers. – Mick Mnemonic Apr 07 '15 at 14:26
  • @MickMnemonic "Asking for help" is generally an important skill. But we are not talking about a minor detail in the implementation of some algorithm. We are talking about the **design** of major elements of a **medical** application - based on SO input. If I would be on such a project; I would try to get out immediately. And yes, users do not design user interfaces. But they are a primary source for requirements; and their (qualified and methodically collected) feedback on UI elements is a must if you don't want to build a UI that is not usable by the domain-expert people using it. – GhostCat Apr 07 '15 at 14:36
  • @Jägermeister, you seem to imply that medical applications should be designed inside a bunker without consulting the programmer community for design best practises -- and that would somehow lead to higher quality and user satisfaction. I think the opposite is true. The end users will dictate the requirements in the business domain's context, but this question is not really domain-specific. You can (and should) apply the same good UX / data access design for an optimistic locking scenario in any application, regardless of the business domain. – Mick Mnemonic Apr 07 '15 at 14:54
  • @MickMnemonic I think that any reasonable application should be designed by an engineering team; being in direct contact with the stakeholders; more specifically the **domain experts**. I agree that the question can be read as "lets discuss the option space"; but I think it can also be read as "my requirements are unclear; lets see what they could be". But we don't even know in which country this application will operate; we have **no** idea about the legal context therefore. And from that other comment of user38... I very much doubt that he has put much though in such subtle details. – GhostCat Apr 07 '15 at 16:33

2 Answers2

2

Doctor B should absolutely be notified in some way that the record has been modified since he opened it. The rest is up to you/the requirements of the program. Does it matter if Doctor A's changes are overwritten? Would it be better to have Doctor B view the changes made by Doctor A, and then decide if the changes (made by Doctor B) should still be saved? Should the changes be merged? It all depends on what you decide to design, as well as any requirements that may be imposed on the system you are creating. Without more detail on the system you are designing or its requirements, it would be impossible to provide a specific answer.

holtc
  • 1,780
  • 3
  • 16
  • 35
  • This interesting answer, For medical records what doctor (A) wrote should be kept & signed by Doctor (A) as last changed by, Doctor (B) should review what other doctor wrote about the patient before. Merging it's impossible and not recommnded, but from your answer i can see the best solution is showing doctor (B) a split page showing on the left pane what last change by doctor (B) has been done, on the right pane what doctor (A) wrote, then doctor (A) may copy some needed data from doctor (B) data & use it within his update, or discarding his update, or overwrite doctor (B) data. – user3822563 Apr 07 '15 at 12:24
  • Exactly, it is essential to let B know that the record has been changed, and past that, it is up to you to decide how best to handle that situation. At a bare minimum, you should tell doctor B to refresh the record and try to update it again, so B will see the changes A made, and then may not even need to make any changes if A's changes were similar enough – holtc Apr 07 '15 at 12:26
0

suggestion: send a real time notification

if A makes changes and hits save you could send a message "Data has been changed by another user !!!" immediately to B before B saved his changes.

This approach is similar to stackoverflow. As I write my answer, you can change your question and I will get a message

an edit has been made to this post; click to load

So if A,B,C... open data set D, they should register themselves as observers. You can implement this approach by using websockets or polling.

alex
  • 8,904
  • 6
  • 49
  • 75
  • Thanks for this idea, but as i know polling will keep selecting from table each X Seconds, is there approach for using polling?! – user3822563 Apr 07 '15 at 12:28
  • I would personally use sockets, as polling could lead to lots of unnecessary db calls, whereas the sockets approach would only require use WHEN a change was made, rather than constantly asking IF a change was made. – holtc Apr 07 '15 at 12:33
  • @user3822563 you should just find a way how to identify the changes of data set D. Of course polling is not the best solution. – alex Apr 07 '15 at 12:35
  • @user3822563 The other thing to keep in mind: does your application allow "offline work". What happens if user B is disconnected from the network for 10 seconds; or 10 minutes? – GhostCat Apr 07 '15 at 14:29