Hide Entry

319 views
Skip to first unread message

Jeffrey Brooks

unread,
Jun 25, 2017, 7:47:53 AM6/25/17
to mementodatabase
I have a database of patients that are pending surgery. I want to be able to hide the entries when the case is done. I don't want to simply delete the entry in the event that I want to reference it later.
Can this be accomplished?

Chris Tracey

unread,
Jun 25, 2017, 8:17:55 AM6/25/17
to mementodatabase
Hi

I don't know if Memento lets you hide cases directly. Others may know. I can think of two other ways to approximate what you are after.

1) Create a filter which excludes cases which are complete. You can put this onto a tab which will it easier to flip between the filtered and unfiltered view.

2) Save completed cases to a different library and then delete them from your original library. This might make more sense if you're unlikely to want to look at them very often (but you still want them there just in case). You can probably do this in Javascript, although I'm not sure if you can do it with Memento's built-in functionality.

Happy to expand on these ideas if you want to explore them.

Thanks

Chris

Jeffrey Brooks

unread,
Jun 25, 2017, 10:26:25 AM6/25/17
to mementodatabase
Chris

That's perfect.

Thanks!

Jeffrey Brooks

unread,
Jun 25, 2017, 11:05:22 AM6/25/17
to mementodatabase
Chris

If I did it via the Javascript method I'd have to write the script from scratch, correct?
Would you be able to help with the script?

Chris Tracey

unread,
Jun 25, 2017, 6:43:30 PM6/25/17
to mementodatabase
Hi Jeffrey

I can certainly try to help. I've only started using Javascript in the last few weeks, so I'm the reverse of an expert.

However I have got a couple of scripts to work so I might be able to get you started. How about you send me a list of the key fields (and their types) and I'll see what I can do.

Thanks

Chris

Jeffrey Brooks

unread,
Jun 25, 2017, 8:04:44 PM6/25/17
to mementodatabase
Chris

I really appreciate that.  So what I did is add a single choice list titled "Active".  The items in that entry are "Yes" and "No".  My thoughts were that if I toggled a completed case to "No", I could run the script and have all patients that have "No" moved to a library titled "Inactive Patients".
Does that help?

Jeff

Bill Crews

unread,
Jun 25, 2017, 8:44:54 PM6/25/17
to mementodatabase
I wish you both the best of luck. My main worry is how to move an entry. Copying one is easy, but I know of no way to delete an entry from a library in JavaScript.

There is an Entry Property called deleted whose value is True if the entry is in the Recycle Bin and False otherwise, but I don't think that can be used to cause a deletion of the entry.

Given this worry, I like Chris's idea of using a Filter Tab to hide entries.

Please prove me wrong; just let me know what's right. And good luck.

Chris Tracey

unread,
Jun 26, 2017, 6:37:56 PM6/26/17
to mementodatabase
Hi Jeff

I think Bill is right in that you can't use Javascript to delete records from libraries. I think this is a Memento issue as there is definitely a delete method in Javascript.

Anyway I've written some code to save closed cases from one library to another (see end of this post). If nothing else, it will be  a starting point for the time when the developer implements a delete function in Memento. I should re-emphasise that I've only used Javascript for a few weeks, and then only as a hobbyist. So I wouldn't use this code if money and/or someone's health depends on it.

I've assumed your main library is called 'All Cases' and has three variables;

1) Unique Id - this is an Integer variable which is set to auto-increment;
2) Operation - a text variable which records the operation.
3) Active - The single choice list which you suggested. It can take the values Open or Closed.

I've set the entry name to unique.

The second library is called 'Closed File' and has the Unique ID and operation variables.

The JS code is attached to an action trigger. When it runs it goes through the following steps:

1) Initialise some key variables which reference the libraries
2) Check if the 'All Cases' file contains any cases. If not then the script will terminate;
3) Loop through each case in the 'All Cases file'
4) If the single-choice variable is set to Closed, then the script runs an inner loop on all cases in the 'Closed File'. If it finds any cases where the Unique Id is a match then it sets a flag which stops the case from being saved.
5) If the case is closed and not already on the closed file then it will be saved to the closed file.

A few points to bear in mind:

1) I've done some basic tests on it and it seems to work as described. However I knocked this out fairly quickly so it may well not be bug-free.
2)  It is also not the most efficient code e.g if step 4 finds a match on the first case in the closed file it will check all of the other cases for a match. This will soon get cumbersome for large files, so I will try and fix this in a few days time;
3) It contains some messages which helped me understand the control flow. They're not essential to the code of course;
4) It works as an action script. I'm guessing it could be placed into a trigger script so you could just apply it when a case was updated.

Thanks

Chris



******************  CODE STARTS HERE ***********************************


// Saving closed records to another file

// Variable to reference the operation library, array of entries and number of entries

var oplib=lib();
var opent=lib().entries();
var oplen=opent.length;

// exit if operation library is empty
if (oplen<=0)

{

message ("No records in main file - closing the script");
exit();
}

// Variables to reference closed case library, and array of entries

var cllib=libByName("Closed File");
var clent=libByName("Closed File").entries();
var cllen=clent.length;


// Loop through current library
// And identify closed cases

for (var ent=0; ent<oplen; ent++)

{   

var clsdflag= opent[ent].field("Active");

if (clsdflag==="Closed")

{
   
// if closed, need to check
// they aren't already on the closed case file
message("Looping through a closed case");

// Initialize flag which tests if entry already on closed case file

var newflag=1;

// Set-up the loop through closed case file
// At the moment it doesn't loop if the closed file is empty

for (var chk=0; chk<cllen; chk++)

{



var messtext2=("Case ") +(ent) + ("  on operation file and case ") + ( chk) + (" on closed  file");
message (messtext2);



// Check for a matching Unique Id obn closed case file


if (opent[ent].field("Unique Id")===clent[chk].field("Unique Id"))

{

// Set flag to show entry already.on 
// closed file

message (("Case ") + (ent) + (" matches with case ") + (chk) + (" on closed file"));
newflag=0;


}

}

// Save in closed file if not already there

// message (("Newflag is ") + (newflag));

if (newflag===1)

{
message ("Saving to closed file");
var newentry= new Object();
newentry["Unique Id"]=opent[ent].field("Unique Id");
newentry["Operation"]=opent[ent].field("Operation");
cllib.create(newentry);
}
}

}


Logan (DarkComet)

unread,
Jul 6, 2017, 6:09:53 PM7/6/17
to mementodatabase
Instead of deleting the entry, why not move it to another library? Have two libraries: Active and Unactive. 

That way if you ever need to go back and look at previous patients information, or send it to another doctor the patient is transferring to, you can easily do so. If you don't want to look at the Unactive list, you could always move it to another group. I believe moving entries between libraries is global to the Memento App, so no matter where the library is or if it is moved to another group, as long as you don't change the name or create another library with that same name, you shouldn't have any problems. 

What Chris Tracey said to you already, you could also just use the filter function and leave it to filter Active entries. Once an entry becomes Unactive, it no longer fits the filter criteria so it is hidden unless you change the filter. 

The last idea I have that involves the filter, if you don't want to have it filter by status of Active/Unactive, you could instead (or in addition) have it where it changes the entries color which you can link to the Boolean (checkbox) which toggles the status to Active/Unactive. Then you would just filter by color and all the Unactive specific color entries are shifted downward going in order of "Active: Most Recent" & "Unactive: Most Recent". That way you can just scroll down the list or search for an entry without changing the filter to view older Unactive patient files. Just an idea and it would visually make things easier to identify for the Doctors. 

As for the code for moving the entries from one library to another based on their status you would most likely use Trigger function which uses Javascript. Off the top of my head, I'm not entirely sure how to do it so I would have to do some research to see if it is possible, that is unless someone has tried it already. I can post what I find and if I can get it working because I personally may want a similar automated system of moving entries for my own use.  :)

Bill Crews

unread,
Jul 6, 2017, 8:55:07 PM7/6/17
to mementodatabase
I think, ultimately, the problem in moving an entry is that it has to be removed from the originating library. In JavaScript, this is difficult, as there is no API for doing this in the Memento JavaScript Library, as I have said previously. The developer is aware of my concern that there should be such a method; I don't know the reason for its continued omission.
Reply all
Reply to author
Forward
0 new messages