# emr hospital

---

### **Step 1: Create a Folder on Desktop**

1. **Create Folder:**
    
    * Right-click on your Desktop and select **New &gt; Folder**.
        
    * Name the folder `MyFullStackApp` (or any name you prefer).
        

### **Step 2: Clone the GitHub Repository**

1. **Open Command Prompt (CMD):**
    
    * Press `Win + R`, type `cmd`, and press **Enter**.
        
2. **Navigate to the Folder:** In the Command Prompt, type the following to navigate to your folder (if your folder is on the desktop):
    
    ```bash
    cd Desktop\MyFullStackApp
    ```
    
3. **Clone the GitHub Repository:** You’ll clone the repository from GitHub. Assuming you have the repository URL (`https://github.com/light2023/3RH_EMR.git`), type this:
    
    ```bash
    git clone https://github.com/light2023/3RH_EMR.git
    ```
    
    After running this command, you'll see output like: (if youre asked for password, go to step 6)
    
    ```plaintext
    Counting objects: 100% (33/33), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (17/17), done.
    Writing objects: 100% (17/17), 84.97 KiB | 14.16 MiB/s, done.
    Total 17 (delta 14), reused 0 (delta 0)
    remote: Resolving deltas: 100% (14/14), completed with 14 local objects.
    To https://github.com/light2023/3RH_EMR.git
       0f97cb2..53dbb66  master -> master
    ```
    
    This means the repository has been successfully cloned into your folder.
    

---

### **Step 3: Set Up PostgreSQL**

1. **Create the PostgreSQL Database and User:**
    
    * Open **pgAdmin** (or use the command line `psql`).
        
    * **Log in as superuser** `postgres`:
        
        * Open **CMD** and type:
            
            ```bash
            psql -U postgres
            ```
            
    * **Create the database and user:** Run these commands to create the database and user with the same name `renewal_ridge_emr`:
        
        ```sql
        CREATE DATABASE renewal_ridge_emr;
        CREATE USER renewal_ridge_emr WITH PASSWORD 'renewal_ridge_emr';
        GRANT ALL PRIVILEGES ON DATABASE renewal_ridge_emr TO renewal_ridge_emr;
        ```
        
    * **Exit the PostgreSQL command line** by typing:
        
        ```sql
        \q
        ```
        
2. **Confirm Database and User:** You can verify the database creation and user setup by logging back in and checking:
    
    ```bash
    psql -U postgres
    \l  -- lists databases
    \du -- lists users
    ```
    

---

### **Step 4: Set Up the Backend (FastAPI)**

1. **Navigate to the Backend Folder:** Assuming the FastAPI backend is in a folder called `backend` within the cloned repository, navigate to it:
    
    ```bash
    cd 3RH_EMR/backend
    ```
    
2. **Create a Virtual Environment (Optional but Recommended):** To isolate dependencies for the Python backend, it's best to create a virtual environment.
    
    ```bash
    python -m venv venv
    ```
    
    To activate the virtual environment:
    
    * **On Windows**:
        
        ```bash
        .\venv\Scripts\activate
        ```
        
3. **Install Python Dependencies:** Install all the required dependencies from the `requirements.txt` file that came with the repository:
    
    ```bash
    pip install -r requirements.txt
    ```
    
4. **Configure Database URL in FastAPI:** Open the FastAPI configuration file (usually `config.py` or `settings.py`) and update the database URL to match your PostgreSQL setup:
    
    ```python
    SQLALCHEMY_DATABASE_URL = "postgresql://renewal_ridge_emr:your_password@localhost/renewal_ridge_emr"
    ```
    
5. **Run FastAPI Backend:** Run the FastAPI app:
    
    ```bash
    uvicorn main:app --reload
    ```
    
    The backend should now be running at `http://127.0.0.1:8000`.
    

---

### **Step 5: Set Up the Frontend (React)**

1. **Navigate to the Frontend Folder:** Now, go to the frontend directory, which should be within the cloned repository:
    
    ```bash
    cd ../frontend
    ```
    
2. **Install React Dependencies:** Before running the React app, install the required packages using npm:
    
    ```bash
    npm install
    ```
    

4. **Run React Development Server:** To start the React app:
    
    ```bash
    npm start
    ```
    
    React should now be running at `http://localhost:3000`.
    

---

### **Step 6: Set Up GitHub Authentication with Personal Access Token**

If you're asked to enter a GitHub password for Git operations (push, pull, etc.), you’ll need to generate a Personal Access Token from GitHub.

1. **Generate Personal Access Token:**
    
    * Go to [GitHub Developer Settings](https://github.com/settings/tokens).
        
    * Click on **Generate new token**.
        
    * Select the necessary scopes (e.g., `repo`, `workflow`).
        
    * Click **Generate token**, and **copy the token**. You will not be able to see it again.
        
2. **Use Token for Git Authentication:** When you run a `git push` or `git pull`, you’ll be prompted for a password. Paste the token instead of your GitHub password.
    

---

### **Step 7: Run and Test Your Full-Stack Application**

* **Backend (FastAPI)**: Open a browser and go to `http://127.0.0.1:8000` to verify that the FastAPI backend is working correctly. You should see the FastAPI documentation.
    
* **Frontend (React)**: Open a browser and go to `http://localhost:3000` to check if the React app is running. It should be able to communicate with the FastAPI backend.
    

---
