]>
Softwares of Agnibho - medscript.git/blob - prescription.py
2 # Copyright (C) 2023 Dr. Agnibho Mondal
3 # This file is part of MedScript.
4 # MedScript is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5 # MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6 # You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
9 from config
import config
12 def __init__ ( self
, file = None ):
14 self
. read_from ( config
[ "prescriber" ])
18 def set_data ( self
, name
= "" , qualification
= "" , registration
= "" , address
= "" , contact
= "" , extra
= "" ):
20 self
. qualification
= qualification
21 self
. registration
= registration
22 self
. address
= address
23 self
. contact
= contact
26 def set_data_from_json ( self
, data
):
27 self
. name
= data
[ "name" ]
28 self
. qualification
= data
[ "qualification" ]
29 self
. registration
= data
[ "registration" ]
30 self
. address
= data
[ "address" ]
31 self
. contact
= data
[ "contact" ]
32 self
. extra
= data
[ "extra" ]
34 def read_from ( self
, file ):
35 with
open ( file , "r" ) as f
:
36 self
. set_data_from_json ( json
. loads ( f
. read ()))
42 def __init__ ( self
, date
= "" , id = "" , name
= "" , age
= "" , sex
= "" , address
= "" , contact
= "" , extra
= "" , mode
= "" , daw
= "" , diagnosis
= "" , note
= "" , report
= "" , advice
= "" , investigation
= "" , medication
= "" , additional
= "" , prescriber
= None ):
43 self
. set_data ( date
, name
, age
, sex
, address
, contact
, extra
, mode
, daw
, diagnosis
, note
, report
, advice
, investigation
, medication
, additional
)
44 if prescriber
is None :
45 self
. prescriber
= Prescriber ()
47 self
. prescriber
= prescriber
49 def set_data ( self
, date
= "" , id = "" , name
= "" , age
= "" , sex
= "" , address
= "" , contact
= "" , extra
= "" , mode
= "" , daw
= "" , diagnosis
= "" , note
= "" , report
= "" , advice
= "" , investigation
= "" , medication
= "" , additional
= "" ):
55 self
. address
= address
56 self
. contact
= contact
60 self
. diagnosis
= diagnosis
64 self
. investigation
= investigation
65 self
. medication
= medication
66 self
. additional
= additional
68 def set_data_from_json ( self
, data
):
69 self
. prescriber
. set_data_from_json ( data
. get ( "prescriber" ))
70 self
. date
= data
. get ( "date" )
71 self
. id = data
. get ( "id" )
72 self
. name
= data
. get ( "name" )
73 self
. age
= data
. get ( "age" )
74 self
. sex
= data
. get ( "sex" )
75 self
. address
= data
. get ( "address" )
76 self
. contact
= data
. get ( "contact" )
77 self
. extra
= data
. get ( "extra" )
78 self
. mode
= data
. get ( "mode" )
79 self
. daw
= data
. get ( "daw" )
80 self
. diagnosis
= data
. get ( "diagnosis" )
81 self
. note
= data
. get ( "note" )
82 self
. report
= data
. get ( "report" )
83 self
. advice
= data
. get ( "advice" )
84 self
. investigation
= data
. get ( "investigation" )
85 self
. medication
= data
. get ( "medication" )
86 self
. additional
= data
. get ( "additional" )
89 return ( json
. dumps ( self
, default
= lambda o
: o
.__ dict
__ , indent
= 4 ))
91 def write_to ( self
, file ):
92 with
open ( file , "w" ) as f
:
95 except AttributeError as e
:
97 except Exception as e
:
99 f
. write ( self
. get_json ())
102 def read_from ( self
, file ):
103 with
open ( file , "r" ) as f
:
104 self
. set_data_from_json ( json
. loads ( f
. read ()))
107 def reload_prescriber ( self
, file = None ):
108 self
. prescriber
= Prescriber ( file )