- Clean Code
- Self-documented Code
- MVC Pattern
- Error Handling
- How to handle Async operations
- Express Best practices
- Configuration: How to use env variables
The task involves creating the necessary functionalities that allow a user with a doctor role to view EHRS (which is a text file that describes the patient's symptoms and medical history) one by one and label them with an ICD-10 diagnostic code and a description of the diagnosis. The application should record the EHRS, doctor identifications and diagnosis labels. The user should be able to log in with their email and password.
- Create an endpoint that allows the user to log in with their email and password, respond with an error message in case of failure with the most convenient error code.
- Create an endpoint that allows the user to retrieve EHRS (use pagination).
- Create an endpoint that allows the user to label an EHR with an ICD-10 diagnostic code and a description of the diagnosis, respond with an error message in case of failure with the most convenient error code.
- Implement a middleware to handle application errors.
Only as an example/reference. You can use create your own schema.
- id
- patient_name
- description
- id
- name
- id
- diagnostic_code
- description
- id
- ehr_id
- doctor_id
- condition_id
The project it's built using the latest version of NestJS, which is a powerful and flexible framework for creating efficient and scalable server-side applications. It includes TypeScript, PostgreSQL, and JWT authentication right out of the box, so you don't have to worry about setting those up yourself.
Features include configuration support with Dotenv, RBAC and CBAC for authorization, TypeORM for interacting with databases, Swagger for API documentation, and Docker Compose for container orchestration. It has pre-configured linting tools and secure HTTP headers with Helmet.
- π± NestJS β latest version
- π TypeScript - Type checking
- βοΈ Dotenv - Supports environment variables
- π Authentication - JWT, RSA256
- π¬ Authorization - RBAC, CBAC
- πͺ TypeORM - Database ORM
- πͺ PostgreSQL - Open-Source Relational Database
- π§ Configuration - Single config for all
- π Swagger - API Documentation
- π³ Docker Compose - Container Orchestration
- π Helmet - secure HTTP headers
- π΄ Insomnia - Insomnia config for endpoints
- π ESLint β Pluggable JavaScript linter
- π Prettier - Opinionated Code Formatter
- β¨ Commitlint - Lint your conventional commits
- π΅οΈββοΈ Code Scanning - Code scanning with CodeQL
Use ehrinsomniaendpoints.json to import the endpoints into Insomnia. Use seeddata.sql to insert some mock values into the tables
bash ./setup.sh
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
- Install the insomnia app
- Import the
endpoints.json
file
- Generate an RSA private key, of size 2048, and output it to a file named key.pem:
openssl genrsa -out private_key.pem 2048
# It needs be copied&pasted from terminal manually
awk 'NF {sub(/\r/, ""); printf"%s\\n",$0;}' private_key.pem
- Extract the public key from the key pair, which can be used in a certificate:
openssl rsa -in private_key.pem -outform PEM -pubout -out public_key.pem
# It needs be copied&pasted from terminal manually
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' public_key.pem
For error middleware see AllExceptionsFilter.