documentation

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 42

1.

INTRODUCTION

In today's fast-paced world, the efficient management of


medicine stocks is crucial for ensuring timely access to essential
medications.

The advent of digital technology has revolutionized various


sectors, including healthcare, by providing innovative solutions to
traditional challenges.

This project aims to develop a Python-based medicine stock


system that seamlessly integrates real-life inventory management
with digital advancements.

The medicine stock system will leverage Python's robust programming


capabilities to create a user-friendly interface for tracking and managing medicine
inventories.

By digitizing the stock management process, this system will enhance accuracy,
reduce human errors, and streamline operations.

The project will incorporate features such as real-time stock updates, automated
alerts for low inventory levels, and detailed reporting to provide comprehensive
insights into stock status.

Through this project, we aim to demonstrate the potential of digital solutions in


transforming traditional medicine stock management practices.
By bridging the gap between real and digital life, this system will contribute to
improved healthcare delivery and ensure that essential medications are always
available when needed.

2. OBJECTIVE AND SCOPE OF THE PROJECT

Objective

The primary objective of this project is to develop a


comprehensive medicine stock system using Python that
integrates real-life inventory management with digital
advancements. This system aims to:
1.Minimize human errors in stock management by automating
the tracking and updating of medicine inventories.
2.Streamline the process of managing medicine stocks, making it
faster and more efficient.
3.Provide real-time updates and alerts to ensure that essential
medications are always available when needed.
4.Offer detailed reporting and analytics to provide insights into
stock status and trends.

Scope

The scope of this project includes the following key


components:
1.Develop a user-friendly interface for tracking and managing
medicine inventories, including adding, updating, and deleting
stock entries.
2.Implement real-time stock updates to reflect the current
inventory status accurately.
3.Set up automated alerts for low inventory levels to prevent
stockouts and ensure timely replenishment.
4.Create detailed reports and analytics to provide insights into
stock status.
5.User Access Control: Implement user access control to ensure
that only authorized personnel can manage and update the
inventory.
6.Ensure compatibility and integration with existing healthcare
systems and databases for seamless data exchange.
3. SYSTEM IMPLEMENTATION

3.1 HARDWARE REQUIREMENTS:

1. OPERATING SYSTEM - Windows 7 and above


2. PROCESSOR - x86 64-bit CPU (Intel / AMD architecture)
3. RAM - 4GB and above
4. HARD DISK - 2GB of free space

3.2 SOFTWARE REQUIREMENTS:

1. Python 3 and above.


2. MySQL version 6 and above
3. Suitable Operating System

4. SOFTWARE DESCRIPTION

4.1 PYTHON:
Python is an open-source (free) programming language that
is used in web programming, data science, artificial
intelligence, and many scientific applications. Learning
python allows the programmer to focus on solving problems,
rather than focusing on syntax. Its relative size and
simplified syntax give it an edge over languages like java and
c++, yet the abundance of libraries gives it the power needed
to accomplish great things.

Python is an interpreted, object-oriented, high-level


programming language with dynamic semantics. Its
highlevel built in data structures, combined with dynamic
typing and dynamic binding, make it very attractive for rapid
application development, as well as for use as a scripting or
glue language to connect existing components together.
Python's simple, easy to learn syntax emphasizes readability
and therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages
program modularity and code reuse. The python interpreter
and the extensive standard library are available in source or
binary form without charge for all major platforms, and can
be freely distributed.

FUNCTIONS:

A function is a block of organized, reusable code that is used


to perform a single, related action. Functions provide better
modularity for your application and a high degree of code
reusing.
As you already know, Python gives you many built-in
functions like print(), etc. but you can also create your own
functions. These functions are called user-defined functions.

Defining a Function:
You can define functions to provide the required
functionality. Here are simple rules to define a function in
Python.
Function blocks begin with the keyword def followed by the
function name and parentheses ( ).
Any input parameters or arguments should be placed within
these parentheses. You can also define parameters inside
these parentheses.
The first statement of a function can be an optional
statement - the documentation string of the function or
docstring.
The code block within every function starts with a colon (:)
and is indented.
The statement return [expression] exits a function,
optionally passing back an expression to the caller. A return
statement with no arguments is the same as return None.

Syntax:
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]

By default, parameters have a positional behavior and you


need to inform them in the same order that they were
defined.
4.2 MySQL:

MySQL is an open-source relational database management


system (RDBMS).Its name is a combination of "My", the
name of co-founder Michael Widenius's daughter My, and
"SQL", the acronym for Structured Query Language. A
relational database organizes data into one or more data
tables in which data may be related to each other; these
relations help structure the data. SQL is a language
programmers use to create, modify and extract data from the
relational database, as well as control user access to the
database. In addition to relational databases and SQL, an
RDBMS like MySQL works with an operating system to
implement a relational database in a computer's storage
system, manages users, allows for network access and
facilitates testing database integrity and creation of backups.

MySQL is free and open-source software under the terms of


the GNU General Public License, and is also available under a
variety of proprietary licenses. MySQL was owned and
sponsored by the Swedish company MySQL AB, which was
bought by Sun Microsystems (now Oracle Corporation). In
2010, when Oracle acquired Sun, Widenius forked the open-
source MySQL project to create MariaDB.

MySQL has stand-alone clients that allow users to interact


directly with a MySQL database using SQL, but more often,
MySQL is used with other programs to implement
applications that need relational database capability. MySQL
is a component of the LAMP web application software stack
(and others), which is an acronym for Linux, Apache, MySQL,
Perl/PHP/Python. MySQL is used by many database-driven
web applications, including Drupal, Joomla, phpBB, and
WordPress. MySQL is also used by many popular websites,
including Facebook, Flickr, Media Wiki, Twitter, and YouTube.

PYTHON-MYSQL CONNECTIVITY:
While working with Python we need to work with databases,
they may be of different types like MySQL, SQLite, NoSQL, etc.
In this article, we will be looking forward to how to connect
MySQL databases using MySQL Connector/Python. MySQL
Connector module of Python is used to connect MySQL
databases with the Python programs, it does that using the
Python Database API Specification v2.0 (PEP 249). It uses the
Python standard library and has no dependencies

5. SOFTWARE DEVELOPMENT LIFE CYCLE


Software Development Life Cycle (also called SDLC) is a
workflow process which defines the core stages and
activities of development cycles or a framework that
describes the activities performed at each stage of a software
development project.
Software Development Life Cycle (SDLC) is a process used
by the software industry to design, develop and test
highquality software’s. The SDLC aims to produce high-
quality software that meets or exceeds customer
expectations, reaches completion within times and cost
estimates. System analysts can use it, designers and
developers to plan and implement the applications and
deliver the systems or products on time and within budget.
With numerous development methodologies, it is never an
easy task to choose an appropriate strategy that sometimes
even it is inevitable to mix-and-match multiple methods to fit
in a single project.
SDLC Phases are as follows
1. Project Initiation
2. Requirements Gathering
3. Analysis
4. Design
5.Development
6.Testing
7. Implementation or deployment
8. Maintenance
The following figure shows the details process of Software
Development Life Cycle.
Project Initiation:
This is the first stage in the Software Development Life Cycle
where the project is initiated. The high-level scope, problems
and solutions are determined, and planning is carried out
accordingly for other stages Requirements Gathering:
Business requirements are gathered. Meetings with project
managers and stakeholders. Identify • “Who will use the
system” • “How the system should work “ • “What should be
the input & output of the system” Analyse requirements for
validity & incorporation of requirements finally, prepare
Requirement specification document.
The requirements are of the type:
• Functional Requirements
• Non-functional Requirements
The end-user requirements from the customer and other
stakeholders (salespeople, domain/industry experts, etc.)
are collected.
Requirements are gathered using the following techniques: •
By conducting Interviews
• By conducting Workshops
• By conducting Surveys and questionnaires
• Focus Groups
• Observations / time study
• By conducting Brainstorming Sessions
•Document Analysis (Ex: Regulatory
requirements)
• Mind Mapping
• Benchmarks
Analysis:

The Analysis Phase is where you break down the deliverables


in the high-level Project Charter into the more detailed
business requirements.
The Analysis Phase is also the part of the project where you
identify the overall direction that the project will take
through the creation of the project strategy documents.
• Understand the business need and processing needs
• Gather, analyse, and validate the information.
• Define the requirements and prototypes for the new
system.
• Evaluate the alternatives and prioritize the requirements.

Examine the information needs of end-user and enhances


the system goal.
• A Software
• Requirement Specification (SRS) document is used in the
analysis phase, which specifies the software, hardware,
functional, and network requirements of the system is
prepared at the end of this phase.
• In this, every achievable requirement is analysed and
documented as Software Requirements Specifications
(SRS) or Functional Requirements Specifications (FRS).
• This is effectively manageable for all the resources
(developers, designers, testers, project managers and any
other possible roles) to work on the chunks at all the stages
in the Software Development Life Cycle.
• In many cases, a requirement gathering, and analysis can
be carried out at the same time.
System Design:

This is the stage which stated, “How to achieve what is


needed?”
• Software Requirements Specifications (SRS) are now
transformed to the system design plan, which contains a
detailed and complete set of specifications, commonly
known as “Design Specification”.
• Prepare design of network, databases, application, system
interfaces, user interfaces, system and software design
from software requirement specification.

• All the technical details like technologies to use, project


constraints, team’s capability, etc. goes into the design
specification document.
• The technical architects and developers develop the logical
plan of the system which is then reviewed by all the
stakeholders.
• Design a contingency, training, maintenance, and operation
plan.
• At last, prepare a design document which will be used
during next phases.

Development:

Taking all the detailed design documents from the design


phase and transforming them into the actual system.
• Build the technical architecture
• Build the database and program
• This stage in more straightforward terms is where the “real
work begins” and we “build what is needed”.
• The developers start to code as per the requirements and
the developed design.
• Along with the coding, all the other required set-up will
begin. i.e., the database set up by database admin, interface
and GUI creation by front-end developers, etc.
• Along with coding, it is also essential for developers to
develop unit tests for their module, peer review other
module’s unit tests, deploy builds to the
intended environment and execute unit tests.
Testing:

This stage is the one where the quality check takes place. The
developed software is assessed to ensure that all the
specified requirements are met.
• Write the test condition and perform the testing of the
system.
• This stage is used to validate whether the application
addresses all User Requirements, technical performance.
• This is performed by the testing team, and the focus is to
find the defects.
• During test case execution, all the error found which are
reported in the test management tool and the decision of
considering the defect as Valid or Invalid depends on
developers.
• Each defect that is found will have to go through the Defect
Life Cycle in the defect management tool.
• Again, the testing approach that the project choose
depends on various factors: the complexity of the project,
the team’s capability, time, etc.
Deployment or Implementation:

Write detailed user documentation and provide training for


the system user.
• Once the testing is completed and, there are no open high
priority issues, then comes the time to deploy the build to
the Production environment. This is the environment
which is accessible by real users. Real users can then use
the software as per their needs.
• Deploying the build to production can be a complicated
process. If the project is an existing application, technology
migration is being carried out etc, it can be an extensive
procedure.
• Depending on business criticality deployment teams may
need to ensure that the application continues to function,
while the deployment is in progress. • Due to the high cut-
over time, the Production deployment usually takes place
during non-peak hours and / or weekends.
Maintenance:

This stage is when the “fine tuning” of the software takes


place. Once the build is deployed to Production environment,
any issues that the real users face are considered as
PostProduction issues.
• These Post-Production issues are addressed and resolved
by the internal team usually termed as Maintenance team.
• This stage also addresses minor change requests, code
fixes, etc. and deploys them in short intervals.
• Build a helpdesk to support the system user.
• One may change the application without impairing existing
functionalities.
• You may add new functionalities to the existing application.
• You can fix any historical defects of the application in this
phase.

6. SYSTEM DESIGN AND DEVELOPMENT

6.1 TABLE DESIGN


6.2 CODING import datetime import
import datetime
import mysql.connector as mc
mycon=mc.connect(host="localhost",user="root",database="shop")
mycur=mycon.cursor()
def store():

print('\nplease provide the required information')


acc=int(input("\nenter the batch no:"))
nm=input("\nenter the name of the medicine with power:")
addr=input("\nenter the name of the manufacturer:")
mand=input("\nenter the date of manufacture(yyyy-mm-dd):")
expd=input("\nenter the date of expiry(yyyy-mm-dd):")
quan=int(input("\nenter the quantity of the imported medicine:"))
sell=0
balance=quan
cost=float(input("\nenter the cost of the imported medicine:"))
sql="insert into
stock(batch_no,name,manuf,date_man,date_exp,quantity,sell,balance,c
ost_unit)values({},'{}','{}','{}','{}',{},{},{},
{})".format(acc,nm,addr,mand,expd,quan,sell,balance,cost)
mycur.execute(sql)
print(nm,"added to the stock")
mycon.commit()
def search_by_name():
ph=input("\nenter the medicine name to search:")
sql="select * from stock where name='{}'".format(ph)
mycur.execute(sql)
rec=mycur.fetchone()
if rec==None:
print(ph,"IS NOT AVAILABLE")
else:
print("batch no:\t",rec[0])
print("medicine name:\t",rec[1])
print("manufacturer:\t",rec[2])
print("date of manufacture:\t",rec[3])
print("date of expiry:\t",rec[4])
print("quantity stored:\t",rec[5])
print("initial cost:\t",rec[8])

def search_by_menu():
ph=input("\nenter the manufacturer name to search:")
sql="select name from stock where manuf='{}'".format(ph)
mycur.execute(sql)
rec=mycur.fetchall()
if rec==None:
print(ph,"IS A WRONG MANUFACTURER")
else:
print("......MEDICINES MANUFACTURED BY",ph,".....")
for nm in rec:
print(nm[0])

def cost_update():

ph=input("\nenter the medicine name to change cost:")


addr=float(input("\nenter the new cost per unit:"))
sql="update stock set cost_unit={} where
name='{}'".format(addr,ph)
try:
mycur.execute(sql)
mycon.commit()
print("NEW COST OF",ph,"IS",addr)
except:
print("unable to change cost!!!!!!")

def sell():

ph=input("\nenter the medicine name to sell:")


addr=int(input("\nenter the qunatity to sell:"))
sql2="select quantity from stock where name='{}'".format(ph)
mycur.execute(sql2)
rec=mycur.fetchone()
if addr>rec[0] :
print("INSUFFICIENT STOCK IN HAND")
return
else:
balance=rec[0]-addr
try:
sql="update stock set sell={},balance={} where
name='{}'".format(addr,balance,ph)
mycur.execute(sql)
mycon.commit()
print(addr,"units of",ph,"sold")
print(balance,"units left")
except:
print("unable to sell medicine!!!!!")

def available():
ph=input("\nenter the medicine name to search:")
sql="select balance from stock where name='{}'".format(ph)
mycur.execute(sql)
rec=mycur.fetchone()
if rec==None:
print(ph,"is not avaialable")
else:
print(rec[0],"units of",ph," is available")

def dispose():

nm=input("\nenter the medicine name to dispose:")


t_date=datetime.date.today()
sql2="select batch_no,name,date_exp,balance from stock where
name='{}' and date_exp<={}".format(nm,t_date)
mycur.execute(sql2)
rec=mycur.fetchone()
if rec==None:
print(nm,"is not expired yet!!!")
else:
print(nm,"is expired")
c=int(input("\nPRESS 1 to dispsoe it:"))
if(c==1):
b=rec[0]
n=rec[1]
d=rec[2]
am=rec[3]
try:
sql="insert into
dispose(batch_no,name,date_exp,balanace)values({},{},{},
{})".format(b,n,d,am)
mycur.execute(sql)
mycon.commit()
print(n,"successfully disposed")
sql3="delete from stock where name={}.format(n)"
mycur.execute(sql3)
mycon.commit()
except:
print("unable to dispose medicine")
else:
print("warning!!!",nm,"must be disposed later")
return

def close():
print("\n🤝🤝 நன்றி வணக்கம் 🤝🤝 ")
mycon.close()
quit()

while True:
print("\nwelcome to our medical shop stocking system")

print("\n\t\t\t>>>①| TO ADD A NEW MEDICINE")

print("\n\t\t\t>>>②| TO SEARCH A MEDICINE BY NAME")


print("\n\t\t\t>>>③| TO SEARCH A MEDICINE BY
MANUFATURER")

print("\n\t\t\t>>>④| TO UPDATE MEDICINE")

print("\n\t\t\t>>>⑤| TO SELL MEDICINE")

print("\n\t\t\t>>>⑥| TO CHECK AVAILABILITY")

print("\n\t\t\t>>>⑦|TO SEARCH EXPIRED MEDICINE")

print("\n\t\t\t>>>⑧| TO CLOSE THE APLLICAION")

choice=int(input("\nENTER UR CHOICE:"))

if choice==1:
store()

elif choice==2:
search_by_name()

elif choice==3:
search_by_menu()
elif choice==4:
cost_update()

elif choice==5:
sell()

elif choice==6:
available()

elif choice==7:
dispose()

else:
close()
output:
7. USER MANUAL
7.1 Python installation
Step 1 − Select Version of Python to Install
Python has various versions available with differences
between the syntax and working of different versions of the
language. We need to choose the version which we want to use
or need. There are different versions of Python 2 and Python 3
available.
Step 2 − Download Python Executable Installer
On the web browser, in the official site of python
(www.python.org), move to the Download for Windows section.
All the available versions of Python will be listed.
Select the version required by you and click on
Download. Let suppose, we chose the Python 3.9.1 version.

On clicking download, various available executable installers


shall be visible with different operating system specifications.
Choose the installer which suits your system operating system
and download the installer. Let suppose, we select the Windows
installer (64 bits).
The download size is less than 30MB.
Step 3 − Run Executable Installer
We downloaded the Python 3.9.1 Windows 64 bit installer. Run
the installer. Make sure to select both the checkboxes at the bottom
and then click Install New.
The installation process will take few minutes to complete and
once the installation is successful, the following screen is
displayed.
Step 4 − Verify Python is installed on Windows

To ensure if Python is successfully installed on your system.


Follow the given steps −
• Open the command prompt.
• Type ‘python’ and press enter.

• The version of the python which you have installed will be


displayed if the python is successfully installed on your
windows.

Step 5 − Verify Pip was installed


Pip is a powerful package management system for
Python software packages. Thus, make sure that you have it
installed.
To verify if pip was installed, follow the given steps −
1. Open the command prompt.
2. Enter pip –V to check if pip was installed.
3. The following output appears if pip is installed
successfully.
We have successfully installed python and pip on our
Windows system.

7.2 MySQL Installation:


Installing MySQL on Windows:
The default installation on any version of Windows
is now much easier than it used to be, as MySQL now comes
neatly packaged with an installer. Simply download the
installer package, unzip it anywhere and run the setup.exe
file.

The default installer setup.exe will walk you through the


trivial process and by default will install everything under C:\
mysql.
Test the server by firing it up from the command prompt the
first time. Go to the location of the mysqld server which is
probably C:\mysql\bin, and type − mysqld.exe --console

NOTE − If you are on NT, then you will have to use


mysqldnt.exe instead of mysqld.exe
If all went well, you will see some messages about startup
and InnoDB. If not, you may have a permissions issue. Make
sure that the directory that holds your data is accessible to
whatever user (probably MySQL) the database processes run
under.
MySQL will not add itself to the start menu, and there is no
particularly nice GUI way to stop the server either. Therefore,
if you tend to start the server by double clicking the mysqld
executable, you should remember to halt the process by
hand by using mysqladmin, Task List, Task Manager, or other
Windows-specific means.
Verifying MySQL Installation:

After MySQL, has been successfully installed, the base


tables have been initialized and the server has been started:
you can verify that everything is working as it should be via
some simple tests.
Use the mysqladmin Utility to Obtain Server Status
Use mysqladmin binary to check the server version. This
binary would be available in /usr/bin on Linux and in C:\
mysql\bin on windows.
[root@host]# mysqladmin --version

It will produce the following result on Linux. It may vary


depending on your installation − mysqladmin Ver 8.23
Distrib 5.0.9-0, for redhat-linux-gnu on i386

If you do not get such a message, then there may be some


problem in your installation and you would need some help to
fix it.
Execute simple SQL commands using the MySQL Client You
can connect to your MySQL server through the MySQL client
and by using the mysql command. At this moment, you do
not need to give any password as by default it will be set as
blank.

You can just use following command −

[root@host]# mysql

It should be rewarded with a mysql> prompt. Now, you are


connected to the MySQL server and you can execute all the
SQL commands at the mysql> prompt as follows − mysql>
SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.13 sec)

Post-installation Steps
MySQL ships with a blank password for the root
MySQL user. As soon as you have successfully installed the
database and the client, you need to set a root password as
given in the following code block −

[root@host]# mysqladmin -u root password


"new_password";
Now to make a connection to your MySQL server, you would
have to use the following command −

[root@host]# mysql -u root -p


Enter password:*******
UNIX users will also want to put your MySQL directory in
your PATH, so you won't have to keep typing out the full path
every time you want to use the command-line client.

For bash, it would be something like − export


PATH = $PATH:/usr/bin:/usr/sbin

Running MySQL at Boot Time

If you want to run the MySQL server at boot time, then make
sure you have the following entry in the /etc/rc.local file.
/etc/init.d/mysqld start
Also, you should have the mysqld binary in the /etc/init.d/
directory.

Python MySQL Connectivity


Interface Python with SQL database
♦ Connecting SQL with Python
♦ creating database connectivity application
♦ Performing insert, delete, update, queries
♦ Display data by using
fetchone(),fetchall(),fetchmany(), rowcount()

Database connectivity
Database connectivity refers to connection and
communication between an application and a database
system.
The term “front-end” refers to the user interface,
while “back-end” means the server application and database
that work behind the scenes to deliver information to the
user. mysql.connector-Library or package to connect
from python to MySQL.

Before we connect the program with mysql, we need


to install connectivity package named mysql-
connectorpython.

Command to install connectivity package:

pip install mysql-connector-python


Command to import connector:-
Import mysql.connector
Steps for python MySQL connectivity
Step 1: Install Python
Step 2: Install MySQL
Step 3: Open Command prompt & Switch on internet
connection
Step 4: Type pip install mysql-connector-python and execute
Step 5: Open python IDLE
Step 6: Import mysql.connector
Steps for creating database connectivity applications

Step 1: Start Python: Start python editor to create your


python script
Step 2: mysql.connector package

Step 3: Establishing connection to MySQL DATABASE

We need to establish a connection to a mysql database using


connect() function of mysql.connector package.

The connect statement creates a connection to the mysql


server and returns a MySQL connection object.

Syntax:
<Connection object>=mysql.connectorconnect
(host=<hostname>, user=<username>, passwd <password>,
database=<dbname>) import mysql.connector
con=mysql.connector.connect(host=”localhost”, user=”root”,
passwd=” “)

Creating a cursor Object:

It is a useful control structure of database


connectivity. It will let us execute all the queries we need.
Cursor stores all the data as a temporary container of
returned data and allows traversal so that we can fetch data
one row at a time from cursor. Cursors are created by the
connection.cursor() method.
Syntax:
<cursor object>=<connectionobject> .cursor()

Eg: Cursor=con.cursor()

Execute SQL query:


We can execute SQL query using execute() function

Syntax:
<cursor object>.execute(SQL QUERY)
Eg: cursor.execute(“select* from data”). The above code will
execute the sql query and store the retrieved records
(resultset) in the cursor object(cursor).

9. BIBLIOGRAPHY

BOOF REFERENCES:

> Computer science with python Preeti Arora.


> NCERT Textbook.
> Computer science with python Sumita Arora.
WEB REFERENCES

>https://pythonworld.in/practical-project/project-list/

>http://python.mykvs.in/uploads/showpapers/testproject.
php
>https://www.cs4school.com/cbse/python-project-forclass-
12

You might also like