Autoform search function


#1

Good Day,

Can anyone give me some advice in terms of how to implement the autoform search function?

I currently have a schema that has been defined as follows:

Patients = new Mongo.Collection('patients');

Patients.allow({
	insert: function(userId, doc) {
		return !!userId;
	},
	update: function(userId, doc) {
		return !!userId;
	}
});

Encounter = new SimpleSchema({
	date: {
		type: Date
	},
	complaint: {
		type: String
	}
});


PatientSchema = new SimpleSchema({
	FirstLastName: {
		type: String,
		label: "First & Last Name "
	},
	IdentityNumber: {
		type: String,
		label: "Identity Number"
	},
	encounter: {
		type: [Encounter]
	},
	inMenu: {
		type: Boolean,
		defaultValue: false,
		optional: true,
		autoform: {
			type: "hidden"
		}
	},
	author: {
		type: String,
		label: "Author",
		autoValue: function() {
			return this.userId
		},
		autoform: {
			type: "hidden"
		}
	},
	createdAt: {
		type: Date,
		label: "Created At",
		autoValue: function() {
			return new Date()
		},
		autoform: {
			type: "hidden"
		}
	}
});

Meteor.methods({
	toggleMenuItem: function(id, currentState) {
		Patients.update(id, {
			$set: {
				inMenu: !currentState
			}
		});
	},
	deletePatient: function(id) {
		Patients.remove(id);
	}
});

Patients.attachSchema( PatientSchema );

Furthermore, I have implemented the following template:

<template name="SearchPatient">
	{{#autoForm id="searchPatientId" schema=Patients}}
  {{> afFormGroup name="IdentityNumber" type="search" }}
  <div class="form-group">
    <button type="submit" class="btn btn-primary">Submit</button>
  </div>
{{/autoForm}}
</template>

I ideally want a scenario where I can enter the FirstLastName or IdentityNumber and the search should return the patient with the associated details.

When it returns the details it should do so in a grid.

Any assistance would be highly appreciated.

Many thanks J.