├── .gitignore ├── ConsultorioMedico-drawio.png ├── MediApp ├── Validar_MediApp_Postman_v2.postman_collection ├── Validar_MediApp_Postman_v2_1.postman_collection ├── medi-app │ ├── README.md │ ├── next-env.d.ts │ ├── next.config.js │ ├── package.json │ ├── postcss.config.js │ ├── public │ │ ├── next.svg │ │ └── vercel.svg │ ├── src │ │ └── app │ │ │ ├── appointment │ │ │ ├── create │ │ │ │ └── page.tsx │ │ │ ├── edit │ │ │ │ └── [id] │ │ │ │ │ └── page.tsx │ │ │ └── list │ │ │ │ └── page.tsx │ │ │ ├── components │ │ │ └── Headers.tsx │ │ │ ├── doctor │ │ │ ├── create │ │ │ │ └── page.tsx │ │ │ ├── edit │ │ │ │ └── [id] │ │ │ │ │ └── page.tsx │ │ │ └── list │ │ │ │ └── page.tsx │ │ │ ├── fake │ │ │ └── page.tsx │ │ │ ├── favicon.ico │ │ │ ├── globals.css │ │ │ ├── home │ │ │ └── page.tsx │ │ │ ├── layout.tsx │ │ │ ├── pacient │ │ │ ├── create │ │ │ │ └── page.tsx │ │ │ ├── edit │ │ │ │ └── [id] │ │ │ │ │ └── page.tsx │ │ │ └── list │ │ │ │ └── page.tsx │ │ │ ├── page.tsx │ │ │ └── prescription │ │ │ ├── [id] │ │ │ └── create │ │ │ │ └── page.tsx │ │ │ └── upload │ │ │ └── page.tsx │ ├── tailwind.config.ts │ └── tsconfig.json └── src │ ├── __tests__ │ ├── database │ │ └── setup.js │ └── repository │ │ └── PacientRepository.test.js │ ├── database │ └── database.js │ ├── index.js │ ├── middleware │ └── authMiddleware.js │ ├── models │ ├── Appointment.js │ ├── Doctor.js │ ├── Pacient.js │ └── Prescription.js │ ├── package.json │ ├── prescriptions │ └── 65c9050bc278111406e284bb.pdf │ ├── repositories │ ├── AppointmentRepository.js │ ├── DoctorRepository.js │ ├── PacientRepository.js │ └── PrescriptionRepository.js │ ├── routes │ ├── AppointmentController.js │ ├── DoctorController.js │ ├── PacientController.js │ ├── PrescriptionController.js │ └── router.js │ └── services │ ├── AppointmentService.js │ ├── DoctorService.js │ ├── PacientService.js │ └── PrescriptionService.js ├── Mod15 └── Worshop2 │ ├── HELP.md │ ├── build.gradle │ ├── build │ ├── classes │ │ └── java │ │ │ └── main │ │ │ └── com │ │ │ └── example │ │ │ └── Worshop2 │ │ │ ├── GreetingController.class │ │ │ └── Workshop2Application.class │ ├── resources │ │ └── main │ │ │ ├── application.properties │ │ │ ├── static │ │ │ └── index.html │ │ │ └── templates │ │ │ └── greeting.html │ └── tmp │ │ └── compileJava │ │ └── previous-compilation-data.bin │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── worshop │ │ │ ├── GreetingController.java │ │ │ └── Workshop2Application.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── index.html │ │ └── templates │ │ └── greeting.html │ └── test │ └── java │ └── com │ └── example │ └── Worshop2 │ └── Worshop2ApplicationTests.java ├── Mod2 ├── escolha.js ├── hello.js ├── inverno.html ├── package.json ├── path.js ├── teste.txt └── verao.html ├── Mod4 ├── Mod4-ArqXDesign-drawio.png ├── Mod4-ExemplosArq-drawio.png └── Mod4-MVC-drawio.png ├── Mod8 ├── Mod8-ExAppMiddleware-drawio.png └── Mod8-ExBasicoMiddleware-drawio.png ├── Mod9 └── Mod9-EntendendoMiddleware-drawio.png └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | MediApp/medi-app/.next/ 2 | MediApp/medi-app/node_modules/ 3 | MediApp/src/node_modules/ 4 | MediApp/src/.vscode/ 5 | MediApp/package-lock.json 6 | MediApp/src/package-lock.json 7 | MediApp/medi-app/package-lock.json -------------------------------------------------------------------------------- /ConsultorioMedico-drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FaculdadeDescomplica/ProgramacaoII/9a972da395b11260dc960ae4ae146f63d7d2688d/ConsultorioMedico-drawio.png -------------------------------------------------------------------------------- /MediApp/Validar_MediApp_Postman_v2.postman_collection: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "c4a1e7d7-6475-4b80-bb5f-06f65db49878", 4 | "name": "Validar MediApp", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", 6 | "_exporter_id": "32075395", 7 | "_collection_link": "https://grey-resonance-892333.postman.co/workspace/Descomplica-24~4d56aaf3-589c-4ee5-a577-14d7fb2060db/collection/32075395-c4a1e7d7-6475-4b80-bb5f-06f65db49878?action=share&source=collection_link&creator=32075395" 8 | }, 9 | "item": [ 10 | { 11 | "name": "Doctor", 12 | "item": [ 13 | { 14 | "name": "Create Doctor", 15 | "event": [ 16 | { 17 | "listen": "prerequest", 18 | "script": { 19 | "exec": [ 20 | "pm.sendRequest({\r", 21 | " url: \"http://localhost:3001/login\",\r", 22 | " method:\"POST\",\r", 23 | " header: {\r", 24 | " 'Content-Type': 'application/json'\r", 25 | " },\r", 26 | " body: {\r", 27 | " mode: 'raw',\r", 28 | " raw: JSON.stringify({ login: \"jmendes\", password: \"1234X\" })\r", 29 | " }\r", 30 | "}, function (err, res){\r", 31 | " postman.setEnvironmentVariable(\"token\", res.json().token);\r", 32 | "});\r", 33 | "" 34 | ], 35 | "type": "text/javascript" 36 | } 37 | }, 38 | { 39 | "listen": "test", 40 | "script": { 41 | "exec": [ 42 | "var jsonData = JSON.parse(responseBody);\r", 43 | "var id = jsonData._id;\r", 44 | "\r", 45 | "pm.test(\"Must return status code 201 and test values\", () =>{\r", 46 | " pm.expect(jsonData.name).to.be.equal(\"Ana Teixeira\");\r", 47 | " pm.expect(jsonData.login).to.be.equal(\"anateixeira\");\r", 48 | " pm.expect(jsonData.password).to.not.be.undefined;\r", 49 | " pm.expect(jsonData.medicalSpecialty).to.be.equal(\"Nutrologia\");\r", 50 | " pm.expect(jsonData.medicalRegistration).to.be.equal(\"90931\");\r", 51 | " pm.expect(jsonData.email).to.be.equal(\"anateixeira@gg.com\");\r", 52 | " pm.expect(jsonData.phone).to.be.equal(\"31 98875-3233\");\r", 53 | "\r", 54 | " //Assert response status code\r", 55 | " pm.response.to.have.status(201);\r", 56 | " \r", 57 | "});\r", 58 | "\r", 59 | "pm.sendRequest({\r", 60 | " url: \"localhost:3001/doctors/\" + id,\r", 61 | " method:\"DELETE\",\r", 62 | " header: {\r", 63 | " 'Content-Type': 'application/json',\r", 64 | " 'Authorization': pm.environment.get(\"token\")\r", 65 | " }\r", 66 | "}, function (err, res){\r", 67 | " pm.response.to.have.status(201);\r", 68 | "});\r", 69 | "\r", 70 | "pm.sendRequest({\r", 71 | " url: \"localhost:3001/getDoctor/\" + id,\r", 72 | " method:\"GET\",\r", 73 | " header: {\r", 74 | " 'Content-Type': 'application/json',\r", 75 | " 'Authorization': pm.environment.get(\"token\")\r", 76 | " }\r", 77 | "}, function (err, res){\r", 78 | " pm.response.to.have.status(201);\r", 79 | " pm.expect(pm.responseBody).to.be.equal(undefined);\r", 80 | "});" 81 | ], 82 | "type": "text/javascript" 83 | } 84 | } 85 | ], 86 | "request": { 87 | "method": "POST", 88 | "header": [ 89 | { 90 | "key": "Authorization", 91 | "value": "{{token}}", 92 | "type": "text" 93 | }, 94 | { 95 | "key": "", 96 | "value": "", 97 | "type": "text", 98 | "disabled": true 99 | } 100 | ], 101 | "body": { 102 | "mode": "raw", 103 | "raw": "{\r\n \"name\": \"Ana Teixeira\",\r\n \"login\": \"anateixeira\",\r\n \"password\": \"1234X\",\r\n \"medicalSpecialty\": \"Nutrologia\",\r\n \"medicalRegistration\": \"90931\",\r\n \"email\": \"anateixeira@gg.com\",\r\n \"phone\": \"31 97564-3233\"\r\n}", 104 | "options": { 105 | "raw": { 106 | "language": "json" 107 | } 108 | } 109 | }, 110 | "url": "localhost:3001/postDoctor" 111 | }, 112 | "response": [] 113 | }, 114 | { 115 | "name": "Read Doctor", 116 | "request": { 117 | "method": "GET", 118 | "header": [ 119 | { 120 | "key": "Authorization", 121 | "value": "{{token}}", 122 | "type": "text" 123 | } 124 | ], 125 | "url": "localhost:3001/getDoctor/659f79d7b035dccba12b3873" 126 | }, 127 | "response": [] 128 | }, 129 | { 130 | "name": "Get All Doctors", 131 | "request": { 132 | "method": "GET", 133 | "header": [ 134 | { 135 | "key": "Authorization", 136 | "value": "{{token}}", 137 | "type": "text" 138 | } 139 | ], 140 | "url": "localhost:3001/doctors/" 141 | }, 142 | "response": [] 143 | }, 144 | { 145 | "name": "Update Doctor", 146 | "request": { 147 | "method": "PUT", 148 | "header": [ 149 | { 150 | "key": "Authorization", 151 | "value": "{{token}}", 152 | "type": "text" 153 | } 154 | ], 155 | "body": { 156 | "mode": "raw", 157 | "raw": "{\r\n \"_id\": \"65a5cf97b60f6ce0c41c6dd9\",\r\n \"name\": \"Joao Mendes Filho de Jesus\",\r\n \"login\": \"jmendesf\",\r\n \"password\": \"$2b$10$Kej78U3rCXx6BC9LVvtHhOsdWhQtjLuBeGeQaJ1ZbmNOzyTB/1pH2\",\r\n \"medicalSpecialty\": \"Psiquiatra\",\r\n \"medicalRegistration\": \"17607\",\r\n \"email\": \"jmendes@gg.com\",\r\n \"phone\": \"31 92232-3233\",\r\n \"createdAt\": \"2024-01-16T00:36:39.150Z\",\r\n \"__v\": 0\r\n}", 158 | "options": { 159 | "raw": { 160 | "language": "json" 161 | } 162 | } 163 | }, 164 | "url": "localhost:3001/doctors/65a5cf97b60f6ce0c41c6dd9" 165 | }, 166 | "response": [] 167 | }, 168 | { 169 | "name": "Delete Doctor", 170 | "request": { 171 | "method": "DELETE", 172 | "header": [ 173 | { 174 | "key": "Authorization", 175 | "value": "{{token}}", 176 | "type": "text" 177 | } 178 | ], 179 | "url": "localhost:3001/doctors/65a5cf97b60f6ce0c41c6dd9" 180 | }, 181 | "response": [] 182 | }, 183 | { 184 | "name": "Test Doctor Post", 185 | "event": [ 186 | { 187 | "listen": "test", 188 | "script": { 189 | "exec": [ 190 | "var jsonData = JSON.parse(responseBody);\r", 191 | "var id = jsonData._id;\r", 192 | "\r", 193 | "pm.test(\"Must return status code 201 and test values\", () =>{\r", 194 | " pm.expect(jsonData.name).to.be.equal(\"Teste Postman\");\r", 195 | " pm.expect(jsonData.login).to.be.equal(\"user_postman\");\r", 196 | " pm.expect(jsonData.password).to.not.be.undefined;\r", 197 | " pm.expect(jsonData.medicalSpecialty).to.be.equal(\"Test Postman\");\r", 198 | " pm.expect(jsonData.medicalRegistration).to.be.equal(\"2235478\");\r", 199 | " pm.expect(jsonData.email).to.be.equal(\"test@gg.com\");\r", 200 | " pm.expect(jsonData.phone).to.be.equal(\"31 98875-3233\");\r", 201 | "\r", 202 | " //Assert response status code\r", 203 | " pm.response.to.have.status(201);\r", 204 | " \r", 205 | "});\r", 206 | "\r", 207 | "pm.sendRequest({\r", 208 | " url: \"localhost:3001/doctors/\" + id,\r", 209 | " method:\"DELETE\",\r", 210 | " header: {\r", 211 | " 'Content-Type': 'application/json',\r", 212 | " 'Authorization': pm.environment.get(\"token\")\r", 213 | " }\r", 214 | "}, function (err, res){\r", 215 | " pm.response.to.have.status(201);\r", 216 | "});\r", 217 | "\r", 218 | "pm.sendRequest({\r", 219 | " url: \"localhost:3001/getDoctor/\" + id,\r", 220 | " method:\"GET\",\r", 221 | " header: {\r", 222 | " 'Content-Type': 'application/json',\r", 223 | " 'Authorization': pm.environment.get(\"token\")\r", 224 | " }\r", 225 | "}, function (err, res){\r", 226 | " pm.response.to.have.status(201);\r", 227 | " pm.expect(pm.responseBody).to.be.equal(undefined);\r", 228 | "});\r", 229 | "" 230 | ], 231 | "type": "text/javascript" 232 | } 233 | }, 234 | { 235 | "listen": "prerequest", 236 | "script": { 237 | "exec": [ 238 | "pm.sendRequest({\r", 239 | " url: \"http://localhost:3001/login\",\r", 240 | " method:\"POST\",\r", 241 | " header: {\r", 242 | " 'Content-Type': 'application/json'\r", 243 | " },\r", 244 | " body: {\r", 245 | " mode: 'raw',\r", 246 | " raw: JSON.stringify({ login: \"jmendes\", password: \"1234X\" })\r", 247 | " }\r", 248 | "}, function (err, res){\r", 249 | " postman.setEnvironmentVariable(\"token\", res.json().token);\r", 250 | "});" 251 | ], 252 | "type": "text/javascript" 253 | } 254 | } 255 | ], 256 | "request": { 257 | "method": "POST", 258 | "header": [ 259 | { 260 | "key": "Authorization", 261 | "value": "{{token}}", 262 | "type": "default" 263 | } 264 | ], 265 | "body": { 266 | "mode": "raw", 267 | "raw": "{\r\n \"name\": \"Teste Postman\",\r\n \"login\": \"user_postman\",\r\n \"password\": \"12345\",\r\n \"medicalSpecialty\": \"Test Postman\",\r\n \"medicalRegistration\": \"2235478\",\r\n \"email\": \"test@gg.com\",\r\n \"phone\": \"31 98875-3233\"\r\n}", 268 | "options": { 269 | "raw": { 270 | "language": "json" 271 | } 272 | } 273 | }, 274 | "url": "localhost:3001/postDoctor" 275 | }, 276 | "response": [] 277 | } 278 | ] 279 | }, 280 | { 281 | "name": "Appointment", 282 | "item": [ 283 | { 284 | "name": "Create Appointment", 285 | "request": { 286 | "method": "POST", 287 | "header": [ 288 | { 289 | "key": "Authorization", 290 | "value": "{{token}}", 291 | "type": "text" 292 | } 293 | ], 294 | "body": { 295 | "mode": "raw", 296 | "raw": "{\r\n \"date\": \"2024-01-25T14:44:56.905+00:00\",\r\n \"doctorId\": \"65a7c3ca9492e73cb2ae33ed\",\r\n \"pacientId\": \"65a5cdebb60f6ce0c41c6dcf\"\r\n}", 297 | "options": { 298 | "raw": { 299 | "language": "json" 300 | } 301 | } 302 | }, 303 | "url": "localhost:3001/postAppointment" 304 | }, 305 | "response": [] 306 | }, 307 | { 308 | "name": "Read Appointment", 309 | "request": { 310 | "method": "GET", 311 | "header": [ 312 | { 313 | "key": "Authorization", 314 | "value": "{{token}}", 315 | "type": "text" 316 | } 317 | ], 318 | "url": "localhost:3001/getAppointment/659e0f5182923bf214ba7d13" 319 | }, 320 | "response": [] 321 | }, 322 | { 323 | "name": "Update Appointment", 324 | "request": { 325 | "method": "PUT", 326 | "header": [ 327 | { 328 | "key": "Authorization", 329 | "value": "{{token}}", 330 | "type": "text" 331 | } 332 | ], 333 | "body": { 334 | "mode": "raw", 335 | "raw": "{\r\n \"date\": \"2024-01-13T14:44:56.905Z\",\r\n \"doctorId\": \"659f79d7b035dccba12b3873\",\r\n \"pacientId\": \"659e120c4bfd6d9c23dedfb9\"\r\n}", 336 | "options": { 337 | "raw": { 338 | "language": "json" 339 | } 340 | } 341 | }, 342 | "url": "localhost:3001/appointments/65a5d041b60f6ce0c41c6ddd" 343 | }, 344 | "response": [] 345 | }, 346 | { 347 | "name": "Delete Appointment", 348 | "request": { 349 | "method": "DELETE", 350 | "header": [ 351 | { 352 | "key": "Authorization", 353 | "value": "{{token}}", 354 | "type": "text" 355 | } 356 | ], 357 | "url": "localhost:3001/appointments/65a5d4a5b60f6ce0c41c6df1" 358 | }, 359 | "response": [] 360 | }, 361 | { 362 | "name": "Get All Appointment", 363 | "request": { 364 | "method": "GET", 365 | "header": [ 366 | { 367 | "key": "Authorization", 368 | "value": "{{token}}", 369 | "type": "text" 370 | } 371 | ], 372 | "url": { 373 | "raw": "localhost:3001/appointments", 374 | "host": [ 375 | "localhost" 376 | ], 377 | "port": "3001", 378 | "path": [ 379 | "appointments" 380 | ], 381 | "query": [ 382 | { 383 | "key": "", 384 | "value": null, 385 | "disabled": true 386 | } 387 | ] 388 | } 389 | }, 390 | "response": [] 391 | }, 392 | { 393 | "name": "Reschudule", 394 | "request": { 395 | "method": "PUT", 396 | "header": [ 397 | { 398 | "key": "Authorization", 399 | "value": "{{token}}", 400 | "type": "text" 401 | } 402 | ], 403 | "body": { 404 | "mode": "raw", 405 | "raw": "{\r\n \"date\": \"2024-01-27T10:45:56.095Z\"\r\n}", 406 | "options": { 407 | "raw": { 408 | "language": "json" 409 | } 410 | } 411 | }, 412 | "url": "localhost:3001/reschedule/65a5d4a5b60f6ce0c41c6df1" 413 | }, 414 | "response": [] 415 | } 416 | ] 417 | }, 418 | { 419 | "name": "Pacient", 420 | "item": [ 421 | { 422 | "name": "Create Pacient", 423 | "request": { 424 | "method": "POST", 425 | "header": [ 426 | { 427 | "key": "Authorization", 428 | "value": "{{token}}", 429 | "type": "text" 430 | } 431 | ], 432 | "body": { 433 | "mode": "raw", 434 | "raw": "{\r\n \"name\": \"Ana Teixeira\",\r\n \"birthDate\": \"1993-05-05\",\r\n \"email\": \"anat@gg.com\",\r\n \"phone\": \"31 91114-5555\"\r\n}\r\n", 435 | "options": { 436 | "raw": { 437 | "language": "json" 438 | } 439 | } 440 | }, 441 | "url": "localhost:3001/postPacient" 442 | }, 443 | "response": [] 444 | }, 445 | { 446 | "name": "Read Pacient", 447 | "request": { 448 | "method": "GET", 449 | "header": [ 450 | { 451 | "key": "Authorization", 452 | "value": "{{token}}", 453 | "type": "text" 454 | } 455 | ], 456 | "url": "localhost:3001/getPacient/65a5cdebb60f6ce0c41c6dcf" 457 | }, 458 | "response": [] 459 | }, 460 | { 461 | "name": "Update Pacient", 462 | "request": { 463 | "method": "PUT", 464 | "header": [ 465 | { 466 | "key": "Authorization", 467 | "value": "{{token}}", 468 | "type": "text" 469 | } 470 | ], 471 | "body": { 472 | "mode": "raw", 473 | "raw": "{\r\n \"_id\": \"65a5cdebb60f6ce0c41c6dcf\",\r\n \"name\": \"Maria de Jesus Filha\",\r\n \"birthDate\": \"1944-05-05T00:00:00.000Z\",\r\n \"email\": \"mariajf@gg.com\",\r\n \"phone\": \"32 91114-5555\"\r\n}", 474 | "options": { 475 | "raw": { 476 | "language": "json" 477 | } 478 | } 479 | }, 480 | "url": "localhost:3001/pacients/65a5cdebb60f6ce0c41c6dcf" 481 | }, 482 | "response": [] 483 | } 484 | ] 485 | }, 486 | { 487 | "name": "Prescription", 488 | "item": [ 489 | { 490 | "name": "Create Prescription", 491 | "request": { 492 | "method": "POST", 493 | "header": [ 494 | { 495 | "key": "Authorization", 496 | "value": "{{token}}", 497 | "type": "text" 498 | } 499 | ], 500 | "body": { 501 | "mode": "raw", 502 | "raw": "{\r\n \"date\": \"2024-01-26\",\r\n \"appointmentId\": \"65a7c5d1338647b902d122cb\",\r\n \"medicine\": \"Xarope\",\r\n \"dosage\": \"10ml\",\r\n \"instructions\":\"\"\r\n}\r\n", 503 | "options": { 504 | "raw": { 505 | "language": "json" 506 | } 507 | } 508 | }, 509 | "url": "localhost:3001/postPrescription" 510 | }, 511 | "response": [] 512 | }, 513 | { 514 | "name": "Read Prescription", 515 | "request": { 516 | "method": "GET", 517 | "header": [ 518 | { 519 | "key": "Authorization", 520 | "value": "{{token}}", 521 | "type": "text" 522 | } 523 | ], 524 | "url": "localhost:3001/getPrescription/65a5ce3db60f6ce0c41c6dd1" 525 | }, 526 | "response": [] 527 | }, 528 | { 529 | "name": "Update Prescription", 530 | "request": { 531 | "method": "PUT", 532 | "header": [ 533 | { 534 | "key": "Authorization", 535 | "value": "{{token}}", 536 | "type": "text" 537 | } 538 | ], 539 | "body": { 540 | "mode": "raw", 541 | "raw": "{\r\n \"date\": \"\",\r\n \"appointmentId\": \"659e0f5182923bf214ba7d13\",\r\n \"medicine\": \"Dipirona, Paracetamol\",\r\n \"dosage\": \"33\",\r\n \"instructions\": \"A cada 6 horas ou em caso de dor\"\r\n}", 542 | "options": { 543 | "raw": { 544 | "language": "json" 545 | } 546 | } 547 | }, 548 | "url": "localhost:3001/prescriptions/65a5ce3db60f6ce0c41c6dd1" 549 | }, 550 | "response": [] 551 | }, 552 | { 553 | "name": "File", 554 | "request": { 555 | "method": "GET", 556 | "header": [ 557 | { 558 | "key": "Authorization", 559 | "value": "{{token}}", 560 | "type": "text" 561 | } 562 | ], 563 | "url": "localhost:3001/generatePrescription/65a7c66d2400a2834369caa6" 564 | }, 565 | "response": [] 566 | } 567 | ] 568 | }, 569 | { 570 | "name": "Login", 571 | "event": [ 572 | { 573 | "listen": "test", 574 | "script": { 575 | "exec": [ 576 | "var jsonData = JSON.parse(responseBody);\r", 577 | "postman.setEnvironmentVariable(\"token\", jsonData.token);" 578 | ], 579 | "type": "text/javascript" 580 | } 581 | }, 582 | { 583 | "listen": "prerequest", 584 | "script": { 585 | "exec": [ 586 | "" 587 | ], 588 | "type": "text/javascript" 589 | } 590 | } 591 | ], 592 | "request": { 593 | "method": "POST", 594 | "header": [], 595 | "body": { 596 | "mode": "raw", 597 | "raw": "{\r\n \"login\": \"jmendes\",\r\n \"password\":\"1234X\"\r\n}", 598 | "options": { 599 | "raw": { 600 | "language": "json" 601 | } 602 | } 603 | }, 604 | "url": "localhost:3001/login" 605 | }, 606 | "response": [] 607 | } 608 | ] 609 | } -------------------------------------------------------------------------------- /MediApp/Validar_MediApp_Postman_v2_1.postman_collection: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "c4a1e7d7-6475-4b80-bb5f-06f65db49878", 4 | "name": "Validar MediApp", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", 6 | "_exporter_id": "32075395", 7 | "_collection_link": "https://grey-resonance-892333.postman.co/workspace/Descomplica-24~4d56aaf3-589c-4ee5-a577-14d7fb2060db/collection/32075395-c4a1e7d7-6475-4b80-bb5f-06f65db49878?action=share&source=collection_link&creator=32075395" 8 | }, 9 | "item": [ 10 | { 11 | "name": "Doctor", 12 | "item": [ 13 | { 14 | "name": "Create Doctor", 15 | "event": [ 16 | { 17 | "listen": "prerequest", 18 | "script": { 19 | "exec": [ 20 | "pm.sendRequest({\r", 21 | " url: \"http://localhost:3001/login\",\r", 22 | " method:\"POST\",\r", 23 | " header: {\r", 24 | " 'Content-Type': 'application/json'\r", 25 | " },\r", 26 | " body: {\r", 27 | " mode: 'raw',\r", 28 | " raw: JSON.stringify({ login: \"jmendes\", password: \"1234X\" })\r", 29 | " }\r", 30 | "}, function (err, res){\r", 31 | " postman.setEnvironmentVariable(\"token\", res.json().token);\r", 32 | "});\r", 33 | "" 34 | ], 35 | "type": "text/javascript" 36 | } 37 | }, 38 | { 39 | "listen": "test", 40 | "script": { 41 | "exec": [ 42 | "var jsonData = JSON.parse(responseBody);\r", 43 | "var id = jsonData._id;\r", 44 | "\r", 45 | "pm.test(\"Must return status code 201 and test values\", () =>{\r", 46 | " pm.expect(jsonData.name).to.be.equal(\"Ana Teixeira\");\r", 47 | " pm.expect(jsonData.login).to.be.equal(\"anateixeira\");\r", 48 | " pm.expect(jsonData.password).to.not.be.undefined;\r", 49 | " pm.expect(jsonData.medicalSpecialty).to.be.equal(\"Nutrologia\");\r", 50 | " pm.expect(jsonData.medicalRegistration).to.be.equal(\"90931\");\r", 51 | " pm.expect(jsonData.email).to.be.equal(\"anateixeira@gg.com\");\r", 52 | " pm.expect(jsonData.phone).to.be.equal(\"31 98875-3233\");\r", 53 | "\r", 54 | " //Assert response status code\r", 55 | " pm.response.to.have.status(201);\r", 56 | " \r", 57 | "});\r", 58 | "\r", 59 | "pm.sendRequest({\r", 60 | " url: \"localhost:3001/doctors/\" + id,\r", 61 | " method:\"DELETE\",\r", 62 | " header: {\r", 63 | " 'Content-Type': 'application/json',\r", 64 | " 'Authorization': pm.environment.get(\"token\")\r", 65 | " }\r", 66 | "}, function (err, res){\r", 67 | " pm.response.to.have.status(201);\r", 68 | "});\r", 69 | "\r", 70 | "pm.sendRequest({\r", 71 | " url: \"localhost:3001/getDoctor/\" + id,\r", 72 | " method:\"GET\",\r", 73 | " header: {\r", 74 | " 'Content-Type': 'application/json',\r", 75 | " 'Authorization': pm.environment.get(\"token\")\r", 76 | " }\r", 77 | "}, function (err, res){\r", 78 | " pm.response.to.have.status(201);\r", 79 | " pm.expect(pm.responseBody).to.be.equal(undefined);\r", 80 | "});" 81 | ], 82 | "type": "text/javascript" 83 | } 84 | } 85 | ], 86 | "request": { 87 | "method": "POST", 88 | "header": [ 89 | { 90 | "key": "Authorization", 91 | "value": "{{token}}", 92 | "type": "text" 93 | }, 94 | { 95 | "key": "", 96 | "value": "", 97 | "type": "text", 98 | "disabled": true 99 | } 100 | ], 101 | "body": { 102 | "mode": "raw", 103 | "raw": "{\r\n \"name\": \"Ana Teixeira\",\r\n \"login\": \"anateixeira\",\r\n \"password\": \"1234X\",\r\n \"medicalSpecialty\": \"Nutrologia\",\r\n \"medicalRegistration\": \"90931\",\r\n \"email\": \"anateixeira@gg.com\",\r\n \"phone\": \"31 97564-3233\"\r\n}", 104 | "options": { 105 | "raw": { 106 | "language": "json" 107 | } 108 | } 109 | }, 110 | "url": { 111 | "raw": "localhost:3001/postDoctor", 112 | "host": [ 113 | "localhost" 114 | ], 115 | "port": "3001", 116 | "path": [ 117 | "postDoctor" 118 | ] 119 | } 120 | }, 121 | "response": [] 122 | }, 123 | { 124 | "name": "Read Doctor", 125 | "request": { 126 | "method": "GET", 127 | "header": [ 128 | { 129 | "key": "Authorization", 130 | "value": "{{token}}", 131 | "type": "text" 132 | } 133 | ], 134 | "url": { 135 | "raw": "localhost:3001/getDoctor/659f79d7b035dccba12b3873", 136 | "host": [ 137 | "localhost" 138 | ], 139 | "port": "3001", 140 | "path": [ 141 | "getDoctor", 142 | "659f79d7b035dccba12b3873" 143 | ] 144 | } 145 | }, 146 | "response": [] 147 | }, 148 | { 149 | "name": "Get All Doctors", 150 | "request": { 151 | "method": "GET", 152 | "header": [ 153 | { 154 | "key": "Authorization", 155 | "value": "{{token}}", 156 | "type": "text" 157 | } 158 | ], 159 | "url": { 160 | "raw": "localhost:3001/doctors/", 161 | "host": [ 162 | "localhost" 163 | ], 164 | "port": "3001", 165 | "path": [ 166 | "doctors", 167 | "" 168 | ] 169 | } 170 | }, 171 | "response": [] 172 | }, 173 | { 174 | "name": "Update Doctor", 175 | "request": { 176 | "method": "PUT", 177 | "header": [ 178 | { 179 | "key": "Authorization", 180 | "value": "{{token}}", 181 | "type": "text" 182 | } 183 | ], 184 | "body": { 185 | "mode": "raw", 186 | "raw": "{\r\n \"_id\": \"65a5cf97b60f6ce0c41c6dd9\",\r\n \"name\": \"Joao Mendes Filho de Jesus\",\r\n \"login\": \"jmendesf\",\r\n \"password\": \"$2b$10$Kej78U3rCXx6BC9LVvtHhOsdWhQtjLuBeGeQaJ1ZbmNOzyTB/1pH2\",\r\n \"medicalSpecialty\": \"Psiquiatra\",\r\n \"medicalRegistration\": \"17607\",\r\n \"email\": \"jmendes@gg.com\",\r\n \"phone\": \"31 92232-3233\",\r\n \"createdAt\": \"2024-01-16T00:36:39.150Z\",\r\n \"__v\": 0\r\n}", 187 | "options": { 188 | "raw": { 189 | "language": "json" 190 | } 191 | } 192 | }, 193 | "url": { 194 | "raw": "localhost:3001/doctors/65a5cf97b60f6ce0c41c6dd9", 195 | "host": [ 196 | "localhost" 197 | ], 198 | "port": "3001", 199 | "path": [ 200 | "doctors", 201 | "65a5cf97b60f6ce0c41c6dd9" 202 | ] 203 | } 204 | }, 205 | "response": [] 206 | }, 207 | { 208 | "name": "Delete Doctor", 209 | "request": { 210 | "method": "DELETE", 211 | "header": [ 212 | { 213 | "key": "Authorization", 214 | "value": "{{token}}", 215 | "type": "text" 216 | } 217 | ], 218 | "url": { 219 | "raw": "localhost:3001/doctors/65a5cf97b60f6ce0c41c6dd9", 220 | "host": [ 221 | "localhost" 222 | ], 223 | "port": "3001", 224 | "path": [ 225 | "doctors", 226 | "65a5cf97b60f6ce0c41c6dd9" 227 | ] 228 | } 229 | }, 230 | "response": [] 231 | }, 232 | { 233 | "name": "Test Doctor Post", 234 | "event": [ 235 | { 236 | "listen": "test", 237 | "script": { 238 | "exec": [ 239 | "var jsonData = JSON.parse(responseBody);\r", 240 | "var id = jsonData._id;\r", 241 | "\r", 242 | "pm.test(\"Must return status code 201 and test values\", () =>{\r", 243 | " pm.expect(jsonData.name).to.be.equal(\"Teste Postman\");\r", 244 | " pm.expect(jsonData.login).to.be.equal(\"user_postman\");\r", 245 | " pm.expect(jsonData.password).to.not.be.undefined;\r", 246 | " pm.expect(jsonData.medicalSpecialty).to.be.equal(\"Test Postman\");\r", 247 | " pm.expect(jsonData.medicalRegistration).to.be.equal(\"2235478\");\r", 248 | " pm.expect(jsonData.email).to.be.equal(\"test@gg.com\");\r", 249 | " pm.expect(jsonData.phone).to.be.equal(\"31 98875-3233\");\r", 250 | "\r", 251 | " //Assert response status code\r", 252 | " pm.response.to.have.status(201);\r", 253 | " \r", 254 | "});\r", 255 | "\r", 256 | "pm.sendRequest({\r", 257 | " url: \"localhost:3001/doctors/\" + id,\r", 258 | " method:\"DELETE\",\r", 259 | " header: {\r", 260 | " 'Content-Type': 'application/json',\r", 261 | " 'Authorization': pm.environment.get(\"token\")\r", 262 | " }\r", 263 | "}, function (err, res){\r", 264 | " pm.response.to.have.status(201);\r", 265 | "});\r", 266 | "\r", 267 | "pm.sendRequest({\r", 268 | " url: \"localhost:3001/getDoctor/\" + id,\r", 269 | " method:\"GET\",\r", 270 | " header: {\r", 271 | " 'Content-Type': 'application/json',\r", 272 | " 'Authorization': pm.environment.get(\"token\")\r", 273 | " }\r", 274 | "}, function (err, res){\r", 275 | " pm.response.to.have.status(201);\r", 276 | " pm.expect(pm.responseBody).to.be.equal(undefined);\r", 277 | "});\r", 278 | "" 279 | ], 280 | "type": "text/javascript" 281 | } 282 | }, 283 | { 284 | "listen": "prerequest", 285 | "script": { 286 | "exec": [ 287 | "pm.sendRequest({\r", 288 | " url: \"http://localhost:3001/login\",\r", 289 | " method:\"POST\",\r", 290 | " header: {\r", 291 | " 'Content-Type': 'application/json'\r", 292 | " },\r", 293 | " body: {\r", 294 | " mode: 'raw',\r", 295 | " raw: JSON.stringify({ login: \"jmendes\", password: \"1234X\" })\r", 296 | " }\r", 297 | "}, function (err, res){\r", 298 | " postman.setEnvironmentVariable(\"token\", res.json().token);\r", 299 | "});" 300 | ], 301 | "type": "text/javascript" 302 | } 303 | } 304 | ], 305 | "request": { 306 | "method": "POST", 307 | "header": [ 308 | { 309 | "key": "Authorization", 310 | "value": "{{token}}", 311 | "type": "default" 312 | } 313 | ], 314 | "body": { 315 | "mode": "raw", 316 | "raw": "{\r\n \"name\": \"Teste Postman\",\r\n \"login\": \"user_postman\",\r\n \"password\": \"12345\",\r\n \"medicalSpecialty\": \"Test Postman\",\r\n \"medicalRegistration\": \"2235478\",\r\n \"email\": \"test@gg.com\",\r\n \"phone\": \"31 98875-3233\"\r\n}", 317 | "options": { 318 | "raw": { 319 | "language": "json" 320 | } 321 | } 322 | }, 323 | "url": { 324 | "raw": "localhost:3001/postDoctor", 325 | "host": [ 326 | "localhost" 327 | ], 328 | "port": "3001", 329 | "path": [ 330 | "postDoctor" 331 | ] 332 | } 333 | }, 334 | "response": [] 335 | } 336 | ] 337 | }, 338 | { 339 | "name": "Appointment", 340 | "item": [ 341 | { 342 | "name": "Create Appointment", 343 | "request": { 344 | "method": "POST", 345 | "header": [ 346 | { 347 | "key": "Authorization", 348 | "value": "{{token}}", 349 | "type": "text" 350 | } 351 | ], 352 | "body": { 353 | "mode": "raw", 354 | "raw": "{\r\n \"date\": \"2024-01-25T14:44:56.905+00:00\",\r\n \"doctorId\": \"65a7c3ca9492e73cb2ae33ed\",\r\n \"pacientId\": \"65a5cdebb60f6ce0c41c6dcf\"\r\n}", 355 | "options": { 356 | "raw": { 357 | "language": "json" 358 | } 359 | } 360 | }, 361 | "url": { 362 | "raw": "localhost:3001/postAppointment", 363 | "host": [ 364 | "localhost" 365 | ], 366 | "port": "3001", 367 | "path": [ 368 | "postAppointment" 369 | ] 370 | } 371 | }, 372 | "response": [] 373 | }, 374 | { 375 | "name": "Read Appointment", 376 | "request": { 377 | "method": "GET", 378 | "header": [ 379 | { 380 | "key": "Authorization", 381 | "value": "{{token}}", 382 | "type": "text" 383 | } 384 | ], 385 | "url": { 386 | "raw": "localhost:3001/getAppointment/659e0f5182923bf214ba7d13", 387 | "host": [ 388 | "localhost" 389 | ], 390 | "port": "3001", 391 | "path": [ 392 | "getAppointment", 393 | "659e0f5182923bf214ba7d13" 394 | ] 395 | } 396 | }, 397 | "response": [] 398 | }, 399 | { 400 | "name": "Update Appointment", 401 | "request": { 402 | "method": "PUT", 403 | "header": [ 404 | { 405 | "key": "Authorization", 406 | "value": "{{token}}", 407 | "type": "text" 408 | } 409 | ], 410 | "body": { 411 | "mode": "raw", 412 | "raw": "{\r\n \"date\": \"2024-01-13T14:44:56.905Z\",\r\n \"doctorId\": \"659f79d7b035dccba12b3873\",\r\n \"pacientId\": \"659e120c4bfd6d9c23dedfb9\"\r\n}", 413 | "options": { 414 | "raw": { 415 | "language": "json" 416 | } 417 | } 418 | }, 419 | "url": { 420 | "raw": "localhost:3001/appointments/65a5d041b60f6ce0c41c6ddd", 421 | "host": [ 422 | "localhost" 423 | ], 424 | "port": "3001", 425 | "path": [ 426 | "appointments", 427 | "65a5d041b60f6ce0c41c6ddd" 428 | ] 429 | } 430 | }, 431 | "response": [] 432 | }, 433 | { 434 | "name": "Delete Appointment", 435 | "request": { 436 | "method": "DELETE", 437 | "header": [ 438 | { 439 | "key": "Authorization", 440 | "value": "{{token}}", 441 | "type": "text" 442 | } 443 | ], 444 | "url": { 445 | "raw": "localhost:3001/appointments/65a5d4a5b60f6ce0c41c6df1", 446 | "host": [ 447 | "localhost" 448 | ], 449 | "port": "3001", 450 | "path": [ 451 | "appointments", 452 | "65a5d4a5b60f6ce0c41c6df1" 453 | ] 454 | } 455 | }, 456 | "response": [] 457 | }, 458 | { 459 | "name": "Get All Appointment", 460 | "request": { 461 | "method": "GET", 462 | "header": [ 463 | { 464 | "key": "Authorization", 465 | "value": "{{token}}", 466 | "type": "text" 467 | } 468 | ], 469 | "url": { 470 | "raw": "localhost:3001/appointments", 471 | "host": [ 472 | "localhost" 473 | ], 474 | "port": "3001", 475 | "path": [ 476 | "appointments" 477 | ], 478 | "query": [ 479 | { 480 | "key": "", 481 | "value": null, 482 | "disabled": true 483 | } 484 | ] 485 | } 486 | }, 487 | "response": [] 488 | }, 489 | { 490 | "name": "Reschudule", 491 | "request": { 492 | "method": "PUT", 493 | "header": [ 494 | { 495 | "key": "Authorization", 496 | "value": "{{token}}", 497 | "type": "text" 498 | } 499 | ], 500 | "body": { 501 | "mode": "raw", 502 | "raw": "{\r\n \"date\": \"2024-01-27T10:45:56.095Z\"\r\n}", 503 | "options": { 504 | "raw": { 505 | "language": "json" 506 | } 507 | } 508 | }, 509 | "url": { 510 | "raw": "localhost:3001/reschedule/65a5d4a5b60f6ce0c41c6df1", 511 | "host": [ 512 | "localhost" 513 | ], 514 | "port": "3001", 515 | "path": [ 516 | "reschedule", 517 | "65a5d4a5b60f6ce0c41c6df1" 518 | ] 519 | } 520 | }, 521 | "response": [] 522 | } 523 | ] 524 | }, 525 | { 526 | "name": "Pacient", 527 | "item": [ 528 | { 529 | "name": "Create Pacient", 530 | "request": { 531 | "method": "POST", 532 | "header": [ 533 | { 534 | "key": "Authorization", 535 | "value": "{{token}}", 536 | "type": "text" 537 | } 538 | ], 539 | "body": { 540 | "mode": "raw", 541 | "raw": "{\r\n \"name\": \"Ana Teixeira\",\r\n \"birthDate\": \"1993-05-05\",\r\n \"email\": \"anat@gg.com\",\r\n \"phone\": \"31 91114-5555\"\r\n}\r\n", 542 | "options": { 543 | "raw": { 544 | "language": "json" 545 | } 546 | } 547 | }, 548 | "url": { 549 | "raw": "localhost:3001/postPacient", 550 | "host": [ 551 | "localhost" 552 | ], 553 | "port": "3001", 554 | "path": [ 555 | "postPacient" 556 | ] 557 | } 558 | }, 559 | "response": [] 560 | }, 561 | { 562 | "name": "Read Pacient", 563 | "request": { 564 | "method": "GET", 565 | "header": [ 566 | { 567 | "key": "Authorization", 568 | "value": "{{token}}", 569 | "type": "text" 570 | } 571 | ], 572 | "url": { 573 | "raw": "localhost:3001/getPacient/65a5cdebb60f6ce0c41c6dcf", 574 | "host": [ 575 | "localhost" 576 | ], 577 | "port": "3001", 578 | "path": [ 579 | "getPacient", 580 | "65a5cdebb60f6ce0c41c6dcf" 581 | ] 582 | } 583 | }, 584 | "response": [] 585 | }, 586 | { 587 | "name": "Update Pacient", 588 | "request": { 589 | "method": "PUT", 590 | "header": [ 591 | { 592 | "key": "Authorization", 593 | "value": "{{token}}", 594 | "type": "text" 595 | } 596 | ], 597 | "body": { 598 | "mode": "raw", 599 | "raw": "{\r\n \"_id\": \"65a5cdebb60f6ce0c41c6dcf\",\r\n \"name\": \"Maria de Jesus Filha\",\r\n \"birthDate\": \"1944-05-05T00:00:00.000Z\",\r\n \"email\": \"mariajf@gg.com\",\r\n \"phone\": \"32 91114-5555\"\r\n}", 600 | "options": { 601 | "raw": { 602 | "language": "json" 603 | } 604 | } 605 | }, 606 | "url": { 607 | "raw": "localhost:3001/pacients/65a5cdebb60f6ce0c41c6dcf", 608 | "host": [ 609 | "localhost" 610 | ], 611 | "port": "3001", 612 | "path": [ 613 | "pacients", 614 | "65a5cdebb60f6ce0c41c6dcf" 615 | ] 616 | } 617 | }, 618 | "response": [] 619 | } 620 | ] 621 | }, 622 | { 623 | "name": "Prescription", 624 | "item": [ 625 | { 626 | "name": "Create Prescription", 627 | "request": { 628 | "method": "POST", 629 | "header": [ 630 | { 631 | "key": "Authorization", 632 | "value": "{{token}}", 633 | "type": "text" 634 | } 635 | ], 636 | "body": { 637 | "mode": "raw", 638 | "raw": "{\r\n \"date\": \"2024-01-26\",\r\n \"appointmentId\": \"65a7c5d1338647b902d122cb\",\r\n \"medicine\": \"Xarope\",\r\n \"dosage\": \"10ml\",\r\n \"instructions\":\"\"\r\n}\r\n", 639 | "options": { 640 | "raw": { 641 | "language": "json" 642 | } 643 | } 644 | }, 645 | "url": { 646 | "raw": "localhost:3001/postPrescription", 647 | "host": [ 648 | "localhost" 649 | ], 650 | "port": "3001", 651 | "path": [ 652 | "postPrescription" 653 | ] 654 | } 655 | }, 656 | "response": [] 657 | }, 658 | { 659 | "name": "Read Prescription", 660 | "request": { 661 | "method": "GET", 662 | "header": [ 663 | { 664 | "key": "Authorization", 665 | "value": "{{token}}", 666 | "type": "text" 667 | } 668 | ], 669 | "url": { 670 | "raw": "localhost:3001/getPrescription/65a5ce3db60f6ce0c41c6dd1", 671 | "host": [ 672 | "localhost" 673 | ], 674 | "port": "3001", 675 | "path": [ 676 | "getPrescription", 677 | "65a5ce3db60f6ce0c41c6dd1" 678 | ] 679 | } 680 | }, 681 | "response": [] 682 | }, 683 | { 684 | "name": "Update Prescription", 685 | "request": { 686 | "method": "PUT", 687 | "header": [ 688 | { 689 | "key": "Authorization", 690 | "value": "{{token}}", 691 | "type": "text" 692 | } 693 | ], 694 | "body": { 695 | "mode": "raw", 696 | "raw": "{\r\n \"date\": \"\",\r\n \"appointmentId\": \"659e0f5182923bf214ba7d13\",\r\n \"medicine\": \"Dipirona, Paracetamol\",\r\n \"dosage\": \"33\",\r\n \"instructions\": \"A cada 6 horas ou em caso de dor\"\r\n}", 697 | "options": { 698 | "raw": { 699 | "language": "json" 700 | } 701 | } 702 | }, 703 | "url": { 704 | "raw": "localhost:3001/prescriptions/65a5ce3db60f6ce0c41c6dd1", 705 | "host": [ 706 | "localhost" 707 | ], 708 | "port": "3001", 709 | "path": [ 710 | "prescriptions", 711 | "65a5ce3db60f6ce0c41c6dd1" 712 | ] 713 | } 714 | }, 715 | "response": [] 716 | }, 717 | { 718 | "name": "File", 719 | "request": { 720 | "method": "GET", 721 | "header": [ 722 | { 723 | "key": "Authorization", 724 | "value": "{{token}}", 725 | "type": "text" 726 | } 727 | ], 728 | "url": { 729 | "raw": "localhost:3001/generatePrescription/65a7c66d2400a2834369caa6", 730 | "host": [ 731 | "localhost" 732 | ], 733 | "port": "3001", 734 | "path": [ 735 | "generatePrescription", 736 | "65a7c66d2400a2834369caa6" 737 | ] 738 | } 739 | }, 740 | "response": [] 741 | } 742 | ] 743 | }, 744 | { 745 | "name": "Login", 746 | "event": [ 747 | { 748 | "listen": "test", 749 | "script": { 750 | "exec": [ 751 | "var jsonData = JSON.parse(responseBody);\r", 752 | "postman.setEnvironmentVariable(\"token\", jsonData.token);" 753 | ], 754 | "type": "text/javascript" 755 | } 756 | }, 757 | { 758 | "listen": "prerequest", 759 | "script": { 760 | "exec": [ 761 | "" 762 | ], 763 | "type": "text/javascript" 764 | } 765 | } 766 | ], 767 | "request": { 768 | "method": "POST", 769 | "header": [], 770 | "body": { 771 | "mode": "raw", 772 | "raw": "{\r\n \"login\": \"jmendes\",\r\n \"password\":\"1234X\"\r\n}", 773 | "options": { 774 | "raw": { 775 | "language": "json" 776 | } 777 | } 778 | }, 779 | "url": { 780 | "raw": "localhost:3001/login", 781 | "host": [ 782 | "localhost" 783 | ], 784 | "port": "3001", 785 | "path": [ 786 | "login" 787 | ] 788 | } 789 | }, 790 | "response": [] 791 | } 792 | ] 793 | } -------------------------------------------------------------------------------- /MediApp/medi-app/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | # or 14 | bun dev 15 | ``` 16 | 17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 18 | 19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /MediApp/medi-app/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /MediApp/medi-app/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {} 3 | 4 | module.exports = nextConfig 5 | -------------------------------------------------------------------------------- /MediApp/medi-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "medi-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "axios": "^1.6.5", 13 | "bootstrap": "^5.3.2", 14 | "next": "14.0.4", 15 | "react": "^18.2.0", 16 | "react-dom": "^18" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^20", 20 | "@types/react": "^18", 21 | "@types/react-dom": "^18", 22 | "autoprefixer": "^10.0.1", 23 | "eslint": "^8", 24 | "eslint-config-next": "14.0.4", 25 | "postcss": "^8", 26 | "tailwindcss": "^3.3.0", 27 | "typescript": "^5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MediApp/medi-app/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /MediApp/medi-app/public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MediApp/medi-app/public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MediApp/medi-app/src/app/appointment/create/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import Link from "next/link"; 3 | import { useRouter } from "next/navigation"; 4 | import React, { useState, useEffect } from "react"; 5 | 6 | export default function AppointmentCreate() { 7 | 8 | const router = useRouter(); 9 | 10 | const [date, setDate] = useState(''); 11 | const [doctorId, setDoctorId] = useState(''); 12 | const [pacientId, setPacientId] = useState(''); 13 | const [doctors, setDoctors] = useState(new Array()); 14 | const [pacients, setPacients] = useState(new Array()); 15 | 16 | const [error, setError] = useState(null); 17 | 18 | useEffect(() => { 19 | fetch('http://127.0.0.1:3001/doctors', { 20 | method: 'GET', 21 | headers: { 22 | 'Content-Type': 'application/json', 23 | 'Authorization': sessionStorage.getItem("token") || '' 24 | }, 25 | }).then(response => response.json()) 26 | .then(data => { 27 | setDoctors(data); 28 | }); 29 | }, [doctors]); 30 | 31 | useEffect(() => { 32 | fetch('http://127.0.0.1:3001/pacients', { 33 | method: 'GET', 34 | headers: { 35 | 'Content-Type': 'application/json', 36 | 'Authorization': sessionStorage.getItem("token") || '' 37 | }, 38 | }).then(response => response.json()) 39 | .then(data => { 40 | setPacients(data); 41 | }); 42 | }, [pacients]); 43 | 44 | const addAppointment = async (e: any) => { 45 | e.preventDefault(); 46 | setError(null); 47 | 48 | if (date != "" && doctorId != "" 49 | && pacientId != "") { 50 | 51 | const formData = { 52 | date: date, 53 | doctorId: doctorId, 54 | pacientId: pacientId 55 | } 56 | 57 | const add = await fetch('http://127.0.0.1:3001/postAppointment', { 58 | method: 'POST', 59 | headers: { 60 | 'Content-Type': 'application/json', 61 | 'Authorization': sessionStorage.getItem("token") || '' 62 | }, 63 | body: JSON.stringify(formData) 64 | }); 65 | 66 | const content = await add.json(); 67 | 68 | if (content.date) { 69 | router.push('/home'); 70 | } else { 71 | setError(content.error); 72 | } 73 | 74 | } 75 | 76 | }; 77 | 78 | return ( 79 | <> 80 | Voltar 81 |
82 | Formulário Criação de Consultas 83 |
84 | 85 | setDate(e.target.value)} /> 86 |
87 |
88 | 89 | 92 |
93 |
94 | 95 | 98 |
99 |
100 | 101 |
102 |
103 | {error &&
{error}
} 104 |
105 |
106 | ) 107 | } -------------------------------------------------------------------------------- /MediApp/medi-app/src/app/appointment/edit/[id]/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import Link from "next/link"; 3 | import { useRouter } from "next/navigation"; 4 | import React, { useEffect, useState } from "react"; 5 | 6 | export default function AppointmentEdit(params: any) { 7 | 8 | const router = useRouter(); 9 | 10 | const [date, setDate] = useState(''); 11 | const [doctorId, setDoctorId] = useState(); 12 | const [pacientId, setPacientId] = useState(''); 13 | const [appointment, setAppointment] = useState({date, doctorId, pacientId}); 14 | const [doctors, setDoctors] = useState(new Array()); 15 | const [pacients, setPacients] = useState(new Array()); 16 | const [error, setError] = useState(null); 17 | 18 | const id = params.params.id; 19 | 20 | 21 | useEffect(() => { 22 | fetch('http://127.0.0.1:3001/getAppointment/' + id, { 23 | method: 'GET', 24 | headers: { 25 | 'Content-Type': 'application/json', 26 | 'Authorization': sessionStorage.getItem("token") || '' 27 | }, 28 | }).then(response => response.json()) 29 | .then(data => { 30 | setAppointment(data); 31 | }) 32 | }, [appointment]); 33 | 34 | useEffect(() => { 35 | fetch('http://127.0.0.1:3001/doctors', { 36 | method: 'GET', 37 | headers: { 38 | 'Content-Type': 'application/json', 39 | 'Authorization': sessionStorage.getItem("token") || '' 40 | }, 41 | }).then(response => response.json()) 42 | .then(data => { 43 | setDoctors(data); 44 | }); 45 | }, [doctors]); 46 | 47 | useEffect(() => { 48 | fetch('http://127.0.0.1:3001/pacients', { 49 | method: 'GET', 50 | headers: { 51 | 'Content-Type': 'application/json', 52 | 'Authorization': sessionStorage.getItem("token") || '' 53 | }, 54 | }).then(response => response.json()) 55 | .then(data => { 56 | setPacients(data); 57 | }); 58 | }, [pacients]); 59 | 60 | const edit = async (e: any) => { 61 | e.preventDefault(); 62 | setError(null); 63 | 64 | 65 | //Caso a variavel esteja vazia, vamos usar o valor que foi carregado pela página, caso ela esteja preenchida, vamos colocar o novo valor 66 | const formData = { 67 | date: date || appointment.date, 68 | doctorId: doctorId ||appointment.doctorId, 69 | pacientId: pacientId || appointment.pacientId, 70 | } 71 | 72 | const add = await fetch('http://127.0.0.1:3001/appointments/' + id, { 73 | method: 'PUT', 74 | headers: { 75 | 'Content-Type': 'application/json', 76 | 'Authorization': sessionStorage.getItem("token") || '' 77 | }, 78 | body: JSON.stringify(formData) 79 | }); 80 | 81 | const content = await add.json(); 82 | 83 | if (content.date) { 84 | router.push('/home'); 85 | } else { 86 | setError(content.error); 87 | } 88 | 89 | }; 90 | 91 | return ( 92 | <> 93 | Voltar 94 |
95 | Formulário Criação de Consulta 96 |
97 | 98 | setDate(e.target.value)} /> 99 |
100 |
101 | 102 | 105 |
106 |
107 | 108 | 111 |
112 |
113 | 114 |
115 |
116 | {error &&
{error}
} 117 |
118 |
119 | ) 120 | } -------------------------------------------------------------------------------- /MediApp/medi-app/src/app/appointment/list/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import React, { useEffect, useState } from 'react'; // HOOK = gancho 3 | import Link from 'next/link'; 4 | 5 | export default function AppointmentList() { 6 | const [appointments, setAppointments] = useState(new Array()); 7 | const [error, setError] = useState(null); 8 | const [doctors, setDoctors] = useState(new Array()); 9 | const [pacients, setPacients] = useState(new Array()); 10 | 11 | useEffect(() => { 12 | fetch('http://127.0.0.1:3001/appointments', { 13 | method: 'GET', 14 | headers: { 15 | 'Content-Type': 'application/json', 16 | 'Authorization': sessionStorage.getItem("token") || '' 17 | }, 18 | }).then(response => response.json()) 19 | .then(data => { 20 | setAppointments(data); 21 | }); 22 | }, [appointments]); 23 | 24 | useEffect(() => { 25 | fetch('http://127.0.0.1:3001/doctors', { 26 | method: 'GET', 27 | headers: { 28 | 'Content-Type': 'application/json', 29 | 'Authorization': sessionStorage.getItem("token") || '' 30 | }, 31 | }).then(response => response.json()) 32 | .then(data => { 33 | setDoctors(data); 34 | }); 35 | }, [doctors]); 36 | 37 | useEffect(() => { 38 | fetch('http://127.0.0.1:3001/pacients', { 39 | method: 'GET', 40 | headers: { 41 | 'Content-Type': 'application/json', 42 | 'Authorization': sessionStorage.getItem("token") || '' 43 | }, 44 | }).then(response => response.json()) 45 | .then(data => { 46 | setPacients(data); 47 | }); 48 | }, [pacients]); 49 | 50 | 51 | const deleteAppointment = async (id: any) => { 52 | const add = await fetch(`http://127.0.0.1:3001/appointments/${id}`, { 53 | method: 'DELETE', 54 | headers: { 55 | 'Content-Type': 'application/json', 56 | 'Authorization': sessionStorage.getItem("token") || '' 57 | }, 58 | }); 59 | const content = await add.json(); 60 | 61 | if (content.date) { 62 | window.location.reload(); 63 | } else { 64 | setError(content.error); 65 | } 66 | } 67 | 68 | const findDoctorName = (id: any) => { 69 | let name; 70 | 71 | doctors.map((doctor) => { 72 | if (doctor._id == id){ 73 | name = doctor.name; 74 | } 75 | }); 76 | 77 | return name; 78 | } 79 | 80 | const findPacientName = (id: any) => { 81 | let name; 82 | 83 | pacients.map((pacient) => { 84 | if (pacient._id == id){ 85 | name = pacient.name; 86 | } 87 | }); 88 | 89 | return name; 90 | } 91 | 92 | return ( 93 | <> 94 | Voltar 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | {!!appointments && appointments.map((appointment: any) => ( 106 | 107 | 108 | 109 | 110 | 112 | 115 | 118 | 121 | 122 | ))} 123 | 124 |
DateDoctorPacient
{appointment.date} 111 | 113 | Edit 114 | 116 | Create new prescription 117 | 119 | Upload prescription 120 |
125 |
126 | {error &&
{error}
} 127 |
128 | 129 | ) 130 | } -------------------------------------------------------------------------------- /MediApp/medi-app/src/app/components/Headers.tsx: -------------------------------------------------------------------------------- 1 | import "bootstrap/dist/css/bootstrap.min.css"; 2 | import "../globals.css"; 3 | import Head from 'next/head' 4 | import React from 'react' 5 | import Link from "next/link"; 6 | 7 | export default function Header() { 8 | return ( 9 | <> 10 | 11 | 12 | 13 |
14 |

Medi-APP

15 |
16 | 17 | ) 18 | } -------------------------------------------------------------------------------- /MediApp/medi-app/src/app/doctor/create/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import Link from "next/link"; 3 | import { useRouter } from "next/navigation"; 4 | import React, { useState } from "react"; 5 | 6 | export default function DoctorCreate() { 7 | 8 | const router = useRouter(); 9 | 10 | const [name, setName] = useState(''); 11 | const [login, setLogin] = useState(''); 12 | const [password, setPassword] = useState(''); 13 | const [medicalSpecialty, setMedicalSpecialty] = useState(''); 14 | const [medicalRegistration, setMedicalRegistration] = useState(''); 15 | const [email, setEmail] = useState(''); 16 | const [phone, setPhone] = useState(''); 17 | const [error, setError] = useState(null); 18 | 19 | const addDoctor = async (e: any) => { 20 | e.preventDefault(); 21 | setError(null); 22 | 23 | if (name != "" && login != "" 24 | && password != "" && medicalSpecialty != "" 25 | && medicalRegistration != "" && email != "" && phone != "") { 26 | 27 | const formData = { 28 | name: name, 29 | login: login, 30 | password: password, 31 | medicalSpecialty: medicalSpecialty, 32 | medicalRegistration: medicalRegistration, 33 | email: email, 34 | phone: phone 35 | } 36 | 37 | const add = await fetch('http://127.0.0.1:3001/postDoctor', { 38 | method: 'POST', 39 | headers: { 40 | 'Content-Type': 'application/json', 41 | 'Authorization': sessionStorage.getItem("token") || '' 42 | }, 43 | body: JSON.stringify(formData) 44 | }); 45 | 46 | const content = await add.json(); 47 | 48 | if (content.login) { 49 | router.push('/home'); 50 | } else { 51 | setError(content.error); 52 | } 53 | 54 | } 55 | 56 | 57 | }; 58 | 59 | return ( 60 | <> 61 | Voltar 62 |
63 | Formulário Criação de Médico 64 |
65 | 66 | setName(e.target.value)} /> 67 |
68 |
69 | 70 |