<commit_before>/**
 * Created by soheil on 02/08/2016.
 */

WebService = Class.create({

	initialize: function () {
		this._settings = new Settings();
		this._baseURL = this._settings.getSetting('codingDefinitionServiceEndpoint');
	},

	getOmimLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/OMIMLookupService?";
	},

	getIcd10LookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/ICDLookupService?";
	},

	getSnomedCTLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/SNOMEDCTLookupService?";
	},

	getGELLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/DiseaseList?";
	},

	getEthnicityLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/Ethnicity?";
	},

	getHPOLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/OntologyService/LookupService?";
	},

	getDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath =  _this.getUrlParameter("accessPath", true);
				return accessPath;
				break;
			case "openclinica":
				var eventCRFId = this.getUrlParameter("eventCRFId");
				var status = this.getUrlParameter("status");
				var participantId = this.getUrlParameter("participantId");
				return "/openclinica/pedigree/get?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	saveDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath    = _this.getUrlParameter("accessPath");
				var participantId = _this.getParticipantIdFromURL();
				return "???";
				break;
			case "openclinica":
				var _this = this;
				var eventCRFId = _this.getUrlParameter("eventCRFId");
				var status = _this.getUrlParameter("status");
				var participantId = _this.getUrlParameter("participantId");
				return "/openclinica/pedigree/update?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getUrlParameter: function getUrlParameter(sParam, doNotDecode) {

		var sPageURL = decodeURIComponent(window.location.search.substring(1));
		if(doNotDecode && doNotDecode == true){
			sPageURL = window.location.search.substring(1);
		}<commit_msg>Add a method to get path to js files on server through the URL<commit_after>/**
 * Created by soheil on 02/08/2016.
 */

WebService = Class.create({

	initialize: function () {
		this._settings = new Settings();
		this._baseURL = this._settings.getSetting('codingDefinitionServiceEndpoint');
	},

	getOmimLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/OMIMLookupService?";
	},

	getIcd10LookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/ICDLookupService?";
	},

	getSnomedCTLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/SNOMEDCTLookupService?";
	},

	getGELLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/DiseaseList?";
	},

	getEthnicityLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/Ethnicity?";
	},

	getHPOLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/OntologyService/LookupService?";
	},

	getDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath =  _this.getUrlParameter("accessPath", true);
				return accessPath;
				break;
			case "openclinica":
				var eventCRFId = this.getUrlParameter("eventCRFId");
				var status = this.getUrlParameter("status");
				var participantId = this.getUrlParameter("participantId");
				return "/openclinica/pedigree/get?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getPathToEditorFiles: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				return "";
				break;
			case "openclinica":
				//get path to pedigree directory like :
				//"http://localhost:8083/openclinica/includes/pedigreeEditor/" or
				//"https://gmc.genomicsengland.nhs.uk/rarediseases/demo/includes/pedigreeEditor/"
				return Helpers.getSiteURL() + "/includes/pedigreeEditor/";
			case "local":
				return Helpers.getSiteURL() + "/";
		}
	},

	saveDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath    = _this.getUrlParameter("accessPath");
				var participantId = _this.getParticipantIdFromURL();
				return "???";
				break;
			case "openclinica":
				var _this = this;
				var eventCRFId = _this.getUrlParameter("eventCRFId");
				var status = _this.getUrlParameter("status");
				var participantId = _this.getUrlParameter("participantId");
				return "/openclinica/pedigree/update?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getUrlParameter: function getUrlParameter(sParam, doNotDecode) {

		var sPageURL = decodeURIComponent(window.location.search.substring(1));
		if(doNotDecode && doNotDecode == true){
			sPageURL = window.location.search.substring(1);
		}
{'fraction_non_alphanumeric': 0.13014008133755084, 'fraction_numerical': 0.004217502635939147, 'mean_word_length': 4.891748003549246, 'pattern_counts': {'":': 15, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '606509', 'n_tokens_mistral': 2274, 'n_tokens_neox': 1976, 'n_words': 383}