Skip to content

Commit

Permalink
feat: added EHR service
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakkas006 committed May 1, 2024
1 parent 3ce2733 commit 8901ca2
Show file tree
Hide file tree
Showing 44 changed files with 4,102 additions and 54 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Healthcare Appointment Scheduling System

## [Basic System Desin](https://ali-akkas.notion.site/Healthcare-Appointment-Scheduling-System-cf67ead3bb1947f58f505c18fb886280?pvs=4)
## About
Building Microservices Architecture using Docker, implementing CI/CD pipelines using GitHub Actions, incorporating asynchronous communication using RabbitMQ and caching with Redis. Additionally, implementing rate limiting, creating a custom API gateway or reverse proxy, and documenting system architecture.

## [Basic System Architecture](https://ali-akkas.notion.site/Healthcare-Appointment-Scheduling-System-cf67ead3bb1947f58f505c18fb886280?pvs=4)

## Overview

Expand Down Expand Up @@ -119,3 +122,8 @@ yarn run test .\tests\**\**\*
```
When push the code in the GitHub automatic run the actions
```

### Postman `API Testing`
```bash
https://api.postman.com/collections/22653708-df253a8d-6b26-4e83-9673-793d1d6c04d5?access_key=PMAT-01HWT700T6H22BASWVF2E3HK9R
```
2 changes: 1 addition & 1 deletion api-gateway/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const limiter = rateLimit({
},
});

app.use('/api', limiter);
app.use('/api/v1', limiter);

app.use([express.json(), cors(), morgan('dev')]);

Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ services:
- healthcare-appointment-system-network
depends_on:
- postgres
- user
- email

# User Service --------------------------------
user:
Expand Down Expand Up @@ -68,6 +70,8 @@ services:
environment:
- DATABASE_URL=postgresql://admin:password@postgres:5432/appointment_db?schema=public
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672
- REDIS_HOST=redis-stack
- REDIS_PORT=6379
volumes:
- ./services/appointment:/app
networks:
Expand All @@ -76,6 +80,28 @@ services:
- postgres
- email
- rabbitmq
- redis-stack

# EHR Service --------------------------------
ehr:
build:
context: ./services/EHR
dockerfile: Dockerfile
ports:
- '4002:8080'
environment:
- DATABASE_URL=postgresql://admin:password@postgres:5432/ehr_db?schema=public
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672
- REDIS_HOST=redis-stack
- REDIS_PORT=6379
volumes:
- ./services/ehr:/app
networks:
- healthcare-appointment-system-network
depends_on:
- postgres
- rabbitmq
- redis-stack

# Notification Service -------------------------------
notification:
Expand Down
1 change: 1 addition & 0 deletions services/EHR/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions services/EHR/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATABASE_URL='postgresql://admin:password@postgres:5432/ehr_db?schema=public'
RABBITMQ_URL='amqp://guest:guest@rabbitmq:5672'
REDIS_HOST='redis-stack'
REDIS_PORT='6379'
130 changes: 130 additions & 0 deletions services/EHR/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
20 changes: 20 additions & 0 deletions services/EHR/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-alpine

WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

COPY . .

RUN npx prisma generate

ENV PORT 8080

EXPOSE 8080

CMD ["yarn", "dev"]



40 changes: 40 additions & 0 deletions services/EHR/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "user",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev -r tsconfig-paths/register ./src/index.ts",
"test": "npx jest",
"build": "tsc && tsc-alias",
"migrate:dev": "prisma migrate dev",
"migrate:prod": "prisma migrate deploy"
},
"dependencies": {
"@prisma/client": "^5.12.1",
"amqplib": "^0.10.4",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"ioredis": "^5.4.1",
"morgan": "^1.10.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/amqplib": "^0.10.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/ioredis": "^5.0.0",
"@types/jest": "^29.5.12",
"@types/morgan": "^1.9.9",
"@types/node": "^20.12.6",
"jest": "^29.7.0",
"prisma": "^5.12.1",
"ts-jest": "^29.1.2",
"ts-node-dev": "^2.0.0",
"tsc": "^2.0.4",
"tsc-alias": "^1.8.8",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.4.4"
}
}
90 changes: 90 additions & 0 deletions services/EHR/prisma/migrations/20240501120311_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-- CreateEnum
CREATE TYPE "Gender" AS ENUM ('MALE', 'FEMALE', 'OTHER');

-- CreateTable
CREATE TABLE "EHR" (
"id" TEXT NOT NULL,
"patientId" TEXT NOT NULL,
"medicalHistories" TEXT[],
"allergies" TEXT[],

CONSTRAINT "EHR_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Patient" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"patientName" TEXT NOT NULL,
"dateOfBirth" TIMESTAMP(3) NOT NULL,
"gender" "Gender" NOT NULL DEFAULT 'MALE',
"medicalHistory" TEXT NOT NULL,
"insuranceInformation" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Patient_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Medication" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"dosage" TEXT NOT NULL,
"start_date" TIMESTAMP(3) NOT NULL,
"end_date" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Medication_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "DiagnosticReport" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"findings" TEXT NOT NULL,

CONSTRAINT "DiagnosticReport_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_EHRToMedication" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "_DiagnosticReportToEHR" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "Patient_userId_key" ON "Patient"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "_EHRToMedication_AB_unique" ON "_EHRToMedication"("A", "B");

-- CreateIndex
CREATE INDEX "_EHRToMedication_B_index" ON "_EHRToMedication"("B");

-- CreateIndex
CREATE UNIQUE INDEX "_DiagnosticReportToEHR_AB_unique" ON "_DiagnosticReportToEHR"("A", "B");

-- CreateIndex
CREATE INDEX "_DiagnosticReportToEHR_B_index" ON "_DiagnosticReportToEHR"("B");

-- AddForeignKey
ALTER TABLE "EHR" ADD CONSTRAINT "EHR_patientId_fkey" FOREIGN KEY ("patientId") REFERENCES "Patient"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_EHRToMedication" ADD CONSTRAINT "_EHRToMedication_A_fkey" FOREIGN KEY ("A") REFERENCES "EHR"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_EHRToMedication" ADD CONSTRAINT "_EHRToMedication_B_fkey" FOREIGN KEY ("B") REFERENCES "Medication"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_DiagnosticReportToEHR" ADD CONSTRAINT "_DiagnosticReportToEHR_A_fkey" FOREIGN KEY ("A") REFERENCES "DiagnosticReport"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_DiagnosticReportToEHR" ADD CONSTRAINT "_DiagnosticReportToEHR_B_fkey" FOREIGN KEY ("B") REFERENCES "EHR"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `patientEmail` to the `EHR` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "EHR" ADD COLUMN "patientEmail" TEXT NOT NULL;
3 changes: 3 additions & 0 deletions services/EHR/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
Loading

0 comments on commit 8901ca2

Please sign in to comment.