;;SPECIFICATION:——-TO MANAGE THE DOCTOR DETAILS OF DEPARTMENT OF HEALTH.—————-
;;PURPOSE: Health department is fully automated where we have 4 health care centres.
;;ONLY ADMINISTRATOR can add,delete,modify and display the details of the doctor
;;ASSUMPTIONS:
;; 1.Database of all centres is centralised.
;;LIMITATION
;; 1.No login is present in the system.
;; 2.Only administrator can access the system
;; 3.A maximum of 1000 records can be added as we have defined the length of the Vector as 1000
;;=========================================================================================================
;;defining the vector.
(define hcc(make-vector 1000)) ;;main vector of the HCC which stores doctor details and location id
(define doc_start_id 1000) ;;for the first Doctor ID and incremented by 1 as a new doctor is added
(define index 0) ;; initial index for hcc_vector(not using vector length function as index is incremented
;;each time a new doctor is added)
(define hcc_temp_id 0)
;;==============================================================================================
;;=============================CLASS FOR THE DOCTOR=============================================
;;==============================================================================================
;;PURPOSE:DOCTOR IS A CLASS WHICH STORES DOCTOR DETAILS(DOCTORID,DOCTORNAME,DOCTORPHONENUMBER,HCCID)
;; AND PERFORMS OPERATIONS ON THEM.
(define (doctor)
;; Data members
(define doctor_id 0)
(define doctor_name “”)
(define doctor_phno 0)
(define doctor_hccid 0)
;; Member Functions
;;=========FUNCTION TO GET THE DOCTOR NAME FROM THE USER==============
;;CONTRACT: (setdocname) void=>void.
;;PURPOSE: It’s used to read the doctor name from console and to validate it for being text.
;;TESTCASE:(setdocname)(“Mary”)=>will set doctor name as Mary
;;(16234)=>The Name has to be a String inside Double Quotes.Please Enter the Name again.
(define (setdocname)
(display “\n Enter the Doctor Name inside double quotes.”)
(set! doctor_name(read))
(if (not (string? doctor_name))
(begin
(display “\n The Name has to be a String inside Double Quotes.”)
(display “\n Please Enter the Name again.”)
(setdocname)
)
(begin
(if (string->number doctor_name)
(begin
(display “\n Please Do not Enter numbers inside double quotes.”)
(display “\n Please Enter the Name Again.”)
(setdocname)
)
(begin
(set! doctor_name doctor_name)
)
)
)
)
)
;;============FUNCTION TO GET THE DOCTOR PHONE NUMBER FROM THE USER=============
;;CONTRACT: (setdocphno) void=>void.
;;PURPOSE: It’s used to read the doctor phone number from console and to validate it for being a number.
;;TESTCASE:(setdocphno)(9900990099)=>will set doctor phone number as 9900990099
;;(gasdgs)=>The Phone Number has to be a Number.Please Enter the Phone Number again.
(define (setdocphno)
(display “\n Enter the Phone Number of the Doctor.”)
(set! doctor_phno(read))
(if (not (number? doctor_phno))
(begin
(display “\n The Phone Number has to be a Number.”)
(display “\n Please Enter the Phone Number again.”)
(setdocphno)
)
(begin
(set! doctor_phno doctor_phno)
)
)
)
;;===========FUNCTION TO GET THE DOCTOR HCC ID FROM THE USER==================
;;CONTRACT: (setdochccid) void=>void.
;;PURPOSE: It’s used to read the doctor hcc id from console and to validate it for bring a number between 1 and 4.
;;TESTCASE:(setdochccid)(1)=>will set doctor hcc id as 1
;;(gasdgs)=>The HCC ID has to be a Number.Please Enter the HCC ID again.
;;(6)=>The HCC ID has to be between 1 and 4.Please Enter the HCC ID again.
(define (setdochccid)
(display “\n Enter the HCC ID of the Doctor.”)
(display “\n 1:Delhi 2:Mumbai 3:Hyderabad 4:Bengaluru”)
(set! doctor_hccid(read))
(if (not (number? doctor_hccid))
(begin
(display “\n The HCC ID has to be a Number.”)
(display “\n Please Enter the HCC ID again.”)
(setdochccid)
)
)
(if (and (>= doctor_hccid 1) (<= doctor_hccid 4))
(begin
(set! doctor_hccid doctor_hccid)
)
(begin
(display “\n The HCC ID has to be between 1 and 4.”)
(display “\n Please Enter the HCC ID again.”)
(setdochccid)
)
)
)
;;============FUNCTION TO DISPLAY THE DOCTOR ID OF THE DOCTOR============
;;CONTRACT:(getdocid) void=>void.
;;PURPOSE:It display the doctor ID.
;;TESTCASE:(getdocid)=>1000.
(define (getdocid)
(display doctor_id)
)
;;============FUNCTION TO DISPLAY THE NAME OF THE DOCTOR=================
;;CONTRACT:(getdocname) void=>void.
;;PURPOSE:It display the doctor Name.
;;TESTCASE:(getdocname)=>Mary.
(define (getdocname)
(display doctor_name)
)
;;============FUNCTION TO DISPLAY THE PHONE NUMBER OF THE DOCTOR============
;;CONTRACT:(getdocphno) void=>void.
;;PURPOSE:It display the doctor phno.
;;TESTCASE:(getdocphno)=>9900990099.
(define (getdocphno)
(display doctor_phno)
)
;;==============FUNCTION TO DISPLAY THE HCC ID OF THE DOCTOR=================
;;CONTRACT:(getdochccid) void=>void.
;;PURPOSE:It display the doctor’s location id.
;;TESTCASE:(getdochccid)=>1.
(define (getdochccid)
(display doctor_hccid)
)
;;==============FUNCTION TO GET THE DOCTOR ID OF THE DOCTOR====================
;;CONTRACT:(get_doc_id) void=>number.
;;PURPOSE:It returns the Doctor ID.
;;TESTCASE:(get_doc_id)=>1000.
(define (get_doc_id)
doctor_id
)
;;===============FUNCTION TO GET THE LOCATION ID OF THE DOCTOR=================
;;CONTRACT:(get_hcc_id) void=>number.
;;PURPOSE:It returns the Doctor Location ID.
;;TESTCASE:(get_hcc_id)=>1
(define (get_hcc_id)
doctor_hccid
)
;;========FUNCTION TO ADD A NEW DOCTOR===================
;;DATA METHOD TO ADD A NEW DOCTOR.
;;CONTRACT: void===>void.
;;PURPOSE:Procedure to add a doctor where doctor details are read from the console.
;;TESTCASES:
;; (Mary 9900990099 1)=>Doctor Added.The Doctor ID is:1000
(define (add_doctor)
(set! doctor_id doc_start_id)
(setdocname)
(setdocphno)
(setdochccid)
(vector-set! hcc index doc_temp)
(set! doc_temp(doctor))
(display “\n Doctor Added.The Doctor ID is:”)
(display doctor_id)
(set! index ( + index 1))
(set! doc_start_id ( + doc_start_id 1))
(main_menu)
)
;;=================FUNCTION TO DISPLAY A DOCTOR/ALL DOCTORS=====================
;;FUCNTION TO DISPLAY A PARTICULAR DOCTOR BASED ON EMPLOYEE ID / LIST OF ALL DOCTORS
;;CONTRACT: (display_doctor) void=>void.
;;Display procedure for displaying all the doctor’s details or the details of the particular doctor.
;;TESTCASE:
;;(1001)==>(1001 mary 9900990099 1 DELHI) – displays details doctor with doctor id as 1001
;;(1)==>display list of all the doctors.
;;(1005) ==> Display’s Doctor does’nt exist if the doctor id is not there.
(define (display_doctor)
(define choice 0)
(define flag 0)
(display “\n To Display list of all the Doctors Enter 1.”)
(display “\n Enter a Doctor ID for a particular doctor.”)
(display “\n **Note – The Doctor ID Starts from 1000**”)
(set! choice(read))
(if (number? choice)
(begin
(if (= choice 1)
(begin
(let loop((i 0))
(define doc_temp(doctor))
(define hcc_temp(hcclocation))
(if (< i index)
(begin
(set! doc_temp (vector-ref hcc i))
(if (not (= (doc_temp ‘get_doc_id) -1))
(begin
(set! flag 1)
(display “\n =====DOCTOR DETAILS=======”)
(display “\n Doctor ID:”)
(doc_temp ‘getdocid)
(display “\n Doctor Name:”)
(doc_temp ‘getdocname)
(display “\n Doctor Phone Number:”)
(doc_temp ‘getdocphno)
(display “\n Doctor HCC ID:”)
(doc_temp ‘getdochccid)
(set! hcc_temp_id (doc_temp ‘gethccid))
(hcc_temp ’set_hcc_id)
(display “\n HCC Name:”)
(hcc_temp ‘disp_hcc_name)
(display “\n ===========================”)
)
)
(loop(+ i 1))
)
)
)
)
)
(if (>= choice 1000)
(begin
(let loop((i 0))
(define doc_temp(doctor))
(define hcc_temp(hcclocation))
(if (< i index)
(begin
(set! doc_temp (vector-ref hcc i))
(if (= (doc_temp ‘get_doc_id) choice)
(begin
(set! flag 1)
(set! doc_temp (vector-ref hcc i))
(display “\n =====DOCTOR DETAILS=======”)
(display “\n Doctor ID:”)
(doc_temp ‘getdocid)
(display “\n Doctor Name:”)
(doc_temp ‘getdocname)
(display “\n Doctor Phone Number:”)
(doc_temp ‘getdocphno)
(display “\n Doctor HCC ID:”)
(doc_temp ‘getdochccid)
(set! hcc_temp_id (doc_temp ‘gethccid))
(hcc_temp ’set_hcc_id)
(display “\n HCC Name:”)
(hcc_temp ‘disp_hcc_name)
(display “\n ===========================”)
)
)
(loop (+ i 1))
)
)
)
)
)
(if (= flag 0)
(begin
(display “\n ======================”)
(display “\n Doctor Does’nt Exist”)
(display “\n ======================”)
)
)
(main_menu)
)
(begin
(newline)
(display “\n ================================================”)
(display “\n The Choice has to be a Number.Please Enter Again”)
(display “\n ================================================”)
(display_doctor)
)
)
)
;;======================FUNCTION TO SET DOCTOR DETAILS AS EMPTY==============
;;PURPOSE:IT’S USED TO SET THE VALUES.USED BY THE delete_doctor function
;;CONTRACT:(empty_doctor)void=>void.
;;TESTCASE:(empty_doctor)(-1 “” 0 0).
(define (empty_doctor)
(set! doctor_id -1)
(set! doctor_name “”)
(set! doctor_phno 0)
(set! doctor_hccid 0)
)
;;=======================FUNCTION TO DELETE A DOCTOR=====================
;;CONTRACT:(delete_doctor) void=>void.
;;PURPOSE:Procedure to delete doctor’s record.
;;TESTCASE:
;;IN DELETE PROCEDURE (1000)=>Doctor is Deleted.
;;If ID is not there then it display Doctor not found.
(define (delete_doctor)
(define choice 0) ;choice is used as local variable for reading the doctor id
(define flag 0)
(define d -1)
(begin
(display “\n Enter the Doctor ID which is to be Deleted”)
(set! choice(read))
(if (number? choice)
(begin
(let loop (( i 0))
(define doc_temp(doctor))
(if (< i index)
(begin
(set! doc_temp (vector-ref hcc i))
(if (= (doc_temp ‘get_doc_id) choice)
(begin
(set! flag 1)
(doc_temp ‘emptydoctor)
(vector-set! hcc i doc_temp)
(display “\n Doctor Deleted”)
)
)
(loop (+ i 1))
)
)
)
)
(begin
(newline)
(display “\n ============================================================”)
(display “\n The Doctor ID has to be Number Please Enter Doctor ID again.”)
(display “\n =============================================================”)
(delete_doctor)
)
)
(if (= flag 0)
(begin
(display “\n ======================”)
(display “\n Doctor Does’nt Exist”)
(display “\n ======================”)
)
)
(main_menu)
)
)
;;=======================FUNCTION TO DISPLAY THE LIST OF ALL DOCTORS IN A PARTICULAR LOCATION==============
;;FUNCTION TO DISPLAY THE LIST OF ALL DOCTORS IN A PARTICULAR LOCATION
;;CONTRACT:(display_location) void=>void.
;;PURPOSE:Display procedure for list of doctors at a particular location.
;;TESTCASE: (1)==>List of all doctors for location 1.
;; if hccid <1 and hccid >4 then location not found.
;;if the input is greater then 4 or less than 1 ==>Location Not found.
(define (display_location)
(define choice 0) ;choice is a local variable where we will read the location id
(define n 0)
(define flag 0)
(begin
(display “\n 1:Delhi 2:Mumbai 3:Hyderabad 4:Bengaluru”)
(display “\n Enter the Location Number : “)
(set! choice(read))
(if (number? choice)
(begin
(if (and (>= choice 1) (<= choice 4))
(begin
(let loop((i 0))
(define doc_temp(doctor))
(define hcc_temp(hcclocation))
(if (< i index)
(begin
(set! doc_temp (vector-ref hcc i))
(if (= (doc_temp ‘gethccid) choice)
(begin
(set! flag 1)
(display “\n =====DOCTOR DETAILS=======”)
(display “\n Doctor ID:”)
(doc_temp ‘getdocid)
(display “\n Doctor Name:”)
(doc_temp ‘getdocname)
(display “\n Doctor Phone Number:”)
(doc_temp ‘getdocphno)
(display “\n Doctor HCC ID:”)
(doc_temp ‘getdochccid)
(set! hcc_temp_id (doc_temp ‘gethccid))
(hcc_temp ’set_hcc_id)
(display “\n HCC Name:”)
(hcc_temp ‘disp_hcc_name)
(display “\n ===========================”)
)
)
(loop (+ i 1))
)
)
)
)
(begin
(display “\n ======================”)
(display “\n Location Does’nt Exist”)
(display “\n ======================”)
(main_menu)
)
)
)
(begin
(display “\n ==================================================”)
(display “\n The Location has to be a Number.Please Enter Again”)
(display “\n ===================================================”)
(display_location)
)
)
(if ( = flag 0)
(begin
(display “\n ========================”)
(display “\n No Doctors in Location.”)
(display “\n =========================”)
)
)
)
(main_menu)
)
;;======================FUNCTION TO MODIFY DOCTOR DETAILS============
;;CONTRACT:(modify_doctor) void=>void.
;;PURPOSE:Procedure to modify all the fields or any individual field of doctor details.
;;TESTCASE:(modify_doctor) 1000 If ID Present then =>displays old values => Asks what has to be modified(name,phone number
;;hccid)and modifes it.Modifying one field is also allowed.
;;If ID not present =>Doctor Does’nt Exist.
(define (modify_doctor)
(define choice 0) ;;to get id of doctor
(define flag 0) ;;for doctor id found / not
(define modify_choice 0)
(begin
(display “\n Enter the ID of the Doctor who is to be Updated.”)
(set! choice(read))
(if (number? choice)
(begin
(let loop((i 0))
(define doc_temp(doctor))
(define hcc_temp(hcclocation))
(if (< i index)
(begin
(set! doc_temp (vector-ref hcc i))
(if (= (doc_temp ‘get_doc_id) choice)
(begin
(set! flag 1)
(display “\n =====OLD DOCTOR DETAILS=======”)
(display “\n Doctor ID:”)
(doc_temp ‘getdocid)
(display “\n Doctor Name:”)
(doc_temp ‘getdocname)
(display “\n Doctor Phone Number:”)
(doc_temp ‘getdocphno)
(display “\n Doctor HCC ID:”)
(doc_temp ‘getdochccid)
(set! hcc_temp_id (doc_temp ‘gethccid))
(hcc_temp ’set_hcc_id)
(display “\n HCC Name:”)
(hcc_temp ‘disp_hcc_name)
(display “\n ===========================”)
(display “\n 1.Modify Doctor Name”)
(display “\n 2.Modify Doctor Phone Number”)
(display “\n 3.Modify Doctor Location(HCCID)”)
(display “\n 4.Modify All Details”)
(display “\n Please Enter your Choice”)
(set! modify_choice(read))
(if (number? modify_choice)
(begin
(case modify_choice
((1) (doc_temp ’setdocname)
(display “\n ======================”)
(display “\n Doctor Name Modified.”)
(display “\n ======================”))
((2) (doc_temp ’setdocphno)
(display “\n ==============================”)
(display “\n Doctor Phone Number Modified.”)
(display “\n ==============================”))
((3) (doc_temp ’setdochccid)
(display “\n =========================”)
(display “\n Doctor HCC ID Modified.”)
(display “\n =========================”))
((4) (doc_temp ’setdocname)
(doc_temp ’setdocphno)
(doc_temp ’setdochccid)
(display “\n =========================”)
(display “\n Doctor Details Modified.”)
(display “\n =========================”))
(else ((display “\n Wrong Choice.”)
(modify_doctor)))
)
)
(begin
(display “\n================================”)
(display “\n The Choice has to be a Number.”)
(display “\n=================================”)
(modify_doctor)
)
)
(vector-set! hcc index doc_temp)
)
)
(loop(+ i 1))
)
)
)
)
(begin
(display “\n ==================================”)
(display “\n The Doctor ID has to be a Number.”)
(display “\n Please Enter the Doctor ID Again.”)
(display “\n ==================================”)
(modify_doctor)
)
)
(if ( = flag 0)
(display “\n Doctor Does’nt Exist.”)
)
(main_menu)
)
)
;;=======================FUNCTION TO EXIT============================
;;CONTRACT:(exitmain) void=>void.
;;PURPOSE:(exitmain) is used to exit.
(define (exitmain)
(begin
(display “\n Exiting ………..Exited”)
)
)
;;===================LAMBDA – THE INTERFACING FUNCTION==================
;;PURPOSE: Its a function for interacting with the methods of the class.
(lambda (msg)
(cond
((eqv? msg ‘add_doctor)(add_doctor))
((eqv? msg ‘display_doctor)(display_doctor))
((eqv? msg ‘getdocid)(getdocid))
((eqv? msg ‘getdocname)(getdocname))
((eqv? msg ‘getdocphno)(getdocphno))
((eqv? msg ‘getdochccid)(getdochccid))
((eqv? msg ‘get_doc_id)(get_doc_id))
((eqv? msg ‘delete_doctor)(delete_doctor))
((eqv? msg ‘exit)(exitmain))
((eqv? msg ‘emptydoctor)(empty_doctor))
((eqv? msg ‘gethccid)(get_hcc_id))
((eqv? msg ‘display_location)(display_location))
((eqv? msg ‘modify_doctor)(modify_doctor))
((eqv? msg ’setdocname)(setdocname))
((eqv? msg ’setdocphno)(setdocphno))
((eqv? msg ’setdochccid)(setdochccid))
(else (error msg “\n Not a Supported Function”))
)
)
) ;;================END OF CLASS DEFINITION FOR DOCTOR==========================
;;==============================================================================
;;==============================================================================
;;******************************************************************************
;;******************************************************************************
;;==============================================================================
;;========================CLASS FOR LOCATION====================================
;;==============================================================================
;;purpose:hcclocation is another class for healthcare centre names.
(define (hcclocation)
;;data members
(define hcc_id 0)
(define hcc_name “”)
;;member functions
;;========FUNCTION TO RETRIVE HCC ID======================
;;CONTRACT:(get_hcc_id) void=>number.
;;PURPOSE: To retrieve the hccid for objects of the class.
;;TESTCASE:(get_hcc_id)=>1.
(define (get_hcc_id) hcc_id)
;;===============FUNCTION TO RETRIVE HCC NAME========================
;;CONTRACT:(get_hcc_id) void=>string.
;;PURPOSE: To retrieve the hccname for objects of the class.
;;TESTCASE:(get_hcc_id)=>Delhi.
(define (get_hcc_name) hcc_name)
;;==============FUNCTION TO SET HCC ID==========================
;;CONTRACT:(set_hcc_id) number=>void.
;;PURPOSE: To set the hcc_id.
(define (set_hcc_id z)
(set! hcc_id z)
)
;;================FUNCTION TO DISPLAY THE NAME OF THE LOCATION===================
;;CONTRACT: (disp_hcc_name) void => void.
;;PURPOSE:To display the names of the health care centre location.
(define (disp_hcc_name)
(cond
((eqv? hcc_id 1)(display “Delhi”))
((eqv? hcc_id 2)(display “Mumbai”))
((eqv? hcc_id 3)(display “Hyderabad”))
((eqv? hcc_id 4)(display “Bengaluru”))
)
)
;;==========INTERFACING FUNCTION – LAMBDA==============
;;PURPOSE: Its a function for interacting with the methods of the hcclocation class.
(lambda (msg)
(cond
((eqv? msg ’set_hcc_id)(set_hcc_id hcc_temp_id))
((eqv? msg ‘disp_hcc_name)(disp_hcc_name))
)
)
) ;;==================END OF LOCATION CLASS======================================
;;===============================================================================
;;===============================================================================
;;Object of the Doctor Class.
(define doc_temp(doctor))
;;CONTRACT:It reads from choice from the console.
;;PURPOSE:Main menu procedure to get the menu for choosing options.
(define (main_menu)
(define choice 0) ;choice is a local declaration for reading the number to select the procedure.
(begin
(display “\n =============================================================”)
(display “\n ===========Welcome to Doctor Management System===============”)
(display “\n =============================================================”)
(display “\n 1.Add a Doctor”)
(display “\n 2.Delete a Doctor”)
(display “\n 3.Modify a Doctor”)
(display “\n 4.Display a Doctor / All Dcotors”)
(display “\n 5.Display List of Doctors in a Location “)
(display “\n 6.Exit”)
(display “\n Enter your CHOICE”)
(set! choice(read))
(cond
((eqv? choice 1) (doc_temp ‘add_doctor))
((eqv? choice 2) (doc_temp ‘delete_doctor))
((eqv? choice 3) (doc_temp ‘modify_doctor))
((eqv? choice 4) (doc_temp ‘display_doctor))
((eqv? choice 5) (doc_temp ‘display_location))
((eqv? choice 6) (doc_temp ‘exit))
(else (main_menu))
)
)
)
(main_menu)
;;==============================================================================================
;;====================================END OF PROGRAM============================================
;;==============================================================================================