<commit_before><%@ include file="/WEB-INF/template/include.jsp" %>

<openmrs:require privilege="Edit Observations" otherwise="/login.htm" redirect="/admin/observations/obs.form" />

<%@ include file="/WEB-INF/template/header.jsp" %>
<%@ include file="localHeader.jsp" %>

<openmrs:htmlInclude file="/scripts/calendar/calendar.js" />

<script type="text/javascript">

	// on concept select:
	function onQuestionSelect(concept) {
		$j("#conceptDescription").show();
		$j("#conceptDescription").html(concept.description);
		updateObsValues(concept);
	}

	// on answer select:
	function onAnswerSelect(concept) {
		$j("#codedDescription").show();
		$j("#codedDescription").html(concept.description);
	}
	
	function showProposeConceptForm() {
		var qs = "?";
		var encounterId = "${obs.encounter.encounterId}" || $j("#encounterId").val();
		if (encounterId != "")
			qs += "&encounterId=" + encounterId;
		var obsConceptId = "${obs.concept.conceptId}" || $j("#conceptId").val();
		if (obsConceptId != "")
			qs += "&obsConceptId=" + obsConceptId;
		document.location = "${pageContext.request.contextPath}/admin/concepts/proposeConcept.form" + qs;
	}
	
	function updateObsValues(tmpConcept) {
		var values = ['valueBooleanRow', 'valueCodedRow', 'valueDatetimeRow', 'valueModifierRow', 'valueTextRow', 'valueNumericRow', 'valueInvalidRow', 'valueComplex'];
		$j.each(values, function(x, val) { $j("#" + val).hide() });
		
		if (tmpConcept != null) {
			var datatype = tmpConcept.hl7Abbreviation;
			if (typeof datatype != 'string')
				datatype = tmpConcept.datatype.hl7Abbreviation;
			
			if (datatype == 'BIT') {
				$j('#valueBooleanRow').show();
			}
			else if (datatype == 'NM' || datatype == 'SN') {
				$j('#valueNumericRow').show();
				DWRConceptService.getConceptNumericUnits(tmpConcept.conceptId, fillNumericUnits);
			}
			else if (datatype == 'CWE') {
				$j('#valueCodedRow').show();
				
				// clear any old values:
				$j("#valueCoded").val("");
				$j("#valueCoded_selection").val("");
				$j("#codedDescription").html("");
				
				// set up the autocomplete for the answers
				var conceptId = $j("#conceptId").val();
				new AutoComplete("valueCoded_selection", new CreateCallback({showAnswersFor: conceptId}).conceptAnswersCallback(), {'minLength':'0'});
				$j("#valueCoded_selection").autocomplete().focus(function(event, ui) {
					if (event.target.value == "")
						$j("#valueCoded_selection").trigger('keydown.autocomplete');
				}); // trigger the drop down on focus

				$j("#valueCoded_selection").focus();
			}
			else if (datatype == 'ST') {
				$j('#valueTextRow').show();
			}
			else if (datatype == 'DT' || datatype == 'TS' || datatype == 'TM') {
				$j('#valueDatetimeRow').show();
			}
			// TODO move datatype 'TM' to own time box.  How to have them select?
			else if (datatype == 'ED') {
				$j('#valueComplex').show();
			}
			else {
				$j('#valueInvalidRow').show();
				DWRConceptService.getQuestionsForAnswer(tmpConcept.conceptId, fillValueInvalidPossible(tmpConcept));
			}
		}
	}
	
	function fillNumericUnits(units) {<commit_msg>Fixing answer dropdown appearing below question dropdown - TRUNK-1652<commit_after><%@ include file="/WEB-INF/template/include.jsp" %>

<openmrs:require privilege="Edit Observations" otherwise="/login.htm" redirect="/admin/observations/obs.form" />

<%@ include file="/WEB-INF/template/header.jsp" %>
<%@ include file="localHeader.jsp" %>

<openmrs:htmlInclude file="/scripts/calendar/calendar.js" />

<script type="text/javascript">

	// on concept select:
	function onQuestionSelect(concept) {
		$j("#conceptDescription").show();
		$j("#conceptDescription").html(concept.description);
		updateObsValues(concept);
	}

	// on answer select:
	function onAnswerSelect(concept) {
		$j("#codedDescription").show();
		$j("#codedDescription").html(concept.description);
	}
	
	function showProposeConceptForm() {
		var qs = "?";
		var encounterId = "${obs.encounter.encounterId}" || $j("#encounterId").val();
		if (encounterId != "")
			qs += "&encounterId=" + encounterId;
		var obsConceptId = "${obs.concept.conceptId}" || $j("#conceptId").val();
		if (obsConceptId != "")
			qs += "&obsConceptId=" + obsConceptId;
		document.location = "${pageContext.request.contextPath}/admin/concepts/proposeConcept.form" + qs;
	}
	
	function updateObsValues(tmpConcept) {
		var values = ['valueBooleanRow', 'valueCodedRow', 'valueDatetimeRow', 'valueModifierRow', 'valueTextRow', 'valueNumericRow', 'valueInvalidRow', 'valueComplex'];
		$j.each(values, function(x, val) { $j("#" + val).hide() });
		
		if (tmpConcept != null) {
			var datatype = tmpConcept.hl7Abbreviation;
			if (typeof datatype != 'string')
				datatype = tmpConcept.datatype.hl7Abbreviation;
			
			if (datatype == 'BIT') {
				$j('#valueBooleanRow').show();
			}
			else if (datatype == 'NM' || datatype == 'SN') {
				$j('#valueNumericRow').show();
				DWRConceptService.getConceptNumericUnits(tmpConcept.conceptId, fillNumericUnits);
			}
			else if (datatype == 'CWE') {
				$j('#valueCodedRow').show();
				
				// clear any old values:
				$j("#valueCoded").val("");
				$j("#valueCoded_selection").val("");
				$j("#codedDescription").html("");
				
				// set up the autocomplete for the answers
				var conceptId = $j("#conceptId").val();
				new AutoComplete("valueCoded_selection", new CreateCallback({showAnswersFor: conceptId}).conceptAnswersCallback(), {'minLength':'0'});
				$j("#valueCoded_selection").autocomplete().focus(function(event, ui) {
					if (event.target.value == "")
						$j("#valueCoded_selection").trigger('keydown.autocomplete');
				}); // trigger the drop down on focus
				
				// something in the autocomplete is setting the focus to the conceptId box after
				// this method is done.  get around this and focus on our answer box by putting
				// a very small delay on the call using setTimeout
				setTimeout("$j('#valueCoded_selection').focus();", 0);
			}
			else if (datatype == 'ST') {
				$j('#valueTextRow').show();
			}
			else if (datatype == 'DT' || datatype == 'TS' || datatype == 'TM') {
				$j('#valueDatetimeRow').show();
			}
			// TODO move datatype 'TM' to own time box.  How to have them select?
			else if (datatype == 'ED') {
				$j('#valueComplex').show();
			}
			else {
				$j('#valueInvalidRow').show();
				DWRConceptService.getQuestionsForAnswer(tmpConcept.conceptId, fillValueInvalidPossible(tmpConcept));
			}
		}
	}
	
	function fillNumericUnits(units) {
{'fraction_non_alphanumeric': 0.18284739454094293, 'fraction_numerical': 0.001705955334987593, 'mean_word_length': 4.410234899328859, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1792772', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2056, 'n_words': 397}