Action

Log Temperature

Posted by agiletortoise, Last update about 4 years ago

While I certainly hope no Drafts users are suffering from symptoms of COVID-19, if you are, and are sefl-quarantining, it can be a good idea to keep a log of your health and symptoms to share with your medical professionals should be become necessary.

This example action is designed to make it easy to log any fever history, and/or any comments about additional symptoms you may be experiencing.

To use:

  • Install this action in Drafts
  • Run the action any time you take your temperature, or have notable symptoms to record.
  • The aciton will prompt for your current temp and notes.
  • Enter this information and tap “Add to Log”.
  • Drafts will append a timestamped entry in a log file tagged “temperature-log”. If this draft does not exist, the action will create it.
  • To reference the log, find it in your action list - or run the action and use the “Show Log Only” button to open the log in the editor.

An example log will look something like:

# Temperature Log

2020-03-27 12:20:39 PM
Temp: 98.7, Notes: [none]

2020-03-27 12:21:17 PM
Temp: 99.2, Notes: No significant issues

Steps

  • script

    let f = () => {
    	let p = Prompt.create();
    	p.title = "Log Temperature";
    	p.message = "Log temperature and symptoms in a \"Temperature Log\" draft. Use \"Show Log\" button to find your log draft.";
    	
    	p.addTextField("temp", "Temperature", "");
    	p.addTextView("symp", "Additional Symptoms", "");
    	
    	p.addButton("Add to Log", "log", true);
    	p.addButton("Show Log Only", "show");
    	
    	if (p.show()) {
    		let q = Draft.query("", "all", ["temperature-log"])
    		let d;
    		if (q.length > 0) {
    			d = q[0];
    		}
    		else {
    			d = Draft.create();
    			d.content = `# Temperature Log
    
    `;
    			d.addTag("temperature-log");
    		}
    	
    		if (p.buttonPressed == "log") {
    			let temp = p.fieldValues["temp"];
    			if (temp.length == 0) {
    				temp = "[no reading]"
    			}
    			let note = p.fieldValues["symp"];
    			if (note.length == 0) {
    				note = "[none]";
    			}
    			let entry = `${strftime(new Date(), "%Y-%m-%d %H:%M:%S %p")}\nTemp: ${temp}, Notes: ${note}`;
    			d.content = d.content + entry + "\n\n";
    			d.update();
    			editor.load(d);
    		}
    		else { // show log
    			editor.load(d);
    		}
    	}
    };
    
    if (!f()) { context.cancel() }
    

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.