<commit_before>"use strict";
var chakram         = require("chakram"),
    util            = require("util"),
    curry           = require("curry"),
    Q               = require("q"),
    auth            = require("../common/auth.js"),
    patients        = require("../patients/common.js"),
    medications     = require("../medications/common.js"),
    fixtures        = require("./fixtures.js");

var expect = chakram.expect;



//Clinican Note Tests

describe("Clinican Notes", function (){


	var editNote = function (data, patientID, journalID, accessToken) {
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/%d", patientID, journalID);
		return chakram.put(url, data, auth.genAuthHeaders(accessToken));
	}
	var viewNote = function (patientID, journalID, accessToken) {
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/%d", patientID, journalID);
		return chakram.get(url, auth.genAuthHeaders(accessToken));
	}
	var createNote = function(data, patientID, accessToken){
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/", patientID);
		return chakram.post(url, data, auth.genAuthHeaders(accessToken));
	}

	describe("testing clinician note priviliges", function () {
	    var user, clinicianUser, patient;
	    //setup clinician user
	    before(function () {
	        return auth.createTestUser({"clinician": true}).then(function (u) {
	            clinicianUser = u;

	        });

	    });
	    // setup current user and one patient for them, with a journal entry where clinician is set to true
	    before(function () {
	        return auth.createTestUser().then(function (u) {
	            user = u;
	            // create patient
	            return patients.createMyPatient({}, user).then(function (p) {
	                patient = p;
	                Q.npost(patient, "share", [clinicianUser.email, "default", "prime"]);
	            }).then(function () {
	                // setup journal entry for Patient
	                return Q.nbind(patient.createJournalEntry, patient)({
	                    text: "Clinican Note",
	                    date: (new Date()).toISOString(),
	                    clinician: true
	                });
	            });
	        });
	    });


	    it("Asserts that clinican can view clinican note", function () {
	        return expect(viewNote(patient._id, patient.entries[0]._id,clinicianUser.accessToken)).to.be.a.journal.viewSuccess;
	    });
	    it("Asserts that clinican can edit clinican note", function () {
	        var modifications = {text: "Different clinican note"};
	        return expect(editNote(modifications,patient._id, patient.entries[0]._id,clinicianUser.accessToken)).to.be.a.journal.success;
	    });
	    it("Asserts that other user cannot view clinican note", function () {
	        return expect(viewNote(patient._id, patient.entries[0]._id, user.accessToken)).to.be.an.api.error(403, "unauthorized")
	    });
	    it("Asserts that other user cannot edit clinican note", function () {
	        var modifications = {text: "Different clinican note"};
	        return expect(editNote(modifications,patient._id, patient.entries[0]._id, user.accessToken)).to.be.an.api.error(403, "unauthorized")
	    });
	    it("Asserts that clinican note cannot contain meditation values", function () {
	        var modifications = {meditation: true};
	        return expect(editNote(modifications, patient._id, patient.entries[0]._id, clinicianUser.accessToken)).to.be.an.api.error(400, "invalid_clinician_note");
	    });
	    it("Asserts that note created by Clincian API user is marked as a clinican note", function() {
	    	var modifications = {text: "New clinican note", date: (new Date()).toISOString()};
	    	return createNote(modifications, patient._id, clinicianUser.accessToken).then( function (response) {
	    		expect(response.body.clinician).to.deep.equal(true);
	    	})
	    });
	});
});<commit_msg>Wording change<commit_after>"use strict";
var chakram         = require("chakram"),
    util            = require("util"),
    curry           = require("curry"),
    Q               = require("q"),
    auth            = require("../common/auth.js"),
    patients        = require("../patients/common.js"),
    medications     = require("../medications/common.js"),
    fixtures        = require("./fixtures.js");

var expect = chakram.expect;



//Clinican Note Tests

describe("Clinican Notes", function (){


	var editNote = function (data, patientID, journalID, accessToken) {
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/%d", patientID, journalID);
		return chakram.put(url, data, auth.genAuthHeaders(accessToken));
	}
	var viewNote = function (patientID, journalID, accessToken) {
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/%d", patientID, journalID);
		return chakram.get(url, auth.genAuthHeaders(accessToken));
	}
	var createNote = function(data, patientID, accessToken){
		var url = util.format("http://localhost:5000/v1/patients/%d/journal/", patientID);
		return chakram.post(url, data, auth.genAuthHeaders(accessToken));
	}

	describe("testing clinician note priviliges", function () {
	    var user, clinicianUser, patient;
	    //setup clinician user
	    before(function () {
	        return auth.createTestUser({"clinician": true}).then(function (u) {
	            clinicianUser = u;

	        });

	    });
	    // setup current user and one patient for them, with a journal entry where clinician is set to true
	    before(function () {
	        return auth.createTestUser().then(function (u) {
	            user = u;
	            // create patient
	            return patients.createMyPatient({}, user).then(function (p) {
	                patient = p;
	                Q.npost(patient, "share", [clinicianUser.email, "default", "prime"]);
	            }).then(function () {
	                // setup journal entry for Patient
	                return Q.nbind(patient.createJournalEntry, patient)({
	                    text: "Clinican Note",
	                    date: (new Date()).toISOString(),
	                    clinician: true
	                });
	            });
	        });
	    });


	    it("Asserts that clinican can view clinican note", function () {
	        return expect(viewNote(patient._id, patient.entries[0]._id,clinicianUser.accessToken)).to.be.a.journal.viewSuccess;
	    });
	    it("Asserts that clinican can edit clinican note", function () {
	        var modifications = {text: "Different clinican note"};
	        return expect(editNote(modifications,patient._id, patient.entries[0]._id,clinicianUser.accessToken)).to.be.a.journal.success;
	    });
	    it("Asserts that patient user cannot view clinican note", function () {
	        return expect(viewNote(patient._id, patient.entries[0]._id, user.accessToken)).to.be.an.api.error(403, "unauthorized")
	    });
	    it("Asserts that patient user cannot edit clinican note", function () {
	        var modifications = {text: "Different clinican note"};
	        return expect(editNote(modifications,patient._id, patient.entries[0]._id, user.accessToken)).to.be.an.api.error(403, "unauthorized")
	    });
	    it("Asserts that clinican note cannot contain meditation values", function () {
	        var modifications = {meditation: true};
	        return expect(editNote(modifications, patient._id, patient.entries[0]._id, clinicianUser.accessToken)).to.be.an.api.error(400, "invalid_clinician_note");
	    });
	    it("Asserts that note created by Clincian API user is marked as a clinican note", function() {
	    	var modifications = {text: "New clinican note", date: (new Date()).toISOString()};
	    	return createNote(modifications, patient._id, clinicianUser.accessToken).then( function (response) {
	    		expect(response.body.clinician).to.deep.equal(true);
	    	})
	    });
	});
});
{'fraction_non_alphanumeric': 0.13906864611089964, 'fraction_numerical': 0.007359472148204543, 'mean_word_length': 2.804054054054054, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1194768', 'n_tokens_mistral': 2397, 'n_tokens_neox': 2180, 'n_words': 519}