]>
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
= "" , properties
= None ):
20 self
. qualification
= qualification
21 self
. registration
= registration
22 self
. address
= address
23 self
. contact
= contact
25 self
. properties
= properties
27 def set_data_from_json ( self
, data
):
29 self
. name
= data
[ "name" ]
30 self
. qualification
= data
[ "qualification" ]
31 self
. registration
= data
[ "registration" ]
32 self
. address
= data
[ "address" ]
33 self
. contact
= data
[ "contact" ]
34 self
. extra
= data
[ "extra" ]
35 if ( "properties" in data
):
36 self
. properties
= data
[ "properties" ]
38 self
. properties
= None
39 except Exception as e
:
42 def read_from ( self
, file ):
44 with
open ( file , "r" ) as f
:
45 self
. set_data_from_json ( json
. loads ( f
. read ()))
46 except Exception as e
:
48 self
. qualification
= ""
49 self
. registration
= ""
59 def __init__ ( self
, date
= "" , id = "" , pid
= "" , name
= "" , dob
= "" , age
= "" , sex
= "" , address
= "" , contact
= "" , extra
= "" , mode
= "" , daw
= "" , diagnosis
= "" , note
= "" , report
= "" , advice
= "" , investigation
= "" , medication
= "" , additional
= "" , certificate
= "" , custom
= None , properties
= None , prescriber
= None ):
60 self
. set_data ( date
, name
, dob
, age
, sex
, address
, contact
, extra
, mode
, daw
, diagnosis
, note
, report
, advice
, investigation
, medication
, additional
, certificate
, custom
, properties
)
61 if prescriber
is None :
62 self
. prescriber
= Prescriber ()
64 self
. prescriber
= prescriber
66 def set_data ( self
, date
= "" , id = "" , pid
= "" , name
= "" , dob
= "" , age
= "" , sex
= "" , address
= "" , contact
= "" , extra
= "" , mode
= "" , daw
= "" , diagnosis
= "" , note
= "" , report
= "" , advice
= "" , investigation
= "" , medication
= "" , additional
= "" , certificate
= "" , custom
= None , properties
= None ):
78 self
. address
= address
79 self
. contact
= contact
83 self
. diagnosis
= diagnosis
87 self
. investigation
= investigation
88 self
. medication
= medication
89 self
. additional
= additional
90 self
. certificate
= certificate
92 self
. properties
= properties
94 def set_data_from_json ( self
, data
):
96 self
. prescriber
. set_data_from_json ( data
. get ( "prescriber" ))
97 self
. date
= data
. get ( "date" )
98 self
. id = data
. get ( "id" )
99 self
. id = data
. get ( "pid" )
100 self
. name
= data
. get ( "name" )
101 self
. dob
= data
. get ( "dob" )
102 self
. age
= data
. get ( "age" )
103 self
. sex
= data
. get ( "sex" )
104 self
. address
= data
. get ( "address" )
105 self
. contact
= data
. get ( "contact" )
106 self
. extra
= data
. get ( "extra" )
107 self
. mode
= data
. get ( "mode" )
108 self
. daw
= data
. get ( "daw" )
109 self
. diagnosis
= data
. get ( "diagnosis" )
110 self
. note
= data
. get ( "note" )
111 self
. report
= data
. get ( "report" )
112 self
. advice
= data
. get ( "advice" )
113 self
. investigation
= data
. get ( "investigation" )
114 self
. medication
= data
. get ( "medication" )
115 self
. additional
= data
. get ( "additional" )
116 self
. certificate
= data
. get ( "certificate" )
117 self
. custom
= data
. get ( "custom" )
118 if ( "properties" in data
):
119 self
. properties
= data
[ "properties" ]
121 self
. properties
= None
122 except Exception as e
:
126 return ( json
. dumps ( self
, default
= lambda o
: o
.__ dict
__ , indent
= 4 ))
128 def write_to ( self
, file ):
129 with
open ( file , "w" ) as f
:
132 except AttributeError as e
:
134 except Exception as e
:
136 f
. write ( self
. get_json ())
139 def read_from ( self
, file ):
140 with
open ( file , "r" ) as f
:
141 self
. set_data_from_json ( json
. loads ( f
. read ()))
144 def reload_prescriber ( self
, file = None ):
145 self
. prescriber
= Prescriber ( file )