fix: set fee validity start date and set status as Completed or Pending
diff --git a/erpnext/healthcare/doctype/fee_validity/fee_validity.json b/erpnext/healthcare/doctype/fee_validity/fee_validity.json
index 8432169..e746b3c 100644
--- a/erpnext/healthcare/doctype/fee_validity/fee_validity.json
+++ b/erpnext/healthcare/doctype/fee_validity/fee_validity.json
@@ -75,7 +75,7 @@
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Status",
-   "options": "Ongoing\nCompleted\nExpired",
+   "options": "Completed\nPending",
    "read_only": 1
   },
   {
@@ -98,7 +98,7 @@
   }
  ],
  "links": [],
- "modified": "2020-03-14 21:42:40.766973",
+ "modified": "2020-03-17 18:29:01.163961",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Fee Validity",
diff --git a/erpnext/healthcare/doctype/fee_validity/fee_validity.py b/erpnext/healthcare/doctype/fee_validity/fee_validity.py
index fc15410..b56b889 100644
--- a/erpnext/healthcare/doctype/fee_validity/fee_validity.py
+++ b/erpnext/healthcare/doctype/fee_validity/fee_validity.py
@@ -11,17 +11,23 @@
 class FeeValidity(Document):
 	def validate(self):
 		self.update_status()
+		self.set_start_date()
 
 	def update_status(self):
 		valid_till = getdate(self.valid_till)
-		today  = getdate()
+		start_date = getdate(self.start_date)
 		if self.visited >= self.max_visits:
 			self.status = 'Completed'
-		elif self.visited < self.max_visits:
-			if valid_till >= today:
-				self.status = 'Ongoing'
-			elif valid_till < today:
-				self.status = 'Expired'
+		else:
+			self.status = 'Pending'
+
+	def set_start_date(self):
+		self.start_date = getdate()
+		for appointment in self.ref_appointments:
+			appointment_date = frappe.db.get_value('Patient Appointment', appointment.appointment, 'appointment_date')
+			if getdate(appointment_date) < self.start_date:
+				self.start_date = getdate(appointment_date)
+
 
 def create_fee_validity(appointment):
 	fee_validity = frappe.new_doc('Fee Validity')
@@ -36,8 +42,3 @@
 	})
 	fee_validity.save(ignore_permissions=True)
 	return fee_validity
-
-def update_validity_status():
-	docs = frappe.get_all('Fee Validity', filters={'status': ['not in', ['Completed', 'Expired']]})
-	for doc in docs:
-		frappe.get_doc("Task", doc.name).update_status()
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index 1cf90c6..361a8d6 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -95,7 +95,7 @@
 	free_follow_ups = frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups')
 	if automate_invoicing:
 		if free_follow_ups:
-			fee_validity = frappe.db.exists('Fee Validity', {'patient': patient, 'status': 'Ongoing'})
+			fee_validity = frappe.db.exists('Fee Validity', {'patient': patient, 'status': 'Pending'})
 			if fee_validity:
 				return {'fee_validity': fee_validity}
 		return True
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index d1b5b7c..1912270 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -42,6 +42,9 @@
 		frappe.throw(msg, title=_('Customer Not Found'))
 
 def get_fee_validity(patient_appointments):
+	if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'):
+		return
+
 	fee_validity_details = []
 	items_to_invoice = []
 	valid_days = frappe.db.get_single_value('Healthcare Settings', 'valid_days')
@@ -346,18 +349,21 @@
 
 
 def check_fee_validity(appointment):
+	if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'):
+		return
+
 	validity = frappe.db.exists('Fee Validity', {
 		'practitioner': appointment.practitioner,
 		'patient': appointment.patient,
-		'status': 'Ongoing'
+		'status': 'Pending',
+		'valid_till': ('>=', appointment.appointment_date)
 	})
 	if not validity:
 		return
 
-	fee_validity = frappe.get_doc('Fee Validity', validity)
-	appointment_date = getdate(appointment.appointment_date)
-	if fee_validity.valid_till >= appointment_date and fee_validity.visited < fee_validity.max_visits:
-		return fee_validity
+	validity = frappe.get_doc('Fee Validity', validity)
+	return validity
+
 
 def manage_fee_validity(appointment):
 	fee_validity = check_fee_validity(appointment)
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 7a938b6..4e22ed5 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -310,8 +310,7 @@
 		"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
 		"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
 		"erpnext.selling.doctype.quotation.quotation.set_expired_status",
-		"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status",
-		"erpnext.healthcare.doctype.fee_validity.fee_validity.update_validity_status"
+		"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status"
 	],
 	"daily_long": [
 		"erpnext.setup.doctype.email_digest.email_digest.send",