]>
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
={}):
20 self
. qualification
= qualification
21 self
. registration
= registration
22 self
. address
= address
23 self
. contact
= contact
25 self
. properties
= properties
28 return ( json
. dumps ( self
, default
= lambda o
: o
.__ dict
__ , indent
= 4 ))
30 def set_data_from_json ( self
, data
):
32 self
. name
= data
[ "name" ]
33 self
. qualification
= data
[ "qualification" ]
34 self
. registration
= data
[ "registration" ]
35 self
. address
= data
[ "address" ]
36 self
. contact
= data
[ "contact" ]
37 self
. extra
= data
[ "extra" ]
38 if ( "properties" in data
and type ( properties
) is dict ):
39 self
. properties
= data
[ "properties" ]
42 except Exception as e
:
45 def read_from ( self
, file ):
47 with
open ( file , "r" ) as f
:
48 self
. set_data_from_json ( json
. loads ( f
. read ()))
49 except Exception as e
:
51 self
. qualification
= ""
52 self
. registration
= ""
62 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
={}, prescriber
= None ):
63 self
. set_data ( date
, name
, dob
, age
, sex
, address
, contact
, extra
, mode
, daw
, diagnosis
, note
, report
, advice
, investigation
, medication
, additional
, certificate
, custom
, properties
)
64 if prescriber
is None :
65 self
. prescriber
= Prescriber ()
67 self
. prescriber
= prescriber
69 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
={}):
81 self
. address
= address
82 self
. contact
= contact
86 self
. diagnosis
= diagnosis
90 self
. investigation
= investigation
91 self
. medication
= medication
92 self
. additional
= additional
93 self
. certificate
= certificate
95 self
. properties
= properties
97 def set_data_from_json ( self
, data
):
99 self
. prescriber
. set_data_from_json ( data
. get ( "prescriber" ))
100 self
. date
= data
. get ( "date" )
101 self
. id = data
. get ( "id" )
102 self
. pid
= data
. get ( "pid" )
103 self
. name
= data
. get ( "name" )
104 self
. dob
= data
. get ( "dob" )
105 self
. age
= data
. get ( "age" )
106 self
. sex
= data
. get ( "sex" )
107 self
. address
= data
. get ( "address" )
108 self
. contact
= data
. get ( "contact" )
109 self
. extra
= data
. get ( "extra" )
110 self
. mode
= data
. get ( "mode" )
111 self
. daw
= data
. get ( "daw" )
112 self
. diagnosis
= data
. get ( "diagnosis" )
113 self
. note
= data
. get ( "note" )
114 self
. report
= data
. get ( "report" )
115 self
. advice
= data
. get ( "advice" )
116 self
. investigation
= data
. get ( "investigation" )
117 self
. medication
= data
. get ( "medication" )
118 self
. additional
= data
. get ( "additional" )
119 self
. certificate
= data
. get ( "certificate" )
120 self
. custom
= data
. get ( "custom" )
121 if ( "properties" in data
):
122 self
. properties
= data
[ "properties" ]
125 except Exception as e
:
128 def set_data_from_copy ( self
, prescription_copy
):
130 self
. date
= prescription_copy
. date
131 self
. id = prescription_copy
. id
132 self
. pid
= prescription_copy
. pid
133 self
. name
= prescription_copy
. name
134 self
. dob
= prescription_copy
. dob
135 self
. age
= prescription_copy
. age
136 self
. sex
= prescription_copy
. sex
137 self
. address
= prescription_copy
. address
138 self
. contact
= prescription_copy
. contact
139 self
. extra
= prescription_copy
. extra
140 self
. mode
= prescription_copy
. mode
141 self
. daw
= prescription_copy
. daw
142 self
. diagnosis
= prescription_copy
. diagnosis
143 self
. note
= prescription_copy
. note
144 self
. report
= prescription_copy
. report
145 self
. advice
= prescription_copy
. advice
146 self
. investigation
= prescription_copy
. investigation
147 self
. medication
= prescription_copy
. medication
148 self
. additional
= prescription_copy
. additional
149 self
. certificate
= prescription_copy
. certificate
150 self
. custom
= prescription_copy
. custom
151 if ( type ( prescription_copy
. properties
) is dict ):
152 self
. properties
= prescription_copy
. properties
155 self
. prescriber
= prescription_copy
. prescriber
156 except Exception as e
:
161 return ( json
. dumps ( self
, default
= lambda o
: o
.__ dict
__ , indent
= 4 ))
163 def write_to ( self
, file ):
164 with
open ( file , "w" ) as f
:
167 except AttributeError as e
:
169 except Exception as e
:
171 f
. write ( self
. get_json ())
174 def read_from ( self
, file ):
175 with
open ( file , "r" ) as f
:
176 self
. set_data_from_json ( json
. loads ( f
. read ()))
179 def reload_prescriber ( self
, file = None ):
180 self
. prescriber
= Prescriber ( file )