2025-09-26 15:58:25 +03:00
2025-09-19 17:22:36 +03:00
2025-09-19 17:22:36 +03:00
2025-09-19 17:22:36 +03:00
2025-09-19 17:22:36 +03:00
2025-08-29 18:05:51 +03:00
2025-09-19 16:59:52 +03:00
2025-07-17 12:39:21 +03:00
2025-09-05 14:09:02 +03:00
2025-09-19 16:59:52 +03:00
2025-09-19 17:22:36 +03:00
2025-09-19 18:07:31 +03:00
2025-09-19 18:07:31 +03:00
2025-09-19 17:22:36 +03:00

MedReport README

Prerequisites

"node": ">=20.0.0",
"pnpm": ">=9.0.0"

Project structure

/ app - pages
/ components - custom components, helper components that not provided by any package. Place to extend an redefine components from packages
/ config - bunch of configs, that are provided by starter kit.
/ content - (temporary?) - to be removed when cleaned all dependencies
/ fonts - (temporary) - contains fonts, should be relocated to another place (maybe public)
/ lib - diffirent libs, services, utils
    - fonts.ts - project fonts setup, which becomes available as a global css variable
    / i18n - translations/localization setup
/ public - public assets
    / locales - translations under a corresponding local - at a specific namespace
/ styles - all styles of the projects, including tailwind variable setup
    - global.css - Global styles for the entire application, a place where should apply variables to global selectors
    - shadcn-ui.css - A place where all global variables are defined for color, sizes and etc, that are used in theme.css. Variables defined here and in theme.css are available as tailwindcss property-class
    - theme.css - more specific variables,  available as tailwindcss property-class
    - makerkit.css - Makerkit-specific global styles
    - markdoc.css - Styles for Markdoc Markdown files.
    -
/ supabase - primary supabase
/ tooling - a workspace package, used for generation packages in node_modules and provides global links for its data. The most important is typescript config
/ utils

Migration from old structure

pnpm clean
pnpm i

if you get missing dependency error do pnpm i --force

Adding new dependency

pnpm add <pacakge-name> -w

Eslint and prettier

To clean code run

npm run lint:fix
npm run prettier:fix

Supabase

Start supabase in docker

npm run supabase:start

Link your local supabase with a supabase project

npm run supabase:deploy

After editing supabase tables/functions etc update migration files

npm run supabase:db:diff

To update database types run:

npm run supabase:typegen:app

Medusa store

To get medusa store working you need to update the env's to your running medusa app and migrate the tables from medusa project to your supabase project

You can get NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY from your medusa app settings

Super admin

To access admin pages follow these steps:

  • Register new user
  • Go to Profile and add Multi-Factor Authentication
  • Authenticate with mfa (at current time profile page prompts it again)
  • update your role. look at supabase/sql/super-admin.sql
  • Sign out and Sign in

Company User

  • With admin account go to http://localhost:3000/admin/accounts
  • For Create Company Account to work you need to have rows in medreport.roles table. For that you can sql in supabase/sql/super-admin.sql

Start email server

docker run -p 1080:1080 -p 1025:1025 maildev/maildev

  • View emails
  • Mail server is running on localhost:1025 without password

Medipost flow

  1. Customer adds analysis to cart in B2B storefront
  2. Customer checks out from cart and is redirected to Montonio
  3. Customer pays and is redirected back to B2B GET B2B/home/cart/montonio-callback?order-token=$JWT
  • Medusa order is created and cart is emptied
  • email is sent to customer
  • B2B sends order XML as private message to Medipost.

When Montonio has confirmed payment, it will call Medusa webhook endpoint and Medusa will mark order payment as captured.

In background a job will call POST B2B/api/job/sync-analysis-results every n minutes and sync private messages with responses from Medipost.

In local dev environment, you can create a private message with analysis responses in Medipost system for a submitted order:
POST B2B/api/order/medipost-test-response body={medusaOrderId:'input here'}
After that run POST /api/job/sync-analysis-results and analysis results should be synced.

In local dev environment, you can import products from B2B to Medusa with this API:

  • POST /api/job/sync-analysis-groups-store
    • Syncs required data of analyses, analysis_elements data from B2B to Medusa and creates relevant products and categories.
      If product or category already exists, then it is not recreated. Old entries are not deleted either currently.

Jobs

Required headers:

  • x-jobs-api-key in UUID format

Endpoints:

  • POST /api/job/sync-analysis-groups
    • Queries Medipost for public messages list and takes analysis info from the latest event.
      Updates analyses and analysis_elements lists in B2B.
  • POST /api/job/sync-analysis-results
    • Queries Medipost for latest private message that has a response and updates order analysis results from lab results data.
  • POST /api/job/sync-connected-online
    • TODO
Description
No description provided
Readme 12 MiB
Languages
TypeScript 80.9%
PLpgSQL 15.6%
HTML 1.5%
CSS 0.8%
Roff 0.6%
Other 0.5%