0% found this document useful (0 votes)
1 views

Pathology

Uploaded by

as3450293
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Pathology

Uploaded by

as3450293
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Required Database:

Source Code
import mysql.connector

from mysql.connector import Error

import os

import platform

myDB = mysql.connector.connect(host='localhost', user='root', passwd='root')

myCursor = myDB.cursor()

def CreateDb():

os.system('cls')

myDB = mysql.connector.connect(host='localhost', user='root', passwd='root')

CreateDBQuery = "CREATE DATABASE if NOT Exists Pathology"

myCursor = myDB.cursor()

myCursor.execute(CreateDBQuery)

## print("Pathology Database created successfully ")

CreateTable()
##

def CreateTable():

os.system('cls')

myDB = mysql.connector.connect(host='localhost',

database='Pathology',

user='root',

passwd='root')

Patient = """CREATE TABLE if not exists Patient (

BookID Varchar(15) ,

PName varchar(20) NOT NULL,

Gender Char(1) NOT NULL,

Address Varchar(20),

contact varchar(10),

email varchar(25),

BookingDate date,

SampleDate Date,

ReportDate date,

TestType Varchar(20),

Center Varchar(10) Default 'LAB',

RefferedBy varchar(15) Default 'SELF',

AdvDeposit double) """

myCursor = myDB.cursor()

result1 = myCursor.execute(Patient)

def AdmitPatient():

os.system('cls')

try:
myDB = mysql.connector.connect(host='localhost',

database='Pathology',

user='root',

passwd='root')

myCursor = myDB.cursor()

sql="select *from Patient"

myCursor.execute(sql)

newBookID="211205000" #new Patient ID

for x in myCursor:

#print(x[0])

newBookID=int(x[0])

#print(newAccountId)

newBookID=int(newBookID)+1

print("\
t************************************************************************")

print("\t\t*\t\tNew Book ID :",newBookID)

PName=input("\t\t*\t\tEnter Patient Name :")

Gender=input("\t\t*\t\tEnter Gander :")

Address=input("\t\t*\t\tEnter Patient Address :")

contact=input("\t\t*\t\tEnter Mobile Number :")

email=input("\t\t*\t\tEnter Email :")

BookDt=input("\t\t*\t\tEnter Booking Date :")

SampleDt=input("\t\t*\t\tEnter Sample Date :")

ReportDt=input("\t\t*\t\tEnter Report Date :")

print("\t\t*\t\t\t\t\t1. Sugar")

print("\t\t*\t\t\t\t\t2. Thyriod")

print("\t\t*\t\t\t\t\t3. MRI")

print("\t\t*\t\t\t\t\t4. CT Scan")
print("\t\t*\t\t\t\t\t5. X-Ray")

print("\t\t*\t\t\t\t\t6. Ultra Sound")

TestType=input("\t\t*\t\tSelect Test Type (1 to 6):")

print("\t\t*\t\t\t\t\t1. Lab")

print("\t\t*\t\t\t\t\t2. Home")

print("\t\t*\t\t\t\t\t3. Hospital")

Center=input("\t\t*\t\tEnter Center :")

RefferedBy=input("\t\t*\t\tReffered By : Dr.")

AdvDeposit=input("\t\t*\t\tEnter Advance Deposit Amount :")

mySql_insert_query = """INSERT INTO Patient VALUES (%s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s,
%s,%s) """

recordTuple = (newBookID ,PName,Gender,Address,contact,email,BookDt,\

SampleDt,ReportDt,TestType,Center,"Dr. "+RefferedBy,AdvDeposit)

myCursor.execute(mySql_insert_query, recordTuple)

myDB.commit()

print("Record inserted successfully into Patient table")

except mysql.connector.Error as error:

print("Failed to insert into MySQL table {}".format(error))

finally:

if (myDB.is_connected()):

myCursor.close()

myDB.close()

print("MySQL connection is closed")

def GererateReport():
myDB = mysql.connector.connect(host='localhost',

database='Pathology',

user='root',

passwd='root')

myCursor = myDB.cursor()

BookID=input("Enter Booking ID :")

print("\t\t*\t\t\t\t\t1. Sugar")

print("\t\t*\t\t\t\t\t2. Thyriod")

print("\t\t*\t\t\t\t\t3. MRI")

print("\t\t*\t\t\t\t\t4. CT Scan")

print("\t\t*\t\t\t\t\t5. X-Ray")

print("\t\t*\t\t\t\t\t6. Ultra Sound")

TestType=input("\t\t*\t\tSelect Test Type (1 to 6):")

sql="select *from Patient where BookID=%s and TestType=%s"

myCursor.execute(sql,(BookID,TestType,))

record = myCursor.fetchall()

print("\t\t===============================================================")

for rec in record:

print("\t\t*\t\tBook ID :",rec[0])

print("\t\t*\t\tPatient Name :",rec[1])

print("\t\t*\t\tGander :",rec[2])

print("\t\t*\t\tBooking Date :",rec[6])

print("\t\t*\t\tSample Date :",rec[7])

print("\t\t*\t\tReport Date :",rec[8])

print("\t\t*\t\tCenter :",rec[10])

print("\t\t*\t\tReffered By :",rec[11])

print("\t\t*\t\tAdvance Deposit Amount :",rec[12])


if rec[9]=='1':

print("\t\t*\t\tTest Type : Sugar")

SugarReport()

if rec[9]=='2':

print("\t\t*\t\tTest Type : Thyriod")

ThyriodReport()

if rec[9]=='3':

print("\t\t*\t\tTest Type : MRI")

MRI()

if rec[9]=='4':

print("\t\t*\t\tTest Type : CT Scan")

if rec[9]=='5':

print("\t\t*\t\tTest Type : X-Ray")

if rec[9]=='6':

print("\t\t*\t\tTest Type : Ultra Sound")

def SugarReport():

print("\t"*20,"Final Test Report")

print("\tTest Name\t\tMethod\t\tObserved Value\t\tBiological Range")

print("\t","-"*190)

print("\t\t\tBIOCHEMISTRY")

print("\t\t\tBlood Glucose(F)\t\tGOD-POD\t\t90.0 mgs/dl\t\t60-100 mgs/dl")

print("\t\t\tBlood Glucose(PP)\t\tGOD-POD\t\t70.0 mgs/dl\t\t100-150 mgs/dl")

print("\t\t\t\t\t\t*****End of the Report*****")

def ThyriodReport():
print("Ordered Items")

print("Thyroid Panel : Venipuncute")

print('-'*150)

print("\tTESTS\t\tRESULT\t\t FLAG\t\t UNITS\t\t REFERENCE INTERVAL\tLAB")

print('-'*150)

print("Thyroid Panel")

print(" Thyroxine (T4)\t\t6.9\t\t\t\tug/dL\t\t4.5 - 12.0\t01")

print(" T3 Uptake\t\t33\t\t\t\t%\t\t24 - 39\t01")

print(" Free Thyroxine Index\t2.3\t\t\t\t\t1.2 - 4.9")

print('-'*150)

print("Thyroid Panel: Thyroxine (T4): reference range 4.5 to 12.0 mcg/dL; T3 Uptake: 22-35%;
Free Thyroxine Index (T7): 1.4 to 3.8.")

def MRI():

print('-'*150)

print("MRI Scan")

print('-'*150)

print('SEQUENCES: Sagittal FLAIR and coronal T2-weighted images are supplemented by axial T1,
T2,and FLAIR images.\

\n\tThere is diffuse dilatation of sulci and ventricles more than one would expect for a patient of
this age group.\

\n\tThere has been extensive tissue loss in the right cerebral hemisphere due to an old insult, \

\n\tpresumably an ischemic event. This primarily involves the right temporal/occipital region
and is\

\n\tassociated with obvious ex vacuo prominence of the right lateral ventricle. There is
wallerian\

\n\tdegeneration of the corticospinal tracts/cerebral peduncle as further corroboration that this


is an old insult.\

\n\tNo previous studies are made available for review.\

\n\tThere are few focal defects identified in the periventricular white matter bilaterally. These
are likely\
\n\tdue to some superimposed small vessel ischemic change rather than a demyelinating
condition.\

\n\tThere is no evidence of focal defects identified within the brainstem at any level. The orbits
are\

\n\tunremarkable.\n\

\nIMPRESSION:\n\

\n\t1. Extensive tissue loss right temporal/occipital region with ex vacuo prominence of right
lateral\

\n\tventricle and wallerian degeneration of the right cerebral peduncle.\

\n\t2. Subtle focal defects periventricular white matter probably due to superimposed small
vessel\

\n\tischemic disease.\

\n\t3. No previous studies are made available for review. At such time that a previous study
becomes\

\n\tavailable, an addendum will be issued.')

def displayAll():

myDB = mysql.connector.connect(host='localhost',

database='Pathology',

user='root',

passwd='root')

myCursor = myDB.cursor()

sql="select *from Patient "

myCursor.execute(sql)

record = myCursor.fetchall()

print("\t\t===============================================================")

for rec in record:

print("\t\t*\t\tBook ID :",rec[0])
print("\t\t*\t\tPatient Name :",rec[1])

print("\t\t*\t\tGander :",rec[2])

print("\t\t*\t\tBooking Date :",rec[6])

print("\t\t*\t\tSample Date :",rec[7])

print("\t\t*\t\tReport Date :",rec[8])

print("\t\t*\t\tCenter :",rec[10])

if rec[9]=='1':

print("\t\t*\t\tTest Type : Sugar")

if rec[9]=='2':

print("\t\t*\t\tTest Type : Thyriod")

if rec[9]=='3':

print("\t\t*\t\tTest Type : MRI")

if rec[9]=='4':

print("\t\t*\t\tTest Type : CT Scan")

if rec[9]=='5':

print("\t\t*\t\tTest Type : X-Ray")

if rec[9]=='6':

print("\t\t*\t\tTest Type : Ultra Sound")

print("\t\t*\t\tReffered By :",rec[11])

print("\t\t*\t\tAdvance Deposit Amount :",rec[12])

print("\t\t===============================================================")

ch=input("Do you want to continue....(Y/N) :")

if ch.upper()=='N':

break

def mainMenu():
CreateDb()

while True:

print("\n\n\t\t\t\t\t\t*****DOON PATHOLOGY CENTER*****\n")

print("\t\t\t1. AdmitPatient")

print("\t\t\t2. Report")

print("\t\t\t3. Display All")

print("\t\t\t4. Exit")

ch=int(input("\t\tEnter choice :" ))

if ch==1:

AdmitPatient()

if ch==2:

GererateReport()

if ch==3:

displayAll()

if ch==4:

break

## Calling Module/Function

mainMenu()
Screen Shot:

You might also like