Clara Form
Patient intake form: a template with validation, drafts and FHIR export
A patient intake form built with Clara Form: contact details, reason for visit, history and consent, with required fields, drafts and FHIR output.
Loading the preview…
<script src="https://cdn.clara.care/form/latest.js"></script>
<main class="demo">
<!-- autosave-interval: a clara-autosave event every 8 s when something changed.
secondary-action: an extra button that saves without validating. -->
<clara-form
lang="en"
submit-label="Submit intake"
secondary-action="Save draft"
autosave-interval="8000"
></clara-form>
<section class="demo-out" aria-labelledby="output-h">
<div class="demo-actions">
<h2 id="output-h">Output</h2>
<span id="draft-status" class="demo-status" role="status"></span>
</div>
<pre id="output" aria-live="polite">Submit the form to see the JSON and FHIR output here.</pre>
</section>
</main>
// Patient intake template. Field ids are the keys of your JSON and the linkIds of the FHIR export.
const template = {
id: 'patient-intake-demo',
name: 'Patient intake',
sections: [
{
key: 'contact',
label: 'Contact details',
fields: [
{ id: 'full_name', type: 'text', label: 'Full name', required: true },
{ id: 'date_of_birth', type: 'text', label: 'Date of birth', placeholder: 'YYYY-MM-DD', pattern: '\\d{4}-\\d{2}-\\d{2}', required: true },
{ id: 'phone', type: 'text', label: 'Phone', placeholder: '+1 555 010 0199' },
{ id: 'email', type: 'text', label: 'Email', pattern: '[^@\\s]+@[^@\\s]+\\.[^@\\s]+', validationMessage: 'Enter a valid email address' },
],
},
{
key: 'visit',
label: 'Reason for visit',
fields: [
{ id: 'reason', type: 'text', label: 'What brings you in today?', required: true },
{ id: 'duration', type: 'select', label: 'Since when?', options: ['Today', 'A few days', 'More than a week', 'More than a month'] },
{ id: 'symptoms', type: 'textarea', label: 'Describe your symptoms' },
],
},
{
key: 'history',
label: 'Medical history',
fields: [
{ id: 'allergies', type: 'text', label: 'Allergies', helpText: 'Medications, foods or materials. Write "none" if you have no known allergies.' },
{ id: 'medications', type: 'textarea', label: 'Current medications' },
{ id: 'conditions', type: 'textarea', label: 'Conditions or previous surgeries' },
{ id: 'smoker', type: 'checkbox', label: 'I smoke or have smoked in the last year' },
],
},
{
key: 'consent',
label: 'Confirmation',
fields: [
{ id: 'accurate', type: 'checkbox', label: 'The information above is accurate to the best of my knowledge', required: true },
],
},
],
};
const form = document.querySelector('clara-form');
form.template = template;
const output = document.querySelector('#output');
const status = document.querySelector('#draft-status');
const show = (value) => { output.textContent = JSON.stringify(value, null, 2); };
// Valid submission: values, labeled JSON and a FHIR R4 QuestionnaireResponse (status: completed).
form.addEventListener('clara-submit', (e) => {
show({ values: e.detail.values, fhir: e.detail.fhir });
});
// Required fields empty, pattern mismatches: the form shows the errors and focuses the first one.
form.addEventListener('clara-invalid', (e) => {
console.log('Fields with errors:', Object.keys(e.detail.errors));
});
// Drafts: the secondary button saves without validating; autosave fires only when something changed.
form.addEventListener('clara-secondary-action', (e) => {
show({ draft: e.detail.values });
status.textContent = 'Draft saved at ' + new Date().toLocaleTimeString();
});
form.addEventListener('clara-autosave', (e) => {
status.textContent = 'Autosaved at ' + new Date().toLocaleTimeString() + ' (' + Object.keys(e.detail.values).length + ' fields)';
});
Every value on this page is synthetic. Never paste real patient data into a public page.
How it works
Write the intake template
Sections for contact, visit, history and consent. required marks mandatory fields; a select offers the duration options; a checkbox collects the confirmation.
Turn on drafts
autosave-interval emits clara-autosave every N milliseconds, only when something changed. secondary-action adds a Save draft button that does not validate.
Validate on submit
clara-submit fires only when the form is valid; otherwise clara-invalid lists the fields with errors and focus moves to the first one.
Store or send
The submit detail carries values, labeled JSON and FHIR. With the submit-url attribute the form posts them to your server without extra code.
A patient intake form collects what the clinic needs before the visit: contact details, the reason for coming, allergies, medication and history, and the patient's confirmation. This example renders a complete intake template with Clara Form, validates required fields, saves drafts every few seconds and returns the submission as JSON and as a FHIR QuestionnaireResponse.
Use it as the front door of your patient intake software: on a tablet in the waiting room, in a patient portal, or inside your EHR. Later, during the consultation, Clara Widget can keep filling the same fields by voice.
Why intake works better as a template
Clinics change their intake questions often. When the form is a JSON template, the clinic edits it in Clara Platform and your software renders the new version without a release. Field ids stay stable, so your database and your FHIR mapping do not change.
The form is accessible out of the box: every input has a label, errors are announced, and the odontogram and other complex fields work with a keyboard.
Privacy
Intake answers are health information. The package never logs them and sends them only to your callbacks or to the submit URL you configure. This public page keeps the values in your browser; the autosave handler here only prints a timestamp.
Questions about this example
Can patients fill the intake form from home?
Yes. Publish the page in your patient portal and post the submission to your server with submit-url, or handle clara-submit yourself. Register that origin as a widget site in Clara Platform if the template loads by id.
How do drafts work?
autosave-interval emits clara-autosave with the current values every interval, only when something changed since the last draft. Save them where you like: your API, or the browser's storage in your own code.
What happens if a required field is empty?
The submit button runs validation. Empty required fields, pattern mismatches and out-of-range numbers show an inline message, clara-invalid fires with the list, and focus moves to the first field with an error.
Can I send the intake to my EHR as FHIR?
Yes. The submit detail includes a FHIR R4 QuestionnaireResponse with status completed, one group per section and typed answers. With submit-format set to fhir the form posts the resource itself.
Is the intake form available in Spanish?
Yes. The lang attribute switches the form's own texts between English and Spanish; your template labels are whatever you write in them.
Planning an integration?
Tell us about your system and your forms. We run small pilots with technology partners.


