Try ERPNext Buy Support Partners Foundation Foundation Members

How to bring patient field to html page created as a Page doctype?

I’ve created a Page doctype and attached htmls page, css and all inside healthcare module. Now it is working fine.

  1. Now i need to bring the patient field into this html page
  2. When i select the patient, rest information should popup in respective html fields

i need an advice on this. Can anyone help me on this ??
Any kind of help much appreciated.

call below function from page constructor:

	const me = this;{
		fieldtype: 'Link',
		label: __('Patient'),
		fieldname: 'patient',
		options: "Patient",
		reqd: 1,
		onchange: function() {
			// functionality

Thanks for reply. As i am new to the code structure and framework of frappe, can you please explain little bit more ?
Should i add this code in custom_page.js file ?? if it so i tried but no luck…

Please share your code of custom_page.js.


frappe.pages['custom-page'].on_page_load = function(wrapper) {
        var page = frappe.ui.make_app_page({
            parent: wrapper,
            title: 'Custom Page',
            single_column: true
        $(frappe.render_template("custompage", page)).prependTo(page.main);

Refer : erpnext/healthcare/page/patient_history.js

frappe.pages['patient_history'].on_page_load = function(wrapper) {
	var me = this;
	var page = frappe.ui.make_app_page({
		parent: wrapper,
		title: 'Patient History',
		single_column: true

	let pid = '';
	page.main.html(frappe.render_template("patient_history", {}));
	var patient = frappe.ui.form.make_control({
		parent: page.main.find(".patient"),
		df: {
			fieldtype: "Link",
			options: "Patient",
			fieldname: "patient",
			change: function(){
				if(pid != patient.get_value() && patient.get_value()){
					me.start = 0;".patient_documents_list").html("");
					get_documents(patient.get_value(), me);
					show_patient_info(patient.get_value(), me);
					show_patient_vital_charts(patient.get_value(), me, "bp", "mmHg", "Blood Pressure");
				pid = patient.get_value();
		only_input: true,

	if (frappe.route_options){
	}"click", ".btn-show-chart", function() {
		var	btn_show_id = $(this).attr("data-show-chart-id"), pts = $(this).attr("data-pts");
		var title = $(this).attr("data-title");
		show_patient_vital_charts(patient.get_value(), me, btn_show_id, pts, title);
	});"click", ".btn-more", function() {
		var	doctype = $(this).attr("data-doctype"), docname = $(this).attr("data-docname");
		if("."+docname).parent().find('.document-html').attr('data-fetched') == "1"){"."+docname).hide();"."+docname).parent().find('.document-html').show();
			if(doctype && docname){
				let exclude = ["patient", "patient_name", 'patient_sex', "encounter_date"];{
					method: "",
						doctype: doctype,
						docname: docname,
						exclude_fields: exclude
					callback: function(r) {
						if (r.message){"."+docname).hide();"."+docname).parent().find('.document-html').html(r.message.html+"\
							<div align='center'><a class='btn octicon octicon-chevron-up btn-default btn-xs\
							btn-less' data-doctype='"+doctype+"' data-docname='"+docname+"'></a></div>");"."+docname).parent().find('.document-html').show();"."+docname).parent().find('.document-html').attr('data-fetched', "1");
					freeze: true
	});"click", ".btn-less", function() {
		var docname = $(this).attr("data-docname");"."+docname).parent().find('.document-id').show();"."+docname).parent().find('.document-html').hide();
	me.start = 0;"click", ".btn-get-records", function(){
		get_documents(patient.get_value(), me);

@sanjay finally i got it. Thanks for guiding me to the correct route