I have no idea what's going wrong here. From what I understand, MEL_CHANGE_MEDICATION has only one required field: the MID. The MID can be pulled out of existing medications using MEDS_AFTER (among others).
I've successfully pulled the MID out of a signed medication and have looked up that MID in the PRESCRIB table in our database. It's real, it exists. But no matter what I try, I get the error code -1, which indicates that the MID is wrong. I've turned it into a string, into a number, into a variable, I've hardcoded it into the function AND into my button, nothing works.
Here's my code:
MEL_CHANGE_MEDICATION("1846761978413920", "", "", "", "", "", "", "", "", "", "", FALSE, "", "", "H", "", "", "", "")
This is driving me insane. I'm doing everything that's being asked, and yet, nothing. I know it's a valid MID because I can find it in the database, but for some reason, MEL doesn't agree with me. And the only error I get is -1.
Not to ask a silly question, but have you tried copying the code into notepad and pasting it from there?
The end quotes on the MID look different than the begin quotes. And the rest of the quotes look like work quotes not notepad quotes...
Just a thought.
You are bracketing the MID with a quote (") and an apostrophe (').
I typed all this directly into VFE, so I think it's just how they looked pasted into this forum. Regardless, I copied and pasted it into Notepad, then back into VFE, but no luck. Don't worry about asking silly questions, because at least half the time I mess up something simple like that.
Has anyone ever made MEL_CHANGE_MEDICATION work? If so, do you have an example of it?
I removed everything from the MEL_CHANGE_MEDICATION function except for the MID, and it worked! At least it returned a 0 in the MEL Trace. I added in a Description change, and that worked too. So now, I can change the description of a medication. But once I added a third parameter, it stopped working.
EDIT: What I'm seeing here is if any part of the function stops working, it breaks everything, but doesn't return an error code other than -1, even when the MID is correct. I had forgotten that the new version of VFE has helpers that will build a function for you and it indicated that the function no longer has to have every possible field represented (in previous versions, you had to put an empty string in place for every possible field if you didn't want it filled).
I built the function back out and discovered that part of my problem was I was putting empty strings in the place of ID numbers. By turning IDs I didn't want to use into 0s, I was able to complete the function.
However... The function will fire, changing the description and the instructions, but the rxType won't update to "H" like I've indicated. The function is still firing and changing, which is weird, because normally if one part doesn't work, it'll just completely shut down.