<commit_before><h1>Profile</h1>

<form name="myForm"  novalidate ng-cloak>
    <input type="hidden" name="id" ng-model="person.id">
    <div class="row">
        <div class="span12">
			<span ng-switch on="hasRoleSelected('Practitioner') || hasRoleSelected('Admin') || hasRoleSelected('Site Admin')">
				<div ng-switch-when="true">
					<h2>Name</h2>
					<div class="control-group" ng-class="{error: myForm.personName.$invalid}">
						<label>Name</label>
						<input type="text" name="personName" ng-model="$parent.person.name" required/>
						<span ng-show="myForm.personName.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<h2>Account</h2>
			<div class="control-group" ng-class="{error: myForm.email.$invalid}">
				<label>Email</label>
				<input type="email" name="email" ng-model="person.email" required/>
				<span ng-show="myForm.email.$error.required" class="help-inline"> Required</span>
			</div>
			<span ng-switch on="hasRoleSelected('Patient') && modeNew">
				<div ng-switch-when="true">
					<div class="control-group" ng-class="{error: passwordInvalid()}">
						<label>Password</label>
						<span ng-switch on="modeNew">
							<input ng-switch-when="true"  type="password" name="password" ng-model="$parent.$parent.password"  ui-reset required/>
							<input ng-switch-default      type="password" name="password" ng-model="$parent.$parent.password"  ui-reset />
						</span>
						<span ng-show="myForm.password.$error.required" class="help-inline"> Required</span>
						<div>Passwords must be at least 8 characters and contain a number, letter and special character.</div>
					</div>
					<div class="control-group" ng-class="{error: passwordConfirmationInvalid()}">
						<label>Password Confirmation</label>
						<span ng-switch on="modeNew">
							<input ng-switch-when="true" type="password" name="passwordConfirmation" ng-model="$parent.$parent.passwordConfirmation"  ui-reset required/>
							<input ng-switch-default     type="password" name="passwordConfirmation" ng-model="$parent.$parent.passwordConfirmation"  ui-reset />
						</span>
						<span ng-show="myForm.passwordConfirmation.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<span ng-switch on="hasRoleSelected('Admin')">
				<div ng-switch-when="true" class="control-group" ng-class="{error: myForm.roles.$invalid}">
					<label>Roles</label>
					<div ng-repeat="role in roles">
						<input id="{{role}}"type="checkbox" ng-disabled="disableRoleEdit" ng-model="$parent.roleChoices[$index]"><label class="checkbox" for="{{role}}">{{role}}</label>
					</div>
				</div>  
			</span>
			<span ng-switch on="hasRoleSelected('Patient')">
				<div ng-switch-when="true">
					<h2>Consent</h2>
					<div class="control-group" ng-class="{error: myForm.agreedToInformationSheet.$invalid}">
						<label>Read and Understood Information Sheet</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToInformationSheet" ng-model="$parent.person.agreedToInformationSheet" required/> 
						<span ng-show="myForm.agreedToInformationSheet.$error.required" class="help-inline"> Required</span>
					</div>
					<div class="control-group" ng-class="{error: myForm.agreedToConsent.$invalid}">
						<label>Signed Consent Form</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToConsent" ng-model="$parent.person.agreedToConsent" required/>
						<span ng-show="myForm.agreedToConsent.$error.required" class="help-inline"> Required</span>
					</div>
					<div class="control-group" ng-class="{error: myForm.agreedToAssent.$invalid}">
						<label>Signed Assent Form</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToAssent" ng-model="$parent.person.agreedToAssent" required/>
						<span ng-show="myForm.agreedToAssent.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<span ng-switch on="hasRole('Admin')">
				<div ng-switch-when="true">
					<h2>Site</h2>
					<div class="control-group" ng-class="{error: myForm.site.$invalid}">
						<div>Selected site: {{person.site.name}}</div>
						<select 
							ui-select2
							name="site"
							ng-model="$parent.person.site" 
							ng-options="g.name for g in sites"
							style="width:400px"
							required>
						</select>		
						<span ng-show="myForm.site.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>

			<br>
			<!--			<select                                                                      
							selectcontacts
							data-placeholder="Select Contact"
							ng-model="modelObj"
							ng-options="contact.title for contact in contacts"
							class="selectcontacts"
							style="width:200px"
							>                                                                            
							<option></option>                                                          
						</select> -->
			<span ng-switch on="hasRoleSelected('Patient')">
				<div ng-switch-when="true">
					<h2>Care Team</h2>
					<div>
						<!--<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue" ui-reset>-->
						<!--<input type="text" ng-model="careTeamSearchItem" typeahead="suggestion for suggestion in cities($viewValue)" ui-reset>-->
						<!--ng-options="i.name.firstNames + ' ' +  i.name.lastName for i in careTeamPersons"-->
						<input 
							ui-select2="careTeamPersons"
							name="careTeamPersons"
							ng-model="$parent.careTeamSearchItem" 
							style="width:60%"
							/>
						<button ng-click="addToCareTeam()" class="btn btn-primary" ng-disabled="canAddToCareTeam()">Add to Care Team</button>

					</div>
					<table class="table-hover" ng-show="careTeam.length &gt; 0" style="width:85%">
						<col class="column-name">
						<col class="column-email">
						<col class="column-action">
						<thead>
							<tr>
								<th>Care Team Member</th>
								<th>Email</th>
								<th>Remove</th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="item in careTeam">
								<td>{{item.name}}</td>
								<td>{{item.email}}</td>
								<td class="action">
									<span ng-click="removeFromCareTeam($index)"> <i class="icon-trash"></i></span>
								</td>   
							</tr>
						</tbody>
					</table>
				</div>
			</span>
        </div>
    </div>
	<br/>
	<!--		isClean {{isClean()}}
			<br>
			invalid {{myForm.$invalid}} {{isValid()}}-->
	<a href="#/dashboard" class="btn">Cancel</a>
	<button ng-click="save()" ng-disabled="isClean() || myForm.$invalid || !isValid()" class="btn btn-primary">Save</button>
	<button ng-click="destroy()" ng-show="person.uuid" class="btn btn-danger">Delete</button>
</form>

<!--<commit_msg>only give delete on person to admin<commit_after><h1>Profile</h1>

<form name="myForm"  novalidate ng-cloak>
    <input type="hidden" name="id" ng-model="person.id">
    <div class="row">
        <div class="span12">
			<span ng-switch on="hasRoleSelected('Practitioner') || hasRoleSelected('Admin') || hasRoleSelected('Site Admin')">
				<div ng-switch-when="true">
					<h2>Name</h2>
					<div class="control-group" ng-class="{error: myForm.personName.$invalid}">
						<label>Name</label>
						<input type="text" name="personName" ng-model="$parent.person.name" required/>
						<span ng-show="myForm.personName.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<h2>Account</h2>
			<div class="control-group" ng-class="{error: myForm.email.$invalid}">
				<label>Email</label>
				<input type="email" name="email" ng-model="person.email" required/>
				<span ng-show="myForm.email.$error.required" class="help-inline"> Required</span>
			</div>
			<span ng-switch on="hasRoleSelected('Patient') && modeNew">
				<div ng-switch-when="true">
					<div class="control-group" ng-class="{error: passwordInvalid()}">
						<label>Password</label>
						<span ng-switch on="modeNew">
							<input ng-switch-when="true"  type="password" name="password" ng-model="$parent.$parent.password"  ui-reset required/>
							<input ng-switch-default      type="password" name="password" ng-model="$parent.$parent.password"  ui-reset />
						</span>
						<span ng-show="myForm.password.$error.required" class="help-inline"> Required</span>
						<div>Passwords must be at least 8 characters and contain a number, letter and special character.</div>
					</div>
					<div class="control-group" ng-class="{error: passwordConfirmationInvalid()}">
						<label>Password Confirmation</label>
						<span ng-switch on="modeNew">
							<input ng-switch-when="true" type="password" name="passwordConfirmation" ng-model="$parent.$parent.passwordConfirmation"  ui-reset required/>
							<input ng-switch-default     type="password" name="passwordConfirmation" ng-model="$parent.$parent.passwordConfirmation"  ui-reset />
						</span>
						<span ng-show="myForm.passwordConfirmation.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<span ng-switch on="hasRoleSelected('Admin')">
				<div ng-switch-when="true" class="control-group" ng-class="{error: myForm.roles.$invalid}">
					<label>Roles</label>
					<div ng-repeat="role in roles">
						<input id="{{role}}"type="checkbox" ng-disabled="disableRoleEdit" ng-model="$parent.roleChoices[$index]"><label class="checkbox" for="{{role}}">{{role}}</label>
					</div>
				</div>  
			</span>
			<span ng-switch on="hasRoleSelected('Patient')">
				<div ng-switch-when="true">
					<h2>Consent</h2>
					<div class="control-group" ng-class="{error: myForm.agreedToInformationSheet.$invalid}">
						<label>Read and Understood Information Sheet</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToInformationSheet" ng-model="$parent.person.agreedToInformationSheet" required/> 
						<span ng-show="myForm.agreedToInformationSheet.$error.required" class="help-inline"> Required</span>
					</div>
					<div class="control-group" ng-class="{error: myForm.agreedToConsent.$invalid}">
						<label>Signed Consent Form</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToConsent" ng-model="$parent.person.agreedToConsent" required/>
						<span ng-show="myForm.agreedToConsent.$error.required" class="help-inline"> Required</span>
					</div>
					<div class="control-group" ng-class="{error: myForm.agreedToAssent.$invalid}">
						<label>Signed Assent Form</label>
						<input ui-date="{ dateFormat: 'dd-mm-yy' }" name="agreedToAssent" ng-model="$parent.person.agreedToAssent" required/>
						<span ng-show="myForm.agreedToAssent.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>
			<span ng-switch on="hasRole('Admin')">
				<div ng-switch-when="true">
					<h2>Site</h2>
					<div class="control-group" ng-class="{error: myForm.site.$invalid}">
						<div>Selected site: {{person.site.name}}</div>
						<select 
							ui-select2
							name="site"
							ng-model="$parent.person.site" 
							ng-options="g.name for g in sites"
							style="width:400px"
							required>
						</select>		
						<span ng-show="myForm.site.$error.required" class="help-inline"> Required</span>
					</div>
				</div>
			</span>

			<br>
			<!--			<select                                                                      
							selectcontacts
							data-placeholder="Select Contact"
							ng-model="modelObj"
							ng-options="contact.title for contact in contacts"
							class="selectcontacts"
							style="width:200px"
							>                                                                            
							<option></option>                                                          
						</select> -->
			<span ng-switch on="hasRoleSelected('Patient')">
				<div ng-switch-when="true">
					<h2>Care Team</h2>
					<div>
						<!--<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue" ui-reset>-->
						<!--<input type="text" ng-model="careTeamSearchItem" typeahead="suggestion for suggestion in cities($viewValue)" ui-reset>-->
						<!--ng-options="i.name.firstNames + ' ' +  i.name.lastName for i in careTeamPersons"-->
						<input 
							ui-select2="careTeamPersons"
							name="careTeamPersons"
							ng-model="$parent.careTeamSearchItem" 
							style="width:60%"
							/>
						<button ng-click="addToCareTeam()" class="btn btn-primary" ng-disabled="canAddToCareTeam()">Add to Care Team</button>

					</div>
					<table class="table-hover" ng-show="careTeam.length &gt; 0" style="width:85%">
						<col class="column-name">
						<col class="column-email">
						<col class="column-action">
						<thead>
							<tr>
								<th>Care Team Member</th>
								<th>Email</th>
								<th>Remove</th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="item in careTeam">
								<td>{{item.name}}</td>
								<td>{{item.email}}</td>
								<td class="action">
									<span ng-click="removeFromCareTeam($index)"> <i class="icon-trash"></i></span>
								</td>   
							</tr>
						</tbody>
					</table>
				</div>
			</span>
        </div>
    </div>
	<br/>
	<!--		isClean {{isClean()}}
			<br>
			invalid {{myForm.$invalid}} {{isValid()}}-->
	<a href="#/dashboard" class="btn">Cancel</a>
	<button ng-click="save()" ng-disabled="isClean() || myForm.$invalid || !isValid()" class="btn btn-primary">Save</button>
	<span ng-switch on="hasRole('Admin')">
		<div ng-switch-when="true">
			<button ng-click="destroy()" ng-show="person.uuid" class="btn btn-danger">Delete</button>
		</div>
	</span>
</form>

<!--
{'fraction_non_alphanumeric': 0.1837318468534546, 'fraction_numerical': 0.004107378612292797, 'mean_word_length': 2.971744829595106, 'pattern_counts': {'":': 0, '<': 347, '<?xml version=': 0, '>': 345, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1983410', 'n_tokens_mistral': 5590, 'n_tokens_neox': 4289, 'n_words': 775}