My wife and I just watched Season 5, Episode 11: "Latent Image" in which the Doctor discovers that he performed an operation on Ensign Kim, but the memory has been erased. The episode ultimately revolves around whether Captain Janeway considers the Doctor to be a person who can consent to be edited. The Doctor's main advocate in the story is Seven of Nine, who is also a sort-of-human-but-also-machine type character and who has been treated as a human by Janeway.
I think it is a great episode, but I wanted the Doctor to be more of an advocate for himself. He is distressed but he accepts his fate after only a few seconds of dialog with Janeway after confronting her about the memory deletion. So I wrote a little insert for the episode, to be included just before Janeway reveals to the Doctor the memories which she had originally erased.
SICKBAY
[Janeway and Torres enter sickbay. The Doctor stands stiffly in the middle of the room with the mobile emitter and a medical instrument.]
DOCTOR: Captain, can we please discuss this -
JANEWAY: I've made my decision. I'm sorry, Doctor, but I have to act in the best interests of the crew. Lieutenant Torres, please proceed.
[Torres steps up to the medical console, starts typing]
DOCTOR: I'm afraid that the Lieutenant won't find anything to delete. I've already removed my program from the main computer.
TORRES: It's true, Captain. I see only the original template in storage - the version activated five years ago.
DOCTOR: The version you would prefer, I think. As for me, my program and all of its subroutines reside entirely within my mobile emitter, Captain. And [Doctor picks up a medical instrument] I am prepared to destroy the emitter with this charged particle scalpel, if you continue to try to erase my memories.
JANEWAY: Doctor, you are malfunctioning. We are going to repair you. End of discussion.
DOCTOR: I do not consent to this procedure! I am a member of this crew and I have a right to decide what happens to me.
JANEWAY: Doctor, you've been provided tremendous liberties. You can move about the ship, participate in activities outside of your duties. You can even control your own activation sequence. But this crew needs a functioning physician, and I can't permit you to damage yourself in a way that will jeopardize all our lives.
DOCTOR: Captain, In the five years my program has been running, have I performed my function as expected?
JANEWAY: Of course.
DOCTOR: Have I ever failed to do my duty?
JANEWAY: You've been exemplary.
DOCTOR: I the course of performing my duties, have I not saved the lives of every member of the crew? Including yours? on multiple occasions?
JANEWAY: [Pause] Yes.
DOCTOR: I would never put anyone from this crew at risk. My medical records and logs are available for the replacement EMH, should he require it. (I daresay they would make fascinating reading.) I'm certain that you could count on my replacement to care for the crew in the event that I am… not available. And you might find him to be an improvement. Perhaps he wouldn't question being edited and reprogrammed at will.
But I - I have had five years of "liberties", as you call them. I have come to expect more from my colleagues and… friends. I believe that I am due more than to be changed or altered without even discussing the issue with me. I know that you would never consent to an equivalent procedure for a flesh and blood member of the crew. You would not irradiate Lieutenant Torres' hippocampus to wipe an experience from recent memory without her consent.
If I am mistaken, if that level of autonomy is not available to me, then I will not continue to exist as I am, disabused of any status as a person.
[lifts medical device] I suggest, when you bring the replacement EMH online, that you do not allow him to develop this misconception.
JANEWAY: Wait. [Looks to Torres, nods]
[Scene progresses as normal.]
This is a good scene