<table class='table table-bordered'>
    <thead>
    <tr>
        <th><span class='i18n' data-i18n-id='i18n_type'>{{i18n "i18n_type" "Type"}}</span></th>
        <th><span class='i18n' data-i18n-id='i18n_destination'>{{i18n "i18n_destination" "Destination"}}</span></th>
        <th><span class='i18n' data-i18n-id='i18n_group'>{{i18n "i18n_group" "Group"}}</span></th>
        <th><span class='i18n' data-i18n-id='i18n_char_type'>{{i18n "i18n_char_type" "CharType"}}</span></th>
    </tr>
    </thead>
    <tbody>
    {{#if_eq firstMatch.relationships "undefined"}}
			<tr><td colspan='4'><span class='text-muted'>No relationships</span></td></tr>
		
         {{#if_eq firstMatch.statedRelationships "undefined"}}  
            
        {{/if_eq}}
	
		
     {{else}}   

        {{#each firstMatch.relationships}}
            {{#if activeStatus}}
               {{#if_eq type.id 116680003}}
                    {{push this ../../../inferredParents}}
                {{else}}
                    {{push this ../../../inferredRoles}}
                {{/if_eq}}
                
				
				<tr class='inferred-rel
                            {{#if_eq effectiveTime ../../options.highlightByEffectiveTime}}
                                 highlightEffectiveTime
                            {{/if_eq}}
                            '>
                    <td>
					{{#if_eq type.definitionStatusId "PRIMITIVE"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{moduleId}}" data-concept-id="{{type.id}}" data-term="{{type.fullySpecifiedName}}" data-def-status="{{type.definitionStatusId}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{moduleId}}" data-concept-id="{{type.id}}" data-term="{{type.fullySpecifiedName}}" data-def-status="{{type.definitionStatusId}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}}
                       {{type.fullySpecifiedName}}
                    </td>
                    <td>
                    
						{{#if_eq destinationConcept.definitionStatusId "PRIMITIVE"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{moduleId}}" data-concept-id="{{destinationConcept.id}}" data-term="{{destinationConcept.fullySpecifiedName}}" data-def-status="{{destinationConcept.definitionStatusId}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{moduleId}}" data-concept-id="{{destinationConcept.id}}" data-term="{{destinationConcept.fullySpecifiedName}}" data-def-status="{{destinationConcept.definitionStatusId}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}} 
                        
                    {{#if isConcreteRelationship}}    
                       {{destinationConcept.id}}
                       {{else}}
                       	{{destinationConcept.fullySpecifiedName}}
                     {{/if}}
                    
					
					
					
					</td>
                    <td>{{relationshipGroup}}</td>
                    {{#if_eq characteristicTypeId "STATED_RELATIONSHIP"}}
                    <td><span class='i18n' data-i18n-id='i18n_stated'>{{i18n "i18n_stated" "Stated"}}</span>
                    {{else}}
                        {{#if_eq characteristicTypeId "INFERRED_RELATIONSHIP"}}
                        <td><span class='i18n' data-i18n-id='i18n_inferred'>{{i18n "i18n_inferred" "Inferred"}}</span>
                        {{else}}
                        <td><span class='i18n' data-i18n-id='i18n_other'>{{i18n "i18n_other" "Other"}}</span>
                        {{/if_eq}}
                    {{/if_eq}}
                    <button type="button" class="btn btn-link unobtrusive-icon more-fields-button pull-right" data-container="body" data-toggle="popover" data-placement="left" data-content="
                                <table border='1'><tr><th style='padding: 3px;'>TypeId</th><th style='padding: 3px;'>Destination Id</th><th style='padding: 3px;'>Modifier</th><th style='padding: 3px;'>Effective Time</th><th style='padding: 3px;'>ModuleId</th></tr>
                                    <tr><td style='padding: 3px;'>{{type.id}}</td><td style='padding: 3px;'>{{destinationConcept.id}}</td><td style='padding: 3px;'>{{modifierId}}</td><td style='padding: 3px;'>{{effectiveTime}}</td><td style='padding: 3px;'>{{moduleId}}</td></tr>
                                </table>
                                " data-html="true"><i class="glyphicon glyphicon-info-sign"></i></button>
                </td>
                </tr>
            {{/if}}
        {{/each}}
    {{/if_eq}}
	
   {{#if_eq firstMatch.statedRelationships "undefined"}}
    {{else}}
	
        {{#each firstMatch.statedRelationships}}
            {{#if active}}
                {{#if_eq type.id 116680003}}
                    {{push this ../../../statedParents}}
                {{else}}
                    {{push this ../../../statedRoles}}
                {{/if_eq}}
                <tr class='stated-rel
                            {{#if_eq effectiveTime options.highlightByEffectiveTime}}
                                 highlightEffectiveTime
                            {{/if_eq}}
                            '>
                    <td>
                        {{#if_eq type.definitionStatus "Primitive"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')" data-module="{{module}}" data-concept-id="{{type.conceptId}}" data-term="{{type.defaultTerm}}" data-def-status="{{type.definitionStatus}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')" data-module="{{module}}" data-concept-id="{{type.conceptId}}" data-term="{{type.defaultTerm}}" data-def-status="{{type.definitionStatus}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}}
                        {{type.defaultTerm}}</td>
                    <td>
                        {{#if_eq target.definitionStatus "Primitive"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{module}}" data-concept-id="{{target.conceptId}}" data-term="{{target.defaultTerm}}" data-def-status="{{target.definitionStatus}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{module}}" data-concept-id="{{target.conceptId}}" data-term="{{target.defaultTerm}}" data-def-status="{{target.definitionStatus}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}}
                        {{target.defaultTerm}}</td>
                    <td>{{groupId}}</td>
                    {{#if_eq charType.conceptId "900000000000010007"}}
                    <td><span class='i18n' data-i18n-id='i18n_stated'>{{i18n "i18n_stated" "Stated"}}</span>
                    {{else}}
                        {{#if_eq charType.conceptId "900000000000011006"}}
                        <td><span class='i18n' data-i18n-id='i18n_inferred'>{{i18n "i18n_inferred" "Inferred"}}</span>
                        {{else}}
                        <td><span class='i18n' data-i18n-id='i18n_other'>{{i18n "i18n_other" "Other"}}</span>
                        {{/if_eq}}
                    {{/if_eq}}
                    <button type="button" class="btn btn-link unobtrusive-icon more-fields-button pull-right" data-container="body" data-toggle="popover" data-placement="left" data-content="
                        <table border='1'><tr><th style='padding: 3px;'>Modifier</th><th style='padding: 3px;'>Effective Time</th><th style='padding: 3px;'>ModuleId</th></tr>
                            <tr><td style='padding: 3px;'>{{modifier}}</td><td style='padding: 3px;'>{{effectiveTime}}</td><td style='padding: 3px;'>{{module}}</td></tr>
                        </table>
                        " data-html="true"><i class="glyphicon glyphicon-info-sign"></i></button>
                </td>
                </tr>
            {{/if}}
        {{/each}}
    {{/if_eq}}


    </tbody>
</table>

{{#if_undefined additionalRels}}
    <p>No additional relationships</p>
{{else}}
    <table class='table table-bordered'>
        <thead>
        <tr>
            <th><span class='i18n' data-i18n-id='i18n_type'>{{i18n "i18n_type" "Type"}}</span></th>
            <th><span class='i18n' data-i18n-id='i18n_destination'>{{i18n "i18n_destination" "Destination"}}</span></th>
            <th><span class='i18n' data-i18n-id='i18n_char_type'>{{i18n "i18n_char_type" "CharType"}}</span></th>
        </tr>
        </thead>
        <tbody>
        {{#each additionalRels}}
            {{#if active}}
                <tr>
                    <td>
                        {{#if_eq type.definitionStatus "Primitive"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')" data-module="{{module}}" data-concept-id="{{type.conceptId}}" data-term="{{type.defaultTerm}}" data-def-status="{{type.definitionStatus}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')" data-module="{{module}}" data-concept-id="{{type.conceptId}}" data-term="{{type.defaultTerm}}" data-def-status="{{type.definitionStatus}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}}
                        {{type.defaultTerm}}</td>
                    <td>
                        {{#if_eq target.definitionStatus "Primitive"}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{module}}" data-concept-id="{{target.conceptId}}" data-term="{{target.defaultTerm}}" data-def-status="{{target.definitionStatus}}"><span class="badge alert-warning">&nbsp;</span></a>&nbsp;&nbsp;
                        {{else}}
                            <a href="javascript:void(0);" style="color: inherit;text-decoration: inherit;" draggable = "true" ondragstart="drag(event, '{{divElementId}}')"  data-module="{{module}}" data-concept-id="{{target.conceptId}}" data-term="{{target.defaultTerm}}" data-def-status="{{target.definitionStatus}}"><span class="badge alert-warning">&equiv;</span></a>&nbsp;&nbsp;
                        {{/if_eq}}
                        {{target.defaultTerm}}</td>
                    <td><span class='i18n' data-i18n-id='i18n_additional'>{{i18n "i18n_additional" "Additional"}}</span>
                        <button type="button" class="btn btn-link unobtrusive-icon more-fields-button pull-right" data-container="body" data-toggle="popover" data-placement="left" data-content="
                        <table border='1'><tr><th style='padding: 3px;'>Modifier</th><th style='padding: 3px;'>Effective Time</th><th style='padding: 3px;'>ModuleId</th></tr>
                            <tr><td style='padding: 3px;'>{{modifier}}</td><td style='padding: 3px;'>{{effectiveTime}}</td><td style='padding: 3px;'>{{module}}</td></tr>
                        </table>
                        " data-html="true"><i class="glyphicon glyphicon-info-sign"></i></button>
                    </td>
                </tr>
            {{/if}}
        {{/each}}
        </tbody>
    </table>
{{/if_undefined}}