├── README.md ├── backend ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml ├── sql.txt └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── demo │ │ │ ├── FirstAppApplication.java │ │ │ ├── LoggingConfiguration.java │ │ │ ├── controller │ │ │ ├── PatientController.java │ │ │ ├── ProblemController.java │ │ │ ├── ReceipeController.java │ │ │ └── StaffController.java │ │ │ ├── dto │ │ │ ├── PatientDto.java │ │ │ ├── PatientDtoForProblemGetDto.java │ │ │ ├── PatientSingleDto.java │ │ │ ├── ProblemDto.java │ │ │ ├── ProblemDtoForPatientSingleDto.java │ │ │ ├── ProblemGetDto.java │ │ │ ├── ReceipeDto.java │ │ │ └── StaffDto.java │ │ │ ├── entity │ │ │ ├── Admission.java │ │ │ ├── City.java │ │ │ ├── Patient.java │ │ │ ├── Problem.java │ │ │ ├── ProblemStatus.java │ │ │ ├── Problems.java │ │ │ ├── Receipe.java │ │ │ ├── Role.java │ │ │ ├── Staff.java │ │ │ ├── User.java │ │ │ └── enums │ │ │ │ ├── City.java │ │ │ │ ├── Department.java │ │ │ │ ├── ProblemStatus.java │ │ │ │ └── Role.java │ │ │ ├── exception │ │ │ ├── ExceptionResponse.java │ │ │ ├── IMExceptionHandler.java │ │ │ └── PatientNotFoundException.java │ │ │ ├── repository │ │ │ ├── AdmissionRepository.java │ │ │ ├── PatientRepository.java │ │ │ ├── ProblemRepository.java │ │ │ ├── ReceipeRepository.java │ │ │ └── StaffRepository.java │ │ │ ├── security │ │ │ ├── JWTAuthorizationFilter.java │ │ │ ├── JwtTokenProvider.java │ │ │ └── WebSecurityConfig.java │ │ │ ├── service │ │ │ ├── PatientService.java │ │ │ ├── ProblemService.java │ │ │ ├── ReceipeService.java │ │ │ └── StaffService.java │ │ │ └── util │ │ │ └── ApiPaths.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── demo │ ├── FirstAppApplicationTests.java │ └── patient │ └── PatientControllerTest.java └── frontend ├── .gitignore ├── =#.## ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js ├── App.test.js ├── Assets └── css │ ├── AddPatient.css │ └── ListPatientComponent.css ├── Navbar └── NavbarComponent.jsx ├── NotFound ├── NotFoundComponent.jsx └── NotFoundCss.css ├── Routes ├── BasicComponent │ ├── PatientDetail.jsx │ ├── PatientDetailModal.jsx │ ├── ProblemDetail.jsx │ ├── ProblemDetailModal.jsx │ ├── ReceipeDetail.jsx │ └── ReceipeDetailModal.jsx ├── IndexPage.jsx ├── IndexPage2.jsx ├── PatientComponents │ ├── AddPatientComponent.jsx │ ├── EditPatientComponent.jsx │ ├── ListPatientComponent.jsx │ ├── ProblemComponent │ │ ├── ProblemFormComponent.jsx │ │ ├── ProblemsComponent.jsx │ │ └── ViewProblemComponent.jsx │ ├── ReceipeComponent │ │ ├── ReceipeFormComponent.jsx │ │ └── ReceipesComponent.jsx │ └── ViewPatientComponent.jsx └── modal.jsx ├── index.css ├── index.js ├── logo.svg ├── serviceWorker.js ├── services ├── AlertifyService.js ├── ApiService.js ├── PatientService.js ├── ProblemService.js └── ReceipeService.js └── setupTests.js /README.md: -------------------------------------------------------------------------------- 1 | # Patient-SpringBoot-React 2 | 3 | This project is simple hospital management system. 4 | 5 | ### Using Tools & Technologies 6 | ``` 7 | - Spring Boot 2.2.2 8 | - REST API (get, post, put, delete, patch) 9 | - ModelMapper, DTO 10 | - JPA, Hibernate 11 | - React 12 | - Bootstrap 4 13 | - Oracle Database 11g 14 | ``` 15 | ### important !!! 16 | ``` 17 | https://reactdatepicker.com/ 18 | https://www.npmjs.com/package/@material/react-checkbox 19 | ``` 20 | ## Requirements 21 | 22 | For building and running the application you need: 23 | 24 | - [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) 25 | - [Maven 3](https://maven.apache.org) 26 | 27 | ## Running the application locally 28 | #### for backend 29 | There are several ways to run a Spring Boot application on your local machine. One way is to execute the `main` method in the `com.example.demo.FirstAppApplication` class from your IDE . 30 | 31 | Alternatively you can use the [Spring Boot Maven plugin](https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html) like so: 32 | 33 | ```shell 34 | mvn spring-boot:run 35 | ``` 36 | #### for Frontend 37 | Installation and Setup Instructions 38 | Example: 39 | Clone down this repository. You will need node and npm installed globally on your machine. 40 | 41 | Installation: `npm install` 42 | 43 | To Run Test Suite: `npm test` 44 | 45 | To Start Server: `npm start` 46 | 47 | To Visit App: `localhost:3000` 48 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /backend/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.5"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /backend/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celalaygar/Hospital-Management-System-React-and-SpringBoot/570acedd8ff64431d8e2f71095780127ced86e0d/backend/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /backend/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /backend/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /backend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.2.RELEASE 9 | 10 | 11 | com.example 12 | firstApp 13 | 0.0.1-SNAPSHOT 14 | firstApp 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | 33 | 34 | 35 | io.jsonwebtoken 36 | jjwt 37 | 0.9.1 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-devtools 42 | runtime 43 | true 44 | 45 | 46 | com.oracle.ojdbc 47 | ojdbc8 48 | runtime 49 | 50 | 51 | 52 | org.modelmapper 53 | modelmapper 54 | 2.3.6 55 | 56 | 57 | 58 | org.projectlombok 59 | lombok 60 | true 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-test 65 | test 66 | 67 | 68 | org.junit.vintage 69 | junit-vintage-engine 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | org.springframework.boot 79 | spring-boot-maven-plugin 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /backend/sql.txt: -------------------------------------------------------------------------------- 1 | CREATE TABLE AAPATIENT 2 | ( 3 | patientid NUMBER(19,0) NOT NULL ENABLE, 4 | name VARCHAR2(255 CHAR), 5 | lastname VARCHAR2(255 CHAR), 6 | age VARCHAR2(255 CHAR), 7 | gender VARCHAR2(255 CHAR), 8 | city VARCHAR2(255 CHAR), 9 | status NUMBER(1,0) 10 | PRIMARY KEY (patientid) 11 | ); 12 | 13 | 14 | CREATE SEQUENCE AA_PATIENT_SEQ START WITH 1 INCREMENT BY 1 15 | INSERT INTO AAPATIENT VALUES (1,'Can','Yücel','51','Male','Zonguldak') 16 | INSERT INTO AAPATIENT VALUES (2,'Harun ','tunay','5','Male','Ankara') 17 | INSERT INTO AAPATIENT VALUES (3,'Firidevs','tunay','6','Female','Kayseri') 18 | INSERT INTO AAPATIENT VALUES (4,'Yücel','Firidevs','31','Male','Sakarya') 19 | INSERT INTO AAPATIENT VALUES (5,'Fatmanur','tunay','23','Female','Zonguldak') 20 | INSERT INTO AAPATIENT VALUES (6,'Derya','Tuna','51','Female','Zonguldak') 21 | INSERT INTO AAPATIENT VALUES (7,'Deryanur','TUnay','51','Female','Ankara') 22 | INSERT INTO AAPATIENT VALUES (13,'Tuna','Cannur','44','Male','Sakarya'); 23 | INSERT INTO AAPATIENT VALUES (14,'Kader','Derya','52','Female','Zonguldak') 24 | INSERT INTO AAPATIENT VALUES (15,'Sezen','Fatsa','36','Female','Sakarya') 25 | INSERT INTO AAPATIENT VALUES (16,'Faruk Ahmet ','tunay','51','Male','Zonguldak') 26 | INSERT INTO AAPATIENT VALUES (17,'Tansu ','Karacam','51','Female','Manisa') 27 | INSERT INTO AAPATIENT VALUES (18,'Tamer','Kerem','51','Male','Adana') 28 | INSERT INTO AAPATIENT VALUES (19,'Tansunur ','Yucel','51','Female','Manisa') 29 | INSERT INTO AAPATIENT VALUES (25,'Ahmet ','Karanur','51','Male','Ankara') 30 | INSERT INTO AAPATIENT VALUES (45,'Feyza ','Katil','13','Female','Rize') 31 | INSERT INTO AAPATIENT VALUES (81,'kemal','Fakir','34','Male','Karaman') 32 | INSERT INTO AAPATIENT VALUES (84,'Nuray ','Zengin','23','Female','Adana') 33 | INSERT INTO AAPATIENT VALUES (87,'Ay Nur','Pembe','34','Female','Sakarya') 34 | INSERT INTO AAPATIENT VALUES (113,'Kemal','Fiesta','34','Male','istanbul') 35 | INSERT INTO AAPATIENT VALUES (112,'Murat','Karakaya','26','Male','Bursa') 36 | INSERT INTO AAPATIENT VALUES (131,'Fuat Kemal','Fiesta','6','Male','Mugla') 37 | INSERT INTO AAPATIENT VALUES (136,'Mehmet Ali','Erbil','17','Male','Karaman') 38 | INSERT INTO AAPATIENT VALUES (143,'Kadir','Mehmetoglu','38','Female','Antalya') 39 | INSERT INTO AAPATIENT VALUES (144,'Sertac','Gulban','34','Male','istanbul') 40 | INSERT INTO AAPATIENT VALUES (145,'Murat Fuat','Karacem','26','Male','Bursa') 41 | INSERT INTO AAPATIENT VALUES (146,'Fuat Kemal','cem','6','Male','Mugla') 42 | INSERT INTO AAPATIENT VALUES (147,'Serdar Kadir','Yildirim','38','Female','Antalya') 43 | INSERT INTO AAPATIENT VALUES (151,'Mehmet Serdar','Erbiloglu','17','Male','Karaman') 44 | 45 | SELECT * FROM AAPATIENT ORDER BY PATIENTID 46 | DELETE FROM AAPATIENT WHERE patientid = 0 47 | 48 | DROP TABLE AAPATIENT -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/FirstAppApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | 4 | import org.modelmapper.ModelMapper; 5 | import org.modelmapper.convention.MatchingStrategies; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @SpringBootApplication 11 | public class FirstAppApplication { 12 | 13 | 14 | //private static final Logger LOGGER=LoggerFactory.getLogger(FirstAppApplication.class); 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(FirstAppApplication.class, args); 18 | //LOGGER.info("--Simple log statement is running with inputs now"); 19 | } 20 | 21 | @Bean 22 | public ModelMapper getModelMapper() { 23 | ModelMapper modelmapper =new ModelMapper(); 24 | modelmapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); 25 | return modelmapper; 26 | } 27 | 28 | // @Bean 29 | // @Scope("prototype") 30 | // Logger logger(InjectionPoint injectionPoint){ 31 | // return LoggerFactory.getLogger(injectionPoint.getMethodParameter().getContainingClass()); 32 | // 33 | // } 34 | } 35 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/LoggingConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.InjectionPoint; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.Scope; 9 | 10 | @Configuration 11 | public class LoggingConfiguration { 12 | @Bean 13 | @Scope("prototype") 14 | Logger logger(InjectionPoint injectionPoint){ 15 | return LoggerFactory.getLogger(injectionPoint.getMethodParameter().getContainingClass()); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/controller/PatientController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import javax.validation.Valid; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.CrossOrigin; 11 | import org.springframework.web.bind.annotation.DeleteMapping; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.PutMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import com.example.demo.dto.PatientDto; 21 | import com.example.demo.dto.PatientSingleDto; 22 | import com.example.demo.entity.Patient; 23 | import com.example.demo.entity.enums.City; 24 | import com.example.demo.service.PatientService; 25 | import com.example.demo.util.ApiPaths; 26 | 27 | import javassist.NotFoundException; 28 | 29 | @RestController 30 | @CrossOrigin(origins = "*") 31 | @RequestMapping(ApiPaths.PatientCtrl.CTRL) 32 | public class PatientController { 33 | 34 | @Autowired 35 | private PatientService patientService; 36 | 37 | @GetMapping 38 | public ResponseEntity> getAll() throws Exception { 39 | return ResponseEntity.ok(patientService.findAll()); 40 | } 41 | 42 | @GetMapping("/find-by-id/{patientid}") 43 | public ResponseEntity getPatientByPatientid( 44 | @PathVariable(name = "patientid", required = true) Long patientid) throws Exception { 45 | return ResponseEntity.ok(patientService.findByPatientId(patientid)); 46 | } 47 | 48 | @GetMapping("/find-by-email/{email}") 49 | public ResponseEntity getPatientByEmail(@PathVariable(name = "email", required = true) String email) 50 | throws Exception { 51 | return ResponseEntity.ok(patientService.findByEmail(email)); 52 | } 53 | 54 | @GetMapping("/find-by-name/{name}") 55 | public ResponseEntity> getPatientByName(@PathVariable(name = "name", required = true) String name) 56 | throws Exception { 57 | return ResponseEntity.ok(patientService.findByName(name)); 58 | } 59 | 60 | @PostMapping 61 | public ResponseEntity savePatient(@Valid @RequestBody Patient patient) { 62 | return ResponseEntity.ok(patientService.save(patient)); 63 | } 64 | 65 | @PutMapping("/{patientid}") 66 | public ResponseEntity updatePatient(@PathVariable(name = "patientid", required = true) Long patientid, 67 | @Valid @RequestBody Patient patient) throws Exception { 68 | return ResponseEntity.ok(patientService.update(patientid, patient)); 69 | } 70 | 71 | @DeleteMapping("/{patientid}") 72 | public ResponseEntity deletePatient(@PathVariable(name = "patientid", required = true) Long patientid) 73 | throws Exception { 74 | return ResponseEntity.ok(patientService.delete(patientid)); 75 | } 76 | 77 | @GetMapping("/deleted-patient") 78 | public ResponseEntity> getAllDeletedPatients() throws Exception { 79 | return ResponseEntity.ok(patientService.findAllDeletedPatients()); 80 | } 81 | 82 | @GetMapping("/cities") 83 | public ResponseEntity> getAllCities() { 84 | return ResponseEntity.ok(Arrays.asList(City.values())); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/controller/ProblemController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import javax.validation.Valid; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.CrossOrigin; 11 | import org.springframework.web.bind.annotation.DeleteMapping; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.PutMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import com.example.demo.dto.ProblemDto; 21 | import com.example.demo.dto.ProblemDtoForPatientSingleDto; 22 | import com.example.demo.dto.ProblemGetDto; 23 | import com.example.demo.entity.Patient; 24 | import com.example.demo.entity.enums.City; 25 | import com.example.demo.entity.enums.ProblemStatus; 26 | import com.example.demo.repository.ProblemRepository; 27 | import com.example.demo.service.ProblemService; 28 | import com.example.demo.util.ApiPaths; 29 | 30 | import javassist.NotFoundException; 31 | 32 | @RestController 33 | @CrossOrigin(origins = "*") 34 | @RequestMapping(ApiPaths.ProblemCtrl.CTRL) 35 | public class ProblemController { 36 | 37 | @Autowired 38 | ProblemService problemService; 39 | 40 | @GetMapping("/find-by-problemid/{problemid}") 41 | public ResponseEntity getProblem(@PathVariable(name = "problemid", required = true) Long problemid) 42 | throws NotFoundException { 43 | return ResponseEntity.ok(problemService.findByProblemid(problemid)); 44 | } 45 | 46 | @GetMapping("/find-all-by-patientid/{patientid}") 47 | public ResponseEntity> getAllProblem(@PathVariable(name = "patientid", required = true) Long patientid) 48 | throws NotFoundException { 49 | return ResponseEntity.ok(problemService.findAllByPatientid(patientid)); 50 | } 51 | @PostMapping 52 | public ResponseEntity saveProblem(@Valid @RequestBody ProblemDto dto) 53 | throws NotFoundException { 54 | return ResponseEntity.ok(problemService.save(dto)); 55 | } 56 | 57 | @PutMapping("/{problemid}") 58 | public ResponseEntity updateProblem(@PathVariable(name = "problemid", required = true) Long problemid, 59 | @Valid @RequestBody ProblemDtoForPatientSingleDto dto) throws Exception { 60 | return ResponseEntity.ok(problemService.update(problemid, dto)); 61 | } 62 | 63 | @DeleteMapping("/{problemid}") 64 | public ResponseEntity deleteProblem(@PathVariable(name = "problemid", required = true) Long problemid) 65 | throws Exception { 66 | return ResponseEntity.ok(problemService.delete(problemid)); 67 | } 68 | 69 | @GetMapping("/status") 70 | public ResponseEntity> getAllBookStatus() { 71 | return ResponseEntity.ok(Arrays.asList(ProblemStatus.values())); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/controller/ReceipeController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import javax.validation.Valid; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.CrossOrigin; 11 | import org.springframework.web.bind.annotation.DeleteMapping; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.PutMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import com.example.demo.dto.ProblemDto; 21 | import com.example.demo.dto.ProblemDtoForPatientSingleDto; 22 | import com.example.demo.dto.ProblemGetDto; 23 | import com.example.demo.dto.ReceipeDto; 24 | import com.example.demo.entity.Patient; 25 | import com.example.demo.entity.enums.City; 26 | import com.example.demo.entity.enums.ProblemStatus; 27 | import com.example.demo.repository.ProblemRepository; 28 | import com.example.demo.service.ProblemService; 29 | import com.example.demo.service.ReceipeService; 30 | import com.example.demo.util.ApiPaths; 31 | 32 | import javassist.NotFoundException; 33 | 34 | @RestController 35 | @CrossOrigin(origins = "*") 36 | @RequestMapping(ApiPaths.ReceipeCtrl.CTRL) 37 | public class ReceipeController { 38 | 39 | @Autowired 40 | ProblemService problemService; 41 | 42 | @Autowired 43 | ReceipeService receipeService; 44 | 45 | @GetMapping("/find-all-by-problemid/{problemid}") 46 | public ResponseEntity> getReceipe(@PathVariable(name = "problemid", required = true) Long problemid) throws Exception { 47 | return ResponseEntity.ok(receipeService.findAllByProblemId(problemid)); 48 | } 49 | 50 | @PostMapping 51 | public ResponseEntity saveReceipe(@Valid @RequestBody ReceipeDto dto) throws NotFoundException { 52 | return ResponseEntity.ok(receipeService.save(dto)); 53 | } 54 | 55 | // @PutMapping("/{receipeid}") 56 | // public ResponseEntity updateReceipe(@PathVariable(name = "receipeid", required = true) Long problemid, 57 | // @Valid @RequestBody ProblemDtoForPatientSingleDto dto) throws Exception { 58 | // return ResponseEntity.ok(problemService.update(problemid, dto)); 59 | // } 60 | 61 | @DeleteMapping("/{receipeid}") 62 | public ResponseEntity deleteReceipe(@PathVariable(name = "receipeid", required = true) Long receipeid) throws Exception { 63 | return ResponseEntity.ok(receipeService.delete(receipeid)); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/controller/StaffController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import javax.validation.Valid; 7 | 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.CrossOrigin; 10 | import org.springframework.web.bind.annotation.DeleteMapping; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PathVariable; 13 | import org.springframework.web.bind.annotation.PostMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestMethod; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.example.demo.dto.StaffDto; 20 | import com.example.demo.entity.Patient; 21 | import com.example.demo.entity.Staff; 22 | import com.example.demo.entity.enums.City; 23 | import com.example.demo.entity.enums.Department; 24 | import com.example.demo.service.StaffService; 25 | 26 | import javassist.NotFoundException; 27 | 28 | @RestController 29 | @CrossOrigin(origins = "*") 30 | @RequestMapping("/staff") 31 | public class StaffController { 32 | private final StaffService staffService; 33 | 34 | 35 | public StaffController(StaffService staffService) { 36 | this.staffService = staffService; 37 | } 38 | // headers = "Accept=application/json", 39 | //@RequestMapping(method = RequestMethod.GET, produces = "application/json") 40 | @GetMapping 41 | public ResponseEntity> getAllStaff() throws NotFoundException { 42 | return ResponseEntity.ok(staffService.getAll()); 43 | } 44 | 45 | @RequestMapping(value = "/deleted-staff",method = RequestMethod.GET, produces = "application/json") 46 | //@GetMapping("/deleted-staff") 47 | public ResponseEntity> getAllDeletedStaff() throws NotFoundException { 48 | return ResponseEntity.ok(staffService.getAllDeletedStaff()); 49 | } 50 | 51 | @RequestMapping(method = RequestMethod.POST, produces = "application/json") 52 | public ResponseEntity savePatient(@Valid @RequestBody Staff staff) throws Exception { 53 | return ResponseEntity.ok(staffService.save(staff)); 54 | } 55 | 56 | @DeleteMapping("/{staffid}") 57 | public ResponseEntity deletePatient(@PathVariable(name = "staffid", required = true) Long staffid) 58 | throws Exception { 59 | return ResponseEntity.ok(staffService.delete(staffid)); 60 | } 61 | 62 | @GetMapping("/cities") 63 | public ResponseEntity> getAllCities() { 64 | return ResponseEntity.ok(Arrays.asList(City.values())); 65 | } 66 | 67 | @GetMapping("/department") 68 | public ResponseEntity> getAllDepertman() { 69 | return ResponseEntity.ok(Arrays.asList(Department.values())); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/PatientDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.persistence.CascadeType; 8 | import javax.persistence.FetchType; 9 | import javax.persistence.OneToMany; 10 | 11 | import com.example.demo.entity.Patient; 12 | import com.example.demo.entity.Problem; 13 | import com.example.demo.entity.enums.City; 14 | 15 | import lombok.AllArgsConstructor; 16 | import lombok.Data; 17 | import lombok.NoArgsConstructor; 18 | import lombok.ToString; 19 | 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | @ToString 24 | public class PatientDto implements Serializable { 25 | private Long patientid; 26 | private String name; 27 | private String lastname; 28 | private String phoneNo; 29 | private Date bornDate; 30 | private String gender; 31 | private City city; 32 | private String email; 33 | private int status; 34 | 35 | private List problems; 36 | } 37 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/PatientDtoForProblemGetDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import com.example.demo.entity.enums.City; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | import lombok.ToString; 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | public class PatientDtoForProblemGetDto implements Serializable { 19 | private Long patientid; 20 | private String name; 21 | private String lastname; 22 | private String phoneNo; 23 | private Date bornDate; 24 | private String gender; 25 | private City city; 26 | private String email; 27 | private int status; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/PatientSingleDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import com.example.demo.entity.enums.City; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | import lombok.ToString; 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @ToString 17 | public class PatientSingleDto implements Serializable { 18 | private Long patientid; 19 | private String name; 20 | private String lastname; 21 | private String phoneNo; 22 | private Date bornDate; 23 | private String gender; 24 | private City city; 25 | private String email; 26 | private int status; 27 | 28 | private List problems; 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/ProblemDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | import com.example.demo.entity.Patient; 7 | import com.example.demo.entity.Problem; 8 | import com.example.demo.entity.enums.ProblemStatus; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @ToString 19 | public class ProblemDto implements Serializable { 20 | 21 | private String problemName; 22 | private String problemDetail; 23 | private ProblemStatus problemStatus; 24 | private Long pId; 25 | private int status; 26 | private Date creationDate; 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/ProblemDtoForPatientSingleDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | import com.example.demo.entity.Patient; 7 | import com.example.demo.entity.Problem; 8 | import com.example.demo.entity.enums.ProblemStatus; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | import lombok.ToString; 14 | 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @ToString 19 | public class ProblemDtoForPatientSingleDto implements Serializable { 20 | private Long problemid; 21 | private String problemName; 22 | private String problemDetail; 23 | private ProblemStatus problemStatus; 24 | private Long pId; 25 | private int status; 26 | private Date creationDate; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/ProblemGetDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | import com.example.demo.entity.Patient; 7 | import com.example.demo.entity.enums.ProblemStatus; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | import lombok.ToString; 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | public class ProblemGetDto implements Serializable { 19 | private Long problemid; 20 | private String problemName; 21 | private String problemDetail; 22 | private ProblemStatus problemStatus; 23 | private Long pId; 24 | private Date creationDate; 25 | private int status; 26 | private PatientDtoForProblemGetDto patient; 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/ReceipeDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import com.example.demo.entity.enums.City; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @ToString 17 | public class ReceipeDto { 18 | private Long receipeid; 19 | 20 | private String detail; 21 | private String barcode; 22 | private String drug_detail; 23 | private String usage; 24 | private String delivery_date; 25 | private int status; 26 | private Long patientid; 27 | private Long problemid; 28 | } 29 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/dto/StaffDto.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.persistence.Temporal; 8 | import javax.persistence.TemporalType; 9 | 10 | import com.example.demo.entity.enums.City; 11 | import com.example.demo.entity.enums.Department; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | import lombok.ToString; 17 | 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @ToString 22 | public class StaffDto implements Serializable { 23 | 24 | private Long staffid; 25 | private String staffname; 26 | private String stafflastname; 27 | private String gender; 28 | private String email; 29 | private City city; 30 | private Department department; 31 | private Date bornDate; 32 | } 33 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Admission.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.FetchType; 9 | import javax.persistence.GeneratedValue; 10 | import javax.persistence.GenerationType; 11 | import javax.persistence.Id; 12 | import javax.persistence.JoinColumn; 13 | import javax.persistence.ManyToOne; 14 | import javax.persistence.SequenceGenerator; 15 | import javax.persistence.Table; 16 | import javax.persistence.Temporal; 17 | import javax.persistence.TemporalType; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | import lombok.NoArgsConstructor; 22 | import lombok.ToString; 23 | 24 | @Data 25 | @AllArgsConstructor 26 | @NoArgsConstructor 27 | @ToString 28 | @Entity 29 | @Table(name = "aaadmission") 30 | public class Admission { 31 | 32 | @Id 33 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 34 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 35 | @Column(name = "admissionid") 36 | private Long admissionid; 37 | 38 | private Long patientid; 39 | 40 | private Long staffid; 41 | 42 | @Temporal(TemporalType.TIMESTAMP) 43 | private Date createdDate; 44 | 45 | @ManyToOne(optional = true, fetch = FetchType.LAZY) 46 | @JoinColumn(name = "patient_id") 47 | private Patient patient; 48 | 49 | @ManyToOne(optional = true, fetch = FetchType.LAZY) 50 | @JoinColumn(name = "staff_id") 51 | private Staff staff; 52 | 53 | private int status; 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/City.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | public enum City { 4 | ADANA, 5 | ADIYAMAN, 6 | ANKARA, 7 | ANTALYA, 8 | AMASYA, 9 | ARDAHAN, 10 | ARTVİN, 11 | AĞRI, 12 | BARTIN, 13 | BALIKESIR, 14 | BOLU, 15 | BITLIS, 16 | BURSA, 17 | BURDUR, 18 | ÇANAKKALE, 19 | ÇORUM, 20 | ÇANKIRI, 21 | DENIZLI, 22 | DİYARBAKIR, 23 | EDIRNE, 24 | ELAZIĞ, 25 | ERZURUM, 26 | ESKIŞEHIR, 27 | ERZINCAN, 28 | GAZİANTEP, 29 | GİRESUN, 30 | HAKKARİ, 31 | HATAY, 32 | ISPARTA, 33 | İSTANBUL, 34 | İZMİR, 35 | KARS, 36 | KASTAMONU, 37 | KAYSERİ, 38 | KARAMAN, 39 | KIRŞEHİR, 40 | KİLİS, 41 | KOCAELİ, 42 | MARDİN, 43 | MANİSA, 44 | MERSİN, 45 | MUĞLA, 46 | MUŞ, 47 | ORDU, 48 | OSMANİYE, 49 | RİZE, 50 | SAKARYA, 51 | SAMSUN, 52 | SİNOP, 53 | ŞIRNAK, 54 | SİVAS, 55 | ŞANLIURFA, 56 | TEKİRDAĞ, 57 | TOKAT, 58 | TRABZON, 59 | YALOVA, 60 | YOZGAT, 61 | ZONGULDAK 62 | } 63 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Patient.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.persistence.CascadeType; 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.EnumType; 11 | import javax.persistence.Enumerated; 12 | import javax.persistence.FetchType; 13 | import javax.persistence.GeneratedValue; 14 | import javax.persistence.GenerationType; 15 | import javax.persistence.Id; 16 | import javax.persistence.JoinColumn; 17 | import javax.persistence.ManyToOne; 18 | import javax.persistence.OneToMany; 19 | import javax.persistence.OrderColumn; 20 | import javax.persistence.SequenceGenerator; 21 | import javax.persistence.Table; 22 | import javax.swing.ImageIcon; 23 | import javax.swing.JLabel; 24 | import javax.xml.bind.annotation.XmlAccessType; 25 | import javax.xml.bind.annotation.XmlAccessorType; 26 | import javax.xml.bind.annotation.XmlRootElement; 27 | import javax.xml.bind.annotation.XmlTransient; 28 | import javax.xml.bind.annotation.XmlType; 29 | 30 | import com.example.demo.entity.enums.City; 31 | import com.sun.istack.NotNull; 32 | 33 | import lombok.AllArgsConstructor; 34 | import lombok.Data; 35 | import lombok.NoArgsConstructor; 36 | import lombok.ToString; 37 | 38 | @Data 39 | @AllArgsConstructor 40 | @NoArgsConstructor 41 | @Entity 42 | @ToString 43 | @Table(name = "aapatient") 44 | public class Patient { 45 | 46 | @Id 47 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 48 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 49 | @Column(name = "patientid") 50 | private Long patientid; 51 | private String name; 52 | private String lastname; 53 | private String phoneNo; 54 | private Date bornDate; 55 | private String gender; 56 | 57 | @Enumerated(EnumType.ORDINAL) 58 | private City city; 59 | 60 | @Column(name = "email", unique = true) 61 | private String email; 62 | 63 | private int status; 64 | 65 | @OneToMany(mappedBy = "patient", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 66 | private List problems; 67 | 68 | @OneToMany(mappedBy = "patient", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 69 | private List admissions; 70 | 71 | 72 | public Patient(String name, String lastname,Date bornDate, String gender, String age, City city, String email, int status) { 73 | super(); 74 | this.name = name; 75 | this.lastname = lastname; 76 | this.bornDate = bornDate; 77 | this.gender = gender; 78 | this.city = city; 79 | this.email = email; 80 | this.status = status; 81 | } 82 | public Patient(String name, String lastname, String gender, City city, String email, int status) { 83 | super(); 84 | this.name = name; 85 | this.lastname = lastname; 86 | this.gender = gender; 87 | this.city = city; 88 | this.email = email; 89 | this.status = status; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Problem.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import javax.persistence.CascadeType; 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.EnumType; 11 | import javax.persistence.Enumerated; 12 | import javax.persistence.FetchType; 13 | import javax.persistence.GeneratedValue; 14 | import javax.persistence.GenerationType; 15 | import javax.persistence.Id; 16 | import javax.persistence.JoinColumn; 17 | import javax.persistence.ManyToOne; 18 | import javax.persistence.OneToMany; 19 | import javax.persistence.OrderColumn; 20 | import javax.persistence.SequenceGenerator; 21 | import javax.persistence.Table; 22 | import javax.persistence.Temporal; 23 | import javax.persistence.TemporalType; 24 | import javax.validation.constraints.NotNull; 25 | 26 | import com.example.demo.entity.enums.ProblemStatus; 27 | 28 | import lombok.AllArgsConstructor; 29 | import lombok.Data; 30 | import lombok.NoArgsConstructor; 31 | import lombok.ToString; 32 | 33 | @Data 34 | @AllArgsConstructor 35 | @NoArgsConstructor 36 | @ToString 37 | @Entity 38 | @Table(name="aaproblem") 39 | public class Problem{ 40 | 41 | @Id 42 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 43 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 44 | @Column(name = "problemid") 45 | private Long problemid; 46 | private String problemName; 47 | private String problemDetail; 48 | 49 | @Enumerated(EnumType.STRING) 50 | private ProblemStatus problemStatus; 51 | private int status; 52 | private Long patientid; 53 | private Long admissionid; 54 | 55 | @Temporal(TemporalType.TIMESTAMP) 56 | Date creationDate; 57 | 58 | @NotNull 59 | @ManyToOne(optional = true, fetch = FetchType.LAZY) 60 | @JoinColumn(name = "patient_id") 61 | private Patient patient; 62 | 63 | 64 | @OneToMany(mappedBy = "problem", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 65 | private List receipes; 66 | } 67 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/ProblemStatus.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | public enum ProblemStatus { 4 | AYAKTA, 5 | YATILIK, 6 | ACİL, 7 | AMELİYATHANE, 8 | YOĞUN_BAKIM 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Problems.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | public class Problems { 4 | 5 | private Long id; 6 | private String problemName; 7 | private String problemDetails; 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Receipe.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.FetchType; 9 | import javax.persistence.GeneratedValue; 10 | import javax.persistence.GenerationType; 11 | import javax.persistence.Id; 12 | import javax.persistence.JoinColumn; 13 | import javax.persistence.ManyToOne; 14 | import javax.persistence.SequenceGenerator; 15 | import javax.persistence.Table; 16 | 17 | import com.example.demo.entity.enums.ProblemStatus; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | import lombok.NoArgsConstructor; 22 | import lombok.ToString; 23 | @Data 24 | @AllArgsConstructor 25 | @NoArgsConstructor 26 | @ToString 27 | @Entity 28 | @Table(name="aareceipe") 29 | public class Receipe { 30 | 31 | @Id 32 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 33 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 34 | @Column(name = "receipeid") 35 | private Long receipeid; 36 | 37 | private String detail; 38 | private String barcode; 39 | private String drug_detail; 40 | private String usage; 41 | private String delivery_date; 42 | private Long problemid; 43 | private Long patientid; 44 | private int status; 45 | @ManyToOne(optional = true, fetch = FetchType.LAZY) 46 | @JoinColumn(name = "problem_id") 47 | private Problem problem; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | public enum Role { 4 | USER, ADMIN 5 | } 6 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/Staff.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import javax.persistence.CascadeType; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.EnumType; 10 | import javax.persistence.Enumerated; 11 | import javax.persistence.FetchType; 12 | import javax.persistence.GeneratedValue; 13 | import javax.persistence.GenerationType; 14 | import javax.persistence.Id; 15 | import javax.persistence.OneToMany; 16 | import javax.persistence.SequenceGenerator; 17 | import javax.persistence.Table; 18 | import javax.persistence.Temporal; 19 | import javax.persistence.TemporalType; 20 | 21 | import com.example.demo.entity.enums.City; 22 | import com.example.demo.entity.enums.Department; 23 | 24 | import lombok.AllArgsConstructor; 25 | import lombok.Data; 26 | import lombok.NoArgsConstructor; 27 | import lombok.ToString; 28 | 29 | @Data 30 | @AllArgsConstructor 31 | @NoArgsConstructor 32 | @ToString 33 | @Entity 34 | @Table(name = "aastaff") 35 | public class Staff { 36 | 37 | @Id 38 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 39 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 40 | @Column(name = "staffid") 41 | private Long staffid; 42 | private String staffname; 43 | private String stafflastname; 44 | private String gender; 45 | 46 | 47 | @Column(name = "email", unique = true) 48 | private String email; 49 | @Enumerated(EnumType.ORDINAL) 50 | private City city; 51 | 52 | @Column(name = "department", length = 100) 53 | @Enumerated(EnumType.ORDINAL) 54 | private Department department; 55 | 56 | @Temporal(TemporalType.TIMESTAMP) 57 | private Date createdDate; 58 | 59 | @Temporal(TemporalType.TIMESTAMP) 60 | private Date bornDate; 61 | 62 | @OneToMany(mappedBy = "staff", cascade = CascadeType.ALL, fetch = FetchType.EAGER) 63 | private List admissions; 64 | 65 | private int status; 66 | } 67 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity; 2 | import javax.persistence.*; 3 | 4 | import com.example.demo.entity.enums.Role; 5 | 6 | import lombok.Data; 7 | import javax.persistence.*; 8 | 9 | 10 | @Data 11 | @Entity 12 | @Table(name="aauser") 13 | public class User { 14 | 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AA_PATIENT_SEQ") 17 | @SequenceGenerator(sequenceName = "AA_PATIENT_SEQ", allocationSize = 1, name = "AA_PATIENT_SEQ") 18 | @Column(name = "userid") 19 | private Long userid; 20 | 21 | @Column(name="name") 22 | private String name; 23 | 24 | @Column(name="username") 25 | private String username; 26 | 27 | @Column(name="password") 28 | private String password; 29 | 30 | @Enumerated(EnumType.STRING) 31 | @Column(name="role") 32 | private Role role; 33 | 34 | //Not persistent. There is no column on database table. 35 | @Transient 36 | private String token; 37 | } 38 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/enums/City.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity.enums; 2 | 3 | public enum City { 4 | ADANA, 5 | ADIYAMAN, 6 | ANKARA, 7 | ANTALYA, 8 | AMASYA, 9 | ARDAHAN, 10 | ARTVİN, 11 | AĞRI, 12 | BARTIN, 13 | BALIKESIR, 14 | BOLU, 15 | BITLIS, 16 | BURSA, 17 | BURDUR, 18 | ÇANAKKALE, 19 | ÇORUM, 20 | ÇANKIRI, 21 | DENIZLI, 22 | DİYARBAKIR, 23 | EDIRNE, 24 | ELAZIĞ, 25 | ERZURUM, 26 | ESKIŞEHIR, 27 | ERZINCAN, 28 | GAZİANTEP, 29 | GİRESUN, 30 | HAKKARİ, 31 | HATAY, 32 | ISPARTA, 33 | İSTANBUL, 34 | İZMİR, 35 | KARS, 36 | KASTAMONU, 37 | KAYSERİ, 38 | KARAMAN, 39 | KIRŞEHİR, 40 | KİLİS, 41 | KOCAELİ, 42 | MARDİN, 43 | MANİSA, 44 | MERSİN, 45 | MUĞLA, 46 | MUŞ, 47 | ORDU, 48 | OSMANİYE, 49 | RİZE, 50 | SAKARYA, 51 | SAMSUN, 52 | SİNOP, 53 | ŞIRNAK, 54 | SİVAS, 55 | ŞANLIURFA, 56 | TEKİRDAĞ, 57 | TOKAT, 58 | TRABZON, 59 | YALOVA, 60 | YOZGAT, 61 | ZONGULDAK 62 | } 63 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/enums/Department.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity.enums; 2 | 3 | public enum Department { 4 | BRAIN_SURGEON, 5 | DENTIST, 6 | DERMATOLOGY, 7 | HEART_SURGEON, 8 | EAR_NOSE_THROAT, 9 | GENERAL_SURGEON, 10 | NUTRITIONIST, 11 | PLASTIC_SURGERY, 12 | } 13 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/enums/ProblemStatus.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity.enums; 2 | 3 | public enum ProblemStatus { 4 | AYAKTA, 5 | YATILIK, 6 | ACİL, 7 | AMELİYATHANE, 8 | YOĞUN_BAKIM 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/entity/enums/Role.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.entity.enums; 2 | 3 | public enum Role { 4 | USER, ADMIN 5 | } 6 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.exception; 2 | 3 | import java.util.Date; 4 | 5 | import com.example.demo.entity.Patient; 6 | import com.example.demo.entity.Problem; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @ToString 17 | public class ExceptionResponse { 18 | private Date date; 19 | private String message; 20 | } 21 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/exception/IMExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.exception; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | import org.springframework.web.context.request.WebRequest; 11 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 12 | 13 | @RestController 14 | @RestControllerAdvice 15 | public class IMExceptionHandler extends ResponseEntityExceptionHandler { 16 | 17 | @ExceptionHandler(PatientNotFoundException.class) 18 | public final ResponseEntity> handlePatientNotFoundException(Exception ex, WebRequest request) { 19 | ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage().split(":")[1]); 20 | logger.error("--Application was Error : "+ex.getMessage()); 21 | return new ResponseEntity<>(exceptionResponse, HttpStatus.NOT_FOUND); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/exception/PatientNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.exception; 2 | 3 | import org.springframework.web.bind.annotation.ResponseStatus; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @ResponseStatus(HttpStatus.NOT_FOUND) 7 | public class PatientNotFoundException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public PatientNotFoundException(String exception) { 12 | super(exception); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/repository/AdmissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.example.demo.entity.Admission; 6 | 7 | public interface AdmissionRepository extends JpaRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/repository/PatientRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.repository; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | 9 | import com.example.demo.entity.Patient; 10 | 11 | public interface PatientRepository extends JpaRepository { 12 | public List findAllByOrderByPatientidAsc(); 13 | 14 | public List findAllByOrderByNameAsc(); 15 | 16 | public Optional findByEmail(String email); 17 | 18 | @Query("select p from Patient p where p.name like %:name%") 19 | List findByName(String name); 20 | 21 | @Query("select p from Patient p where p.status = 1 order by p.patientid ASC") 22 | List findAllByStatusEquelsOne(); 23 | 24 | @Query("select p from Patient p where p.status = 0") 25 | List findAllByStatusEquelsZero(); 26 | } 27 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/repository/ProblemRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | 8 | import com.example.demo.entity.Patient; 9 | import com.example.demo.entity.Problem; 10 | 11 | public interface ProblemRepository extends JpaRepository { 12 | 13 | @Query("select p from Problem p where p.status = 1 order by p.problemid ASC") 14 | List findAllByStatusEquelsOne(); 15 | @Query("select p from Problem p where patientid=:patientid and p.status = 1 order by p.problemid ASC") 16 | List findByPatientidWithStatusOne(Long patientid); 17 | } 18 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/repository/ReceipeRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.repository; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | 10 | import com.example.demo.entity.Patient; 11 | import com.example.demo.entity.Receipe; 12 | 13 | public interface ReceipeRepository extends JpaRepository { 14 | 15 | @Query("select p from Receipe p where p.status = 1 order by p.receipeid ASC") 16 | List findAllByStatusEquelsOne(); 17 | 18 | @Query("select p from Receipe p where p.status = 1 and p.problemid=:problemid order by p.receipeid ASC") 19 | List findAllByProblemId(@Param("problemid") Long problemid); 20 | } 21 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/repository/StaffRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | 8 | import com.example.demo.entity.Staff; 9 | 10 | public interface StaffRepository extends JpaRepository { 11 | @Query("select s from Staff s where s.status = 1 order by s.staffid ASC") 12 | List findAllByStatusEquelsOne(); 13 | @Query("select s from Staff s where s.status = 0 order by s.staffid ASC") 14 | List findAllByStatusEquelsZero(); 15 | } 16 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/security/JWTAuthorizationFilter.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.security; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | //import org.springframework.security.authentication.AuthenticationManager; 10 | //import org.springframework.security.core.Authentication; 11 | //import org.springframework.security.core.context.SecurityContextHolder; 12 | //import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; 13 | 14 | public class JWTAuthorizationFilter /* extends BasicAuthenticationFilter */{ 15 | 16 | // private JwtTokenProvider jwtTokenProvider; 17 | // 18 | // public JWTAuthorizationFilter(AuthenticationManager authenticationManager, 19 | // JwtTokenProvider tokenProvider) { 20 | // super(authenticationManager); 21 | // jwtTokenProvider = tokenProvider; 22 | // } 23 | // 24 | // @Override 25 | // protected void doFilterInternal(HttpServletRequest request, 26 | // HttpServletResponse response, FilterChain chain) 27 | // throws IOException, ServletException { 28 | // Authentication authentication = jwtTokenProvider.getAuthentication(request); 29 | // 30 | // if(authentication !=null && jwtTokenProvider.validateToken(request)){ 31 | // SecurityContextHolder.getContext().setAuthentication(authentication); 32 | // } 33 | // chain.doFilter(request, response); 34 | // } 35 | } 36 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/security/JwtTokenProvider.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.security; 2 | 3 | 4 | import io.jsonwebtoken.Claims; 5 | import io.jsonwebtoken.Jwts; 6 | import io.jsonwebtoken.SignatureAlgorithm; 7 | import org.springframework.beans.factory.annotation.Value; 8 | //import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 9 | //import org.springframework.security.core.Authentication; 10 | //import org.springframework.security.core.GrantedAuthority; 11 | //import org.springframework.security.core.authority.SimpleGrantedAuthority; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import java.util.Arrays; 16 | import java.util.Date; 17 | import java.util.List; 18 | import java.util.stream.Collectors; 19 | 20 | //@Component 21 | public class JwtTokenProvider { 22 | // 23 | // @Value("${app.jwt.secret}") 24 | // private String jwtSecret; 25 | // 26 | // @Value("${app.jwt.token.prefix}") 27 | // private String jwtTokenPrefix; 28 | // 29 | // @Value("${app.jwt.header.string}") 30 | // private String jwtHeaderString; 31 | // 32 | // @Value("${app.jwt.expiration-in-ms}") 33 | // private Long jwtExpirationInMs; 34 | // 35 | // public String generateToken(Authentication auth){ 36 | // String authorities = auth.getAuthorities().stream() 37 | // .map(GrantedAuthority::getAuthority) 38 | // .collect(Collectors.joining()); 39 | // 40 | // return Jwts.builder().setSubject(auth.getName()) 41 | // .claim("roles", authorities) 42 | // .setExpiration(new Date(System.currentTimeMillis() + jwtExpirationInMs)) 43 | // .signWith(SignatureAlgorithm.HS512, jwtSecret).compact(); 44 | // } 45 | // 46 | // public Authentication getAuthentication(HttpServletRequest request){ 47 | // String token = resolveToken(request); 48 | // if(token == null){ 49 | // return null; 50 | // } 51 | // Claims claims = Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(token).getBody(); 52 | // String username = claims.getSubject(); 53 | // final List authorities = Arrays.stream(claims.get("roles").toString().split(",")) 54 | // .map(role -> role.startsWith("ROLE_")?role:"ROLE_"+role) 55 | // .map(SimpleGrantedAuthority::new) 56 | // .collect(Collectors.toList()); 57 | // return username!= null ? new UsernamePasswordAuthenticationToken(username, null, authorities): null; 58 | // } 59 | // 60 | // public boolean validateToken(HttpServletRequest request){ 61 | // String token = resolveToken(request); 62 | // if(token == null){ 63 | // return false; 64 | // } 65 | // Claims claims = Jwts.parser().setSigningKey(jwtSecret).parseClaimsJws(token).getBody(); 66 | // if(claims.getExpiration().before(new Date())){ 67 | // return false; 68 | // } 69 | // return true; 70 | // } 71 | // 72 | // private String resolveToken(HttpServletRequest req){ 73 | // //Bearer key... 74 | // String bearerToken = req.getHeader(jwtHeaderString); 75 | // if(bearerToken!=null && bearerToken.startsWith(jwtTokenPrefix)){ 76 | // return bearerToken.substring(7, bearerToken.length()); 77 | // } 78 | // return null; 79 | // } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/security/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | //import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | //import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | //import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | //import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | //import org.springframework.security.core.userdetails.UserDetailsService; 11 | //import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 12 | //import org.springframework.security.crypto.password.PasswordEncoder; 13 | //import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 14 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 15 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 16 | 17 | //@Configuration 18 | //@EnableWebSecurity 19 | public class WebSecurityConfig /* extends WebSecurityConfigurerAdapter */{ 20 | // 21 | // @Autowired 22 | // private JwtTokenProvider jwtTokenProvider; 23 | // 24 | // @Autowired 25 | // private UserDetailsService userDetailsService; 26 | // 27 | // @Bean 28 | // public PasswordEncoder passwordEncoder(){ 29 | // return new BCryptPasswordEncoder(); 30 | // } 31 | // 32 | // @Override 33 | // protected void configure(HttpSecurity http) throws Exception { 34 | // //Cross-origin-resource-sharing: localhost:8080, localhost:4200(allow for it.) 35 | // http.cors().and() 36 | // .authorizeRequests() 37 | // //These are public paths 38 | // .antMatchers("/resources/**", "/error", "/api/user/**").permitAll() 39 | // //These can be reachable for just have admin role. 40 | // .antMatchers("/api/admin/**").hasRole("ADMIN") 41 | // //All remaining paths should need authentication. 42 | // .anyRequest().fullyAuthenticated() 43 | // .and() 44 | // //logout will log the user out by invalidated session. 45 | // .logout().permitAll() 46 | // .logoutRequestMatcher(new AntPathRequestMatcher("/api/user/logout", "POST")) 47 | // .and() 48 | // //login form and path 49 | // .formLogin().loginPage("/api/user/login").and() 50 | // //enable basic authentication 51 | // .httpBasic().and() 52 | // //We will handle it later. 53 | // //Cross side request forgery 54 | // .csrf().disable(); 55 | // 56 | // //jwt filter 57 | // http.addFilter(new JWTAuthorizationFilter(authenticationManager(),jwtTokenProvider)); 58 | // } 59 | // 60 | // 61 | // 62 | // @Override 63 | // protected void configure(AuthenticationManagerBuilder auth) throws Exception { 64 | // auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); 65 | // } 66 | // 67 | // //Cross origin resource sharing. 68 | // @Bean 69 | // public WebMvcConfigurer corsConfigurer(){ 70 | // return new WebMvcConfigurer() { 71 | // @Override 72 | // public void addCorsMappings(CorsRegistry registry) { 73 | // registry.addMapping("/**").allowedOrigins("*").allowedMethods("*"); 74 | // } 75 | // }; 76 | // } 77 | } -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/service/PatientService.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.service; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | import javax.validation.Valid; 9 | 10 | import org.modelmapper.ModelMapper; 11 | import org.slf4j.Logger; 12 | import org.springframework.stereotype.Service; 13 | 14 | import com.example.demo.dto.PatientDto; 15 | import com.example.demo.dto.PatientSingleDto; 16 | import com.example.demo.entity.Patient; 17 | import com.example.demo.exception.PatientNotFoundException; 18 | import com.example.demo.repository.PatientRepository; 19 | 20 | import javassist.NotFoundException; 21 | 22 | @Service 23 | public class PatientService { 24 | private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 25 | 26 | private final PatientRepository patientRepository; 27 | private final ModelMapper modelMapper; 28 | private final Logger logger; 29 | 30 | public PatientService(PatientRepository patientRepository, ModelMapper modelMapper, Logger logger) { 31 | this.patientRepository = patientRepository; 32 | this.modelMapper = modelMapper; 33 | this.logger = logger; 34 | } 35 | 36 | public List findAll() throws Exception { 37 | try { 38 | // List patients = patientRepository.findAllByOrderByPatientidAsc(); 39 | List patients = patientRepository.findAllByStatusEquelsOne(); 40 | if (patients.size() < 1) { 41 | logger.error("There is never patients "); 42 | throw new PatientNotFoundException("There is never patient "); 43 | } 44 | PatientDto[] dtos = modelMapper.map(patients, PatientDto[].class); 45 | List patientDtos = Arrays.asList(dtos); 46 | patientDtos.forEach(patient->{ 47 | patient.getProblems().forEach(problem->{ 48 | problem.setPId(patient.getPatientid()); 49 | }); 50 | }); 51 | return Arrays.asList(dtos); 52 | } catch (Exception e) { 53 | throw new Exception(e); 54 | } 55 | } 56 | 57 | public List findAllDeletedPatients() { 58 | List patients = patientRepository.findAllByStatusEquelsZero(); 59 | if (patients.size() > 0) { 60 | PatientDto[] authorDtos = modelMapper.map(patients, PatientDto[].class); 61 | return Arrays.asList(authorDtos); 62 | } else { 63 | logger.error("There is no deleted patient "); 64 | throw new PatientNotFoundException("There is no deleted patient "); 65 | } 66 | } 67 | 68 | public Patient save(Patient patient) { 69 | patient.setStatus(1); 70 | patient = patientRepository.save(patient); 71 | if (patient.getPatientid() > -1) 72 | return patient; 73 | else{ 74 | logger.error("A problem occurred during saving patient" ); 75 | throw new PatientNotFoundException("A problem occurred during saving patient" ); 76 | } 77 | } 78 | 79 | public Boolean delete(@Valid Long patientid) throws Exception { 80 | Optional optPatient = patientRepository.findById(patientid); 81 | if (optPatient.isPresent()) { 82 | optPatient.get().setStatus(0); 83 | optPatient.get().getProblems().forEach(p -> { 84 | p.setStatus(0); 85 | }); 86 | patientRepository.save(optPatient.get()); 87 | // patientRepository.delete(optpatient.get()); 88 | return true; 89 | } else { 90 | logger.error("--Patient does not exist with this id " + patientid); 91 | throw new PatientNotFoundException("Patient does not exist with this id " + patientid); 92 | } 93 | } 94 | 95 | public PatientSingleDto findByPatientId(Long patientid) throws Exception { 96 | Optional optPatient = patientRepository.findById(patientid); 97 | if (optPatient.isPresent()) { 98 | optPatient.get().getProblems().removeIf(problem -> problem.getStatus() == 0); 99 | PatientSingleDto dto = modelMapper.map(optPatient.get(), PatientSingleDto.class); 100 | return dto; 101 | } else { 102 | logger.error("--Patient does not exist with this id " + patientid); 103 | throw new PatientNotFoundException("Patient does not exist with this id " + patientid); 104 | } 105 | } 106 | 107 | public Patient findByEmail(String email) throws Exception { 108 | Optional patient = patientRepository.findByEmail(email); 109 | if (patient.isPresent()) 110 | return patient.get(); 111 | else { 112 | logger.error("--Patient does not exist with this email " + email); 113 | throw new PatientNotFoundException("Patient does not exist with this email " + email); 114 | } 115 | } 116 | 117 | public Boolean update(Long patientid, @Valid Patient patient) throws Exception { 118 | Optional p = patientRepository.findById(patientid); 119 | if (p.isPresent()) { 120 | patient.setPatientid(patientid); 121 | patientRepository.save(patient); 122 | return true; 123 | } else { 124 | logger.error("--Patient does not exist with this id " + patientid); 125 | throw new PatientNotFoundException("Patient does not exist with this id " + patientid); 126 | } 127 | } 128 | 129 | public List findByName(String name) throws Exception { 130 | List patients = patientRepository.findByName(name); 131 | if (patients.size() > 0) { 132 | return patients; 133 | } else { 134 | logger.error("--Patient does not exist with this name " + name); 135 | throw new PatientNotFoundException("Patient does not exist with this name " + name); 136 | } 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/service/ProblemService.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.service; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | import javax.validation.Valid; 9 | 10 | import org.modelmapper.ModelMapper; 11 | import org.slf4j.Logger; 12 | import org.springframework.stereotype.Service; 13 | 14 | import com.example.demo.dto.ProblemDto; 15 | import com.example.demo.dto.ProblemDtoForPatientSingleDto; 16 | import com.example.demo.dto.ProblemGetDto; 17 | import com.example.demo.entity.Patient; 18 | import com.example.demo.entity.Problem; 19 | import com.example.demo.repository.PatientRepository; 20 | import com.example.demo.repository.ProblemRepository; 21 | import com.sun.xml.bind.v2.runtime.unmarshaller.XsiNilLoader.Array; 22 | 23 | import javassist.NotFoundException; 24 | 25 | @Service 26 | public class ProblemService { 27 | private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 28 | private final ProblemRepository problemRepository; 29 | private final PatientRepository patientRepository; 30 | private final ModelMapper modelMapper; 31 | private final Logger logger; 32 | 33 | public ProblemService(ProblemRepository problemRepository, PatientRepository patientRepository, 34 | ModelMapper modelMapper, Logger logger) { 35 | this.patientRepository = patientRepository; 36 | this.problemRepository = problemRepository; 37 | this.modelMapper = modelMapper; 38 | this.logger = logger; 39 | } 40 | 41 | public ProblemDtoForPatientSingleDto save(ProblemDto dto) throws NotFoundException { 42 | Optional patient = patientRepository.findById(dto.getPId()); 43 | if (!patient.isPresent()) { 44 | logger.error("Patient does already exist wtih patientid : " + dto.getPId()); 45 | throw new NotFoundException("Patient does already exist with patientid : " + dto.getPId()); 46 | } 47 | Problem problem = modelMapper.map(dto, Problem.class); 48 | problem.setPatient(patient.get()); 49 | problem.setPatientid(patient.get().getPatientid()); 50 | problemRepository.save(problem); 51 | ProblemDtoForPatientSingleDto getDto = modelMapper.map(problem, ProblemDtoForPatientSingleDto.class); 52 | return getDto; 53 | } 54 | 55 | public Boolean delete(Long problemid) throws NotFoundException { 56 | Optional optional = problemRepository.findById(problemid); 57 | if (!optional.isPresent()) { 58 | logger.error("Problem does not exist wtih problemid : " + problemid); 59 | throw new NotFoundException("Problem does not exist with problemid : " + problemid); 60 | } 61 | optional.get().setStatus(0); 62 | problemRepository.save(optional.get()); 63 | // problemRepository.delete(optional.get()); 64 | return true; 65 | } 66 | 67 | public ProblemGetDto findByProblemid(Long problemid) throws NotFoundException { 68 | Optional optional = problemRepository.findById(problemid); 69 | if (!optional.isPresent()) { 70 | logger.error("Problem does not exist wtih problemid : " + problemid); 71 | throw new NotFoundException("Problem does not exist with problemid : " + problemid); 72 | } 73 | ProblemGetDto dto = modelMapper.map(optional.get(), ProblemGetDto.class); 74 | return dto; 75 | } 76 | 77 | public Boolean update(Long problemid, @Valid ProblemDtoForPatientSingleDto dto) throws NotFoundException { 78 | Optional optional = problemRepository.findById(problemid); 79 | if (!optional.isPresent()) { 80 | logger.error("Problem does not exist wtih problemid : " + problemid); 81 | throw new NotFoundException("Problem does not exist with problemid : " + problemid); 82 | } 83 | return true; 84 | } 85 | 86 | public List findAllByPatientid(Long patientid) throws NotFoundException { 87 | List list = problemRepository.findByPatientidWithStatusOne(patientid); 88 | if(list.size()>0) { 89 | 90 | return Arrays.asList(modelMapper.map(list, ProblemDtoForPatientSingleDto[].class)); 91 | } 92 | logger.error("Problem does not exist wtih patientid : " + patientid); 93 | throw new NotFoundException("Problem does not exist with patientid : " + patientid); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/service/ReceipeService.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.service; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import org.modelmapper.ModelMapper; 8 | import org.slf4j.Logger; 9 | import org.springframework.stereotype.Service; 10 | 11 | import com.example.demo.dto.PatientDto; 12 | import com.example.demo.dto.ReceipeDto; 13 | import com.example.demo.entity.Problem; 14 | import com.example.demo.entity.Receipe; 15 | import com.example.demo.exception.PatientNotFoundException; 16 | import com.example.demo.repository.ProblemRepository; 17 | import com.example.demo.repository.ReceipeRepository; 18 | 19 | import javassist.NotFoundException; 20 | 21 | @Service 22 | public class ReceipeService { 23 | private final ReceipeRepository receipeRepository; 24 | private final ModelMapper modelMapper; 25 | private final Logger logger; 26 | private final ProblemRepository problemRepository; 27 | 28 | public ReceipeService(ReceipeRepository receipeRepository, ModelMapper modelMapper, Logger logger, 29 | ProblemRepository problemRepository) { 30 | this.receipeRepository = receipeRepository; 31 | this.modelMapper = modelMapper; 32 | this.logger = logger; 33 | this.problemRepository = problemRepository; 34 | } 35 | 36 | public List getAll() throws Exception { 37 | try { 38 | List list = receipeRepository.findAllByStatusEquelsOne(); 39 | if (list.size() > 0) { 40 | ReceipeDto[] dtos = modelMapper.map(list, ReceipeDto[].class); 41 | return Arrays.asList(dtos); 42 | } else { 43 | logger.error("there is no any receipe"); 44 | throw new PatientNotFoundException("there is no any receipe"); 45 | } 46 | } catch (Exception e) { 47 | throw new Exception(e); 48 | } 49 | } 50 | 51 | public void findByreceipeId() { 52 | 53 | } 54 | 55 | public List findAllByProblemId(Long problemid) throws Exception { 56 | try { 57 | List list = receipeRepository.findAllByProblemId(problemid); 58 | if (list.size() > 0) { 59 | ReceipeDto[] dtos = modelMapper.map(list, ReceipeDto[].class); 60 | return Arrays.asList(dtos); 61 | } else { 62 | logger.info("This problem has no any receipe"); 63 | throw new PatientNotFoundException("This problem has no any receipe"); 64 | } 65 | } catch (Exception e) { 66 | throw new Exception(e); 67 | } 68 | } 69 | 70 | public ReceipeDto save(ReceipeDto dto) throws NotFoundException { 71 | Optional opt = problemRepository.findById(dto.getProblemid()); 72 | if (opt.isPresent()) { 73 | dto.setStatus(1); 74 | Receipe receipe = modelMapper.map(dto, Receipe.class); 75 | receipe.setProblem(opt.get()); 76 | receipe.setProblemid(opt.get().getProblemid()); 77 | receipe.setPatientid(opt.get().getPatientid()); 78 | receipe = receipeRepository.save(receipe); 79 | if (receipe.getReceipeid() > -1) { 80 | dto.setReceipeid(receipe.getReceipeid()); 81 | logger.info("Perfect.. Saving Receipe for related problem is ok"); 82 | return dto; 83 | } else { 84 | logger.error("A problem occurred during saving receipe"); 85 | throw new PatientNotFoundException("A problem occurred during saving receipe"); 86 | } 87 | } else { 88 | logger.error("There is no such problem with problem id : " + dto.getProblemid()); 89 | throw new NotFoundException("There is no such problem with problem id : " + dto.getProblemid()); 90 | } 91 | 92 | } 93 | 94 | public boolean delete(Long receipeid) throws NotFoundException { 95 | Optional optional = receipeRepository.findById(receipeid); 96 | if (!optional.isPresent()) { 97 | logger.error("Receipe does not exist wtih receipeid : " + receipeid); 98 | throw new NotFoundException("Receipe does not exist with receipeid : " + receipeid); 99 | } 100 | optional.get().setStatus(0); 101 | receipeRepository.save(optional.get()); 102 | logger.info("Receipe was deleted wtih receipeid : " + receipeid); 103 | return true; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/service/StaffService.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.service; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Arrays; 5 | import java.util.Date; 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | import javax.validation.Valid; 10 | 11 | import org.modelmapper.ModelMapper; 12 | import org.slf4j.Logger; 13 | import org.springframework.stereotype.Service; 14 | 15 | import com.example.demo.dto.StaffDto; 16 | import com.example.demo.entity.Staff; 17 | import com.example.demo.exception.PatientNotFoundException; 18 | import com.example.demo.repository.StaffRepository; 19 | 20 | import javassist.NotFoundException; 21 | 22 | @Service 23 | public class StaffService { 24 | private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 25 | private final ModelMapper modelMapper; 26 | private final Logger logger; 27 | private final StaffRepository staffRepository; 28 | 29 | public StaffService(StaffRepository staffRepository, ModelMapper modelMapper, Logger logger) { 30 | this.staffRepository = staffRepository; 31 | this.modelMapper = modelMapper; 32 | this.logger = logger; 33 | } 34 | 35 | public StaffDto save(Staff staff) throws Exception { 36 | try { 37 | staff.setCreatedDate(new Date()); 38 | staff.setStatus(1); 39 | staff = staffRepository.save(staff); 40 | if (staff.getStaffid() > -1) { 41 | StaffDto staffDto = modelMapper.map(staff, StaffDto.class); 42 | return staffDto; 43 | } else { 44 | logger.error("--Staff can not exist"); 45 | throw new Exception("Staff can not exist"); 46 | } 47 | } catch (Exception e) { 48 | throw new Exception(e); 49 | } 50 | } 51 | 52 | public List getAll() throws NotFoundException { 53 | List staffs = staffRepository.findAllByStatusEquelsOne(); 54 | if (staffs.size() > 0) { 55 | StaffDto[] staffDtos = modelMapper.map(staffs, StaffDto[].class); 56 | return Arrays.asList(staffDtos); 57 | } else { 58 | logger.error("--There is never Staff"); 59 | throw new NotFoundException("There is never Staff"); 60 | } 61 | } 62 | 63 | public List getAllDeletedStaff() throws NotFoundException { 64 | List staffs = staffRepository.findAllByStatusEquelsZero(); 65 | if (staffs.size() > 0) { 66 | StaffDto[] staffDtos = modelMapper.map(staffs, StaffDto[].class); 67 | return Arrays.asList(staffDtos); 68 | } else { 69 | logger.error("--There is never deleted Staff"); 70 | throw new NotFoundException("There is never deleted Staff"); 71 | } 72 | } 73 | 74 | public Boolean delete(@Valid Long staffid) throws Exception { 75 | Optional optional = staffRepository.findById(staffid); 76 | if (optional.isPresent()) { 77 | optional.get().setStatus(0); 78 | staffRepository.save(optional.get()); 79 | return true; 80 | } else { 81 | logger.error("--Staff does not exist with this id " + staffid); 82 | throw new Exception("Staff does not exist with this id " + staffid); 83 | } 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /backend/src/main/java/com/example/demo/util/ApiPaths.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.util; 2 | 3 | public class ApiPaths { 4 | private static final String BASE_PATH = "/api"; 5 | private static final String PATIENT_PATH = "/patient"; 6 | private static final String PROBLEM_PATH = "/problem"; 7 | private static final String RECEIPE_PATH = "/receipe"; 8 | 9 | public static final class PatientCtrl { 10 | public static final String CTRL = BASE_PATH + PATIENT_PATH; 11 | } 12 | public static final class ProblemCtrl { 13 | public static final String CTRL = BASE_PATH + PROBLEM_PATH; 14 | } 15 | public static final class ReceipeCtrl { 16 | public static final String CTRL = BASE_PATH + RECEIPE_PATH; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /backend/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8185 2 | 3 | spring.jpa.hibernate.ddl-auto=update 4 | spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect 5 | spring.datasource.url= jdbc:oracle:thin:@IP_ADRES:PORT_NUMBER:DB_NAME 6 | spring.datasource.username=username 7 | spring.datasource.password=password 8 | spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver 9 | ## this shows the sql actions in the terminal logs 10 | #spring.jpa.show-sql=true 11 | 12 | 13 | 14 | #jwt 15 | app.jwt.secret=ArbitrarySecretKey 16 | #1 day 17 | app.jwt.expiration-in-ms=86400000 18 | app.jwt.token.prefix=Bearer 19 | app.jwt.header.string=Authorization -------------------------------------------------------------------------------- /backend/src/test/java/com/example/demo/FirstAppApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class FirstAppApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /backend/src/test/java/com/example/demo/patient/PatientControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.patient; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | import java.util.List; 8 | 9 | import static org.mockito.ArgumentMatchers.any; 10 | import static org.mockito.Mockito.when; 11 | 12 | import org.assertj.core.util.Arrays; 13 | import org.hamcrest.MatcherAssert; 14 | import org.hamcrest.Matchers; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | import org.mockito.InjectMocks; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 21 | import org.springframework.http.HttpEntity; 22 | import org.springframework.http.HttpHeaders; 23 | import org.springframework.http.HttpStatus; 24 | import org.springframework.http.ResponseEntity; 25 | import org.springframework.mock.web.MockHttpServletRequest; 26 | import org.springframework.test.context.junit.jupiter.SpringExtension; 27 | import org.springframework.web.client.RestTemplate; 28 | import org.springframework.web.context.request.RequestContextHolder; 29 | import org.springframework.web.context.request.ServletRequestAttributes; 30 | 31 | import com.example.demo.controller.PatientController; 32 | import com.example.demo.dto.PatientDto; 33 | import com.example.demo.entity.Patient; 34 | import com.example.demo.entity.enums.City; 35 | import com.example.demo.service.PatientService; 36 | 37 | @ExtendWith(SpringExtension.class) 38 | //@SpringBootTest 39 | //@RunWith(SpringRunner.class) 40 | @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) 41 | public class PatientControllerTest { 42 | @InjectMocks 43 | PatientController patientController; 44 | 45 | @Autowired 46 | private PatientService patientService; 47 | 48 | private RestTemplate restTemplate; 49 | 50 | private ResponseEntity response; 51 | 52 | @Test 53 | public void testGetAllPatientWithStatusOne() throws URISyntaxException { 54 | restTemplate = new RestTemplate(); 55 | String baseUrl = "http://localhost:8185/patient"; 56 | URI uri = new URI(baseUrl); 57 | ResponseEntity result = restTemplate.getForEntity(baseUrl, Object.class); 58 | // List 59 | assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); 60 | } 61 | 62 | @Test 63 | public void savePatientV1() { 64 | try { 65 | Patient p1 = new Patient("zipato", "zazula", "Male", City.ANKARA, "zipato@gmail.com", 1); 66 | String addURI = "http://localhost:8185/patient"; 67 | 68 | HttpHeaders headers = new HttpHeaders(); 69 | headers.add("Accept", "application/json"); 70 | headers.add("Content-Type", "application/json"); 71 | HttpEntity entity = new HttpEntity(p1, headers); 72 | 73 | response = this.restTemplate.postForEntity(addURI, p1, Patient.class); 74 | // responseBody = response.getBody().toString(); 75 | assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); 76 | } catch (Exception e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | 81 | @Test 82 | void savePatientV2() { 83 | Patient p1 = new Patient("kamara", "tamara", "Female", City.ANKARA, "kamara.tamara@mynet.com", 1); 84 | Patient p2 = patientService.save(p1); 85 | assertThat(p2.getPatientid()).isNotNull(); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /frontend/=#.##: -------------------------------------------------------------------------------- 1 | + moment@2.24.0 2 | + react-dom@16.12.0 3 | + react@16.12.0 4 | + react-dates@21.8.0 5 | added 38 packages from 16 contributors, updated 3 packages and audited 906485 packages in 34.523s 6 | found 1 high severity vulnerability 7 | run `npm audit fix` to fix them, or `npm audit` for details 8 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode. 10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits. 13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode. 18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder. 23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes. 26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firs-react", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material/react-checkbox": "^0.15.0", 7 | "@testing-library/jest-dom": "^4.2.4", 8 | "@testing-library/react": "^9.3.3", 9 | "@testing-library/user-event": "^7.1.2", 10 | "alertifyjs": "^1.13.1", 11 | "axios": "^1.6.0", 12 | "formik": "^2.0.8", 13 | "moment": "^2.24.0", 14 | "raw-loader": "^3.1.0", 15 | "react": "^16.12.0", 16 | "react-alertify-js": "0.0.1", 17 | "react-checkbox": "^0.1.3", 18 | "react-datepicker": "^2.11.0", 19 | "react-dates": "^21.8.0", 20 | "react-dom": "^16.12.0", 21 | "react-moment": "^0.9.7", 22 | "react-preloaders": "^3.0.3", 23 | "react-router": "^5.1.2", 24 | "react-router-dom": "^5.1.2", 25 | "react-scripts": "5.0.1", 26 | "react-select": "^3.0.8" 27 | }, 28 | "scripts": { 29 | "start": "set PORT=5422 && react-scripts start", 30 | "build": "react-scripts build", 31 | "test": "react-scripts test", 32 | "eject": "react-scripts eject" 33 | }, 34 | "eslintConfig": { 35 | "extends": "react-app" 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celalaygar/Hospital-Management-System-React-and-SpringBoot/570acedd8ff64431d8e2f71095780127ced86e0d/frontend/public/favicon.ico -------------------------------------------------------------------------------- /frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | React App 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celalaygar/Hospital-Management-System-React-and-SpringBoot/570acedd8ff64431d8e2f71095780127ced86e0d/frontend/public/logo192.png -------------------------------------------------------------------------------- /frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/celalaygar/Hospital-Management-System-React-and-SpringBoot/570acedd8ff64431d8e2f71095780127ced86e0d/frontend/public/logo512.png -------------------------------------------------------------------------------- /frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- 1 | /* .App { 2 | text-align: center; 3 | } */ 4 | 5 | 6 | -------------------------------------------------------------------------------- /frontend/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './App.css'; 3 | import { Switch, Route, BrowserRouter } from "react-router-dom"; //Router, 4 | import ListPatientComponent from './Routes/PatientComponents/ListPatientComponent'; 5 | import ViewPatientComponent from './Routes/PatientComponents/ViewPatientComponent'; 6 | import AddPatientComponent from './Routes/PatientComponents/AddPatientComponent'; 7 | import EditPatientComponent from './Routes/PatientComponents/EditPatientComponent'; 8 | import NotFoundComponent from './NotFound/NotFoundComponent'; 9 | import ViewProblemComponent from './Routes/PatientComponents/ProblemComponent/ViewProblemComponent'; 10 | import IndexPage2 from './Routes/IndexPage2'; 11 | import { Lines } from 'react-preloaders'; 12 | import ReceipeFormComponent from './Routes/PatientComponents/ReceipeComponent/ReceipeFormComponent'; 13 | import NavbarComponent from './Navbar/NavbarComponent'; 14 | import ProblemFormComponent from './Routes/PatientComponents/ProblemComponent/ProblemFormComponent'; 15 | // https://www.youtube.com/watch?v=DQ93TxqKkWo 16 | function App() { 17 | return ( 18 | 19 | 20 | 21 | 22 | 23 | 24 | {/* style={{width: 400, height: 100}} */} 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {/* */} 47 | {/* ; */} 48 | 49 | 50 | 51 | {/* ; */} 52 | 53 | {/* ; */} 54 | 55 | ); 56 | } 57 | 58 | export default App; -------------------------------------------------------------------------------- /frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /frontend/src/Assets/css/AddPatient.css: -------------------------------------------------------------------------------- 1 | .ck input.ck-input.ck-input-text { 2 | box-shadow: var(--ck-inner-shadow),0 0; 3 | background: var(--ck-color-input-background); 4 | border: 1px solid var(--ck-color-input-border); 5 | padding: var(--ck-spacing-extra-tiny) var(--ck-spacing-medium); 6 | transition-property: box-shadow,border; 7 | transition: .2s ease-in-out; 8 | 9 | height: inherit; 10 | width: inherit; 11 | font-size: inherit; 12 | margin: 0; 13 | box-sizing: border-box; 14 | } 15 | 16 | .title { 17 | color: #057888 18 | } 19 | .ck { height : '100px' } 20 | .ck-editor__main{ height : '100px' } 21 | .ck-editor { height : '200px' } 22 | 23 | .ck-editor { 24 | width: 700px; 25 | height: 500px; 26 | } 27 | 28 | @media (max-width: 1200px) { 29 | .ck-editor { 30 | width: 450px; 31 | height: 200px; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /frontend/src/Assets/css/ListPatientComponent.css: -------------------------------------------------------------------------------- 1 | .checkbox-label { 2 | margin: 0 0 10px 0; 3 | color : darkblue; 4 | } 5 | .title{ 6 | color: darkblue; 7 | } -------------------------------------------------------------------------------- /frontend/src/Navbar/NavbarComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | 3 | export default class NavbarComponent extends Component { 4 | render() { 5 | return ( 6 | 7 | 8 | Home 9 | 10 | 11 | 12 | 13 | 14 | 15 | Patients 16 | 17 | 18 | 19 | Patients 20 | 21 | 22 | Patients 23 | Add Patient 24 | 25 | 26 | 27 | 28 | 29 | 30 | ) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /frontend/src/NotFound/NotFoundComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import './NotFoundCss.css' 3 | 4 | 5 | class NotFoundComponent extends Component { 6 | 7 | 8 | render() { 9 | return ( 10 | 11 | 12 | 13 | 14 | Oops! 15 | 404 Not Found 16 | 17 | Sorry, an error has occured, Requested page not found! 18 | 19 | 20 | 21 | Take Me Home 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | ); 30 | } 31 | } 32 | 33 | export default NotFoundComponent; -------------------------------------------------------------------------------- /frontend/src/NotFound/NotFoundCss.css: -------------------------------------------------------------------------------- 1 | .error-template {padding: 40px 15px;text-align: center;} 2 | .error-actions {margin-top:15px;margin-bottom:15px;} 3 | .error-actions .btn { margin-right:10px; } -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/PatientDetail.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import * as alertify from 'alertifyjs'; 3 | import "alertifyjs/build/css/themes/default.min.css"; 4 | import "alertifyjs/build/css/themes/bootstrap.min.css"; 5 | import "alertifyjs/build/css/alertify.min.css"; 6 | import PatientService from '../../services/PatientService'; 7 | import { withRouter } from 'react-router'; 8 | import Moment from 'react-moment'; 9 | 10 | class PatientDetail extends Component { 11 | constructor(props) { 12 | super(props) 13 | this.state = { 14 | patientid: props.patientid, 15 | name: props.name, 16 | lastname: props.lastname, 17 | phoneNo: props.phoneNo, 18 | email: props.email, 19 | bornDate: props.bornDate, 20 | gender: props.gender, 21 | city: props.city, 22 | message: '' 23 | }; 24 | // props.array.map(a => { 25 | // console.log(a + ' : ' + props[a] + ' : ' + (typeof props[a])) 26 | // }) 27 | } 28 | editPatient(id) { 29 | alertify.confirm( 30 | "Are you sure to edit this patient.", 31 | ok => { 32 | window.localStorage.setItem("patientId", id); 33 | this.props.history.push('/edit-patient'); 34 | }, 35 | cancel => { 36 | alertify.error('Cancel'); 37 | } 38 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 39 | } 40 | deletePatient(patientid) { 41 | alertify.confirm("Are you sure to delete this patient.", 42 | function () { 43 | PatientService.deletePatient(patientid) 44 | .then(res => { 45 | window.location.href = '/patients'; 46 | alertify.success("Deleting is ok "); 47 | }) 48 | }, 49 | function () { 50 | alertify.error('Cancel'); 51 | } 52 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 53 | } 54 | render() { 55 | var age = null; 56 | if (this.props.bornDate != null) { 57 | var born = Number(this.props.bornDate.substr(0, 4)); 58 | var now = Number(new Date().toLocaleDateString('tr-TR').substr(6, 4)); 59 | age = now - born; 60 | } 61 | return ( 62 | 63 | 64 | Patient Detail 65 | 66 | Patient id : {this.props.patientid} 67 | Name : {this.props.name} 68 | Last Name : {this.props.lastname} 69 | Phone No : {this.props.phoneNo} 70 | Age : 71 | {age !== null ? age : null} 72 | 73 | Born Date : 74 | {this.props.bornDate !== null ? 75 | {this.props.bornDate} : null 76 | } 77 | 78 | Email : {this.props.email} 79 | City : {this.props.city} 80 | Gender : {this.props.gender} 81 | {this.props.showButtons? 82 | 83 | this.editPatient(this.props.patientid)} > 86 | Edit 87 | 88 | this.deletePatient(this.props.patientid)}> 91 | Delete 92 | 93 | 94 | : null} 95 | 96 | 97 | 98 | ) 99 | } 100 | } 101 | export default withRouter(PatientDetail) 102 | -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/PatientDetailModal.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { withRouter } from 'react-router'; 3 | import Moment from 'react-moment'; 4 | 5 | class PatientDetailModal extends Component { 6 | constructor(props) { 7 | super(props) 8 | this.state = { 9 | patientid: props.patient.patientid, 10 | name: props.patient.name, 11 | lastname: props.patient.lastname, 12 | email: props.patient.email, 13 | phoneNo: props.patient.phoneNo, 14 | bornDate: props.patient.bornDate, 15 | gender: props.patient.gender, 16 | city: props.patient.city, 17 | message: '' 18 | }; 19 | } 20 | render() { 21 | var age = null; 22 | if (this.props.patient.bornDate != null) { 23 | var born = Number(this.props.patient.bornDate.substr(0, 4)); 24 | var now = Number(new Date().toLocaleDateString('tr-TR').substr(6, 4)); 25 | age = now - born; 26 | } 27 | return ( 28 | 29 | 30 | 31 | 32 | Patient Detail 33 | 34 | × 35 | 36 | 37 | 38 | 39 | 40 | {this.props.patient.name} {this.props.patient.lastname} 41 | 42 | Patient id : {this.props.patient.patientid} 43 | Name : {this.props.patient.name} 44 | Last Name : {this.props.patient.lastname} 45 | Phne No : {this.props.patient.phoneNo} 46 | Age : 47 | {age !== null ? age : null} 48 | 49 | Born Date : 50 | {this.props.patient.bornDate !== null ? 51 | {this.props.patient.bornDate} : null 52 | } 53 | 54 | Email : {this.props.patient.email} 55 | City : {this.props.patient.city} 56 | Gender : {this.props.patient.gender} 57 | 58 | 59 | 60 | 61 | 62 | Close 63 | 64 | 65 | 66 | 67 | ) 68 | } 69 | } 70 | export default withRouter(PatientDetailModal) 71 | -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/ProblemDetail.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Moment from 'react-moment' 3 | import { withRouter } from 'react-router' 4 | 5 | class ProblemDetail extends Component { 6 | 7 | constructor(props) { 8 | super(props) 9 | this.state = { 10 | 11 | } 12 | this.openReceipeForm = this.openReceipeForm.bind(this); 13 | } 14 | 15 | openReceipeForm(patientid, problemid){ 16 | window.localStorage.setItem("patientId", patientid); 17 | window.localStorage.setItem("problemId", problemid); 18 | this.props.history.push('/problem/receipe-form'); 19 | } 20 | render() { 21 | return ( 22 | 23 | 24 | Problem Detail 25 | 26 | Problem Name : {this.props.problemName} 27 | Problem Detail : {this.props.problemDetail} 28 | Problem Status : {this.props.problemStatus} 29 | Creation Date (Y/M/D H/M) : 30 | {this.props.creationDate} 31 | 32 | 33 | 34 | 35 | ) 36 | } 37 | } 38 | export default withRouter(ProblemDetail) -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/ProblemDetailModal.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Moment from 'react-moment' 3 | import { withRouter } from 'react-router' 4 | 5 | class ProblemDetailModal extends Component { 6 | 7 | constructor(props) { 8 | super(props) 9 | this.state = { 10 | 11 | } 12 | } 13 | 14 | render() { 15 | return ( 16 | 17 | 18 | 19 | 20 | Problem Detail 21 | 22 | × 23 | 24 | 25 | 26 | 27 | 28 | Problem Detail 29 | 30 | Problem Name : {this.props.problem.problemName} 31 | Problem Detail : {this.props.problem.problemDetail} 32 | Problem Status : {this.props.problem.problemStatus} 33 | Creation Date (Y/M/D H/M) : 34 | {this.props.problem.creationDate} 35 | 36 | 37 | 38 | 39 | 40 | 41 | Close 42 | 43 | 44 | 45 | 46 | ) 47 | } 48 | } 49 | export default withRouter(ProblemDetailModal) -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/ReceipeDetail.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | // import * as alertify from 'alertifyjs'; 3 | // import "alertifyjs/build/css/themes/default.min.css"; 4 | // import "alertifyjs/build/css/themes/bootstrap.min.css"; 5 | // import "alertifyjs/build/css/alertify.min.css"; 6 | import { withRouter } from 'react-router'; 7 | import Moment from 'react-moment'; 8 | 9 | class ReceipeDetail extends Component { 10 | constructor(props) { 11 | super(props) 12 | this.state = { 13 | receipeid: props.receipeid, 14 | detail: props.detail, 15 | drug_detail: props.drug_detail, 16 | delivery_date: props.delivery_date, 17 | patientid:props.patientid, 18 | problemid:props.problemid 19 | }; 20 | } 21 | render() { 22 | return ( 23 | 24 | 25 | Receipe Detail 26 | 27 | 28 | receipe id : {this.props.receipeid} 29 | Detail : {this.props.detail} 30 | Drug detail : {this.props.drug_detail} 31 | Usage : {this.props.usage} 32 | Barcode : {this.props.barcode} 33 | Delivery Date : 34 | {this.props.delivery_date !== null ? 35 | 36 | {this.props.delivery_date} 37 | 38 | : null} 39 | 40 | 41 | 42 | 43 | ) 44 | } 45 | } 46 | export default withRouter(ReceipeDetail) 47 | -------------------------------------------------------------------------------- /frontend/src/Routes/BasicComponent/ReceipeDetailModal.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | // import * as alertify from 'alertifyjs'; 3 | // import "alertifyjs/build/css/themes/default.min.css"; 4 | // import "alertifyjs/build/css/themes/bootstrap.min.css"; 5 | // import "alertifyjs/build/css/alertify.min.css"; 6 | import { withRouter } from 'react-router'; 7 | import Moment from 'react-moment'; 8 | 9 | class ReceipeDetailModal extends Component { 10 | constructor(props) { 11 | super(props) 12 | this.state = { 13 | receipeid: props.receipe.receipeid, 14 | detail: props.receipe.detail, 15 | drug_detail: props.receipe.drug_detail, 16 | delivery_date: props.receipe.delivery_date, 17 | patientid: props.receipe.patientid, 18 | problemid: props.receipe.problemid 19 | }; 20 | } 21 | render() { 22 | return ( 23 | 24 | 25 | 26 | Receipe Detail 27 | 28 | × 29 | 30 | 31 | 32 | 33 | 34 | Receipe Detail 35 | 36 | 37 | receipe id : {this.props.receipe.receipeid} 38 | Detail : {this.props.receipe.detail} 39 | Drug detail : {this.props.receipe.drug_detail} 40 | Usage : {this.props.receipe.usage} 41 | Barcode : {this.props.receipe.barcode} 42 | Delivery Date : 43 | {this.props.receipe.delivery_date !== null ? 44 | 45 | {this.props.receipe.delivery_date} 46 | 47 | : null} 48 | 49 | 50 | 51 | 52 | 53 | 54 | Close 55 | 56 | 57 | 58 | 59 | ) 60 | } 61 | } 62 | export default withRouter(ReceipeDetailModal) 63 | -------------------------------------------------------------------------------- /frontend/src/Routes/IndexPage.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Axios from 'axios'; 3 | 4 | 5 | class IndexPage extends Component { 6 | state = { 7 | patients: [] 8 | } 9 | 10 | 11 | deletePatient(id,e){ 12 | console.log("Clicked "+ id); 13 | Axios.delete(`http://localhost:8182/patient/${id}`); 14 | console.log("-------------") 15 | Axios.get(`http://localhost:8182/patient`) 16 | .then(res => { 17 | const patients = res.data; 18 | console.log(res) 19 | this.setState({ patients }); 20 | }) 21 | } 22 | getAll = (e) =>{ 23 | console.log("-------------") 24 | Axios.get(`http://localhost:8182/patient`) 25 | .then(res => { 26 | const patients = res.data; 27 | console.log(res) 28 | this.setState({ patients }); 29 | }) 30 | 31 | } 32 | componentDidMount() { 33 | 34 | Axios.get(`http://localhost:8182/patient`) 35 | .then(res => { 36 | const patients = res.data; 37 | console.log(res) 38 | this.setState({ patients }); 39 | }) 40 | 41 | } 42 | render() { 43 | return ( 44 | 45 | 46 | Hello 47 | 48 | 49 | 50 | 51 | patientid 52 | name 53 | lastname 54 | city 55 | gender 56 | Action 57 | 58 | 59 | 60 | { this.state.patients.map(p => 61 | 62 | {p.patientid} 63 | {p.name} 64 | {p.lastname} 65 | {p.city} 66 | {p.gender} 67 | 68 | 69 | Delete 70 | 71 | 72 | )} 73 | 74 | 75 | 76 | 77 | ); 78 | } 79 | } 80 | 81 | export default IndexPage; -------------------------------------------------------------------------------- /frontend/src/Routes/IndexPage2.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | //import Axios from 'axios'; 3 | import {ErrorMessage, Field, Form, Formik} from "formik"; 4 | 5 | export default class IndexPage2 extends Component { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | /* meal : {code: this.props.match.params.code, name: 'Mantı', price: 12, photo: 'text', detail: 'Süper bi yemek!', 10 | creationDate: moment(new Date()).format('YYYY-MM-DD')}*/ 11 | meal: { 12 | code: '', 13 | name: '', 14 | email: '', 15 | // price: '', 16 | // photo: '', 17 | // detail: '', 18 | // campaign: '', 19 | // creationDate: moment(new Date()).format('YYYY-MM-DD') 20 | }, 21 | action: 'update' 22 | } 23 | } 24 | validate(values) { 25 | let errors = {}; 26 | 27 | if (!values.code) 28 | errors.code = 'Enter a meal code!'; 29 | else if (values.code.length < 3) 30 | errors.code = 'Enter at least 3 characters into code!'; 31 | 32 | if (!values.name) 33 | errors.name = 'Enter a meal name!'; 34 | else if (values.name.length < 2) 35 | errors.name = 'Enter at least 2 characters into name!'; 36 | 37 | 38 | if (!values.email) { 39 | errors.email = 'Required'; 40 | } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) { 41 | errors.email = 'Invalid email address'; 42 | } 43 | 44 | // const re = /^[0-9\b]+$/; 45 | // if (!values.price) 46 | // errors.price = 'Enter a meal price!'; 47 | // else if (values.price === '' || !re.test(values.price)) 48 | // errors.price = 'Enter only numbers into price!'; 49 | 50 | // if (!moment(values.creationDate).isValid()) 51 | // errors.creationDate = 'Enter a valid date!'; 52 | return errors; 53 | } 54 | 55 | onSubmit = (values) => { 56 | console.log(values); 57 | // if(this.state.action==='update'){ 58 | // MealDataService.updateMeal(this.state.meal.code, values) 59 | // .then(response => { 60 | // this.props.history.push(`/meallist`); 61 | // }) 62 | // }else{ 63 | // MealDataService.createMeal(values) 64 | // .then(response => { 65 | // this.props.history.push(`/meallist`); 66 | // }) 67 | // } 68 | } 69 | 70 | componentDidMount = () => { 71 | // if (this.props.match.params.code === "new") { 72 | // this.setState({action: 'create'}); 73 | // return; 74 | // } 75 | 76 | // MealDataService.retrieveMeal(this.props.match.params.code) 77 | // .then(response => { 78 | // console.log(response); 79 | // this.setState({meal: response.data}); 80 | // }); 81 | 82 | }; 83 | render() { 84 | let {code, name,email} = this.state.meal; 85 | return ( 86 | 87 | Meal 88 | 89 | 93 | { (props) => ( 94 | 95 | {/* 96 | */} 97 | 98 | Code 99 | 100 | 101 | 102 | 103 | Name 104 | 105 | 106 | 107 | 108 | Email 109 | 110 | 111 | 112 | {/* 113 | Price 114 | 115 | 116 | 117 | Photo 118 | 119 | 120 | 121 | Detail 122 | 123 | 124 | 125 | Creation Date 126 | 127 | 128 | 129 | Campaign? 130 | setFieldValue(event.target.checked)} checked={campaign}/> 132 | */} 133 | Save 134 | 135 | ) } 136 | 137 | 138 | 139 | ) 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/AddPatientComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import PatientService from '../../services/PatientService'; 3 | import * as alertify from 'alertifyjs'; 4 | import "alertifyjs/build/css/alertify.css"; 5 | import DatePicker from "react-datepicker"; 6 | import AlertifyService from '../../services/AlertifyService'; 7 | 8 | class AddPatientComponent extends Component { 9 | constructor(props) { 10 | super(props); 11 | this.state = { 12 | name: '', 13 | lastname: '', 14 | email: '', 15 | phoneNo:'', 16 | gender: 'Male', 17 | city: 'ANKARA', 18 | bornDate: new Date(), 19 | status: 1, 20 | cities: [] 21 | } 22 | // this.saveUser = this.saveUser.bind(this); 23 | this.getAllCities(); 24 | } 25 | getAllCities() { 26 | PatientService.getCities().then(res => { 27 | this.setState({ cities: res.data }); 28 | 29 | }); 30 | } 31 | controlQuickly() { 32 | return this.state.name === null || this.state.name === '' || this.state.name === ' ' || 33 | this.state.lastname === null || this.state.lastname === '' || this.state.lastname === ' '; 34 | } 35 | saveUser = (e) => { 36 | if (!this.controlQuickly()) { 37 | e.preventDefault(); 38 | let patient = this.state; 39 | PatientService.addPatient(patient) 40 | .then(res => { 41 | this.setState({ message: 'User added successfully.' }); 42 | this.props.history.push('/patients'); 43 | alertify.success("Adding patient is ok"); 44 | }).catch((error) => { 45 | console.log(error.response) 46 | if (error.response) { 47 | this.setState({ errorMessage: error.response.data.message, patientid: null }); 48 | AlertifyService.alert(error.response.data.message); 49 | //this.props.history.push('/patients'); 50 | } 51 | else if (error.request) console.log(error.request); 52 | else console.log(error.message); 53 | }); 54 | } else 55 | AlertifyService.alert(' * işaretli alanları doldurunuz...'); 56 | } 57 | onChangeData(type, data) { 58 | const stateData = this.state; 59 | stateData[type] = data; 60 | this.setState({ stateData }); 61 | } 62 | back() { 63 | this.props.history.push('/patients'); 64 | } 65 | render() { 66 | //let bornDate = this.state.bornDate; 67 | const isWeekday = date => { 68 | const day = date.getDay(date); 69 | return day !== 0 && day !== 6; 70 | }; 71 | let { name, lastname,phoneNo, email, bornDate, gender, city } = this.state; 72 | return ( 73 | 74 | 75 | this.back()}> Back 78 | 79 | 80 | 81 | ADD PATİENT 82 | 83 | 84 | Name * 85 | this.onChangeData('name', e.target.value)} /> 86 | 87 | 88 | Last Name * 89 | this.onChangeData('lastname', e.target.value)} /> 90 | 91 | 92 | Phone * 93 | this.onChangeData('phoneNo', e.target.value)} /> 94 | 95 | 96 | Email: 97 | this.onChangeData('email', e.target.value)} /> 98 | 99 | 100 | Born Date * 101 | 102 | this.onChangeData('bornDate', e)} 108 | filterDate={isWeekday} // disable weekend 109 | timeIntervals={15} // time range around 15 min 110 | //showWeekNumbers // show week number 111 | timeFormat="HH:mm" // show time format 112 | dateFormat="yyyy/MM/dd h:mm aa" // show all of time format 113 | /> 114 | 115 | 116 | 117 | Gender * 118 | this.onChangeData('gender', e.target.value)} > 121 | Male 122 | Female 123 | 124 | 125 | 126 | City * 127 | this.onChangeData('city', e.target.value)} > 130 | {this.state.cities.map(city => 131 | {city} 132 | )} 133 | 134 | 135 | 136 | Save 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | ); 150 | } 151 | } 152 | 153 | export default AddPatientComponent; -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/EditPatientComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import PatientService from '../../services/PatientService'; 3 | import * as alertify from 'alertifyjs'; 4 | import "alertifyjs/build/css/alertify.css"; 5 | import DatePicker from "react-datepicker"; 6 | 7 | export default class EditPatientComponent extends Component { 8 | constructor(props) { 9 | super(props) 10 | this.state = { 11 | patientid: '', 12 | name: '', 13 | lastname: '', 14 | gender: 'Male', 15 | email: '', 16 | bornDate: null, 17 | city: 'Ankara', 18 | status: 1, 19 | cities: [] 20 | } 21 | this.loadPatient(); 22 | this.loadPatient = this.loadPatient.bind(this); 23 | this.getAllCities(); 24 | } 25 | getAllCities() { 26 | PatientService.getCities().then(res => { 27 | this.setState({ cities: res.data }); 28 | }); 29 | } 30 | componentDidMount() { 31 | this.loadPatient(); 32 | this.getAllCities(); 33 | } 34 | 35 | loadPatient() { 36 | PatientService.getPatientById(window.localStorage.getItem("patientId")).then((res) => { 37 | let p = res.data; 38 | this.setState({ 39 | patientid: p.patientid, 40 | name: p.name, 41 | lastname: p.lastname, 42 | email: p.email, 43 | phoneNo: p.phoneNo, 44 | bornDate: p.bornDate, 45 | gender: p.gender, 46 | city: p.city, 47 | status: p.status, 48 | }); 49 | }); 50 | } 51 | editPatient = (e) => { 52 | e.preventDefault(); 53 | let patient = this.state; 54 | patient['patientid'] = window.localStorage.getItem("patientId"); 55 | PatientService.editPatient(patient).then(res => { 56 | this.props.history.push('/patients'); 57 | alertify.success("Updated patient is ok"); 58 | }); 59 | } 60 | onChangeData(type, data) { 61 | const stateData = this.state; 62 | stateData[type] = data; 63 | this.setState({ stateData }); 64 | } 65 | render() { 66 | let bornDate = new Date(); 67 | 68 | if (this.state.bornDate !== null) 69 | bornDate = new Date(this.state.bornDate.toString()); 70 | const isWeekday = date => { 71 | const day = date.getDay(date); 72 | return day !== 0 && day !== 6; 73 | }; 74 | let {name, lastname,phoneNo, email, gender, city} = this.state; 75 | return ( 76 | 77 | 78 | Edit Patient 79 | 80 | 81 | 82 | User Name: 83 | this.onChangeData('name', e.target.value)} /> 84 | 85 | 86 | Last Name: 87 | this.onChangeData('lastname', e.target.value)} /> 88 | 89 | 90 | Phone No: 91 | this.onChangeData('phoneNo', e.target.value)} /> 92 | 93 | 94 | Email: 95 | this.onChangeData('email', e.target.value)} /> 96 | 97 | 98 | Born Date: 99 | {bornDate !== null ? 100 | 101 | this.onChangeData('bornDate', e)} 107 | filterDate={isWeekday} // disable weekend 108 | timeIntervals={15} // time range around 15 min 109 | //showWeekNumbers // show week number 110 | timeFormat="HH:mm" // show time format 111 | dateFormat="yyyy/MM/dd h:mm aa" // show all of time format 112 | /> 113 | 114 | : 115 | null 116 | 117 | } 118 | 119 | 120 | Gender: 121 | this.onChangeData('gender', e.target.value)} > 122 | Male 123 | Female 124 | 125 | 126 | 127 | City: 128 | this.onChangeData('city', e.target.value)}> 129 | {this.state.cities.map(c => 130 | 131 | {c} 132 | )} 133 | 134 | 135 | Update 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | ) 151 | } 152 | } -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ListPatientComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import PatientService from '../../services/PatientService'; 3 | import "@material/react-checkbox/dist/checkbox.css"; 4 | import Checkbox from '@material/react-checkbox'; 5 | import "alertifyjs/build/css/themes/default.min.css"; 6 | import "alertifyjs/build/css/themes/bootstrap.min.css"; 7 | import "alertifyjs/build/css/alertify.min.css"; 8 | import "../../Assets/css/ListPatientComponent.css" 9 | // import Modal from 'react-modal'; 10 | import * as alertify from 'alertifyjs'; 11 | 12 | import Moment from 'react-moment'; 13 | import PatientDetailModal from '../BasicComponent/PatientDetailModal'; 14 | 15 | const items = [ 16 | 'Name', 17 | 'Lastname', 18 | 'Email', 19 | 'City' 20 | ]; 21 | let filterArray = [] 22 | let checked = { 23 | name: false, 24 | lastname: false, 25 | email: false, 26 | city: false 27 | } 28 | let filterAllPatients 29 | class ListPatientComponent extends Component { 30 | constructor(props) { 31 | super(props) 32 | this.state = { 33 | patients: [], 34 | message: null, 35 | indeterminate: false, 36 | filters: [], 37 | patient:{} 38 | } 39 | this.reloadPatientList = this.reloadPatientList.bind(this); 40 | } 41 | componentDidMount() { 42 | this.reloadPatientList(); 43 | } 44 | 45 | reloadPatientList() { 46 | PatientService.getPatients().then((res) => { 47 | this.setState({ patients: res.data }) 48 | filterAllPatients = res.data 49 | }); 50 | } 51 | deletePatient(patientid) { 52 | alertify.confirm( 53 | "Are you sure to delete this patient.", 54 | ok => { 55 | PatientService.deletePatient(patientid).then(res => { 56 | this.setState({ message: 'User deleted successfully. ' + res }); 57 | this.setState({ patients: this.state.patients.filter(patient => patient.patientid !== patientid) }); 58 | }); 59 | alertify.success('to delete patient is ok'); 60 | }, 61 | cancel => { alertify.error('Cancel'); } 62 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 63 | } 64 | editPatient(id) { 65 | alertify.confirm( 66 | "Are you sure to edit this patient.", 67 | ok => { 68 | window.localStorage.setItem("patientId", id); 69 | this.props.history.push('/edit-patient'); 70 | }, 71 | cancel => { alertify.error('Cancel'); } 72 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 73 | } 74 | viewPatient(patientid) { 75 | window.localStorage.setItem("patientId", patientid); 76 | this.props.history.push('/view-patient/' + patientid); 77 | } 78 | addPatient() { 79 | //window.localStorage.removeItem("userId"); 80 | this.props.history.push('/add-patient'); 81 | } 82 | onChangeSearchByName = (e) => { 83 | this.filterPatients(e.target.value); 84 | } 85 | filterPatients = (value) => { 86 | if (filterArray.length > 0) { 87 | var results = []; 88 | if (value !== '' && value.length > 0) { 89 | results = filterAllPatients.filter(patient => { 90 | let find = false; 91 | filterArray.forEach(function (filter) { 92 | let control = patient[filter.toLowerCase()].toLowerCase().indexOf(value.toLowerCase()); 93 | if (control > -1) find = true; 94 | }); 95 | return find; 96 | }); 97 | this.setState({ patients: results }); 98 | } 99 | else { this.reloadPatientList(); } 100 | } else { 101 | alertify.set('notifier', 'delay', 2); 102 | //alertify.set('notifier','position', 'top-center'); 103 | alertify.error('Please select any parameters'); 104 | } 105 | } 106 | createCheckboxes = () => (items.map((item) => this.createCheckbox(item))) 107 | createCheckbox = label => ( 108 | 109 | { this.changeStateForChecked(e, label); }} 113 | /> 114 | {label} 115 | 116 | ) 117 | changeStateForChecked = (e, label) => { 118 | checked[label] = e.target.checked; 119 | var index = filterArray.indexOf(label); 120 | if (checked[label]) { 121 | if (index === -1) { filterArray.push(label); } 122 | } else { 123 | if (index !== -1) { filterArray.splice(index, 1); } 124 | } 125 | } 126 | viewPatientQuickly(patient){ 127 | this.setState({patient}); 128 | } 129 | render() { 130 | return ( 131 | 132 | 133 | this.addPatient()}> 136 | Add Patient 137 | 138 | 139 | 140 | 141 | 142 | 147 | 148 | 149 | 150 | {this.createCheckboxes()} 151 | 152 | 153 | 154 | 155 | 156 | Full Name 157 | Email 158 | Born Date 159 | City 160 | Action 161 | 162 | 163 | 164 | {this.state.patients.map(patient => 165 | 166 | {patient.name} {patient.lastname} 167 | {/* {patient.patientid} */} 168 | {patient.email} 169 | 170 | {patient.bornDate !== null ? 171 | 172 | {patient.bornDate} 173 | 174 | : null} 175 | 176 | {patient.city} 177 | 178 | 179 | Actions 185 | 186 | this.viewPatient(patient.patientid)} > View 189 | 190 | this.viewPatientQuickly(patient)} > View Quickly 194 | 195 | this.editPatient(patient.patientid)} > Edit 198 | 199 | this.deletePatient(patient.patientid)}> Delete 202 | 203 | 204 | 205 | 206 | )} 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | ); 218 | } 219 | 220 | } 221 | 222 | export default ListPatientComponent; -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ProblemComponent/ProblemFormComponent.jsx: -------------------------------------------------------------------------------- 1 | 2 | import React, { Component } from 'react' 3 | import ProblemService from '../../../services/ProblemService'; 4 | import { ErrorMessage, Field, Form, Formik } from "formik"; 5 | import ReactDatePicker from 'react-datepicker'; 6 | import Select from 'react-select'; 7 | import "react-datepicker/dist/react-datepicker.css"; 8 | import AlertifyService from '../../../services/AlertifyService'; 9 | //import Select from 'react-select'; 10 | 11 | var statuses = []; 12 | export default class ProblemFormComponent extends Component { 13 | 14 | constructor(props) { 15 | super(props) 16 | this.state = { 17 | patientid: window.localStorage.getItem("patientId"), 18 | 19 | problemName: '', 20 | problemDetail: '', 21 | creationDate: new Date(), 22 | problemStatus: 'AYAKTA', 23 | pid: props.match.params.patientid, 24 | 25 | status: 1, 26 | problemStatuses: [], 27 | errorMessage: "", 28 | selectedOption: null, 29 | options: [] 30 | } 31 | this.loadStatus = this.loadStatus.bind(this); 32 | } 33 | componentDidMount() { 34 | this.loadStatus(); 35 | } 36 | loadStatus() { 37 | statuses = []; 38 | ProblemService.getProblemStatus().then(res => { 39 | this.setState({ problemStatuses: res.data }); 40 | for (var i = 0; i < this.state.problemStatuses.length; i++) { 41 | statuses.push({ value: this.state.problemStatuses[i], label: this.state.problemStatuses[i] }) 42 | } 43 | }); 44 | } 45 | viewPatient(patientid) { 46 | window.localStorage.setItem("patientId", patientid); 47 | this.props.history.push('/view-patient/' + patientid); 48 | } 49 | validate(values) { 50 | let errors = {}; 51 | if (!values.problemName) 52 | errors.problemName = 'Enter a Problem Name!'; 53 | else if (values.problemName.length < 5) 54 | errors.problemName = 'Enter at least 5 characters into Problem Name!'; 55 | 56 | if (!values.problemDetail) 57 | errors.problemDetail = 'Enter a Problem Detail!'; 58 | else if (values.problemDetail.length < 5) 59 | errors.problemDetail = 'Enter at least 5 characters into Problem Detail!'; 60 | return errors; 61 | } 62 | addProblem = () => { 63 | if (this.state.problemName === '' || this.state.problemDetail === '') { 64 | AlertifyService.alert("Fill in the blanks"); 65 | } else { 66 | if (this.state.patientid != null) { 67 | let newProblem = this.state; 68 | newProblem['status'] = 1; 69 | newProblem['pid'] = this.state.patientid; 70 | ProblemService.add(newProblem).then(res => { 71 | // let data = res.data; 72 | this.setState({ 73 | problemName: '', 74 | problemDetail: '', 75 | problemStatus: 'AYAKTA', 76 | creationDate: new Date() 77 | }); 78 | AlertifyService.successMessage("Saving problem for related patient is ok.. "); 79 | this.viewPatient(this.state.patientid); 80 | }); 81 | } else { 82 | AlertifyService.alert("There is no patient.."); 83 | } 84 | } 85 | } 86 | onChangeData(type, e) { 87 | const addproblem = this.state; 88 | addproblem[type] = e; 89 | this.setState({ addproblem }); 90 | } 91 | render() { 92 | let { problemName, problemDetail, problemStatus, creationDate } = this.state; 93 | const { selectedOption } = this.state.options; 94 | const isWeekday = date => { 95 | const day = date.getDay(date); 96 | return day !== 0 && day !== 6; 97 | }; 98 | return ( 99 | 100 | 101 | Problem Form 102 | 103 | this.viewPatient(this.state.patientid)} > Back 106 | 107 | 112 | 113 | 114 | Problem Name : 115 | this.onChangeData('problemName', e.target.value)} /> 121 | 122 | 123 | 124 | Problem Detail : 125 | this.onChangeData('problemDetail', e.target.value)} /> 131 | 132 | 133 | {this.state.problemStatuses.length > 0 ? 134 | 135 | Status : {statuses} 136 | this.onChangeData('problemStatus', e.value)} 139 | options={statuses} 140 | /> 141 | 142 | : null} 143 | 144 | Date : 145 | this.onChangeData('creationDate', e)} 151 | filterDate={isWeekday} // disable weekend 152 | timeIntervals={15} // time range around 15 min 153 | //showWeekNumbers // show week number 154 | timeFormat="HH:mm" // show time format 155 | dateFormat="yyyy/MM/dd h:mm aa" // show all of time format 156 | /> 157 | 158 | 159 | this.viewPatient(this.state.patientid)} 163 | data-dismiss="modal">Close 164 | 165 | Save 166 | 167 | 168 | 169 | 170 | 171 | ) 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ProblemComponent/ProblemsComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import Moment from 'react-moment'; 3 | import * as alertify from 'alertifyjs'; 4 | import "alertifyjs/build/css/alertify.css"; 5 | import "alertifyjs/build/css/themes/default.css"; 6 | import "@material/react-checkbox/dist/checkbox.css"; 7 | import ProblemService from '../../../services/ProblemService'; 8 | import AlertifyService from '../../../services/AlertifyService'; 9 | import { withRouter } from 'react-router'; 10 | import ProblemDetailModal from '../../BasicComponent/ProblemDetailModal'; 11 | 12 | let filterAllProblem = []; 13 | let filters = ["problemName", "problemStatus"]; 14 | class ProblemsComponent extends Component { 15 | constructor(props) { 16 | super(props) 17 | this.state = { 18 | patientid: props.patientid, 19 | problems: [], 20 | problem:{} 21 | 22 | } 23 | this.getAllProblems = this.getAllProblems.bind(this); 24 | } 25 | componentDidMount() { 26 | this.getAllProblems(); 27 | } 28 | getAllProblems() { 29 | ProblemService.getAllByPatientId(this.state.patientid).then(res => { 30 | this.setState({ problems: res.data }); 31 | }); 32 | } 33 | onChangeSearchByStatusOrDate = (e) => { this.filterProblems(e.target.value); } 34 | filterProblems(value) { 35 | var results = []; 36 | if (value !== '') { 37 | results = filterAllProblem.filter(problem => { 38 | let find = false; 39 | //filters.forEach(filter=>{ 40 | filters.forEach(function (filter) { 41 | let control = problem[filter].toLowerCase().indexOf(value.toLowerCase()); 42 | if (control > -1) find = true; 43 | }); 44 | return find; 45 | }); 46 | this.setState({ problems: results }); 47 | } 48 | else { this.loadPatient(); } 49 | } 50 | limitingPatientDetail(data) { 51 | if (data.length < 31) return data; 52 | else return data.substr(0, 30) + "..."; 53 | } 54 | deleteProblem(problemid) { 55 | alertify.confirm("Are you sure to delete the problem.", 56 | ok => { 57 | ProblemService.delete(problemid).then(res => { 58 | //this.setState({ problems: this.state.problems.filter(p => p.problemid !== problemid) }); 59 | AlertifyService.successMessage('Deleting is ok : '); 60 | this.getAllProblems(); 61 | }); 62 | }, 63 | cancel => { AlertifyService.errorMessage('Cancel'); } 64 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 65 | } 66 | viewProblem(problemid) { 67 | window.localStorage.setItem("problemid", problemid); 68 | this.props.history.push('/problem/' + problemid); 69 | } 70 | viewQuickly(problem){ 71 | this.setState({problem:problem}); 72 | } 73 | render() { 74 | let problems = this.state.problems; 75 | return ( 76 | 77 | 78 | 79 | Problems 80 | 81 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | Problem Name 95 | Problem Detail 96 | Problem Status 97 | Create Date 98 | Action 99 | 100 | 101 | 102 | {problems.map(problem => 103 | 104 | 105 | {problem.problemName} 106 | {this.limitingPatientDetail(problem.problemDetail)} 107 | 108 | {problem.problemStatus} 109 | 110 | 111 | {problem.creationDate} 112 | 113 | 114 | 115 | 116 | Actions 122 | 123 | 124 | this.viewProblem(problem.problemid)} > 127 | View 128 | 129 | this.viewQuickly(problem)} > 133 | View Quickly 134 | 135 | this.deleteProblem(problem.problemid)} > 138 | Delete 139 | 140 | 141 | 142 | 143 | )} 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | ) 153 | } 154 | } 155 | export default withRouter(ProblemsComponent); -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ProblemComponent/ViewProblemComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import ProblemService from '../../../services/ProblemService' 3 | //import Moment from 'react-moment'; 4 | import PatientDetail from '../../BasicComponent/PatientDetail'; 5 | import ProblemDetail from '../../BasicComponent/ProblemDetail'; 6 | import "@material/react-checkbox/dist/checkbox.css"; 7 | import AlertifyService from '../../../services/AlertifyService'; 8 | import ReceipesComponent from "../ReceipeComponent/ReceipesComponent"; 9 | 10 | 11 | 12 | 13 | export default class ViewProblemComponent extends Component { 14 | 15 | constructor(props) { 16 | super(props) 17 | this.state = { 18 | problemid: props.match.params.problemid, 19 | patient: {}, 20 | receipes: [], 21 | problemDetail: null, 22 | problemName: null, 23 | problemStatus: null, 24 | pid: null, 25 | creationDate: null, 26 | errorMessage: "" 27 | } 28 | // this.loadProblemDetail(); 29 | this.loadProblemDetail = this.loadProblemDetail.bind(this); 30 | } 31 | componentDidMount() { 32 | this.loadProblemDetail(); 33 | } 34 | 35 | loadProblemDetail() { 36 | ProblemService.getProblem(this.state.problemid).then(res => { 37 | let p = res.data; 38 | this.setState({ 39 | patient:p.patient, 40 | problemDetail:p.problemDetail, 41 | problemName:p.problemName, 42 | problemStatus:p.problemStatus, 43 | creationDate:p.creationDate, 44 | pid:p.pid, 45 | }); 46 | }).catch((error) => { 47 | // Error 48 | if (error.response) { 49 | this.setState({ errorMessage: error.response.data.message, problemid: null }); 50 | AlertifyService.alert(error.response.data.message); 51 | 52 | } else if (error.request) { 53 | console.log(error.request); 54 | } else { 55 | console.log(error.message); 56 | } 57 | }); 58 | } 59 | viewPatient(patientid) { 60 | window.localStorage.setItem("patientId", patientid); 61 | this.props.history.push('/view-patient/' + patientid); 62 | } 63 | openReceipeForm(patientid, problemid) { 64 | window.localStorage.setItem("patientId", patientid); 65 | window.localStorage.setItem("problemId", problemid); 66 | this.props.history.push('/receipe-form'); 67 | } 68 | render() { 69 | 70 | return ( 71 | 72 | 73 | Problem Details 74 | 75 | 76 | 77 | 78 | 79 | this.viewPatient(this.state.patient.patientid)}> 82 | Back 83 | this.openReceipeForm(this.state.patient.patientid, this.state.problemid)} > 86 | Add Receipe 87 | 88 | 89 | 90 | 99 | 100 | 101 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | ) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ReceipeComponent/ReceipeFormComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import DatePicker from "react-datepicker"; 3 | import ReceipeService from "../../../services/ReceipeService"; 4 | import AlertifyService from '../../../services/AlertifyService'; 5 | export default class ReceipeFormComponent extends Component { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | detail: '', 10 | drug_detail: '', 11 | barcode: '', 12 | usage:'', 13 | delivery_date: new Date(), 14 | problemid: window.localStorage.getItem('problemId') 15 | } 16 | this.saveReceipe = this.saveReceipe.bind(this); 17 | } 18 | 19 | onChangeData (type, data) { 20 | const stateData = this.state; 21 | stateData[type] = data; 22 | this.setState({ stateData }); 23 | } 24 | 25 | viewProblem(problemid) { 26 | window.localStorage.setItem("problemid", problemid); 27 | this.props.history.push('/problem/' + problemid); 28 | } 29 | saveReceipe = (e) => { 30 | let data = this.state; 31 | ReceipeService.save(data).then(res => { 32 | data = res.data; 33 | if(data.receipeid>0){ 34 | AlertifyService.successMessage("Saving receipe for related problem is ok.. "); 35 | // this.setState({ 36 | // detail: '', 37 | // drug_detail: '', 38 | // barcode: '', 39 | // delivery_date: new Date(), 40 | // problemid: window.localStorage.getItem('problemId') 41 | // }); 42 | this.viewProblem(this.state.problemid); 43 | } 44 | else{ 45 | AlertifyService.alert("Saving receipe for related problem is not ok.. "); 46 | } 47 | }); 48 | } 49 | render() { 50 | let {detail, drug_detail, barcode, delivery_date} = this.state; 51 | const isWeekday = date => { 52 | const day = date.getDay(date); 53 | return day !== 0 && day !== 6; 54 | }; 55 | return ( 56 | 57 | 58 | this.viewProblem(this.state.problemid)}>Back 61 | 62 | 63 | 64 | ADD RECEIPE 65 | 66 | 67 | 68 | Detail: 69 | this.onChangeData('detail', e.target.value)} /> 75 | 76 | 77 | Drug Detail: 78 | this.onChangeData('drug_detail', e.target.value)} /> 84 | 85 | 86 | Usage 87 | this.onChangeData('usage', e.target.value)} /> 93 | 94 | 95 | Barcode 96 | this.onChangeData('barcode', e.target.value)} /> 102 | 103 | 104 | Delivery Date: 105 | 106 | this.onChangeData('delivery_date', e)} 112 | filterDate={isWeekday} // disable weekend 113 | timeIntervals={15} // time range around 15 min 114 | //showWeekNumbers // show week number 115 | timeFormat="HH:mm" // show time format 116 | dateFormat="yyyy/MM/dd h:mm aa" // show all of time format 117 | /> 118 | 119 | 120 | Add 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | ) 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ReceipeComponent/ReceipesComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import "@material/react-checkbox/dist/checkbox.css"; 3 | import AlertifyService from '../../../services/AlertifyService'; 4 | import ReceipeService from '../../../services/ReceipeService'; 5 | import Moment from 'react-moment'; 6 | 7 | import * as alertify from 'alertifyjs'; 8 | import "alertifyjs/build/css/alertify.css"; 9 | import "alertifyjs/build/css/themes/default.css"; 10 | import "@material/react-checkbox/dist/checkbox.css"; 11 | import { withRouter } from 'react-router'; 12 | import ReceipeDetailModal from '../../BasicComponent/ReceipeDetailModal'; 13 | 14 | class ReceipesComponent extends Component { 15 | 16 | constructor(props) { 17 | super(props) 18 | this.state = { 19 | problemid: props.problemid, 20 | receipes: [], 21 | receipe: {} 22 | } 23 | this.getAllReceipes = this.getAllReceipes.bind(this); 24 | } 25 | componentDidMount() { 26 | this.getAllReceipes(); 27 | } 28 | getAllReceipes() { 29 | ReceipeService.getAllByProblemId(this.state.problemid).then((res) => { 30 | this.setState({ receipes: res.data }) 31 | }).catch((error) => { 32 | if (error.response) { 33 | AlertifyService.alert(error.response.data.message); 34 | } 35 | else if (error.request) console.log(error.request); 36 | else console.log(error.message); 37 | }); 38 | } 39 | 40 | viewQuickly(r) { 41 | this.setState({ receipe: r }) 42 | } 43 | 44 | deleteReceipe(receipid) { 45 | alertify.confirm("Are you sure to delete the receipe.", 46 | ok => { 47 | ReceipeService.deleteReceipe(receipid).then((res) => { 48 | if (res.data === true) { 49 | AlertifyService.successMessage('Receipe was deleted.'); 50 | this.getAllReceipes(); 51 | } 52 | }).catch((error) => { 53 | if (error.response) { 54 | AlertifyService.alert(error.response.data.message); 55 | } 56 | else if (error.request) console.log(error.request); 57 | else console.log(error.message); 58 | }); 59 | }, 60 | cancel => { AlertifyService.errorMessage('Cancel'); } 61 | ).set({ title: "Attention" }).set({ transition: 'slide' }).show(); 62 | } 63 | render() { 64 | let receipes = this.state.receipes; 65 | return ( 66 | 67 | 68 | 69 | Receipes 70 | 71 | 72 | 73 | 74 | 75 | ID 76 | Receipe Detail 77 | Drug Detail 78 | Create Date 79 | Action 80 | 81 | 82 | 83 | {receipes.map(r => 84 | 85 | 86 | {r.receipeid} 87 | {r.detail} 88 | {r.drug_detail} 89 | 90 | 91 | {r.delivery_date} 92 | 93 | 94 | 95 | 96 | Actions 102 | 103 | 104 | this.viewQuickly(r)} 108 | data-toggle="modal" data-target="#receipemModal" > 109 | View Quickly 110 | 111 | this.deleteReceipe(r.receipeid)} > 114 | Delete 115 | 116 | 117 | 118 | 119 | )} 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | ) 131 | } 132 | } 133 | export default withRouter(ReceipesComponent); -------------------------------------------------------------------------------- /frontend/src/Routes/PatientComponents/ViewPatientComponent.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import PatientService from '../../services/PatientService'; 3 | import PatientDetail from '../BasicComponent/PatientDetail'; 4 | import AlertifyService from '../../services/AlertifyService'; 5 | import ProblemsComponent from './ProblemComponent/ProblemsComponent'; 6 | 7 | export default class ViewPatientComponent extends Component { 8 | constructor(props) { 9 | super(props) 10 | this.state = { 11 | patientid: props.match.params.patientid, 12 | patient: null, 13 | name: '', 14 | lastname: '', 15 | email: '', 16 | gender: '', 17 | bornDate: null, 18 | city: '', 19 | problems: [], 20 | message: null 21 | } 22 | this.loadPatient = this.loadPatient.bind(this); 23 | } 24 | 25 | componentDidMount() { 26 | this.loadPatient(); 27 | } 28 | 29 | loadPatient() { 30 | PatientService.getPatientById(this.state.patientid).then(res => { 31 | let p = res.data; 32 | this.setState({ patient: p }); 33 | this.setState({ 34 | patientid: p.patientid, 35 | problems: p.problems 36 | }); 37 | }).catch((error) => { 38 | if (error.response) { 39 | AlertifyService.alert(error.response.data.message); 40 | this.props.history.push('/patients'); 41 | } 42 | else if (error.request) console.log(error.request); 43 | else console.log(error.message); 44 | }); 45 | } 46 | viewProblem(problemid) { 47 | this.props.history.push('/problem/' + problemid); 48 | } 49 | viewProblemForm(patientid){ 50 | window.localStorage.setItem("patientId", patientid); 51 | this.props.history.push('/add-problem'); 52 | } 53 | back(){ 54 | this.props.history.push('/patients'); 55 | } 56 | render() { 57 | let patient = this.state.patient; 58 | return ( 59 | 60 | {/* Show and close modal */} 61 | 62 | this.back()}> Back 65 | this.viewProblemForm(patient.patientid)} 69 | data-whatever="@getbootstrap">Add Problem 70 | 71 | 72 | 73 | {/* Patient Details */} 74 | 75 | {patient != null ? 76 | 88 | : null} 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | ) 99 | } 100 | } -------------------------------------------------------------------------------- /frontend/src/Routes/modal.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Modal from 'react-modal'; 4 | 5 | const customStyles = { 6 | content : { 7 | top : '50%', 8 | left : '50%', 9 | right : 'auto', 10 | bottom : 'auto', 11 | marginRight : '-50%', 12 | transform : 'translate(-50%, -50%)' 13 | } 14 | }; 15 | Modal.setAppElement('#yourAppElement') 16 | 17 | class App extends React.Component { 18 | constructor() { 19 | super(); 20 | 21 | this.state = { 22 | modalIsOpen: false 23 | }; 24 | 25 | this.openModal = this.openModal.bind(this); 26 | this.afterOpenModal = this.afterOpenModal.bind(this); 27 | this.closeModal = this.closeModal.bind(this); 28 | } 29 | 30 | openModal() { 31 | this.setState({modalIsOpen: true}); 32 | } 33 | 34 | afterOpenModal() { 35 | // references are now sync'd and can be accessed. 36 | this.subtitle.style.color = '#f00'; 37 | } 38 | 39 | closeModal() { 40 | this.setState({modalIsOpen: false}); 41 | } 42 | 43 | render() { 44 | return ( 45 | 46 | Open Modal 47 | 54 | 55 | this.subtitle = subtitle}>Hello 56 | close 57 | I am a modal 58 | 59 | 60 | tab navigation 61 | stays 62 | inside 63 | the modal 64 | 65 | 66 | 67 | ); 68 | } 69 | } 70 | 71 | ReactDOM.render(, appElement); -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | //import IndexPage from './component/IndexPage' 6 | import * as serviceWorker from './serviceWorker'; 7 | //import FlavorForm from './component/FlavorForm'; 8 | 9 | ReactDOM.render(, document.getElementById('root')); 10 | //ReactDOM.render(, document.getElementById('root')); 11 | //ReactDOM.render(, document.getElementById('root')); 12 | //ReactDOM.render(, document.getElementById('root')); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /frontend/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /frontend/src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' } 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready.then(registration => { 134 | registration.unregister(); 135 | }); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /frontend/src/services/AlertifyService.js: -------------------------------------------------------------------------------- 1 | import * as alertify from 'alertifyjs'; 2 | import "alertifyjs/build/css/alertify.css"; 3 | import "alertifyjs/build/css/themes/default.css"; 4 | import "@material/react-checkbox/dist/checkbox.css"; 5 | 6 | class AlertifyService { 7 | 8 | // confirm(message) { 9 | // alertify.alert(message, function () { 10 | // alertify.error('OK'); 11 | // }); 12 | // return true; 13 | // } 14 | 15 | alert(message) { 16 | //window.location.href = '/patients'; 17 | //this.props.history.push('/patients' ); 18 | alertify.alert(message, function () { 19 | alertify.error(message); 20 | }); //.set({ title: "Attention" }).set({ transition: 'slide' }).show(); 21 | return true; 22 | } 23 | successMessage(message){ 24 | alertify.success(message); 25 | return true; 26 | } 27 | errorMessage(message){ 28 | alertify.error(message); 29 | return true; 30 | } 31 | } 32 | 33 | export default new AlertifyService(); -------------------------------------------------------------------------------- /frontend/src/services/ApiService.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const API_BASE_URL = 'http://localhost:8185/api'; 4 | class ApiService { 5 | 6 | getAllDatas(url) { 7 | return axios.get(API_BASE_URL + url); 8 | } 9 | getAll(url) { 10 | return axios.get(API_BASE_URL + url); 11 | } 12 | getOneById(url) { 13 | return axios.get(API_BASE_URL + url); 14 | } 15 | 16 | // fetchPatientByEmail(email) { 17 | // return axios.get(USER_API_BASE_URL + '/find-by-email/' + email); 18 | // } 19 | 20 | deleteById(url) { 21 | return axios.delete(API_BASE_URL + url); 22 | } 23 | 24 | post(url, data) { 25 | return axios.post(API_BASE_URL + url, data); 26 | } 27 | 28 | put(url, data) { 29 | return axios.put(API_BASE_URL + url, data); 30 | } 31 | 32 | } 33 | 34 | export default new ApiService(); -------------------------------------------------------------------------------- /frontend/src/services/PatientService.js: -------------------------------------------------------------------------------- 1 | import ApiService from "./ApiService"; 2 | 3 | 4 | const PATIENT_API_BASE_URL = '/patient'; 5 | const CITIES = '/cities'; 6 | class PatientService { 7 | 8 | getPatients() { 9 | return ApiService.getAll(PATIENT_API_BASE_URL); 10 | } 11 | 12 | getPatientById(patientId) { 13 | return ApiService.getOneById(PATIENT_API_BASE_URL + '/find-by-id/' + patientId); 14 | } 15 | 16 | // fetchPatientByEmail(email) { 17 | // return axios.get(PATIENT_API_BASE_URL + '/find-by-email/' + email); 18 | // } 19 | 20 | deletePatient(Id) { 21 | return ApiService.deleteById(PATIENT_API_BASE_URL + '/' + Id); 22 | } 23 | 24 | addPatient(patient) { 25 | return ApiService.post(PATIENT_API_BASE_URL, patient); 26 | } 27 | 28 | editPatient(patient) { 29 | return ApiService.put(PATIENT_API_BASE_URL + '/' + patient.patientid, patient); 30 | } 31 | getCities() { 32 | return ApiService.getAllDatas(PATIENT_API_BASE_URL+CITIES); 33 | } 34 | } 35 | 36 | export default new PatientService(); -------------------------------------------------------------------------------- /frontend/src/services/ProblemService.js: -------------------------------------------------------------------------------- 1 | import ApiService from "./ApiService"; 2 | 3 | 4 | const PROBLEM_API_BASE_URL = '/problem'; 5 | const PROBLEM_STATUS = '/status'; 6 | const FIND_ALL = '/find-all-by-patientid/'; 7 | const PROBLEM_WİTH_PROBLEMID = '/find-by-problemid/'; 8 | 9 | class ProblemService { 10 | 11 | getProblem(problemid) { 12 | return ApiService.getAll(PROBLEM_API_BASE_URL + PROBLEM_WİTH_PROBLEMID + problemid); 13 | } 14 | 15 | getAllByPatientId(patientId) { 16 | return ApiService.getOneById(PROBLEM_API_BASE_URL + FIND_ALL + patientId); 17 | } 18 | 19 | // fetchPatientByEmail(email) { 20 | // return axios.get(PATIENT_API_BASE_URL + '/find-by-email/' + email); 21 | // } 22 | 23 | delete(Id) { 24 | return ApiService.deleteById(PROBLEM_API_BASE_URL + '/' + Id); 25 | } 26 | 27 | add(problem) { 28 | return ApiService.post(PROBLEM_API_BASE_URL, problem); 29 | } 30 | 31 | // editPatient(patient) { 32 | // return ApiService.put(PROBLEM_API_BASE_URL + '/' + patient.patientid, patient); 33 | // } 34 | getProblemStatus() { 35 | return ApiService.getAllDatas(PROBLEM_API_BASE_URL + PROBLEM_STATUS ); 36 | } 37 | } 38 | 39 | export default new ProblemService(); -------------------------------------------------------------------------------- /frontend/src/services/ReceipeService.js: -------------------------------------------------------------------------------- 1 | import ApiService from "./ApiService"; 2 | 3 | 4 | const RECEIPE_BASE_URL = '/receipe'; 5 | const FIND_BY_R_ID = '/find-by-id/'; 6 | const FIND_ALL = /find-all-by-problemid/; 7 | 8 | class ReceipeService { 9 | 10 | getAllReceipes() { 11 | return ApiService.getAllDatas(RECEIPE_BASE_URL); 12 | } 13 | 14 | getAllByProblemId(problemId) { 15 | return ApiService.getAll(RECEIPE_BASE_URL + FIND_ALL + problemId); 16 | } 17 | 18 | getReceipeByReceipeId(receipeId) { 19 | return ApiService.getOneById(RECEIPE_BASE_URL + FIND_BY_R_ID + receipeId); 20 | } 21 | 22 | // fetchPatientByEmail(email) { 23 | // return axios.get(PATIENT_API_BASE_URL + '/find-by-email/' + email); 24 | // } 25 | 26 | deleteReceipe(receipeId) { 27 | return ApiService.deleteById(RECEIPE_BASE_URL + '/' + receipeId); 28 | } 29 | 30 | save(receipe) { 31 | return ApiService.post(RECEIPE_BASE_URL, receipe); 32 | } 33 | 34 | // editReceipe(patient) { 35 | // return ApiService.put(RECEIPE_API_BASE_URL + '/' + patient.patientid, patient); 36 | // } 37 | } 38 | 39 | export default new ReceipeService(); -------------------------------------------------------------------------------- /frontend/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | --------------------------------------------------------------------------------
Problems
Receipes