<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src='googleSheetsPortal.js'></script>
<script src='guiForm.js'></script>
<script src='gui.js'></script>
</head>
<body>
<div id='uI'>
</div>
<div id='status' style= 'margin: auto; width:300px;text-align:center;' ></div>
</body>
<script>
var googleSheetsPortalScript='https://script.google.com/macros/s/AKfycbzb8hgt89mbgNpDRxZ6Cp3W-10AnAP1mnIJu_WS0wRjoJjJa9c/exec';
makeField('Identification number');
makeField('First name');
makeField('Last name');
makeDateField('Date of birth');
makeField('Age');
makeField('Sex');
makeField('Phone number');
makeField('Email address');
displayUi('uI',getFormUiAsString());
function send(){
if(isCharactersValid('Identification number', 'numeric')==true&&isCharactersValid('First name', 'alpha')==true&&isCharactersValid('Last name', 'alpha')==true&&isCharactersValid('monthField','numeric')==true&&isCharactersValid('dayField','numeric')==true&&isCharactersValid('yearField','numeric')==true&&isCharactersValid('Phone number', 'numeric')==true&&isCharactersValid('Age', 'numeric')==true&&isCharactersValid('Sex', 'alpha')==true&&isCharactersValid('Email address','')==true){
displayUi('status','');
setEnabled('submitButtonGuiForm',false);
sendDataToGoogleSheets(['patientIsRegistering',getFieldText('Identification number'),getFieldText('First name'),getFieldText('Last name'),getFieldText('monthField')+'-'+getFieldText('dayField')+'-'+getFieldText('yearField'),getFieldText('Age'),getFieldText('Sex'),getFieldText('Phone number'),getFieldText('Email address')],googleSheetsPortalScript);
}else{
isCharactersValid('Identification number', 'numeric');
isCharactersValid('First name', 'alpha');
isCharactersValid('Last name', 'alpha');
isCharactersValid('monthField','numeric');
isCharactersValid('dayField','numeric');
isCharactersValid('yearField','numeric');
isCharactersValid('Phone number', 'numeric');
isCharactersValid('Age', 'numeric');
isCharactersValid('Sex', 'alpha');
isCharactersValid('Email address','');
displayUi('status','Invalid characters');
}
}
function receiveDataFromGoogleSheets(){
if(getDataFromGoogleSheets()=='registrationSuccessful'){
displayUi('uI', "<div style= 'margin: auto; width:300px;' ><h3>Thank You</h3><h4 >Please proceed to the testing area.</h4></div>");}
}
</script>
</html>