Skip to content

Commit 3e8a1a9

Browse files
committed
add hospital state
1 parent 608dd85 commit 3e8a1a9

6 files changed

Lines changed: 14 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE hospitals DROP COLUMN state;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE hospitals ADD COLUMN state TEXT NOT NULL DEFAULT '';

src/handlers/hospitals.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub struct CreateHospitalRequest {
3232
pub hospital_type: Option<HospitalTypeEnum>,
3333
pub address: String,
3434
pub city: String,
35+
pub state: String,
3536
pub country: String,
3637
pub primary_phone: String,
3738
pub emergency_phone: Option<String>,
@@ -58,6 +59,7 @@ pub struct UpdateHospitalRequest {
5859
pub hospital_type: Option<HospitalTypeEnum>,
5960
pub address: Option<String>,
6061
pub city: Option<String>,
62+
pub state: Option<String>,
6163
pub country: Option<String>,
6264
pub primary_phone: Option<String>,
6365
pub emergency_phone: Option<String>,
@@ -77,6 +79,7 @@ pub struct HospitalResponse {
7779
pub hospital_type: Option<HospitalTypeEnum>,
7880
pub address: String,
7981
pub city: String,
82+
pub state: String,
8083
pub country: String,
8184
pub primary_phone: String,
8285
pub emergency_phone: Option<String>,
@@ -135,6 +138,7 @@ pub async fn create_hospital(
135138
hospital_type: hospital.hospital_type,
136139
address: hospital.address,
137140
city: hospital.city,
141+
state: hospital.state,
138142
country: hospital.country,
139143
primary_phone: hospital.primary_phone,
140144
emergency_phone: hospital.emergency_phone,
@@ -186,6 +190,7 @@ pub async fn update_hospital(
186190
hospital_type: hospital.hospital_type,
187191
address: hospital.address,
188192
city: hospital.city,
193+
state: hospital.state,
189194
country: hospital.country,
190195
primary_phone: hospital.primary_phone,
191196
emergency_phone: hospital.emergency_phone,
@@ -468,6 +473,7 @@ pub async fn get_hospitals(
468473
hospital_type: hospital.hospital_type,
469474
address: hospital.address,
470475
city: hospital.city,
476+
state: hospital.state,
471477
country: hospital.country,
472478
primary_phone: hospital.primary_phone,
473479
emergency_phone: hospital.emergency_phone,
@@ -517,6 +523,7 @@ pub async fn get_hospital_by_id(
517523
hospital_type: hospital.hospital_type,
518524
address: hospital.address,
519525
city: hospital.city,
526+
state: hospital.state,
520527
country: hospital.country,
521528
primary_phone: hospital.primary_phone,
522529
emergency_phone: hospital.emergency_phone,

src/hospitals/service.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct UpdateHospitalChangeset {
2020
hospital_type: Option<HospitalTypeEnum>,
2121
address: Option<String>,
2222
city: Option<String>,
23+
state: Option<String>,
2324
country: Option<String>,
2425
primary_phone: Option<String>,
2526
emergency_phone: Option<String>,
@@ -60,6 +61,7 @@ pub fn create_hospital(
6061
hospital_type.eq(payload.hospital_type),
6162
address.eq(payload.address),
6263
city.eq(payload.city),
64+
state.eq(payload.state),
6365
country.eq(payload.country),
6466
primary_phone.eq(payload.primary_phone),
6567
emergency_phone.eq(payload.emergency_phone),
@@ -151,6 +153,7 @@ pub fn update_hospital(
151153
hospital_type: payload.hospital_type,
152154
address: payload.address,
153155
city: payload.city,
156+
state: payload.state,
154157
country: payload.country,
155158
primary_phone: payload.primary_phone,
156159
emergency_phone: payload.emergency_phone,

src/models.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub struct Hospital {
160160
pub hospital_type: Option<HospitalTypeEnum>,
161161
pub address: String,
162162
pub city: String,
163+
pub state: String,
163164
pub country: String,
164165
pub primary_phone: String,
165166
pub emergency_phone: Option<String>,

src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ diesel::table! {
153153
hospital_type -> Nullable<HospitalType>,
154154
address -> Text,
155155
city -> Text,
156+
state -> Text,
156157
country -> Text,
157158
primary_phone -> Varchar,
158159
emergency_phone -> Nullable<Varchar>,
@@ -197,7 +198,6 @@ diesel::table! {
197198
}
198199
}
199200

200-
201201
diesel::table! {
202202
use diesel::sql_types::*;
203203
use super::sql_types::BloodType;

0 commit comments

Comments
 (0)