{"id":22895537,"url":"https://github.com/andregit1/doctor-schedules","last_synced_at":"2026-05-06T03:31:58.589Z","repository":{"id":267497531,"uuid":"901111748","full_name":"andregit1/doctor-schedules","owner":"andregit1","description":"A RESTful API for doctor schedule management.","archived":false,"fork":false,"pushed_at":"2024-12-10T16:56:24.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-20T05:46:37.644Z","etag":null,"topics":["dotenv","expressjs","javascript","jsonwebtoken","nodejs","pg","postgresql","sequelize-orm","sequelizejs","sequlize-cli","swagger-ui-express"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andregit1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-10T04:08:45.000Z","updated_at":"2024-12-10T16:56:28.000Z","dependencies_parsed_at":"2024-12-10T18:25:29.204Z","dependency_job_id":"fffba61a-e45d-4208-b737-f058197799f3","html_url":"https://github.com/andregit1/doctor-schedules","commit_stats":null,"previous_names":["andregit1/doctor-schedules"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andregit1/doctor-schedules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andregit1%2Fdoctor-schedules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andregit1%2Fdoctor-schedules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andregit1%2Fdoctor-schedules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andregit1%2Fdoctor-schedules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andregit1","download_url":"https://codeload.github.com/andregit1/doctor-schedules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andregit1%2Fdoctor-schedules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32677916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotenv","expressjs","javascript","jsonwebtoken","nodejs","pg","postgresql","sequelize-orm","sequelizejs","sequlize-cli","swagger-ui-express"],"created_at":"2024-12-13T23:30:01.871Z","updated_at":"2026-05-06T03:31:58.572Z","avatar_url":"https://github.com/andregit1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\nA RESTful API for doctor schedule management.\n\n## Prerequisites\n\nEnsure you have the following installed:\n\n- **Node.js** (v22.12.0)\n- **PostgreSQL** (v14.15)\n\n## Setup Instructions\n\n### 1. Clone the Repository\n\n```bash\ngit clone git@github.com:andregit1/doctor-schedules.git\ncd doctor-schedules\n```\n\n### 2. Install Dependencies\n\n```bash\nnpm install\n```\n\n### 3. Configure Environment\n\nCreate a `.env` file with the following content:\n\n```\nPOSTGRES_DB=doctor_schedule\nPOSTGRES_USER=your_postgres_username\nPOSTGRES_PASSWORD=your_postgres_password\nDB_HOST=127.0.0.1\nPORT=3000\nSERVER_URL=http://localhost:3000\nJWT_SECRET=your_secret_key\nJWT_EXPIRED=30m\n```\n\nReplace the placeholder values with valid credentials.\n\n### 4. Database Setup\n\nInitialize Sequelize and set up the database:\n\n```bash\nnpx sequelize db:create\nnpx sequelize db:migrate\nnpx sequelize db:seed:all\n```\n\n### 5. Start the Server\n\nStart the API in development mode:\n\n```bash\nnpm run dev\n```\n\n### 6. Access API Documentation\n\nVisit [http://localhost:3000/api-docs](http://localhost:3000/api-docs) to explore the API using Swagger UI.\n\n---\n\n### 7. Scenario Overview\n\n#### Input Details:\n\n- **Existing Schedule in DB**: `2024-12-16`, `08:00-12:00` for **Doctor ID 1**.\n- **Payload Schedule**: `2024-12-01 to 2024-12-31`, `09:00-17:00` for **Doctor ID 1**.\n- **Payload Example**:\n  ```json\n  {\n  \t\"doctor_id\": 1,\n  \t\"day\": \"Monday\",\n  \t\"time_start\": \"09:00\",\n  \t\"time_finish\": \"17:00\",\n  \t\"quota\": 10,\n  \t\"status\": true,\n  \t\"dateRange\": \"2024-12-01 to 2024-12-31\"\n  }\n  ```\n\n#### Logic:\n\n1. **Same Date \u0026 Time Overlap**: New schedules overlapping with existing ones for the same doctor on the same date will be skipped.\n2. **No Overlap**: New schedules outside of existing schedules or for different doctors are allowed.\n3. **Date Range Check**: The payload's date range (`2024-12-01` to `2024-12-31`) is filtered for valid schedules.\n\n---\n\n#### Decision Matrix\n\n| **Date**   | **Doctor ID** | **Existing Schedule** | **Payload Schedule** | **Result**    | **Reason**                                                     |\n| ---------- | ------------- | --------------------- | -------------------- | ------------- | -------------------------------------------------------------- |\n| 2024-12-01 | 1             | N/A                   | 09:00-17:00          | **Valid**     | No existing schedule for Doctor ID 1.                          |\n| 2024-12-02 | 1             | N/A                   | 09:00-17:00          | **Valid**     | No existing schedule for Doctor ID 1.                          |\n| 2024-12-16 | 1             | 08:00-12:00           | 09:00-17:00          | **Not Valid** | Overlaps with existing schedule `08:00-12:00` for Doctor ID 1. |\n| 2024-12-17 | 1             | N/A                   | 09:00-17:00          | **Valid**     | No existing schedule for Doctor ID 1.                          |\n| 2024-12-31 | 1             | N/A                   | 09:00-17:00          | **Valid**     | No existing schedule for Doctor ID 1.                          |\n\n---\n\n#### Explanation:\n\n1. **Valid Schedules**: Created if no overlap exists between the `time_start` and `time_finish` for the same doctor on the same date.\n2. **Not Valid Schedules**: Skipped if any overlap exists with an existing schedule for the same doctor on the same date.\n\n---\n\n#### **Valid Schedule Criteria**\n\n| Criteria                | Validation Logic                                                                     | Valid Example                                    | Invalid Example                                                  |\n| ----------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------ | ---------------------------------------------------------------- |\n| **Day Validation**      | Must match valid days in **English** or **Indonesian**. **Case insensitive**.        | `monday`, `senin`                                | `mondy`, `senon`                                                 |\n| **Time Range**          | Must not overlap with existing schedules for the same doctor on the same date.       | `09:00-12:00` if no overlap                      | `09:00-10:00` if overlaps with `08:00-12:00` for the same doctor |\n| **Date Range**          | Must fall within the specified payload date range (`start_date` to `end_date`).      | `2024-12-01` in range `2024-12-01 to 2024-12-31` | `2025-01-01` outside range                                       |\n| **Doctor Availability** | The `doctor_id` must exist in the database (linked to an active doctor profile).     | `doctor_id = 1` if exists                        | `doctor_id = 999` if not found                                   |\n| **Quota**               | The quota must be a positive integer.                                                | `10`                                             | `-5`, `abc`                                                      |\n| **Day Consistency**     | The schedule date must match the expected day (e.g., `2024-12-01` must be a Sunday). | `sunday` for `2024-12-01`                        | `monday` for `2024-12-01`                                        |\n\n---\n\n#### **Validation Table**\n\n| Record # | Date       | Day       | Time Start | Time End | Quota | Doctor ID | Valid?  | Reason                                                                             |\n| -------- | ---------- | --------- | ---------- | -------- | ----- | --------- | ------- | ---------------------------------------------------------------------------------- |\n| 1        | 2024-12-01 | Sunday    | 09:00      | 12:00    | 10    | 1         | **Yes** | Matches valid day, time range, date range, quota, and doctor availability.         |\n| 2        | 2024-12-02 | Monday    | 10:00      | 11:00    | 15    | 1         | **Yes** | All criteria satisfied.                                                            |\n| 3        | 2024-12-03 | Tuesday   | 08:00      | 09:00    | 20    | 999       | **No**  | Invalid `doctor_id`; doctor not found in the database.                             |\n| 4        | 2024-12-16 | Monday    | 09:00      | 17:00    | 5     | 1         | **No**  | Overlaps with existing schedule (`08:00-12:00`) for Doctor ID 1.                   |\n| 5        | 2025-01-01 | Wednesday | 09:00      | 12:00    | 10    | 1         | **No**  | Date outside the valid range (`2024-12-01 to 2024-12-31`).                         |\n| 6        | 2024-12-01 | Monday    | 09:00      | 12:00    | 10    | 1         | **No**  | `day` is inconsistent with the actual date (`2024-12-01` is a Sunday, not Monday). |\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandregit1%2Fdoctor-schedules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandregit1%2Fdoctor-schedules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandregit1%2Fdoctor-schedules/lists"}