initial commit
This commit is contained in:
parent
b36b900c44
commit
60767dad12
418
README.md
418
README.md
|
|
@ -0,0 +1,418 @@
|
|||
uv run bootstrap all \
|
||||
--content-config ./config.json \
|
||||
--content-modules-root ./modules-data \
|
||||
--content-module-code M0001 \
|
||||
--media-manifest ./media.json \
|
||||
--media-media-root ./modules-data/M0001-Acupuncture Points
|
||||
|
||||
|
||||
uv run bootstrap media \
|
||||
--manifest "./modules-data/M0001-Acupuncture Points/media.json" \
|
||||
--media-root "./modules-data/M0001-Acupuncture Points" \
|
||||
--validate-only
|
||||
|
||||
uv run bootstrap media \
|
||||
--manifest "./modules-data/M0001-Acupuncture Points/media.json" \
|
||||
--media-root "./modules-data/M0001-Acupuncture Points"
|
||||
|
||||
uv run acupedia-bootstrap content \
|
||||
--config ./modules-data/config.json \
|
||||
--modules-root ./modules-data \
|
||||
--module-code M0001 \
|
||||
--publish-content
|
||||
|
||||
|
||||
uv run seed \
|
||||
--config ./modules-data/config.json \
|
||||
--modules-root ./modules-data \
|
||||
--module-code M0001 \
|
||||
--seed-search-facets-only
|
||||
|
||||
uv run seed \
|
||||
--config ./modules-data/config.json \
|
||||
--modules-root ./modules-data \
|
||||
--module-code M0001 \
|
||||
--template-code M0001_CT0003 \
|
||||
--content-code LU-1 \
|
||||
--publish-content
|
||||
|
||||
|
||||
uv run reset \
|
||||
--scope module \
|
||||
--module-code M0002 \
|
||||
--execute
|
||||
|
||||
|
||||
acupedia-bootstrap commerce --plans ./modules-data/plans.json
|
||||
|
||||
acupedia-access grant-plan \
|
||||
--email av.salunke@gmail.com \
|
||||
--plan-code POINTS_ACU
|
||||
|
||||
for seeders that use ORM models, we should treat the SQLAlchemy model package as the compile-time contract and audit every seeder field against Base.metadata/mapped attributes before packaging.
|
||||
|
||||
|
||||
{
|
||||
"version": 1,
|
||||
"plans": [
|
||||
{
|
||||
"code": "POINTS_ACU",
|
||||
"name": "Acu Points Module (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "300.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 10,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_SCALP",
|
||||
"name": "Scalp Points Module (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "100.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 20,
|
||||
"modules": [
|
||||
{ "module_code": "M0003" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_EAR",
|
||||
"name": "Ear Points Module (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "200.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 30,
|
||||
"modules": [
|
||||
{ "module_code": "M0002" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_TUNG",
|
||||
"name": "Tung Points Module (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "300.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": false,
|
||||
"sort_order": 40,
|
||||
"modules": []
|
||||
},
|
||||
{
|
||||
"code": "POINTS_PACK",
|
||||
"name": "Points Complete Pack (1 Yr)",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "900.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 50,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" },
|
||||
{ "module_code": "M0002" },
|
||||
{ "module_code": "M0003" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "PATTERN_CORE",
|
||||
"name": "Pattern Module Access (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "500.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 60,
|
||||
"modules": [
|
||||
{ "module_code": "M0011" },
|
||||
{ "module_code": "M0012" },
|
||||
{ "module_code": "M0013" },
|
||||
{ "module_code": "M0014" },
|
||||
{ "module_code": "M0015" },
|
||||
{ "module_code": "M0016" },
|
||||
{ "module_code": "M0017" },
|
||||
{ "module_code": "M0018" },
|
||||
{ "module_code": "M0019" },
|
||||
{ "module_code": "M0020" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "NUTRITION_CORE",
|
||||
"name": "Nutrition Module Access (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "600.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 70,
|
||||
"modules": [
|
||||
{ "module_code": "M0031" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_GYNAE",
|
||||
"name": "Therapeutics: Gynecology (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "600.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 80,
|
||||
"modules": [
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_EAR",
|
||||
"name": "Therapeutics: Ear reflexology (1 Yr)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "600.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 90,
|
||||
"modules": [
|
||||
{ "module_code": "M0041" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_CORE",
|
||||
"name": "Therapeutics Complete Bundle (1 Yr)",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "1200.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 100,
|
||||
"modules": [
|
||||
{ "module_code": "M0041" },
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "LIFETIME_ALL",
|
||||
"name": "Lifetime All-Access Plan",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "lifetime",
|
||||
"module_fee": "15000.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"is_active": true,
|
||||
"sort_order": 110,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" },
|
||||
{ "module_code": "M0002" },
|
||||
{ "module_code": "M0003" },
|
||||
{ "module_code": "M0011" },
|
||||
{ "module_code": "M0012" },
|
||||
{ "module_code": "M0013" },
|
||||
{ "module_code": "M0014" },
|
||||
{ "module_code": "M0015" },
|
||||
{ "module_code": "M0016" },
|
||||
{ "module_code": "M0017" },
|
||||
{ "module_code": "M0018" },
|
||||
{ "module_code": "M0019" },
|
||||
{ "module_code": "M0020" },
|
||||
{ "module_code": "M0031" },
|
||||
{ "module_code": "M0041" },
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"code": "POINTS_ACU_USD",
|
||||
"name": "Acu Points Module (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "5.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 210,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_SCALP_USD",
|
||||
"name": "Scalp Points Module (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "2.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 220,
|
||||
"modules": [
|
||||
{ "module_code": "M0003" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_EAR_USD",
|
||||
"name": "Ear Points Module (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "3.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 230,
|
||||
"modules": [
|
||||
{ "module_code": "M0002" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "POINTS_TUNG_USD",
|
||||
"name": "Tung Points Module (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "5.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": false,
|
||||
"sort_order": 240,
|
||||
"modules": []
|
||||
},
|
||||
{
|
||||
"code": "POINTS_PACK_USD",
|
||||
"name": "Points Complete Pack (1 Yr - USD)",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "15.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 250,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" },
|
||||
{ "module_code": "M0002" },
|
||||
{ "module_code": "M0003" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "PATTERN_CORE_USD",
|
||||
"name": "Pattern Module Access (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "10.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 260,
|
||||
"modules": [
|
||||
{ "module_code": "M0011" },
|
||||
{ "module_code": "M0012" },
|
||||
{ "module_code": "M0013" },
|
||||
{ "module_code": "M0014" },
|
||||
{ "module_code": "M0015" },
|
||||
{ "module_code": "M0016" },
|
||||
{ "module_code": "M0017" },
|
||||
{ "module_code": "M0018" },
|
||||
{ "module_code": "M0019" },
|
||||
{ "module_code": "M0020" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "NUTRITION_CORE_USD",
|
||||
"name": "Nutrition Module Access (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "15.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 270,
|
||||
"modules": [
|
||||
{ "module_code": "M0031" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_GYNAE_USD",
|
||||
"name": "Therapeutics: Gynecology (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "15.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 280,
|
||||
"modules": [
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_EAR_USD",
|
||||
"name": "Therapeutics: Ear reflexology (1 Yr - USD)",
|
||||
"plan_type": "one_time",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "15.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 290,
|
||||
"modules": [
|
||||
{ "module_code": "M0041" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "THERAPEUTICS_CORE_USD",
|
||||
"name": "Therapeutics Complete Bundle (1 Yr - USD)",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "yearly",
|
||||
"module_fee": "30.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 300,
|
||||
"modules": [
|
||||
{ "module_code": "M0041" },
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "LIFETIME_ALL_USD",
|
||||
"name": "Lifetime All-Access Plan (USD)",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "lifetime",
|
||||
"module_fee": "350.00",
|
||||
"currency_code": "USD",
|
||||
"country": "USA",
|
||||
"is_active": true,
|
||||
"sort_order": 310,
|
||||
"modules": [
|
||||
{ "module_code": "M0001" },
|
||||
{ "module_code": "M0002" },
|
||||
{ "module_code": "M0003" },
|
||||
{ "module_code": "M0011" },
|
||||
{ "module_code": "M0012" },
|
||||
{ "module_code": "M0013" },
|
||||
{ "module_code": "M0014" },
|
||||
{ "module_code": "M0015" },
|
||||
{ "module_code": "M0016" },
|
||||
{ "module_code": "M0017" },
|
||||
{ "module_code": "M0018" },
|
||||
{ "module_code": "M0019" },
|
||||
{ "module_code": "M0020" },
|
||||
{ "module_code": "M0031" },
|
||||
{ "module_code": "M0041" },
|
||||
{ "module_code": "M0042" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
# AccuPedia Bootstrap Orchestration CLI — Full Legacy-Compatible Surface
|
||||
|
||||
This CLI is now the canonical public entry point for:
|
||||
|
||||
```text
|
||||
auth
|
||||
content
|
||||
media
|
||||
commerce
|
||||
validate
|
||||
all
|
||||
```
|
||||
|
||||
The `content` and `media` commands preserve the legacy option surface while
|
||||
running against the four-schema architecture.
|
||||
|
||||
## Content
|
||||
|
||||
Equivalent to the legacy content CLI:
|
||||
|
||||
```bash
|
||||
python -m bootstrap content --config ./config.json --modules-root ./modules
|
||||
```
|
||||
|
||||
Fine-grained examples:
|
||||
|
||||
```bash
|
||||
python -m bootstrap content --config ./config.json --modules-root ./modules --module-code M0001
|
||||
```
|
||||
|
||||
```bash
|
||||
python -m bootstrap content --config ./config.json --modules-root ./modules --module-code M0001 --template-code M0001_CT0003
|
||||
```
|
||||
|
||||
```bash
|
||||
python -m bootstrap content --config ./config.json --modules-root ./modules --module-code M0001 --template-code M0001_CT0003 --content-code LU-1
|
||||
```
|
||||
|
||||
Supported content options:
|
||||
|
||||
```text
|
||||
--config
|
||||
--modules-root
|
||||
--module-code repeatable
|
||||
--template-code repeatable
|
||||
--content-code repeatable
|
||||
--seed-search-facets-only
|
||||
--seed-search-facet-only retained alias
|
||||
--skip-search-facets
|
||||
--publish-content
|
||||
--continue-on-error
|
||||
--created-by
|
||||
```
|
||||
|
||||
Legacy validation rules are preserved exactly.
|
||||
|
||||
The old `--schema` option is deliberately not exposed. Four-schema production
|
||||
ownership is fixed and content seeders own the `content` schema.
|
||||
|
||||
## Media
|
||||
|
||||
Equivalent to the legacy media CLI:
|
||||
|
||||
```bash
|
||||
python -m bootstrap media --manifest ./media.json --media-root ./images
|
||||
```
|
||||
|
||||
Supported options:
|
||||
|
||||
```text
|
||||
--manifest
|
||||
--media-root
|
||||
--validate-only
|
||||
--dry-run
|
||||
--force-reupload
|
||||
```
|
||||
|
||||
The original MinIO environment contract is preserved:
|
||||
|
||||
```text
|
||||
MINIO_ENDPOINT
|
||||
MINIO_ACCESS_KEY
|
||||
MINIO_SECRET_KEY
|
||||
MINIO_BUCKET
|
||||
MINIO_SECURE
|
||||
```
|
||||
|
||||
Media exit semantics are preserved:
|
||||
|
||||
```text
|
||||
0 = success
|
||||
2 = media report not OK
|
||||
```
|
||||
|
||||
## Global options
|
||||
|
||||
```text
|
||||
--database-url
|
||||
--log-level
|
||||
```
|
||||
|
||||
`--database-url` defaults to `DATABASE_URL`.
|
||||
|
||||
## Full bootstrap
|
||||
|
||||
The `all` command uses explicit prefixes to prevent ambiguity:
|
||||
|
||||
```bash
|
||||
python -m bootstrap all --content-config ./config.json --content-modules-root ./modules --media-manifest ./media.json --media-media-root ./images
|
||||
```
|
||||
|
||||
Content selectors under `all` use `--content-*`; media controls use `--media-*`.
|
||||
|
||||
Execution order:
|
||||
|
||||
```text
|
||||
auth
|
||||
↓
|
||||
content
|
||||
↓
|
||||
media
|
||||
↓
|
||||
commerce
|
||||
↓
|
||||
validate
|
||||
```
|
||||
|
||||
No single global transaction is introduced.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from .orchestrator import BootstrapOrchestrator, BootstrapRunResult
|
||||
|
||||
__all__ = ["BootstrapOrchestrator", "BootstrapRunResult"]
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .seed_auth import AuthBootstrapSeeder
|
||||
from .seed_commerce import CommerceBootstrapSeeder
|
||||
from .seed_content.orchestrator import SeedOrchestrator
|
||||
from .seed_media.service import ImageSeedService
|
||||
from .seed_media.validators import load_manifest
|
||||
|
||||
class AuthBootstrapAdapter:
|
||||
async def run(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
bootstrap_admin: Any | None = None,
|
||||
) -> dict[str, object]:
|
||||
result = await AuthBootstrapSeeder(session).seed(
|
||||
bootstrap_admin=bootstrap_admin
|
||||
)
|
||||
return {
|
||||
"roles": result.roles,
|
||||
"permissions": result.permissions,
|
||||
"role_permissions": result.role_permissions,
|
||||
"bootstrap_admin_created": result.bootstrap_admin_created,
|
||||
}
|
||||
|
||||
|
||||
class ContentBootstrapAdapter:
|
||||
"""
|
||||
Exact adapter over the existing content SeedOrchestrator contract.
|
||||
|
||||
Important:
|
||||
- no outer transaction
|
||||
- SeedOrchestrator retains per-template commit/SAVEPOINT behavior
|
||||
- all legacy fine-grained selectors are preserved
|
||||
"""
|
||||
|
||||
async def run(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
config_path: Path,
|
||||
modules_root: Path,
|
||||
module_codes: set[str] | None = None,
|
||||
template_codes: set[str] | None = None,
|
||||
content_codes: set[str] | None = None,
|
||||
search_facets_only: bool = False,
|
||||
skip_search_facets: bool = False,
|
||||
publish_content: bool = False,
|
||||
continue_on_error: bool = False,
|
||||
created_by: UUID | None = None,
|
||||
) -> dict[str, object]:
|
||||
|
||||
|
||||
summaries = await SeedOrchestrator(session).process_config(
|
||||
config_path=config_path.resolve(),
|
||||
modules_root=modules_root.resolve(),
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
search_facets_only=search_facets_only,
|
||||
skip_search_facets=skip_search_facets,
|
||||
publish_content=publish_content,
|
||||
continue_on_error=continue_on_error,
|
||||
created_by=created_by,
|
||||
)
|
||||
|
||||
serialized: list[dict[str, object]] = []
|
||||
for summary in summaries:
|
||||
serialized.append(
|
||||
{
|
||||
"module_code": summary.module_code,
|
||||
"definition_sets_processed": summary.definition_sets_processed,
|
||||
"content_rows_succeeded": summary.content_rows_succeeded,
|
||||
"content_rows_failed": summary.content_rows_failed,
|
||||
"associations_written": summary.associations_written,
|
||||
"stale_associations_removed": summary.stale_associations_removed,
|
||||
"errors": list(summary.errors),
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"status": "completed",
|
||||
"modules": serialized,
|
||||
}
|
||||
|
||||
|
||||
class MediaBootstrapAdapter:
|
||||
"""
|
||||
Exact adapter over the existing image/media seeder behavior.
|
||||
|
||||
Storage configuration is supplied by bootstrap CLI from the same
|
||||
environment variables used by the legacy script.
|
||||
"""
|
||||
|
||||
async def run(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
manifest_path: Path,
|
||||
media_root: Path,
|
||||
storage: Any,
|
||||
bucket: str,
|
||||
validate_only: bool = False,
|
||||
dry_run: bool = False,
|
||||
force_reupload: bool = False,
|
||||
) -> dict[str, object]:
|
||||
|
||||
|
||||
manifest = load_manifest(manifest_path)
|
||||
|
||||
service = ImageSeedService(
|
||||
session=session,
|
||||
storage=storage,
|
||||
bucket=bucket,
|
||||
)
|
||||
report = await service.seed(
|
||||
manifest=manifest,
|
||||
media_root=media_root,
|
||||
dry_run=dry_run,
|
||||
validate_only=validate_only,
|
||||
force_reupload=force_reupload,
|
||||
)
|
||||
|
||||
return {
|
||||
"ok": report.ok,
|
||||
"total": report.total,
|
||||
"validated": report.validated,
|
||||
"uploaded": report.uploaded,
|
||||
"reused_objects": report.reused_objects,
|
||||
"db_upserts": report.db_upserts,
|
||||
"associations_upserted": report.associations_upserted,
|
||||
"errors": [
|
||||
{
|
||||
"index": issue.index,
|
||||
"file": issue.file,
|
||||
"message": issue.message,
|
||||
}
|
||||
for issue in report.errors
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class CommerceBootstrapAdapter:
|
||||
async def run(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
plans_path: Path | None = None,
|
||||
plans: Any = None,
|
||||
coupons: Any = None,
|
||||
) -> dict[str, object]:
|
||||
seeder = CommerceBootstrapSeeder(session)
|
||||
kwargs: dict[str, Any] = {}
|
||||
if plans_path is not None:
|
||||
kwargs["plans_path"] = plans_path
|
||||
if plans is not None:
|
||||
kwargs["plans"] = plans
|
||||
if coupons is not None:
|
||||
kwargs["coupons"] = coupons
|
||||
|
||||
result = await seeder.seed(**kwargs)
|
||||
return {
|
||||
"plans": result.plans,
|
||||
"plan_module_mappings": result.plan_module_mappings,
|
||||
"coupons": result.coupons,
|
||||
}
|
||||
|
|
@ -0,0 +1,480 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from uuid import UUID
|
||||
|
||||
from app.integrations.storage import ObjectStorage, StorageConfig
|
||||
from .seed_auth.models import BootstrapAdminSeed
|
||||
from .seed_content.validators import SeederError
|
||||
|
||||
from .config import BootstrapConfig
|
||||
from .db import create_session_factory
|
||||
from .orchestrator import BootstrapOrchestrator
|
||||
|
||||
|
||||
logger = logging.getLogger("accupedia.bootstrap")
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="accupedia-bootstrap",
|
||||
description="AccuPedia bounded-context bootstrap and seeding CLI.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--database-url",
|
||||
default=os.environ.get("DATABASE_URL"),
|
||||
help="PostgreSQL async SQLAlchemy URL. Defaults to DATABASE_URL.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--log-level",
|
||||
default="INFO",
|
||||
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
|
||||
)
|
||||
|
||||
sub = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
auth = sub.add_parser("auth", help="Seed auth roles/permissions/admin.")
|
||||
_add_admin_args(auth)
|
||||
|
||||
content = sub.add_parser(
|
||||
"content",
|
||||
help="Run the existing content/module seeder.",
|
||||
)
|
||||
_add_content_args(content)
|
||||
|
||||
media = sub.add_parser(
|
||||
"media",
|
||||
help="Seed AccuPedia content media from a manifest.",
|
||||
)
|
||||
_add_media_args(media)
|
||||
|
||||
commerce = sub.add_parser(
|
||||
"commerce",
|
||||
help="Idempotently seed commerce plans and module mappings from plans.json.",
|
||||
)
|
||||
commerce.add_argument(
|
||||
"--plans",
|
||||
type=Path,
|
||||
default=None,
|
||||
help="Path to plans.json. Defaults to app/bootstrap/seed_commerce/plans.json.",
|
||||
)
|
||||
|
||||
all_cmd = sub.add_parser(
|
||||
"all",
|
||||
help="Run auth -> content -> media -> commerce -> validate.",
|
||||
)
|
||||
_add_admin_args(all_cmd)
|
||||
_add_content_args(all_cmd, prefix="content-")
|
||||
_add_media_args(all_cmd, prefix="media-")
|
||||
all_cmd.add_argument(
|
||||
"--commerce-plans",
|
||||
type=Path,
|
||||
default=None,
|
||||
help="Path to commerce plans.json for the commerce step.",
|
||||
)
|
||||
|
||||
sub.add_parser(
|
||||
"validate",
|
||||
help="Validate required schema/tables and seed counts.",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def _add_admin_args(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument("--bootstrap-admin-email")
|
||||
parser.add_argument("--bootstrap-admin-name")
|
||||
parser.add_argument(
|
||||
"--bootstrap-admin-password-env",
|
||||
default="ACCUPEDIA_BOOTSTRAP_ADMIN_PASSWORD",
|
||||
help=(
|
||||
"Environment variable containing the bootstrap admin password. "
|
||||
"The password is never accepted directly as a CLI argument."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bootstrap-admin-country",
|
||||
default="India",
|
||||
)
|
||||
|
||||
|
||||
def _add_content_args(
|
||||
parser: argparse.ArgumentParser,
|
||||
*,
|
||||
prefix: str = "",
|
||||
) -> None:
|
||||
if not prefix:
|
||||
parser.add_argument("--config", type=Path, required=True)
|
||||
parser.add_argument("--modules-root", type=Path, required=True)
|
||||
parser.add_argument(
|
||||
"--module-code",
|
||||
action="append",
|
||||
dest="module_codes",
|
||||
help="Seed only the selected module code. Repeat for multiple modules.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--template-code",
|
||||
action="append",
|
||||
dest="template_codes",
|
||||
help=(
|
||||
"Fine-grained mode: seed all source content for the selected template. "
|
||||
"Repeat to seed multiple templates. Requires exactly one --module-code."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-code",
|
||||
action="append",
|
||||
dest="content_codes",
|
||||
help=(
|
||||
"Fine-grained mode: seed only the authored content row identified by its "
|
||||
"'code'. Repeat for multiple rows. Requires exactly one --module-code "
|
||||
"and exactly one --template-code."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--seed-search-facets-only",
|
||||
"--seed-search-facet-only",
|
||||
dest="seed_search_facets_only",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Seed/reconcile search_facets.json and rebuild the search projection only. "
|
||||
"Does not seed module metadata, definitions, presentations, or content."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-search-facets",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Skip automatic search-facet seeding/reindex after a normal/template/content run."
|
||||
),
|
||||
)
|
||||
parser.add_argument("--publish-content", action="store_true")
|
||||
parser.add_argument("--continue-on-error", action="store_true")
|
||||
parser.add_argument("--created-by", type=UUID, default=None)
|
||||
return
|
||||
|
||||
if prefix != "content-":
|
||||
raise ValueError(f"Unsupported content option prefix: {prefix}")
|
||||
|
||||
parser.add_argument("--content-config", type=Path, required=True)
|
||||
parser.add_argument("--content-modules-root", type=Path, required=True)
|
||||
parser.add_argument(
|
||||
"--content-module-code",
|
||||
action="append",
|
||||
dest="content_module_codes",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-template-code",
|
||||
action="append",
|
||||
dest="content_template_codes",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-content-code",
|
||||
action="append",
|
||||
dest="content_content_codes",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-seed-search-facets-only",
|
||||
"--content-seed-search-facet-only",
|
||||
dest="content_seed_search_facets_only",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-skip-search-facets",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-publish-content",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-continue-on-error",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--content-created-by",
|
||||
type=UUID,
|
||||
default=None,
|
||||
)
|
||||
|
||||
|
||||
def _add_media_args(
|
||||
parser: argparse.ArgumentParser,
|
||||
*,
|
||||
prefix: str = "",
|
||||
) -> None:
|
||||
if not prefix:
|
||||
parser.add_argument("--manifest", type=Path, required=True)
|
||||
parser.add_argument("--media-root", type=Path, required=True)
|
||||
parser.add_argument("--validate-only", action="store_true")
|
||||
parser.add_argument("--dry-run", action="store_true")
|
||||
parser.add_argument("--force-reupload", action="store_true")
|
||||
return
|
||||
|
||||
if prefix != "media-":
|
||||
raise ValueError(f"Unsupported media option prefix: {prefix}")
|
||||
|
||||
parser.add_argument("--media-manifest", type=Path, required=True)
|
||||
parser.add_argument("--media-media-root", type=Path, required=True)
|
||||
parser.add_argument(
|
||||
"--media-validate-only",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--media-dry-run",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--media-force-reupload",
|
||||
action="store_true",
|
||||
)
|
||||
def _validate_content_args(
|
||||
*,
|
||||
module_codes: set[str] | None,
|
||||
template_codes: set[str] | None,
|
||||
content_codes: set[str] | None,
|
||||
seed_search_facets_only: bool,
|
||||
skip_search_facets: bool,
|
||||
publish_content: bool,
|
||||
) -> None:
|
||||
if template_codes and (not module_codes or len(module_codes) != 1):
|
||||
raise SeederError(
|
||||
"--template-code requires exactly one --module-code so a partial "
|
||||
"seed cannot accidentally target similarly named templates in other modules"
|
||||
)
|
||||
|
||||
if content_codes:
|
||||
if not module_codes or len(module_codes) != 1:
|
||||
raise SeederError("--content-code requires exactly one --module-code")
|
||||
if not template_codes or len(template_codes) != 1:
|
||||
raise SeederError("--content-code requires exactly one --template-code")
|
||||
|
||||
if seed_search_facets_only:
|
||||
if not module_codes:
|
||||
raise SeederError(
|
||||
"--seed-search-facets-only requires at least one --module-code"
|
||||
)
|
||||
if template_codes or content_codes:
|
||||
raise SeederError("--seed-search-facets-only cannot be combined with --template-code or --content-code")
|
||||
if skip_search_facets:
|
||||
raise SeederError(
|
||||
"--seed-search-facets-only cannot be combined with --skip-search-facets"
|
||||
)
|
||||
if publish_content:
|
||||
raise SeederError(
|
||||
"--publish-content is not applicable to --seed-search-facets-only"
|
||||
)
|
||||
|
||||
|
||||
def _build_admin(args: argparse.Namespace) -> BootstrapAdminSeed | None:
|
||||
email = getattr(args, "bootstrap_admin_email", None)
|
||||
name = getattr(args, "bootstrap_admin_name", None)
|
||||
|
||||
if not email and not name:
|
||||
return None
|
||||
if not email or not name:
|
||||
raise ValueError(
|
||||
"Both --bootstrap-admin-email and --bootstrap-admin-name are required."
|
||||
)
|
||||
|
||||
env_name = args.bootstrap_admin_password_env
|
||||
password = os.getenv(env_name, "")
|
||||
if not password:
|
||||
raise ValueError(
|
||||
f"Bootstrap admin password environment variable is empty: {env_name}"
|
||||
)
|
||||
|
||||
return BootstrapAdminSeed(
|
||||
email=email,
|
||||
password=password,
|
||||
display_name=name,
|
||||
country=args.bootstrap_admin_country,
|
||||
)
|
||||
|
||||
|
||||
def _env(
|
||||
name: str,
|
||||
*,
|
||||
required: bool = True,
|
||||
default: str | None = None,
|
||||
) -> str:
|
||||
value = os.getenv(name, default)
|
||||
if required and not value:
|
||||
raise RuntimeError(f"Required environment variable {name} is not set")
|
||||
return value or ""
|
||||
|
||||
|
||||
def _build_storage() -> tuple[ObjectStorage, str]:
|
||||
endpoint = _env("MINIO_ENDPOINT")
|
||||
access_key = _env("MINIO_ACCESS_KEY")
|
||||
secret_key = _env("MINIO_SECRET_KEY")
|
||||
bucket = _env(
|
||||
"MINIO_BUCKET",
|
||||
default="accupedia-media",
|
||||
required=False,
|
||||
)
|
||||
secure = _env(
|
||||
"MINIO_SECURE",
|
||||
default="false",
|
||||
required=False,
|
||||
).lower() in {"1", "true", "yes", "on"}
|
||||
|
||||
storage = ObjectStorage(
|
||||
StorageConfig(
|
||||
endpoint=endpoint,
|
||||
access_key=access_key,
|
||||
secret_key=secret_key,
|
||||
bucket=bucket,
|
||||
secure=secure,
|
||||
)
|
||||
)
|
||||
return storage, bucket
|
||||
|
||||
|
||||
async def async_main() -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
database_url = args.database_url
|
||||
if not database_url:
|
||||
raise SeederError("DATABASE_URL is required")
|
||||
|
||||
logging.basicConfig(
|
||||
level=getattr(logging, args.log_level),
|
||||
format="%(asctime)s %(levelname)s %(name)s - %(message)s",
|
||||
)
|
||||
|
||||
engine, session_factory = create_session_factory(database_url)
|
||||
orchestrator = BootstrapOrchestrator(session_factory)
|
||||
|
||||
try:
|
||||
if args.command == "auth":
|
||||
result = await orchestrator.run_auth(
|
||||
bootstrap_admin=_build_admin(args),
|
||||
)
|
||||
|
||||
elif args.command == "content":
|
||||
module_codes = set(args.module_codes) if args.module_codes else None
|
||||
template_codes = set(args.template_codes) if args.template_codes else None
|
||||
content_codes = set(args.content_codes) if args.content_codes else None
|
||||
|
||||
_validate_content_args(
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
seed_search_facets_only=args.seed_search_facets_only,
|
||||
skip_search_facets=args.skip_search_facets,
|
||||
publish_content=args.publish_content,
|
||||
)
|
||||
|
||||
result = await orchestrator.run_content(
|
||||
config_path=args.config,
|
||||
modules_root=args.modules_root,
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
search_facets_only=args.seed_search_facets_only,
|
||||
skip_search_facets=args.skip_search_facets,
|
||||
publish_content=args.publish_content,
|
||||
continue_on_error=args.continue_on_error,
|
||||
created_by=args.created_by,
|
||||
)
|
||||
|
||||
elif args.command == "media":
|
||||
storage, bucket = _build_storage()
|
||||
result = await orchestrator.run_media(
|
||||
manifest_path=args.manifest,
|
||||
media_root=args.media_root,
|
||||
storage=storage,
|
||||
bucket=bucket,
|
||||
validate_only=args.validate_only,
|
||||
dry_run=args.dry_run,
|
||||
force_reupload=args.force_reupload,
|
||||
)
|
||||
|
||||
elif args.command == "commerce":
|
||||
result = await orchestrator.run_commerce(plans_path=args.plans)
|
||||
|
||||
elif args.command == "validate":
|
||||
result = await orchestrator.run_validate()
|
||||
|
||||
elif args.command == "all":
|
||||
module_codes = (
|
||||
set(args.content_module_codes)
|
||||
if args.content_module_codes
|
||||
else None
|
||||
)
|
||||
template_codes = (
|
||||
set(args.content_template_codes)
|
||||
if args.content_template_codes
|
||||
else None
|
||||
)
|
||||
content_codes = (
|
||||
set(args.content_content_codes)
|
||||
if args.content_content_codes
|
||||
else None
|
||||
)
|
||||
|
||||
_validate_content_args(
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
seed_search_facets_only=args.content_seed_search_facets_only,
|
||||
skip_search_facets=args.content_skip_search_facets,
|
||||
publish_content=args.content_publish_content,
|
||||
)
|
||||
|
||||
storage, bucket = _build_storage()
|
||||
|
||||
result = await orchestrator.run_all(
|
||||
bootstrap_admin=_build_admin(args),
|
||||
content_config_path=args.content_config,
|
||||
modules_root=args.content_modules_root,
|
||||
media_manifest_path=args.media_manifest,
|
||||
media_root=args.media_media_root,
|
||||
storage=storage,
|
||||
bucket=bucket,
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
search_facets_only=args.content_seed_search_facets_only,
|
||||
skip_search_facets=args.content_skip_search_facets,
|
||||
publish_content=args.content_publish_content,
|
||||
continue_on_error=args.content_continue_on_error,
|
||||
created_by=args.content_created_by,
|
||||
validate_only=args.media_validate_only,
|
||||
dry_run=args.media_dry_run,
|
||||
force_reupload=args.media_force_reupload,
|
||||
plans_path=args.commerce_plans,
|
||||
)
|
||||
|
||||
else:
|
||||
parser.error(f"Unsupported command: {args.command}")
|
||||
return 2
|
||||
|
||||
print(json.dumps(result.to_dict(), indent=2, default=str))
|
||||
|
||||
if args.command == "media":
|
||||
return 0 if result.status == "success" else 2
|
||||
|
||||
return 0 if result.status == "success" else 1
|
||||
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
raise SystemExit(asyncio.run(async_main()))
|
||||
except Exception as exc:
|
||||
logger.exception("Bootstrap failed: %s", exc)
|
||||
raise SystemExit(1) from exc
|
||||
|
||||
#
|
||||
#if __name__ == "__main__":
|
||||
# main()
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class BootstrapConfig:
|
||||
database_url: str
|
||||
content_config_path: Path | None = None
|
||||
media_manifest_path: Path | None = None
|
||||
media_root: Path | None = None
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "BootstrapConfig":
|
||||
database_url = os.getenv("DATABASE_URL", "").strip()
|
||||
if not database_url:
|
||||
raise ValueError("DATABASE_URL is required.")
|
||||
|
||||
def optional_path(name: str) -> Path | None:
|
||||
value = os.getenv(name, "").strip()
|
||||
return Path(value).expanduser().resolve() if value else None
|
||||
|
||||
return cls(
|
||||
database_url=database_url,
|
||||
content_config_path=optional_path("ACCUPEDIA_CONTENT_CONFIG"),
|
||||
media_manifest_path=optional_path("ACCUPEDIA_MEDIA_MANIFEST"),
|
||||
media_root=optional_path("ACCUPEDIA_MEDIA_ROOT"),
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy.ext.asyncio import (
|
||||
AsyncSession,
|
||||
async_sessionmaker,
|
||||
create_async_engine,
|
||||
)
|
||||
|
||||
|
||||
def create_session_factory(
|
||||
database_url: str,
|
||||
) -> tuple[object, async_sessionmaker[AsyncSession]]:
|
||||
engine = create_async_engine(
|
||||
database_url,
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
session_factory = async_sessionmaker(
|
||||
engine,
|
||||
expire_on_commit=False,
|
||||
class_=AsyncSession,
|
||||
)
|
||||
return engine, session_factory
|
||||
|
|
@ -0,0 +1,260 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
||||
|
||||
from .adapters import (
|
||||
AuthBootstrapAdapter,
|
||||
CommerceBootstrapAdapter,
|
||||
ContentBootstrapAdapter,
|
||||
MediaBootstrapAdapter,
|
||||
)
|
||||
from .result import BootstrapRunResult, StepResult
|
||||
from .validation import BootstrapValidator
|
||||
|
||||
|
||||
class BootstrapOrchestrator:
|
||||
"""
|
||||
Deterministic orchestration over bounded-context seeders.
|
||||
|
||||
The orchestrator coordinates ordering and transaction boundaries only.
|
||||
It does not absorb bounded-context seeding rules.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
session_factory: async_sessionmaker[AsyncSession],
|
||||
) -> None:
|
||||
self.session_factory = session_factory
|
||||
self.auth = AuthBootstrapAdapter()
|
||||
self.content = ContentBootstrapAdapter()
|
||||
self.media = MediaBootstrapAdapter()
|
||||
self.commerce = CommerceBootstrapAdapter()
|
||||
self.validator = BootstrapValidator()
|
||||
|
||||
async def run_auth(
|
||||
self,
|
||||
*,
|
||||
bootstrap_admin: Any | None = None,
|
||||
) -> BootstrapRunResult:
|
||||
details = await self._transaction(
|
||||
lambda session: self.auth.run(
|
||||
session,
|
||||
bootstrap_admin=bootstrap_admin,
|
||||
)
|
||||
)
|
||||
return self._success("auth", "auth", details)
|
||||
|
||||
async def run_content(
|
||||
self,
|
||||
*,
|
||||
config_path: Path,
|
||||
modules_root: Path,
|
||||
module_codes: set[str] | None = None,
|
||||
template_codes: set[str] | None = None,
|
||||
content_codes: set[str] | None = None,
|
||||
search_facets_only: bool = False,
|
||||
skip_search_facets: bool = False,
|
||||
publish_content: bool = False,
|
||||
continue_on_error: bool = False,
|
||||
created_by: UUID | None = None,
|
||||
) -> BootstrapRunResult:
|
||||
async with self.session_factory() as session:
|
||||
details = await self.content.run(
|
||||
session,
|
||||
config_path=config_path,
|
||||
modules_root=modules_root,
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
search_facets_only=search_facets_only,
|
||||
skip_search_facets=skip_search_facets,
|
||||
publish_content=publish_content,
|
||||
continue_on_error=continue_on_error,
|
||||
created_by=created_by,
|
||||
)
|
||||
return self._success("content", "content", details)
|
||||
|
||||
async def run_media(
|
||||
self,
|
||||
*,
|
||||
manifest_path: Path,
|
||||
media_root: Path,
|
||||
storage: Any,
|
||||
bucket: str,
|
||||
validate_only: bool = False,
|
||||
dry_run: bool = False,
|
||||
force_reupload: bool = False,
|
||||
) -> BootstrapRunResult:
|
||||
async with self.session_factory() as session:
|
||||
details = await self.media.run(
|
||||
session,
|
||||
manifest_path=manifest_path,
|
||||
media_root=media_root,
|
||||
storage=storage,
|
||||
bucket=bucket,
|
||||
validate_only=validate_only,
|
||||
dry_run=dry_run,
|
||||
force_reupload=force_reupload,
|
||||
)
|
||||
|
||||
step_status = "success" if bool(details.get("ok", True)) else "failed"
|
||||
return BootstrapRunResult(
|
||||
command="media",
|
||||
status=step_status,
|
||||
steps=[
|
||||
StepResult(
|
||||
name="media",
|
||||
status=step_status,
|
||||
details=details,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
async def run_commerce(
|
||||
self,
|
||||
*,
|
||||
plans_path: Path | None = None,
|
||||
plans: Any = None,
|
||||
coupons: Any = None,
|
||||
) -> BootstrapRunResult:
|
||||
details = await self._transaction(
|
||||
lambda session: self.commerce.run(
|
||||
session,
|
||||
plans_path=plans_path,
|
||||
plans=plans,
|
||||
coupons=coupons,
|
||||
)
|
||||
)
|
||||
return self._success("commerce", "commerce", details)
|
||||
|
||||
async def run_validate(self) -> BootstrapRunResult:
|
||||
async with self.session_factory() as session:
|
||||
validation = await self.validator.validate(session)
|
||||
|
||||
step = StepResult(
|
||||
name="validate",
|
||||
status="success" if validation.ok else "failed",
|
||||
details={
|
||||
**validation.details,
|
||||
"missing_tables": list(validation.missing_tables),
|
||||
},
|
||||
)
|
||||
return BootstrapRunResult(
|
||||
command="validate",
|
||||
status=step.status,
|
||||
steps=[step],
|
||||
)
|
||||
|
||||
async def run_all(
|
||||
self,
|
||||
*,
|
||||
bootstrap_admin: Any | None = None,
|
||||
content_config_path: Path,
|
||||
modules_root: Path,
|
||||
media_manifest_path: Path,
|
||||
media_root: Path,
|
||||
storage: Any,
|
||||
bucket: str,
|
||||
module_codes: set[str] | None = None,
|
||||
template_codes: set[str] | None = None,
|
||||
content_codes: set[str] | None = None,
|
||||
search_facets_only: bool = False,
|
||||
skip_search_facets: bool = False,
|
||||
publish_content: bool = False,
|
||||
continue_on_error: bool = False,
|
||||
created_by: UUID | None = None,
|
||||
validate_only: bool = False,
|
||||
dry_run: bool = False,
|
||||
force_reupload: bool = False,
|
||||
plans_path: Path | None = None,
|
||||
plans: Any = None,
|
||||
coupons: Any = None,
|
||||
) -> BootstrapRunResult:
|
||||
combined = BootstrapRunResult(
|
||||
command="all",
|
||||
status="success",
|
||||
)
|
||||
|
||||
results = (
|
||||
await self.run_auth(bootstrap_admin=bootstrap_admin),
|
||||
await self.run_content(
|
||||
config_path=content_config_path,
|
||||
modules_root=modules_root,
|
||||
module_codes=module_codes,
|
||||
template_codes=template_codes,
|
||||
content_codes=content_codes,
|
||||
search_facets_only=search_facets_only,
|
||||
skip_search_facets=skip_search_facets,
|
||||
publish_content=publish_content,
|
||||
continue_on_error=continue_on_error,
|
||||
created_by=created_by,
|
||||
),
|
||||
await self.run_media(
|
||||
manifest_path=media_manifest_path,
|
||||
media_root=media_root,
|
||||
storage=storage,
|
||||
bucket=bucket,
|
||||
validate_only=validate_only,
|
||||
dry_run=dry_run,
|
||||
force_reupload=force_reupload,
|
||||
),
|
||||
)
|
||||
|
||||
for result in results:
|
||||
combined.steps.extend(result.steps)
|
||||
if result.status != "success":
|
||||
combined.status = "failed"
|
||||
return combined
|
||||
|
||||
commerce_result = await self.run_commerce(
|
||||
plans_path=plans_path,
|
||||
plans=plans,
|
||||
coupons=coupons,
|
||||
)
|
||||
combined.steps.extend(commerce_result.steps)
|
||||
if commerce_result.status != "success":
|
||||
combined.status = "failed"
|
||||
return combined
|
||||
|
||||
validate_result = await self.run_validate()
|
||||
combined.steps.extend(validate_result.steps)
|
||||
if validate_result.status != "success":
|
||||
combined.status = "failed"
|
||||
|
||||
return combined
|
||||
|
||||
async def _transaction(
|
||||
self,
|
||||
fn: Callable[[AsyncSession], Awaitable[dict[str, object]]],
|
||||
) -> dict[str, object]:
|
||||
async with self.session_factory() as session:
|
||||
try:
|
||||
details = await fn(session)
|
||||
await session.commit()
|
||||
return details
|
||||
except Exception:
|
||||
await session.rollback()
|
||||
raise
|
||||
|
||||
@staticmethod
|
||||
def _success(
|
||||
command: str,
|
||||
step_name: str,
|
||||
details: dict[str, object],
|
||||
) -> BootstrapRunResult:
|
||||
return BootstrapRunResult(
|
||||
command=command,
|
||||
status="success",
|
||||
steps=[
|
||||
StepResult(
|
||||
name=step_name,
|
||||
status="success",
|
||||
details=details,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class StepResult:
|
||||
name: str
|
||||
status: str
|
||||
details: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class BootstrapRunResult:
|
||||
command: str
|
||||
status: str
|
||||
steps: list[StepResult] = field(default_factory=list)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"command": self.command,
|
||||
"status": self.status,
|
||||
"steps": [asdict(item) for item in self.steps],
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from .service import AuthBootstrapSeeder, AuthBootstrapResult
|
||||
|
||||
__all__ = ["AuthBootstrapSeeder", "AuthBootstrapResult"]
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from .models import PermissionSeed, RolePermissionSeed, RoleSeed
|
||||
|
||||
|
||||
DEFAULT_ROLES = (
|
||||
RoleSeed("admin", "Full administrative access.", True),
|
||||
RoleSeed("practitioner", "Standard practitioner access.", True),
|
||||
)
|
||||
|
||||
DEFAULT_PERMISSIONS = (
|
||||
PermissionSeed("content.read", "Read published clinical content.", "content"),
|
||||
PermissionSeed("content.manage", "Create and manage clinical content.", "content"),
|
||||
PermissionSeed("content.publish", "Publish clinical content.", "content"),
|
||||
PermissionSeed(
|
||||
"commerce.manage",
|
||||
"Manage plans, subscriptions and entitlements.",
|
||||
"commerce",
|
||||
),
|
||||
PermissionSeed("users.manage", "Manage application users and RBAC.", "auth"),
|
||||
PermissionSeed("audit.read", "Read administrative audit information.", "platform"),
|
||||
)
|
||||
|
||||
DEFAULT_ROLE_PERMISSIONS = (
|
||||
RolePermissionSeed(
|
||||
"admin",
|
||||
tuple(permission.key for permission in DEFAULT_PERMISSIONS),
|
||||
),
|
||||
RolePermissionSeed(
|
||||
"practitioner",
|
||||
("content.read",),
|
||||
),
|
||||
)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class RoleSeed:
|
||||
name: str
|
||||
description: str | None = None
|
||||
is_system_role: bool = True
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class PermissionSeed:
|
||||
key: str
|
||||
description: str | None = None
|
||||
module: str = "system"
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class RolePermissionSeed:
|
||||
role_name: str
|
||||
permission_keys: tuple[str, ...] = field(default_factory=tuple)
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class BootstrapAdminSeed:
|
||||
email: str
|
||||
password: str
|
||||
display_name: str
|
||||
country: str = "India"
|
||||
phone_number: str | None = None
|
||||
role_names: tuple[str, ...] = ("admin",)
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.models import AppUser, Permission, Role, RolePermission, UserRole
|
||||
|
||||
|
||||
class AuthSeedRepository:
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
async def upsert_role(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
description: str | None,
|
||||
is_system_role: bool,
|
||||
) -> Role:
|
||||
role = (
|
||||
await self.session.execute(
|
||||
select(Role).where(Role.role_name == name)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if role is None:
|
||||
role = Role(
|
||||
role_name=name,
|
||||
description=description,
|
||||
is_system_role=is_system_role,
|
||||
)
|
||||
self.session.add(role)
|
||||
else:
|
||||
role.description = description
|
||||
role.is_system_role = is_system_role
|
||||
|
||||
await self.session.flush()
|
||||
return role
|
||||
|
||||
async def upsert_permission(
|
||||
self,
|
||||
*,
|
||||
key: str,
|
||||
description: str | None,
|
||||
module: str,
|
||||
) -> Permission:
|
||||
permission = (
|
||||
await self.session.execute(
|
||||
select(Permission).where(Permission.permission_key == key)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if permission is None:
|
||||
permission = Permission(
|
||||
permission_key=key,
|
||||
description=description,
|
||||
module=module,
|
||||
)
|
||||
self.session.add(permission)
|
||||
else:
|
||||
permission.description = description
|
||||
permission.module = module
|
||||
|
||||
await self.session.flush()
|
||||
return permission
|
||||
|
||||
async def ensure_role_permission(
|
||||
self,
|
||||
*,
|
||||
role_id: UUID,
|
||||
permission_id: UUID,
|
||||
) -> None:
|
||||
existing = (
|
||||
await self.session.execute(
|
||||
select(RolePermission).where(
|
||||
RolePermission.role_id == role_id,
|
||||
RolePermission.permission_id == permission_id,
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if existing is None:
|
||||
self.session.add(
|
||||
RolePermission(
|
||||
role_id=role_id,
|
||||
permission_id=permission_id,
|
||||
)
|
||||
)
|
||||
await self.session.flush()
|
||||
|
||||
async def get_user_by_email(self, email: str) -> AppUser | None:
|
||||
return (
|
||||
await self.session.execute(
|
||||
select(AppUser).where(AppUser.email == email)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
async def create_admin(
|
||||
self,
|
||||
*,
|
||||
email: str,
|
||||
password_hash: str,
|
||||
display_name: str,
|
||||
country: str,
|
||||
phone_number: str | None,
|
||||
) -> AppUser:
|
||||
user = AppUser(
|
||||
email=email,
|
||||
password_hash=password_hash,
|
||||
display_name=display_name,
|
||||
country=country,
|
||||
phone_number=phone_number,
|
||||
is_active=True,
|
||||
)
|
||||
self.session.add(user)
|
||||
await self.session.flush()
|
||||
return user
|
||||
|
||||
async def get_role(self, name: str) -> Role | None:
|
||||
return (
|
||||
await self.session.execute(
|
||||
select(Role).where(Role.role_name == name)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
async def ensure_user_role(
|
||||
self,
|
||||
*,
|
||||
user_id: UUID,
|
||||
role_id: UUID,
|
||||
) -> None:
|
||||
existing = (
|
||||
await self.session.execute(
|
||||
select(UserRole).where(
|
||||
UserRole.user_id == user_id,
|
||||
UserRole.role_id == role_id,
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if existing is None:
|
||||
self.session.add(
|
||||
UserRole(
|
||||
user_id=user_id,
|
||||
role_id=role_id,
|
||||
)
|
||||
)
|
||||
await self.session.flush()
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.features.auth.security import hash_password, normalize_email, validate_password_strength
|
||||
|
||||
from .defaults import DEFAULT_PERMISSIONS, DEFAULT_ROLE_PERMISSIONS, DEFAULT_ROLES
|
||||
from .models import BootstrapAdminSeed
|
||||
from .repository import AuthSeedRepository
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class AuthBootstrapResult:
|
||||
roles: int
|
||||
permissions: int
|
||||
role_permissions: int
|
||||
bootstrap_admin_created: bool
|
||||
|
||||
|
||||
class AuthBootstrapSeeder:
|
||||
"""Idempotent auth bootstrap. Bootstrap admin is strictly optional."""
|
||||
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
self.repo = AuthSeedRepository(session)
|
||||
|
||||
async def seed(
|
||||
self,
|
||||
*,
|
||||
bootstrap_admin: BootstrapAdminSeed | None = None,
|
||||
) -> AuthBootstrapResult:
|
||||
roles = {}
|
||||
for item in DEFAULT_ROLES:
|
||||
roles[item.name] = await self.repo.upsert_role(
|
||||
name=item.name, description=item.description, is_system_role=item.is_system_role
|
||||
)
|
||||
|
||||
permissions = {}
|
||||
for item in DEFAULT_PERMISSIONS:
|
||||
permissions[item.key] = await self.repo.upsert_permission(
|
||||
key=item.key,
|
||||
description=item.description,
|
||||
module=item.module,
|
||||
)
|
||||
|
||||
role_permission_count = 0
|
||||
for mapping in DEFAULT_ROLE_PERMISSIONS:
|
||||
role = roles[mapping.role_name]
|
||||
for key in mapping.permission_keys:
|
||||
await self.repo.ensure_role_permission(
|
||||
role_id=role.id,
|
||||
permission_id=permissions[key].id,
|
||||
)
|
||||
role_permission_count += 1
|
||||
|
||||
created = False
|
||||
if bootstrap_admin is not None:
|
||||
email = normalize_email(bootstrap_admin.email)
|
||||
user = await self.repo.get_user_by_email(email)
|
||||
if user is None:
|
||||
validate_password_strength(bootstrap_admin.password)
|
||||
user = await self.repo.create_admin(
|
||||
email=email,
|
||||
password_hash=hash_password(bootstrap_admin.password),
|
||||
display_name=bootstrap_admin.display_name.strip(),
|
||||
country=bootstrap_admin.country.strip() or "India",
|
||||
phone_number=bootstrap_admin.phone_number,
|
||||
)
|
||||
created = True
|
||||
|
||||
for role_name in bootstrap_admin.role_names:
|
||||
role = await self.repo.get_role(role_name)
|
||||
if role is None:
|
||||
raise ValueError(
|
||||
f"Bootstrap admin role does not exist: {role_name}"
|
||||
)
|
||||
await self.repo.ensure_user_role(
|
||||
user_id=user.id, role_id=role.id
|
||||
)
|
||||
|
||||
return AuthBootstrapResult(
|
||||
roles=len(roles),
|
||||
permissions=len(permissions),
|
||||
role_permissions=role_permission_count,
|
||||
bootstrap_admin_created=created,
|
||||
)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from .service import CommerceBootstrapSeeder, CommerceBootstrapResult
|
||||
|
||||
__all__ = ["CommerceBootstrapSeeder", "CommerceBootstrapResult"]
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from .models import AccessPlanSeed
|
||||
|
||||
|
||||
DEFAULT_ACCESS_PLANS = (
|
||||
AccessPlanSeed(
|
||||
code="LIFETIME_ALL",
|
||||
name="Lifetime All Access",
|
||||
description="Lifetime access to all active AccuPedia modules.",
|
||||
plan_type="bundle",
|
||||
billing_period="lifetime",
|
||||
member_fee=Decimal("0.00"),
|
||||
module_fee=Decimal("0.00"),
|
||||
currency_code="INR",
|
||||
country="India",
|
||||
is_active=False,
|
||||
),
|
||||
AccessPlanSeed(
|
||||
code="LIFETIME_ALL_USD",
|
||||
name="Lifetime All Access USD",
|
||||
description="Lifetime access to all active AccuPedia modules.",
|
||||
plan_type="bundle",
|
||||
billing_period="lifetime",
|
||||
member_fee=Decimal("0.00"),
|
||||
module_fee=Decimal("0.00"),
|
||||
currency_code="USD",
|
||||
country="International",
|
||||
is_active=False,
|
||||
),
|
||||
)
|
||||
|
||||
DEFAULT_COUPONS = ()
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from app.db.enums import BillingPeriod, PlanType
|
||||
|
||||
from .models import AccessPlanSeed
|
||||
|
||||
|
||||
DEFAULT_PLANS_PATH = Path(__file__).with_name("plans.json")
|
||||
|
||||
|
||||
class CommerceSeedConfigError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def load_access_plans(path: Path = DEFAULT_PLANS_PATH) -> tuple[AccessPlanSeed, ...]:
|
||||
try:
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
except FileNotFoundError as exc:
|
||||
raise CommerceSeedConfigError(f"Commerce plans file not found: {path}") from exc
|
||||
except json.JSONDecodeError as exc:
|
||||
raise CommerceSeedConfigError(
|
||||
f"Invalid JSON in commerce plans file {path}: {exc}"
|
||||
) from exc
|
||||
|
||||
if not isinstance(payload, dict):
|
||||
raise CommerceSeedConfigError("plans.json root must be a JSON object")
|
||||
if payload.get("version") != 1:
|
||||
raise CommerceSeedConfigError("plans.json version must be 1")
|
||||
|
||||
raw_plans = payload.get("plans")
|
||||
if not isinstance(raw_plans, list):
|
||||
raise CommerceSeedConfigError("plans.json 'plans' must be an array")
|
||||
|
||||
seen_codes: set[str] = set()
|
||||
plans: list[AccessPlanSeed] = []
|
||||
for index, raw in enumerate(raw_plans):
|
||||
if not isinstance(raw, dict):
|
||||
raise CommerceSeedConfigError(f"plans[{index}] must be an object")
|
||||
|
||||
code = _required_text(raw, "code", index).upper()
|
||||
if code in seen_codes:
|
||||
raise CommerceSeedConfigError(f"Duplicate plan code in plans.json: {code}")
|
||||
seen_codes.add(code)
|
||||
|
||||
plan_type = _required_text(raw, "plan_type", index).lower()
|
||||
billing_period = _required_text(raw, "billing_period", index).lower()
|
||||
try:
|
||||
PlanType(plan_type)
|
||||
except ValueError as exc:
|
||||
raise CommerceSeedConfigError(
|
||||
f"plans[{index}].plan_type is invalid: {plan_type}"
|
||||
) from exc
|
||||
try:
|
||||
BillingPeriod(billing_period)
|
||||
except ValueError as exc:
|
||||
raise CommerceSeedConfigError(
|
||||
f"plans[{index}].billing_period is invalid: {billing_period}"
|
||||
) from exc
|
||||
|
||||
modules = raw.get("modules", [])
|
||||
if not isinstance(modules, list):
|
||||
raise CommerceSeedConfigError(f"plans[{index}].modules must be an array")
|
||||
module_codes: list[str] = []
|
||||
seen_modules: set[str] = set()
|
||||
for module_index, module in enumerate(modules):
|
||||
if not isinstance(module, dict):
|
||||
raise CommerceSeedConfigError(
|
||||
f"plans[{index}].modules[{module_index}] must be an object"
|
||||
)
|
||||
module_code = _required_text(
|
||||
module, "module_code", index, prefix=f"modules[{module_index}]."
|
||||
).upper()
|
||||
if module_code in seen_modules:
|
||||
raise CommerceSeedConfigError(
|
||||
f"Duplicate module {module_code} in plan {code}"
|
||||
)
|
||||
seen_modules.add(module_code)
|
||||
module_codes.append(module_code)
|
||||
|
||||
metadata = raw.get("metadata", {})
|
||||
if not isinstance(metadata, dict):
|
||||
raise CommerceSeedConfigError(f"plans[{index}].metadata must be an object")
|
||||
|
||||
plans.append(
|
||||
AccessPlanSeed(
|
||||
code=code,
|
||||
name=_required_text(raw, "name", index),
|
||||
description=_optional_text(raw.get("description")),
|
||||
plan_type=plan_type,
|
||||
billing_period=billing_period,
|
||||
member_fee=_decimal(raw.get("member_fee", "0.00"), index, "member_fee"),
|
||||
module_fee=_decimal(raw.get("module_fee", "0.00"), index, "module_fee"),
|
||||
currency_code=_required_text(raw, "currency_code", index).upper(),
|
||||
country=_required_text(raw, "country", index),
|
||||
trial_days=_nonnegative_int(raw.get("trial_days", 0), index, "trial_days"),
|
||||
is_active=_boolean(raw.get("is_active", True), index, "is_active"),
|
||||
sort_order=_nonnegative_int(raw.get("sort_order", 0), index, "sort_order"),
|
||||
metadata=dict(metadata),
|
||||
module_codes=tuple(module_codes),
|
||||
)
|
||||
)
|
||||
|
||||
return tuple(plans)
|
||||
|
||||
|
||||
def _required_text(raw: dict[str, Any], key: str, index: int, *, prefix: str = "") -> str:
|
||||
value = raw.get(key)
|
||||
if not isinstance(value, str) or not value.strip():
|
||||
raise CommerceSeedConfigError(f"plans[{index}].{prefix}{key} is required")
|
||||
return value.strip()
|
||||
|
||||
|
||||
def _optional_text(value: Any) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
if not isinstance(value, str):
|
||||
raise CommerceSeedConfigError("description must be a string or null")
|
||||
value = value.strip()
|
||||
return value or None
|
||||
|
||||
|
||||
def _decimal(value: Any, index: int, key: str) -> Decimal:
|
||||
try:
|
||||
result = Decimal(str(value))
|
||||
except (InvalidOperation, ValueError) as exc:
|
||||
raise CommerceSeedConfigError(f"plans[{index}].{key} must be numeric") from exc
|
||||
if result < 0:
|
||||
raise CommerceSeedConfigError(f"plans[{index}].{key} must be >= 0")
|
||||
return result
|
||||
|
||||
|
||||
def _nonnegative_int(value: Any, index: int, key: str) -> int:
|
||||
if isinstance(value, bool) or not isinstance(value, int) or value < 0:
|
||||
raise CommerceSeedConfigError(f"plans[{index}].{key} must be an integer >= 0")
|
||||
return value
|
||||
|
||||
|
||||
def _boolean(value: Any, index: int, key: str) -> bool:
|
||||
if not isinstance(value, bool):
|
||||
raise CommerceSeedConfigError(f"plans[{index}].{key} must be boolean")
|
||||
return value
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class AccessPlanSeed:
|
||||
code: str
|
||||
name: str
|
||||
description: str | None
|
||||
plan_type: str
|
||||
billing_period: str
|
||||
member_fee: Decimal = Decimal("0.00")
|
||||
module_fee: Decimal = Decimal("0.00")
|
||||
currency_code: str = "INR"
|
||||
country: str = "India"
|
||||
trial_days: int = 0
|
||||
is_active: bool = True
|
||||
sort_order: int = 0
|
||||
metadata: dict[str, object] = field(default_factory=dict)
|
||||
module_codes: tuple[str, ...] = field(default_factory=tuple)
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class CouponSeed:
|
||||
code: str
|
||||
discount_type: str
|
||||
value: Decimal
|
||||
start_date: datetime
|
||||
end_date: datetime
|
||||
coupon_category: str = "general"
|
||||
max_discount_limit: Decimal = Decimal("0.00")
|
||||
usage_limit: int = 0
|
||||
applicable_plan_ids: tuple[UUID, ...] = field(default_factory=tuple)
|
||||
applicable_module_ids: tuple[UUID, ...] = field(default_factory=tuple)
|
||||
min_purchase_amount: Decimal = Decimal("0.00")
|
||||
is_first_purchase_only: bool = False
|
||||
is_active: bool = True
|
||||
description: str | None = None
|
||||
created_by: UUID | None = None
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"version": 1,
|
||||
"plans": [
|
||||
{
|
||||
"code": "LIFETIME_ALL",
|
||||
"name": "Lifetime All Access",
|
||||
"description": "Lifetime access bundle. Add the required module codes before activating this plan.",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "lifetime",
|
||||
"member_fee": "0.00",
|
||||
"module_fee": "0.00",
|
||||
"currency_code": "INR",
|
||||
"country": "India",
|
||||
"trial_days": 0,
|
||||
"is_active": false,
|
||||
"sort_order": 1000,
|
||||
"metadata": {},
|
||||
"modules": []
|
||||
},
|
||||
{
|
||||
"code": "LIFETIME_ALL_USD",
|
||||
"name": "Lifetime All Access USD",
|
||||
"description": "Lifetime access bundle for international users. Add the required module codes before activating this plan.",
|
||||
"plan_type": "bundle",
|
||||
"billing_period": "lifetime",
|
||||
"member_fee": "0.00",
|
||||
"module_fee": "0.00",
|
||||
"currency_code": "USD",
|
||||
"country": "International",
|
||||
"trial_days": 0,
|
||||
"is_active": false,
|
||||
"sort_order": 1010,
|
||||
"metadata": {},
|
||||
"modules": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import delete, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.enums import BillingPeriod, PlanType
|
||||
from app.db.models import AccessPlan, AccessPlanModule, Coupon, Module
|
||||
|
||||
|
||||
class CommerceSeedRepository:
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
async def upsert_plan(self, seed) -> AccessPlan:
|
||||
plan = (
|
||||
await self.session.execute(
|
||||
select(AccessPlan).where(AccessPlan.code == seed.code)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
values = dict(
|
||||
name=seed.name,
|
||||
description=seed.description,
|
||||
plan_type=PlanType(seed.plan_type),
|
||||
billing_period=BillingPeriod(seed.billing_period),
|
||||
member_fee=seed.member_fee,
|
||||
module_fee=seed.module_fee,
|
||||
currency_code=seed.currency_code,
|
||||
country=seed.country,
|
||||
trial_days=seed.trial_days,
|
||||
is_active=seed.is_active,
|
||||
sort_order=seed.sort_order,
|
||||
metadata_json=dict(seed.metadata),
|
||||
)
|
||||
|
||||
if plan is None:
|
||||
plan = AccessPlan(
|
||||
code=seed.code,
|
||||
**values,
|
||||
)
|
||||
self.session.add(plan)
|
||||
else:
|
||||
for key, value in values.items():
|
||||
setattr(plan, key, value)
|
||||
|
||||
await self.session.flush()
|
||||
return plan
|
||||
|
||||
async def reconcile_plan_modules(
|
||||
self,
|
||||
*,
|
||||
plan: AccessPlan,
|
||||
module_codes: tuple[str, ...],
|
||||
) -> int:
|
||||
modules = {}
|
||||
for code in module_codes:
|
||||
module = (
|
||||
await self.session.execute(
|
||||
select(Module).where(Module.code == code)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if module is None:
|
||||
raise ValueError(
|
||||
f"Unknown content module code for plan {plan.code}: {code}"
|
||||
)
|
||||
modules[code] = module
|
||||
|
||||
existing = (
|
||||
await self.session.execute(
|
||||
select(AccessPlanModule).where(AccessPlanModule.plan_id == plan.id)
|
||||
)
|
||||
).scalars().all()
|
||||
existing_by_module_id = {row.module_id: row for row in existing}
|
||||
desired_module_ids = {module.id for module in modules.values()}
|
||||
|
||||
stale_ids = set(existing_by_module_id) - desired_module_ids
|
||||
if stale_ids:
|
||||
await self.session.execute(
|
||||
delete(AccessPlanModule).where(
|
||||
AccessPlanModule.plan_id == plan.id,
|
||||
AccessPlanModule.module_id.in_(stale_ids),
|
||||
)
|
||||
)
|
||||
|
||||
for module in modules.values():
|
||||
if module.id not in existing_by_module_id:
|
||||
self.session.add(
|
||||
AccessPlanModule(plan_id=plan.id, module_id=module.id)
|
||||
)
|
||||
|
||||
await self.session.flush()
|
||||
return len(desired_module_ids)
|
||||
|
||||
async def upsert_coupon(self, seed) -> Coupon:
|
||||
coupon = (
|
||||
await self.session.execute(
|
||||
select(Coupon).where(Coupon.code == seed.code)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
values = dict(
|
||||
discount_type=seed.discount_type,
|
||||
coupon_category=seed.coupon_category,
|
||||
value=seed.value,
|
||||
max_discount_limit=seed.max_discount_limit,
|
||||
start_date=seed.start_date,
|
||||
end_date=seed.end_date,
|
||||
usage_limit=seed.usage_limit,
|
||||
applicable_plan_ids=(
|
||||
list(seed.applicable_plan_ids)
|
||||
if seed.applicable_plan_ids
|
||||
else None
|
||||
),
|
||||
applicable_module_ids=(
|
||||
list(seed.applicable_module_ids)
|
||||
if seed.applicable_module_ids
|
||||
else None
|
||||
),
|
||||
min_purchase_amount=seed.min_purchase_amount,
|
||||
is_first_purchase_only=seed.is_first_purchase_only,
|
||||
is_active=seed.is_active,
|
||||
description=seed.description,
|
||||
created_by=seed.created_by,
|
||||
)
|
||||
|
||||
if coupon is None:
|
||||
coupon = Coupon(
|
||||
code=seed.code,
|
||||
**values,
|
||||
)
|
||||
self.session.add(coupon)
|
||||
else:
|
||||
for key, value in values.items():
|
||||
setattr(coupon, key, value)
|
||||
|
||||
await self.session.flush()
|
||||
return coupon
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .loader import DEFAULT_PLANS_PATH, load_access_plans
|
||||
from .models import AccessPlanSeed, CouponSeed
|
||||
from .repository import CommerceSeedRepository
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class CommerceBootstrapResult:
|
||||
plans: int
|
||||
plan_module_mappings: int
|
||||
coupons: int
|
||||
|
||||
|
||||
class CommerceBootstrapSeeder:
|
||||
"""Idempotent, configuration-driven commerce bootstrap."""
|
||||
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
self.repo = CommerceSeedRepository(session)
|
||||
|
||||
async def seed(
|
||||
self,
|
||||
*,
|
||||
plans_path: Path = DEFAULT_PLANS_PATH,
|
||||
plans: Iterable[AccessPlanSeed] | None = None,
|
||||
coupons: Iterable[CouponSeed] = (),
|
||||
) -> CommerceBootstrapResult:
|
||||
resolved_plans = tuple(plans) if plans is not None else load_access_plans(plans_path)
|
||||
|
||||
plan_count = 0
|
||||
mapping_count = 0
|
||||
for seed in resolved_plans:
|
||||
plan = await self.repo.upsert_plan(seed)
|
||||
mapping_count += await self.repo.reconcile_plan_modules(
|
||||
plan=plan,
|
||||
module_codes=seed.module_codes,
|
||||
)
|
||||
plan_count += 1
|
||||
|
||||
coupon_count = 0
|
||||
for seed in coupons:
|
||||
await self.repo.upsert_coupon(seed)
|
||||
coupon_count += 1
|
||||
|
||||
return CommerceBootstrapResult(
|
||||
plans=plan_count,
|
||||
plan_module_mappings=mapping_count,
|
||||
coupons=coupon_count,
|
||||
)
|
||||
|
|
@ -2,3 +2,5 @@ from .modules import ModuleSeeder
|
|||
from .orchestrator import SeedOrchestrator
|
||||
|
||||
__all__ = ["ModuleSeeder", "SeedOrchestrator"]
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
|
@ -7,6 +7,8 @@ from uuid import UUID, uuid4
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .models import (
|
||||
AttributeDefinition,
|
||||
BatchSeedSummary,
|
||||
|
|
@ -32,11 +34,11 @@ class ContentSeeder:
|
|||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
schema: str = "acu_content",
|
||||
schema: str = CONTENT_SCHEMA,
|
||||
max_depth: int = 32,
|
||||
) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._schema = resolve_content_schema(schema)
|
||||
self._max_depth = max_depth
|
||||
|
||||
async def seed_document(
|
||||
|
|
@ -7,6 +7,8 @@ from uuid import UUID
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .models import DefinitionSet
|
||||
from .validators import (
|
||||
DefinitionConflictError,
|
||||
|
|
@ -29,9 +31,9 @@ class AttributeDefinitionSeeder:
|
|||
M0002_CT0001.regional_anatomy.structures
|
||||
"""
|
||||
|
||||
def __init__(self, session: AsyncSession, *, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, *, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._schema = resolve_content_schema(schema)
|
||||
|
||||
async def seed(self, document: Mapping[str, Any]) -> DefinitionSet:
|
||||
validate_definition_document(document)
|
||||
|
|
@ -6,6 +6,8 @@ from uuid import UUID, uuid4
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .models import ModuleConfigEntry, ModuleManifest, ModuleSeedResult
|
||||
from .validators import ModuleValidationError, slugify
|
||||
|
||||
|
|
@ -13,9 +15,9 @@ from .validators import ModuleValidationError, slugify
|
|||
class ModuleSeeder:
|
||||
"""Idempotent seeding for modules and module_contents."""
|
||||
|
||||
def __init__(self, session: AsyncSession, *, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, *, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._schema = resolve_content_schema(schema)
|
||||
|
||||
async def upsert_module(self, *, config: ModuleConfigEntry, manifest: ModuleManifest) -> ModuleSeedResult:
|
||||
if config.code != manifest.code:
|
||||
|
|
@ -7,6 +7,8 @@ from uuid import UUID
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .contents import ContentSeeder
|
||||
from .definitions import AttributeDefinitionSeeder
|
||||
from .models import ModuleProcessSummary
|
||||
|
|
@ -34,14 +36,14 @@ class SeedOrchestrator:
|
|||
template transaction provides the durable commit boundary.
|
||||
"""
|
||||
|
||||
def __init__(self, session: AsyncSession, *, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, *, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._definitions = AttributeDefinitionSeeder(session, schema=schema)
|
||||
self._contents = ContentSeeder(session, schema=schema)
|
||||
self._modules = ModuleSeeder(session, schema=schema)
|
||||
self._presentations = TemplatePresentationSeeder(session, schema=schema)
|
||||
self._search_facets = SearchFacetSeeder(session, schema=schema)
|
||||
self._schema = resolve_content_schema(schema)
|
||||
self._definitions = AttributeDefinitionSeeder(session, schema=self._schema)
|
||||
self._contents = ContentSeeder(session, schema=self._schema)
|
||||
self._modules = ModuleSeeder(session, schema=self._schema)
|
||||
self._presentations = TemplatePresentationSeeder(session, schema=self._schema)
|
||||
self._search_facets = SearchFacetSeeder(session, schema=self._schema)
|
||||
|
||||
async def process_config(
|
||||
self,
|
||||
|
|
@ -6,6 +6,8 @@ from typing import Any, Mapping
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .models import DefinitionSet, PresentationContractSeedResult
|
||||
from .validators import validate_presentation_contracts
|
||||
|
||||
|
|
@ -22,9 +24,9 @@ class TemplatePresentationSeeder:
|
|||
database partial unique index is never violated.
|
||||
"""
|
||||
|
||||
def __init__(self, session: AsyncSession, *, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, *, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._schema = resolve_content_schema(schema)
|
||||
|
||||
async def seed(
|
||||
self,
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from app.db.schemas import CONTENT_SCHEMA
|
||||
|
||||
|
||||
_SCHEMA_IDENTIFIER_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
|
||||
|
||||
|
||||
def resolve_content_schema(schema: str = CONTENT_SCHEMA) -> str:
|
||||
"""
|
||||
Validate and return the schema used by content/media seeders.
|
||||
|
||||
Production/default ownership is ``content``. The explicit override is
|
||||
retained for isolated tests or temporary development schemas, preserving
|
||||
the existing seeder constructor capability without accepting arbitrary SQL.
|
||||
"""
|
||||
candidate = schema.strip()
|
||||
if not _SCHEMA_IDENTIFIER_RE.fullmatch(candidate):
|
||||
raise ValueError(f"Invalid PostgreSQL schema identifier: {schema!r}")
|
||||
return candidate
|
||||
|
||||
|
||||
__all__ = [
|
||||
"CONTENT_SCHEMA",
|
||||
"resolve_content_schema",
|
||||
]
|
||||
|
|
@ -7,6 +7,8 @@ from typing import Any
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from .schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from app.features.search.repository import SearchRepository
|
||||
|
||||
|
||||
|
|
@ -23,10 +25,10 @@ def _required_string(value: Any, field: str) -> str:
|
|||
class SearchFacetSeeder:
|
||||
"""Idempotently seed canonical search facets and attribute mappings."""
|
||||
|
||||
def __init__(self, session: AsyncSession, *, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, *, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self.session = session
|
||||
self.schema = schema
|
||||
self.repository = SearchRepository(session, schema=schema)
|
||||
self.schema = resolve_content_schema(schema)
|
||||
self.repository = SearchRepository(session, schema=self.schema)
|
||||
|
||||
async def seed_file(self, path: Path, *, module_code: str) -> tuple[int, int]:
|
||||
if not path.exists():
|
||||
|
|
@ -9,6 +9,8 @@ from uuid import UUID
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from ..seed_content.schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ContentTarget:
|
||||
|
|
@ -27,7 +29,7 @@ class MediaAssetRow:
|
|||
|
||||
class ImageSeedRepository:
|
||||
"""
|
||||
Repository aligned with the current AccuPedia acu_content schema.
|
||||
Repository aligned with the AccuPedia four-schema architecture; all media and content tables are owned by the content schema.
|
||||
|
||||
Current schema notes:
|
||||
- media_assets has no physical `sha256` column.
|
||||
|
|
@ -40,8 +42,14 @@ class ImageSeedRepository:
|
|||
(content_id, media_asset_id, usage_type)
|
||||
"""
|
||||
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
schema: str = CONTENT_SCHEMA,
|
||||
) -> None:
|
||||
self.session = session
|
||||
self._schema = resolve_content_schema(schema)
|
||||
|
||||
async def resolve_content_target(
|
||||
self,
|
||||
|
|
@ -50,18 +58,18 @@ class ImageSeedRepository:
|
|||
template_code: str,
|
||||
source_key: str,
|
||||
) -> ContentTarget | None:
|
||||
stmt = text("""
|
||||
stmt = text(f"""
|
||||
SELECT
|
||||
ci.id AS content_id,
|
||||
ci.source_key,
|
||||
m.code AS module_code,
|
||||
ads.code AS template_code
|
||||
FROM acu_content.content_items ci
|
||||
JOIN acu_content.module_contents mc
|
||||
FROM {self._schema}.content_items ci
|
||||
JOIN {self._schema}.module_contents mc
|
||||
ON mc.content_id = ci.id
|
||||
JOIN acu_content.modules m
|
||||
JOIN {self._schema}.modules m
|
||||
ON m.id = mc.module_id
|
||||
JOIN acu_content.attribute_definition_sets ads
|
||||
JOIN {self._schema}.attribute_definition_sets ads
|
||||
ON ads.id = ci.attribute_definition_set_id
|
||||
WHERE m.code = :module_code
|
||||
AND ads.code = :template_code
|
||||
|
|
@ -108,12 +116,12 @@ class ImageSeedRepository:
|
|||
SHA-256 is stored inside media_assets.metadata JSONB because the
|
||||
current production schema does not have a dedicated sha256 column.
|
||||
"""
|
||||
stmt = text("""
|
||||
stmt = text(f"""
|
||||
SELECT
|
||||
id,
|
||||
storage_key,
|
||||
metadata ->> 'sha256' AS sha256
|
||||
FROM acu_content.media_assets
|
||||
FROM {self._schema}.media_assets
|
||||
WHERE storage_key = :storage_key
|
||||
ORDER BY created_at, id
|
||||
LIMIT 2
|
||||
|
|
@ -173,12 +181,12 @@ class ImageSeedRepository:
|
|||
}
|
||||
)
|
||||
|
||||
lookup_stmt = text("""
|
||||
lookup_stmt = text(f"""
|
||||
SELECT
|
||||
id,
|
||||
storage_key,
|
||||
metadata ->> 'sha256' AS sha256
|
||||
FROM acu_content.media_assets
|
||||
FROM {self._schema}.media_assets
|
||||
WHERE storage_key = :storage_key
|
||||
ORDER BY created_at, id
|
||||
FOR UPDATE
|
||||
|
|
@ -203,10 +211,10 @@ class ImageSeedRepository:
|
|||
if existing_rows:
|
||||
media_asset_id = existing_rows[0]["id"]
|
||||
|
||||
update_stmt = text("""
|
||||
UPDATE acu_content.media_assets
|
||||
update_stmt = text(f"""
|
||||
UPDATE {self._schema}.media_assets
|
||||
SET
|
||||
media_kind = CAST('image' AS acu_content.media_kind_enum),
|
||||
media_kind = CAST('image' AS {self._schema}.media_kind_enum),
|
||||
file_name = :file_name,
|
||||
file_path = :storage_key,
|
||||
original_filename = :original_filename,
|
||||
|
|
@ -248,8 +256,8 @@ class ImageSeedRepository:
|
|||
).mappings().one()
|
||||
|
||||
else:
|
||||
insert_stmt = text("""
|
||||
INSERT INTO acu_content.media_assets (
|
||||
insert_stmt = text(f"""
|
||||
INSERT INTO {self._schema}.media_assets (
|
||||
media_kind,
|
||||
file_name,
|
||||
file_path,
|
||||
|
|
@ -269,7 +277,7 @@ class ImageSeedRepository:
|
|||
updated_at
|
||||
)
|
||||
VALUES (
|
||||
CAST('image' AS acu_content.media_kind_enum),
|
||||
CAST('image' AS {self._schema}.media_kind_enum),
|
||||
:file_name,
|
||||
:storage_key,
|
||||
:original_filename,
|
||||
|
|
@ -322,9 +330,9 @@ class ImageSeedRepository:
|
|||
content_id: UUID,
|
||||
media_asset_id: UUID,
|
||||
) -> None:
|
||||
stmt = text("""
|
||||
stmt = text(f"""
|
||||
SELECT media_asset_id
|
||||
FROM acu_content.content_media
|
||||
FROM {self._schema}.content_media
|
||||
WHERE content_id = :content_id
|
||||
AND media_role = 'primary'
|
||||
AND media_asset_id IS NOT NULL
|
||||
|
|
@ -369,8 +377,8 @@ class ImageSeedRepository:
|
|||
del alt_text
|
||||
del metadata
|
||||
|
||||
stmt = text("""
|
||||
INSERT INTO acu_content.content_media (
|
||||
stmt = text(f"""
|
||||
INSERT INTO {self._schema}.content_media (
|
||||
content_id,
|
||||
media_asset_id,
|
||||
media_role,
|
||||
|
|
@ -7,6 +7,8 @@ from typing import Any
|
|||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from ..seed_content.schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .identity import (
|
||||
build_source_key,
|
||||
build_storage_key,
|
||||
|
|
@ -14,7 +16,7 @@ from .identity import (
|
|||
)
|
||||
from .models import MediaEntry, MediaManifest
|
||||
from .repository import ImageSeedRepository
|
||||
from ..integrations.storage import ObjectStorage
|
||||
from app.integrations.storage import ObjectStorage
|
||||
from .validators import validate_image_file
|
||||
|
||||
|
||||
|
|
@ -47,9 +49,11 @@ class ImageSeedService:
|
|||
session: AsyncSession,
|
||||
storage: ObjectStorage,
|
||||
bucket: str,
|
||||
schema: str = CONTENT_SCHEMA,
|
||||
) -> None:
|
||||
self.session = session
|
||||
self.repository = ImageSeedRepository(session)
|
||||
self.schema = resolve_content_schema(schema)
|
||||
self.repository = ImageSeedRepository(session, schema=self.schema)
|
||||
self.storage = storage
|
||||
self.bucket = bucket
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
||||
REQUIRED_TABLES = (
|
||||
"auth.app_users",
|
||||
"auth.roles",
|
||||
"auth.permissions",
|
||||
"auth.role_permissions",
|
||||
"content.modules",
|
||||
"content.content_items",
|
||||
"content.media_assets",
|
||||
"commerce.access_plans",
|
||||
"commerce.access_plan_modules",
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class ValidationResult:
|
||||
ok: bool
|
||||
missing_tables: tuple[str, ...]
|
||||
details: dict[str, object]
|
||||
|
||||
|
||||
class BootstrapValidator:
|
||||
async def validate(self, session: AsyncSession) -> ValidationResult:
|
||||
missing: list[str] = []
|
||||
|
||||
for qualified in REQUIRED_TABLES:
|
||||
schema, table = qualified.split(".", 1)
|
||||
exists = await session.scalar(
|
||||
text(
|
||||
"""
|
||||
select exists (
|
||||
select 1
|
||||
from information_schema.tables
|
||||
where table_schema = :schema
|
||||
and table_name = :table
|
||||
)
|
||||
"""
|
||||
),
|
||||
{"schema": schema, "table": table},
|
||||
)
|
||||
if not exists:
|
||||
missing.append(qualified)
|
||||
|
||||
details: dict[str, object] = {
|
||||
"required_tables": len(REQUIRED_TABLES),
|
||||
"missing_table_count": len(missing),
|
||||
}
|
||||
|
||||
if not missing:
|
||||
details["role_count"] = int(
|
||||
await session.scalar(text("select count(*) from auth.roles")) or 0
|
||||
)
|
||||
details["permission_count"] = int(
|
||||
await session.scalar(text("select count(*) from auth.permissions")) or 0
|
||||
)
|
||||
details["module_count"] = int(
|
||||
await session.scalar(text("select count(*) from content.modules")) or 0
|
||||
)
|
||||
details["content_count"] = int(
|
||||
await session.scalar(text("select count(*) from content.content_items")) or 0
|
||||
)
|
||||
details["media_asset_count"] = int(
|
||||
await session.scalar(text("select count(*) from content.media_assets")) or 0
|
||||
)
|
||||
details["access_plan_count"] = int(
|
||||
await session.scalar(text("select count(*) from commerce.access_plans")) or 0
|
||||
)
|
||||
|
||||
return ValidationResult(
|
||||
ok=not missing,
|
||||
missing_tables=tuple(missing),
|
||||
details=details,
|
||||
)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# Test access CLI
|
||||
|
||||
Grant a plan and all modules mapped through `commerce.access_plan_modules`:
|
||||
|
||||
```bash
|
||||
python -m app.cli.access grant-plan \
|
||||
--email user@example.com \
|
||||
--plan-code POINTS_ACU
|
||||
```
|
||||
|
||||
Optional finite test access:
|
||||
|
||||
```bash
|
||||
python -m app.cli.access grant-plan \
|
||||
--email user@example.com \
|
||||
--plan-code POINTS_ACU \
|
||||
--expires-in-days 30
|
||||
```
|
||||
|
||||
Revoke access sourced from the plan:
|
||||
|
||||
```bash
|
||||
python -m app.cli.access revoke-plan \
|
||||
--email user@example.com \
|
||||
--plan-code POINTS_ACU
|
||||
```
|
||||
|
||||
`--user-id <uuid>` can be used instead of `--email`.
|
||||
|
||||
The grant operation is idempotent for an already-active subscription and active module entitlements. It never invents plan/module mappings; the selected plan must already have rows in `commerce.access_plan_modules`.
|
||||
|
|
@ -0,0 +1,397 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import os
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import or_, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
|
||||
from app.db.enums import EntitlementStatus, SubscriptionStatus
|
||||
from app.db.models import (
|
||||
AccessPlan,
|
||||
AccessPlanModule,
|
||||
AppUser,
|
||||
Module,
|
||||
UserEntitlement,
|
||||
UserSubscription,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class GrantSummary:
|
||||
user_id: UUID
|
||||
email: str
|
||||
plan_code: str
|
||||
subscription_id: UUID
|
||||
modules_mapped: int
|
||||
entitlements_created: int
|
||||
entitlements_reused: int
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RevokeSummary:
|
||||
user_id: UUID
|
||||
email: str
|
||||
plan_code: str
|
||||
subscriptions_cancelled: int
|
||||
entitlements_revoked: int
|
||||
|
||||
|
||||
def utcnow() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Grant or revoke AccuPedia plan/module access for test users."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--database-url",
|
||||
default=os.environ.get("DATABASE_URL"),
|
||||
help="SQLAlchemy async database URL. Defaults to DATABASE_URL.",
|
||||
)
|
||||
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
grant = subparsers.add_parser(
|
||||
"grant-plan",
|
||||
help="Associate an access plan and all of its mapped modules to a user.",
|
||||
)
|
||||
_add_user_selector(grant)
|
||||
grant.add_argument("--plan-code", required=True)
|
||||
grant.add_argument(
|
||||
"--expires-in-days",
|
||||
type=int,
|
||||
default=None,
|
||||
help="Optional test expiry. Omit for no expiry.",
|
||||
)
|
||||
grant.add_argument(
|
||||
"--reason",
|
||||
default="CLI test access grant",
|
||||
help="Reason stored on created entitlements.",
|
||||
)
|
||||
|
||||
revoke = subparsers.add_parser(
|
||||
"revoke-plan",
|
||||
help="Cancel active subscriptions and revoke active entitlements sourced from a plan.",
|
||||
)
|
||||
_add_user_selector(revoke)
|
||||
revoke.add_argument("--plan-code", required=True)
|
||||
revoke.add_argument(
|
||||
"--reason",
|
||||
default="CLI test access revoke",
|
||||
help="Reason stored on revoked entitlements/subscriptions.",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def _add_user_selector(parser: argparse.ArgumentParser) -> None:
|
||||
selector = parser.add_mutually_exclusive_group(required=True)
|
||||
selector.add_argument("--email")
|
||||
selector.add_argument("--user-id", type=UUID)
|
||||
|
||||
|
||||
async def _resolve_user(
|
||||
session: AsyncSession,
|
||||
*,
|
||||
email: str | None,
|
||||
user_id: UUID | None,
|
||||
) -> AppUser:
|
||||
if user_id is not None:
|
||||
stmt = select(AppUser).where(AppUser.id == user_id)
|
||||
else:
|
||||
assert email is not None
|
||||
normalized = email.strip().lower()
|
||||
stmt = select(AppUser).where(AppUser.email == normalized)
|
||||
|
||||
user = (await session.execute(stmt)).scalar_one_or_none()
|
||||
if user is None:
|
||||
selector = str(user_id) if user_id is not None else email
|
||||
raise ValueError(f"User not found: {selector}")
|
||||
if not user.is_active:
|
||||
raise ValueError(f"User is inactive: {user.email}")
|
||||
return user
|
||||
|
||||
|
||||
async def _resolve_plan(session: AsyncSession, plan_code: str) -> AccessPlan:
|
||||
normalized = plan_code.strip().upper()
|
||||
plan = (
|
||||
await session.execute(
|
||||
select(AccessPlan).where(AccessPlan.code == normalized)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if plan is None:
|
||||
raise ValueError(f"Access plan not found: {normalized}")
|
||||
if not plan.is_active:
|
||||
raise ValueError(f"Access plan is inactive: {normalized}")
|
||||
return plan
|
||||
|
||||
|
||||
async def _mapped_modules(
|
||||
session: AsyncSession,
|
||||
plan_id: UUID,
|
||||
) -> list[Module]:
|
||||
result = await session.execute(
|
||||
select(Module)
|
||||
.join(AccessPlanModule, AccessPlanModule.module_id == Module.id)
|
||||
.where(
|
||||
AccessPlanModule.plan_id == plan_id,
|
||||
Module.is_active.is_(True),
|
||||
)
|
||||
.order_by(Module.code.asc(), Module.id.asc())
|
||||
)
|
||||
modules = list(result.scalars().all())
|
||||
if not modules:
|
||||
raise ValueError(
|
||||
"The plan has no active module mappings in commerce.access_plan_modules."
|
||||
)
|
||||
return modules
|
||||
|
||||
|
||||
async def grant_plan(
|
||||
session: AsyncSession,
|
||||
*,
|
||||
email: str | None,
|
||||
user_id: UUID | None,
|
||||
plan_code: str,
|
||||
expires_in_days: int | None,
|
||||
reason: str,
|
||||
) -> GrantSummary:
|
||||
if expires_in_days is not None and expires_in_days <= 0:
|
||||
raise ValueError("--expires-in-days must be greater than zero")
|
||||
|
||||
user = await _resolve_user(session, email=email, user_id=user_id)
|
||||
plan = await _resolve_plan(session, plan_code)
|
||||
modules = await _mapped_modules(session, plan.id)
|
||||
|
||||
now = utcnow()
|
||||
requested_expiry = (
|
||||
now + timedelta(days=expires_in_days)
|
||||
if expires_in_days is not None
|
||||
else None
|
||||
)
|
||||
|
||||
subscription = (
|
||||
await session.execute(
|
||||
select(UserSubscription)
|
||||
.where(
|
||||
UserSubscription.user_id == user.id,
|
||||
UserSubscription.plan_id == plan.id,
|
||||
UserSubscription.status == SubscriptionStatus.ACTIVE,
|
||||
or_(
|
||||
UserSubscription.expires_at.is_(None),
|
||||
UserSubscription.expires_at > now,
|
||||
),
|
||||
)
|
||||
.order_by(
|
||||
UserSubscription.started_at.desc(),
|
||||
UserSubscription.id.desc(),
|
||||
)
|
||||
.limit(1)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if subscription is None:
|
||||
subscription = UserSubscription(
|
||||
user_id=user.id,
|
||||
plan_id=plan.id,
|
||||
status=SubscriptionStatus.ACTIVE,
|
||||
started_at=now,
|
||||
expires_at=requested_expiry,
|
||||
auto_renew=False,
|
||||
payment_provider="cli-test",
|
||||
payment_reference=None,
|
||||
metadata_json={"source": "cli-test"},
|
||||
)
|
||||
session.add(subscription)
|
||||
await session.flush()
|
||||
elif requested_expiry is not None:
|
||||
subscription.expires_at = requested_expiry
|
||||
subscription.updated_at = now
|
||||
|
||||
created = 0
|
||||
reused = 0
|
||||
for module in modules:
|
||||
existing = (
|
||||
await session.execute(
|
||||
select(UserEntitlement)
|
||||
.where(
|
||||
UserEntitlement.user_id == user.id,
|
||||
UserEntitlement.module_id == module.id,
|
||||
UserEntitlement.status == EntitlementStatus.ACTIVE,
|
||||
or_(
|
||||
UserEntitlement.expires_at.is_(None),
|
||||
UserEntitlement.expires_at > now,
|
||||
),
|
||||
)
|
||||
.order_by(
|
||||
UserEntitlement.granted_at.desc(),
|
||||
UserEntitlement.id.desc(),
|
||||
)
|
||||
.limit(1)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
if existing is not None:
|
||||
reused += 1
|
||||
continue
|
||||
|
||||
session.add(
|
||||
UserEntitlement(
|
||||
user_id=user.id,
|
||||
module_id=module.id,
|
||||
source_subscription_id=subscription.id,
|
||||
source_plan_id=plan.id,
|
||||
status=EntitlementStatus.ACTIVE,
|
||||
granted_at=now,
|
||||
grant_reason=reason.strip() or "CLI test access grant",
|
||||
expires_at=requested_expiry,
|
||||
metadata_json={"source": "cli-test"},
|
||||
)
|
||||
)
|
||||
created += 1
|
||||
|
||||
await session.commit()
|
||||
|
||||
return GrantSummary(
|
||||
user_id=user.id,
|
||||
email=user.email,
|
||||
plan_code=plan.code,
|
||||
subscription_id=subscription.id,
|
||||
modules_mapped=len(modules),
|
||||
entitlements_created=created,
|
||||
entitlements_reused=reused,
|
||||
)
|
||||
|
||||
|
||||
async def revoke_plan(
|
||||
session: AsyncSession,
|
||||
*,
|
||||
email: str | None,
|
||||
user_id: UUID | None,
|
||||
plan_code: str,
|
||||
reason: str,
|
||||
) -> RevokeSummary:
|
||||
user = await _resolve_user(session, email=email, user_id=user_id)
|
||||
plan = await _resolve_plan(session, plan_code)
|
||||
now = utcnow()
|
||||
revoke_reason = reason.strip() or "CLI test access revoke"
|
||||
|
||||
subscriptions = list(
|
||||
(
|
||||
await session.execute(
|
||||
select(UserSubscription).where(
|
||||
UserSubscription.user_id == user.id,
|
||||
UserSubscription.plan_id == plan.id,
|
||||
UserSubscription.status == SubscriptionStatus.ACTIVE,
|
||||
)
|
||||
)
|
||||
).scalars().all()
|
||||
)
|
||||
for subscription in subscriptions:
|
||||
subscription.status = SubscriptionStatus.CANCELLED
|
||||
subscription.cancelled_at = now
|
||||
subscription.cancellation_reason = revoke_reason
|
||||
subscription.auto_renew = False
|
||||
subscription.updated_at = now
|
||||
|
||||
entitlements = list(
|
||||
(
|
||||
await session.execute(
|
||||
select(UserEntitlement).where(
|
||||
UserEntitlement.user_id == user.id,
|
||||
UserEntitlement.source_plan_id == plan.id,
|
||||
UserEntitlement.status == EntitlementStatus.ACTIVE,
|
||||
)
|
||||
)
|
||||
).scalars().all()
|
||||
)
|
||||
for entitlement in entitlements:
|
||||
entitlement.status = EntitlementStatus.REVOKED
|
||||
entitlement.revoked_at = now
|
||||
entitlement.revoke_reason = revoke_reason
|
||||
entitlement.updated_at = now
|
||||
|
||||
await session.commit()
|
||||
|
||||
return RevokeSummary(
|
||||
user_id=user.id,
|
||||
email=user.email,
|
||||
plan_code=plan.code,
|
||||
subscriptions_cancelled=len(subscriptions),
|
||||
entitlements_revoked=len(entitlements),
|
||||
)
|
||||
|
||||
|
||||
async def run(args: argparse.Namespace) -> int:
|
||||
if not args.database_url:
|
||||
raise ValueError("DATABASE_URL is required")
|
||||
|
||||
engine = create_async_engine(
|
||||
args.database_url,
|
||||
pool_pre_ping=True,
|
||||
future=True,
|
||||
)
|
||||
session_factory = async_sessionmaker(
|
||||
engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False,
|
||||
autoflush=False,
|
||||
)
|
||||
|
||||
try:
|
||||
async with session_factory() as session:
|
||||
if args.command == "grant-plan":
|
||||
summary = await grant_plan(
|
||||
session,
|
||||
email=args.email,
|
||||
user_id=args.user_id,
|
||||
plan_code=args.plan_code,
|
||||
expires_in_days=args.expires_in_days,
|
||||
reason=args.reason,
|
||||
)
|
||||
print(
|
||||
"GRANTED "
|
||||
f"user={summary.email} user_id={summary.user_id} "
|
||||
f"plan={summary.plan_code} subscription_id={summary.subscription_id} "
|
||||
f"modules={summary.modules_mapped} "
|
||||
f"entitlements_created={summary.entitlements_created} "
|
||||
f"entitlements_reused={summary.entitlements_reused}"
|
||||
)
|
||||
return 0
|
||||
|
||||
summary = await revoke_plan(
|
||||
session,
|
||||
email=args.email,
|
||||
user_id=args.user_id,
|
||||
plan_code=args.plan_code,
|
||||
reason=args.reason,
|
||||
)
|
||||
print(
|
||||
"REVOKED "
|
||||
f"user={summary.email} user_id={summary.user_id} "
|
||||
f"plan={summary.plan_code} "
|
||||
f"subscriptions_cancelled={summary.subscriptions_cancelled} "
|
||||
f"entitlements_revoked={summary.entitlements_revoked}"
|
||||
)
|
||||
return 0
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = build_parser().parse_args()
|
||||
try:
|
||||
raise SystemExit(asyncio.run(run(args)))
|
||||
except Exception as exc:
|
||||
print(f"ERROR: {exc}")
|
||||
raise SystemExit(1) from exc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import func, or_, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.enums import EntitlementStatus, SubscriptionStatus
|
||||
|
|
@ -49,6 +49,10 @@ class AccessRepository:
|
|||
.where(
|
||||
UserSubscription.user_id == user_id,
|
||||
UserSubscription.status == SubscriptionStatus.ACTIVE,
|
||||
or_(
|
||||
UserSubscription.expires_at.is_(None),
|
||||
UserSubscription.expires_at > func.now(),
|
||||
),
|
||||
)
|
||||
.order_by(
|
||||
UserSubscription.started_at.asc(),
|
||||
|
|
@ -94,6 +98,10 @@ class AccessRepository:
|
|||
.where(
|
||||
UserEntitlement.user_id == user_id,
|
||||
UserEntitlement.status == EntitlementStatus.ACTIVE,
|
||||
or_(
|
||||
UserEntitlement.expires_at.is_(None),
|
||||
UserEntitlement.expires_at > func.now(),
|
||||
),
|
||||
)
|
||||
.order_by(
|
||||
Module.name.asc(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
from .api import router
|
||||
__all__ = ["router"]
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
from __future__ import annotations
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from app.db.models import AppUser
|
||||
from app.features.payments import get_razorpay_service
|
||||
from .deps import get_admin_service, get_current_admin
|
||||
from .schema import AdminCreateSuperAdminRequest, AdminPromoteUserRequest, AdminRefundRequest, AdminRefundResponse, AdminSyncResponse, AdminUserListResponse
|
||||
from .service import AdminService
|
||||
|
||||
router = APIRouter(prefix="/admin", tags=["Administrative Portal"])
|
||||
|
||||
@router.post("/refund", response_model=AdminRefundResponse)
|
||||
async def process_admin_refund(payload: AdminRefundRequest, admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try: return await service.process_refund(payload, admin)
|
||||
except LookupError as exc: raise HTTPException(404, detail=str(exc)) from exc
|
||||
except ValueError as exc: raise HTTPException(400, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(503, detail=str(exc)) from exc
|
||||
except Exception as exc: raise HTTPException(502, detail=f"Razorpay refunds gateway execution failed: {exc}") from exc
|
||||
|
||||
@router.post("/force-sync", response_model=AdminSyncResponse)
|
||||
async def admin_force_sync_gateway(admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try: return await service.force_sync()
|
||||
except RuntimeError as exc: raise HTTPException(503, detail=str(exc)) from exc
|
||||
|
||||
@router.get("/razorpay/customers")
|
||||
async def list_razorpay_customers(admin: AppUser = Depends(get_current_admin)):
|
||||
try:
|
||||
items = get_razorpay_service().client.customer.all({"count":100}).get("items", [])
|
||||
return {"status":"success","count":len(items),"customers":[{"id":c.get("id"),"name":c.get("name"),"email":c.get("email"),"contact":c.get("contact"),"created_at":c.get("created_at")} for c in items]}
|
||||
except Exception as exc:
|
||||
return {"status":"error","count":0,"customers":[],"error":str(exc)}
|
||||
|
||||
@router.get("/razorpay/plans")
|
||||
async def list_razorpay_plans(admin: AppUser = Depends(get_current_admin)):
|
||||
try:
|
||||
items = get_razorpay_service().client.plan.all({"count":100}).get("items", [])
|
||||
return {"status":"success","count":len(items),"plans":[{"id":x.get("id"),"period":x.get("period"),"interval":x.get("interval"),"item_name":(x.get("item") or {}).get("name"),"item_amount":(x.get("item") or {}).get("amount"),"item_currency":(x.get("item") or {}).get("currency"),"created_at":x.get("created_at")} for x in items]}
|
||||
except Exception as exc:
|
||||
return {"status":"error","count":0,"plans":[],"error":str(exc)}
|
||||
|
||||
@router.get("/razorpay/subscriptions")
|
||||
async def list_razorpay_subscriptions(admin: AppUser = Depends(get_current_admin)):
|
||||
try:
|
||||
items = get_razorpay_service().client.subscription.all({"count":100}).get("items", [])
|
||||
return {"status":"success","count":len(items),"subscriptions":[{"id":x.get("id"),"plan_id":x.get("plan_id"),"customer_id":x.get("customer_id"),"status":x.get("status"),"total_count":x.get("total_count"),"paid_count":x.get("paid_count"),"current_start":x.get("current_start"),"current_end":x.get("current_end"),"created_at":x.get("created_at")} for x in items]}
|
||||
except Exception as exc:
|
||||
return {"status":"error","count":0,"subscriptions":[],"error":str(exc)}
|
||||
|
||||
@router.get("/razorpay/payments")
|
||||
async def list_razorpay_payments(admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try:
|
||||
from sqlalchemy import select
|
||||
from app.db.models import Invoice, PaymentTransaction
|
||||
items = get_razorpay_service().client.payment.all({"count":100}).get("items", [])
|
||||
ids = [x.get("id") for x in items if x.get("id")]
|
||||
invoice_map = {}
|
||||
if ids:
|
||||
rows = (await service.session.execute(select(PaymentTransaction.gateway_transaction_id, Invoice.invoice_number).join(Invoice, Invoice.payment_transaction_id == PaymentTransaction.id).where(PaymentTransaction.gateway_transaction_id.in_(ids)))).all()
|
||||
invoice_map = {pid: inv for pid, inv in rows}
|
||||
return {"status":"success","count":len(items),"payments":[{"id":x.get("id"),"amount":x.get("amount"),"currency":x.get("currency"),"status":x.get("status"),"method":x.get("method"),"email":x.get("email"),"contact":x.get("contact"),"order_id":x.get("order_id"),"description":x.get("description"),"created_at":x.get("created_at"),"invoice_number":invoice_map.get(x.get("id"))} for x in items]}
|
||||
except Exception as exc:
|
||||
return {"status":"error","count":0,"payments":[],"error":str(exc)}
|
||||
|
||||
@router.get("/payments/{payment_id}/invoice")
|
||||
async def get_or_create_payment_invoice(payment_id: str, admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try:
|
||||
url, _, _ = await service.get_or_create_invoice(payment_id)
|
||||
return {"short_url": url}
|
||||
except LookupError as exc: raise HTTPException(404, detail=str(exc)) from exc
|
||||
except Exception as exc: raise HTTPException(502, detail=f"Failed to generate invoice from Razorpay: {exc}") from exc
|
||||
|
||||
@router.post("/payments/{payment_id}/share-invoice")
|
||||
async def share_payment_invoice(payment_id: str, admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try: return await service.share_invoice(payment_id)
|
||||
except LookupError as exc: raise HTTPException(404, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(500, detail=str(exc)) from exc
|
||||
|
||||
@router.get("/super-admins", response_model=list[AdminUserListResponse])
|
||||
async def list_super_admins(admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
return await service.list_users(True)
|
||||
|
||||
@router.get("/practitioners", response_model=list[AdminUserListResponse])
|
||||
async def list_practitioners(admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
return await service.list_users(False)
|
||||
|
||||
@router.get("/users-subscriptions")
|
||||
async def get_all_users_subscriptions(admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
return await service.subscriptions()
|
||||
|
||||
@router.post("/promote-user")
|
||||
async def promote_user_to_admin(payload: AdminPromoteUserRequest, admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try: return await service.promote(payload, admin)
|
||||
except LookupError as exc: raise HTTPException(404, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(500, detail=str(exc)) from exc
|
||||
|
||||
@router.post("/create-super-admin", status_code=status.HTTP_201_CREATED)
|
||||
async def create_super_admin(payload: AdminCreateSuperAdminRequest, admin: AppUser = Depends(get_current_admin), service: AdminService = Depends(get_admin_service)):
|
||||
try: return await service.create_super_admin(payload, admin)
|
||||
except ValueError as exc: raise HTTPException(400, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(500, detail=str(exc)) from exc
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
from __future__ import annotations
|
||||
from fastapi import Depends, HTTPException
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.models import AppUser, Role, UserRole
|
||||
from app.db.session import get_db_session
|
||||
from app.features.checkout.deps import get_current_user
|
||||
from .repository import AdminRepository
|
||||
from .service import AdminService
|
||||
|
||||
async def get_current_admin(user: AppUser = Depends(get_current_user), session: AsyncSession = Depends(get_db_session)) -> AppUser:
|
||||
roles = (await session.execute(
|
||||
select(Role.role_name).join(UserRole, UserRole.role_id == Role.id).where(UserRole.user_id == user.id)
|
||||
)).scalars().all()
|
||||
if not ({"super_admin", "finance_admin"} & set(roles)):
|
||||
raise HTTPException(403, detail="Forbidden: Administrative privileges required.")
|
||||
return user
|
||||
|
||||
def get_admin_repository(session: AsyncSession = Depends(get_db_session)) -> AdminRepository:
|
||||
return AdminRepository(session)
|
||||
|
||||
def get_admin_service(repository: AdminRepository = Depends(get_admin_repository)) -> AdminService:
|
||||
return AdminService(repository.session)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from __future__ import annotations
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
class AdminRepository:
|
||||
"""Feature persistence boundary over the shared four-schema AsyncSession."""
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
from __future__ import annotations
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class AdminRefundRequest(BaseModel):
|
||||
payment_transaction_id: UUID
|
||||
refund_amount: Decimal = Field(gt=0)
|
||||
support_ticket_reference: str = Field(min_length=1)
|
||||
reason_detail: str | None = None
|
||||
|
||||
class AdminRefundResponse(BaseModel):
|
||||
status: str
|
||||
refund_decision_id: UUID
|
||||
gateway_refund_id: str
|
||||
refunded_amount: Decimal
|
||||
currency: str
|
||||
|
||||
class AdminSyncResponse(BaseModel):
|
||||
status: str
|
||||
message: str
|
||||
records_processed: int
|
||||
sync_log: list[str]
|
||||
|
||||
class AdminPromoteUserRequest(BaseModel):
|
||||
email: str
|
||||
|
||||
class AdminCreateSuperAdminRequest(BaseModel):
|
||||
email: str
|
||||
password: str = Field(min_length=8)
|
||||
display_name: str | None = None
|
||||
phone_number: str | None = None
|
||||
|
||||
class AdminUserListResponse(BaseModel):
|
||||
id: UUID
|
||||
email: str
|
||||
display_name: str | None = None
|
||||
phone_number: str | None = None
|
||||
country: str
|
||||
is_active: bool
|
||||
roles: list[str]
|
||||
external_ref: str | None = None
|
||||
subscriptions: list[dict] = Field(default_factory=list)
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
from __future__ import annotations
|
||||
import uuid
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.enums import BillingPeriod, EntitlementStatus, PaymentStatus, SubscriptionStatus
|
||||
from app.db.models import AccessPlan, AccessPlanModule, AppUser, Invoice, PaymentTransaction, RefundDecision, Role, UserBillingProfile, UserEntitlement, UserRole, UserSubscription
|
||||
from app.features.auth.security import hash_password, validate_password_strength
|
||||
from app.features.email import send_invoice_email
|
||||
from app.features.payments import get_razorpay_service
|
||||
from .schema import AdminCreateSuperAdminRequest, AdminPromoteUserRequest, AdminRefundRequest, AdminRefundResponse, AdminSyncResponse, AdminUserListResponse
|
||||
|
||||
class AdminService:
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
async def process_refund(self, request: AdminRefundRequest, admin: AppUser) -> AdminRefundResponse:
|
||||
tx = (await self.session.execute(select(PaymentTransaction).where(PaymentTransaction.id == request.payment_transaction_id, PaymentTransaction.status == PaymentStatus.SUCCESS))).scalar_one_or_none()
|
||||
if not tx: raise LookupError("The specified successful payment transaction could not be located.")
|
||||
if request.refund_amount > tx.amount: raise ValueError("Refund amount cannot exceed the captured payment amount.")
|
||||
existing = (await self.session.execute(select(RefundDecision.id).where(RefundDecision.payment_transaction_id == tx.id).limit(1))).scalar_one_or_none()
|
||||
if existing: raise ValueError("A refund has already been registered or calculated for this transaction.")
|
||||
sub = (await self.session.execute(select(UserSubscription).where(UserSubscription.id == tx.subscription_id))).scalar_one()
|
||||
rzp = get_razorpay_service()
|
||||
refund = rzp.create_refund(payment_id=tx.gateway_transaction_id, amount=request.refund_amount, currency=tx.currency, notes={"support_ticket":request.support_ticket_reference,"admin_id":str(admin.id),"reason":request.reason_detail or "Customer request"})
|
||||
now = datetime.now(timezone.utc)
|
||||
start = sub.started_at
|
||||
if start.tzinfo is None: start = start.replace(tzinfo=timezone.utc)
|
||||
active_months = max(1, (now - start).days // 30)
|
||||
reduction = (Decimal("1") - (request.refund_amount / Decimal(tx.amount))) * Decimal("100")
|
||||
decision = RefundDecision(payment_transaction_id=tx.id, original_paid_amount=tx.amount, original_currency=tx.currency, calculated_reduction_percent=reduction, refund_amount=request.refund_amount, active_duration_months=active_months, support_ticket_reference=request.support_ticket_reference, reason_detail=request.reason_detail, status="approved", approved_by_admin_id=admin.id, decided_at=now)
|
||||
self.session.add(decision)
|
||||
tx.status = PaymentStatus.REVERSED
|
||||
sub.status = SubscriptionStatus.REFUNDED
|
||||
sub.cancelled_at = now
|
||||
sub.cancellation_reason = "refund_processed"
|
||||
sub.cancelled_by = admin.id
|
||||
ents = (await self.session.execute(select(UserEntitlement).where(UserEntitlement.source_subscription_id == sub.id, UserEntitlement.status == EntitlementStatus.ACTIVE))).scalars().all()
|
||||
for ent in ents:
|
||||
ent.status = EntitlementStatus.REVOKED; ent.revoked_at = now; ent.revoked_by = admin.id; ent.revoke_reason = "refund_processed"
|
||||
await self.session.commit(); await self.session.refresh(decision)
|
||||
return AdminRefundResponse(status="refunded", refund_decision_id=decision.id, gateway_refund_id=refund["id"], refunded_amount=request.refund_amount, currency=tx.currency)
|
||||
|
||||
async def force_sync(self) -> AdminSyncResponse:
|
||||
rzp = get_razorpay_service(); log: list[str] = []; count = 0
|
||||
payments = rzp.client.payment.all({"count": 100}).get("items", [])
|
||||
for payment in payments:
|
||||
if payment.get("status") != "captured" or not payment.get("id"): continue
|
||||
pid = payment["id"]
|
||||
if (await self.session.execute(select(PaymentTransaction.id).where(PaymentTransaction.gateway_transaction_id == pid))).scalar_one_or_none(): continue
|
||||
order_id = payment.get("order_id")
|
||||
if not order_id: log.append(f"Skipped {pid}: no Razorpay order_id"); continue
|
||||
sub = (await self.session.execute(select(UserSubscription).where(UserSubscription.payment_reference == order_id).limit(1))).scalar_one_or_none()
|
||||
if not sub: log.append(f"Skipped {pid}: no matching local subscription for {order_id}"); continue
|
||||
await self._reconcile_payment(payment, sub); count += 1; log.append(f"Reconciled {pid} → subscription {sub.id}")
|
||||
if not log: log.append("All records are already synchronized. No changes needed.")
|
||||
await self.session.commit()
|
||||
return AdminSyncResponse(status="completed", message=f"Sync complete. {count} record(s) processed.", records_processed=count, sync_log=log)
|
||||
|
||||
async def _reconcile_payment(self, payment: dict, sub: UserSubscription) -> None:
|
||||
now = datetime.now(timezone.utc)
|
||||
plan = (await self.session.execute(select(AccessPlan).where(AccessPlan.id == sub.plan_id))).scalar_one_or_none()
|
||||
if sub.status == SubscriptionStatus.PENDING:
|
||||
sub.status = SubscriptionStatus.ACTIVE; sub.started_at = now; sub.expires_at = now + timedelta(days=3650 if plan and plan.billing_period == BillingPeriod.LIFETIME else 365)
|
||||
amount = Decimal(str(payment.get("amount",0))) / 100; curr = str(payment.get("currency","INR")).upper()
|
||||
tx = PaymentTransaction(user_id=sub.user_id, subscription_id=sub.id, gateway_name="razorpay", gateway_transaction_id=payment["id"], status=PaymentStatus.SUCCESS, amount=amount, currency=curr)
|
||||
self.session.add(tx); await self.session.flush()
|
||||
meta = sub.metadata_json or {}; taxable=Decimal(str(meta.get("taxable_amount",0))); gst=Decimal(str(meta.get("gst_amount",0))); base=Decimal(str(meta.get("base_subtotal",amount))); discount=Decimal(str(meta.get("total_discounts",0)))
|
||||
user = (await self.session.execute(select(AppUser).where(AppUser.id == sub.user_id))).scalar_one()
|
||||
self.session.add(Invoice(payment_transaction_id=tx.id, invoice_number=f"INV-{now.strftime('%Y%m%d')}-{uuid.uuid4().hex[:6].upper()}", billing_name=user.display_name or user.email, billing_email=user.email, billing_address="Synced from Razorpay", base_amount=base, discount_amount=discount, taxable_amount=taxable, gst_amount=gst, total_amount=amount, currency_code=curr, exchange_rate_to_inr=Decimal("1"), total_amount_inr=amount if curr=="INR" else None))
|
||||
module_ids=(await self.session.execute(select(AccessPlanModule.module_id).where(AccessPlanModule.plan_id==sub.plan_id))).scalars().all()
|
||||
for module_id in module_ids:
|
||||
active=(await self.session.execute(select(UserEntitlement.id).where(UserEntitlement.user_id==sub.user_id,UserEntitlement.module_id==module_id,UserEntitlement.status==EntitlementStatus.ACTIVE).limit(1))).scalar_one_or_none()
|
||||
if active is None: self.session.add(UserEntitlement(user_id=sub.user_id,module_id=module_id,source_subscription_id=sub.id,source_plan_id=sub.plan_id,status=EntitlementStatus.ACTIVE,granted_at=now,grant_reason="force_sync_reconciliation",expires_at=sub.expires_at))
|
||||
|
||||
async def list_users(self, super_admin_only: bool) -> list[AdminUserListResponse]:
|
||||
users=(await self.session.execute(select(AppUser).order_by(AppUser.email))).scalars().all(); out=[]
|
||||
for user in users:
|
||||
roles=list((await self.session.execute(select(Role.role_name).join(UserRole,UserRole.role_id==Role.id).where(UserRole.user_id==user.id))).scalars().all())
|
||||
if super_admin_only != ("super_admin" in roles): continue
|
||||
subs=(await self.session.execute(select(UserSubscription,AccessPlan).join(AccessPlan,AccessPlan.id==UserSubscription.plan_id,isouter=True).where(UserSubscription.user_id==user.id,UserSubscription.status!=SubscriptionStatus.PENDING).order_by(UserSubscription.started_at.desc()))).all()
|
||||
out.append(AdminUserListResponse(id=user.id,email=user.email,display_name=user.display_name,phone_number=user.phone_number,country=user.country,is_active=user.is_active,roles=roles,external_ref=user.external_ref,subscriptions=[{"id":str(s.id),"plan_code":p.code if p else "UNKNOWN","plan_name":p.name if p else "Unknown Access Plan","status":getattr(s.status,"value",s.status),"started_at":s.started_at.isoformat() if s.started_at else None,"expires_at":s.expires_at.isoformat() if s.expires_at else None,"payment_reference":s.payment_reference} for s,p in subs]))
|
||||
return out
|
||||
|
||||
async def subscriptions(self) -> list[dict]:
|
||||
rows=(await self.session.execute(select(UserSubscription,AppUser,AccessPlan).join(AppUser,AppUser.id==UserSubscription.user_id).join(AccessPlan,AccessPlan.id==UserSubscription.plan_id,isouter=True).where(UserSubscription.status!=SubscriptionStatus.PENDING).order_by(UserSubscription.started_at.desc()))).all(); now=datetime.now(timezone.utc); result=[]
|
||||
for sub,user,plan in rows:
|
||||
exp=sub.expires_at; days=max(0,(exp-now).days) if exp and sub.status==SubscriptionStatus.ACTIVE else 0
|
||||
result.append({"id":str(sub.id),"user_email":user.email,"user_name":user.display_name or user.email.split('@')[0].title(),"user_phone":user.phone_number,"user_external_ref":user.external_ref,"plan_code":plan.code if plan else "UNKNOWN","plan_name":plan.name if plan else "Unknown Access Plan","status":getattr(sub.status,"value",sub.status),"started_at":sub.started_at.isoformat() if sub.started_at else None,"expires_at":exp.isoformat() if exp else None,"days_left":days,"payment_reference":sub.payment_reference})
|
||||
return result
|
||||
|
||||
async def promote(self, request: AdminPromoteUserRequest, admin: AppUser) -> dict:
|
||||
user=(await self.session.execute(select(AppUser).where(AppUser.email==str(request.email).lower()))).scalar_one_or_none()
|
||||
if not user: raise LookupError("The specified user account could not be found.")
|
||||
role=(await self.session.execute(select(Role).where(Role.role_name=="super_admin"))).scalar_one_or_none()
|
||||
if not role: raise RuntimeError("The super_admin system role was not found in the database.")
|
||||
exists=(await self.session.execute(select(UserRole.user_id).where(UserRole.user_id==user.id,UserRole.role_id==role.id))).scalar_one_or_none()
|
||||
if exists: return {"status":"already_admin","message":f"{request.email} is already a Super Admin."}
|
||||
self.session.add(UserRole(user_id=user.id,role_id=role.id,assigned_by=admin.id))
|
||||
await self._ensure_rzp_customer(user); await self.session.commit()
|
||||
return {"status":"success","message":f"Successfully promoted {request.email} to Super Admin."}
|
||||
|
||||
async def create_super_admin(self, request: AdminCreateSuperAdminRequest, admin: AppUser) -> dict:
|
||||
email=str(request.email).lower()
|
||||
if (await self.session.execute(select(AppUser.id).where(AppUser.email==email))).scalar_one_or_none(): raise ValueError("An account with this email address is already registered.")
|
||||
validate_password_strength(request.password)
|
||||
user=AppUser(email=email,password_hash=hash_password(request.password),display_name=request.display_name or email.split('@')[0].title(),phone_number=request.phone_number,country="India",preferred_language="en",is_active=True)
|
||||
self.session.add(user); await self.session.flush()
|
||||
roles=(await self.session.execute(select(Role).where(Role.role_name.in_(["practitioner","super_admin"])))).scalars().all()
|
||||
for role in roles: self.session.add(UserRole(user_id=user.id,role_id=role.id,assigned_by=admin.id))
|
||||
await self._ensure_rzp_customer(user); await self.session.commit()
|
||||
return {"status":"success","message":f"Successfully created new Super Admin account: {email}"}
|
||||
|
||||
async def _ensure_rzp_customer(self,user:AppUser)->None:
|
||||
if user.external_ref: return
|
||||
try: user.external_ref=get_razorpay_service().create_customer(name=user.display_name or user.email,email=user.email,phone=user.phone_number).get("id")
|
||||
except Exception: pass
|
||||
|
||||
async def get_or_create_invoice(self,payment_id:str)->tuple[str|None,str,str]:
|
||||
tx=(await self.session.execute(select(PaymentTransaction).where(PaymentTransaction.gateway_transaction_id==payment_id))).scalar_one_or_none()
|
||||
if not tx: raise LookupError("Payment transaction not found.")
|
||||
invoice=(await self.session.execute(select(Invoice).where(Invoice.payment_transaction_id==tx.id))).scalar_one_or_none(); rzp=get_razorpay_service(); user=(await self.session.execute(select(AppUser).where(AppUser.id==tx.user_id))).scalar_one()
|
||||
if invoice and invoice.invoice_number.startswith("inv_"):
|
||||
remote=rzp.client.invoice.fetch(invoice.invoice_number); url=remote.get("short_url")
|
||||
if not url and remote.get("status")=="draft": url=rzp.client.invoice.issue(invoice.invoice_number).get("short_url")
|
||||
if url: return url,invoice.invoice_number,user.email
|
||||
profile=(await self.session.execute(select(UserBillingProfile).where(UserBillingProfile.user_id==user.id,UserBillingProfile.is_default.is_(True)))).scalar_one_or_none()
|
||||
payment=rzp.fetch_payment(payment_id); customer={"name":profile.billing_name if profile else (user.display_name or user.email),"email":payment.get("email") or user.email}
|
||||
contact=payment.get("contact") or (profile.billing_phone if profile else user.phone_number)
|
||||
if contact: customer["contact"]=contact
|
||||
remote=rzp.client.invoice.create(data={"type":"invoice","customer":customer,"line_items":[{"name":payment.get("description") or "Access Plan Subscription","amount":payment.get("amount"),"currency":payment.get("currency","INR"),"quantity":1}],"email_notify":False,"sms_notify":False,"notes":{"payment_id":payment_id}}); inv_id=remote.get("id"); url=remote.get("short_url")
|
||||
if remote.get("status")=="draft": url=rzp.client.invoice.issue(inv_id).get("short_url") or url
|
||||
if invoice: invoice.invoice_number=inv_id
|
||||
else:
|
||||
amount=Decimal(str(payment.get("amount",0)))/100; curr=str(payment.get("currency","INR")).upper(); taxable=(amount/Decimal("1.0236")*Decimal("0.02")).quantize(Decimal("0.01")) if curr=="INR" else (amount/Decimal("1.03")*Decimal("0.03")).quantize(Decimal("0.01")); gst=(taxable*Decimal("0.18")).quantize(Decimal("0.01")) if curr=="INR" else Decimal("0"); base=amount-taxable-gst
|
||||
self.session.add(Invoice(payment_transaction_id=tx.id,invoice_number=inv_id,billing_name=customer["name"],billing_email=customer["email"],billing_address=f"{profile.address_line1}, {profile.city}, {profile.state}, {profile.postal_code}, {profile.country}" if profile else "Not Configured",base_amount=base,discount_amount=Decimal("0"),taxable_amount=taxable,gst_amount=gst,total_amount=amount,currency_code=curr,exchange_rate_to_inr=Decimal("1"),total_amount_inr=amount if curr=="INR" else None))
|
||||
await self.session.commit(); return url,inv_id,customer["email"]
|
||||
|
||||
async def share_invoice(self,payment_id:str)->dict:
|
||||
url,num,email=await self.get_or_create_invoice(payment_id)
|
||||
if not url: raise RuntimeError("Razorpay invoice does not have a download URL.")
|
||||
if not send_invoice_email(to=email,invoice_number=num,invoice_url=url): raise RuntimeError("Failed to send invoice email. Please check SMTP / Mailhog configuration.")
|
||||
return {"status":"success","message":f"Invoice shared successfully with {email}."}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
from .api import router
|
||||
__all__ = ["router"]
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import annotations
|
||||
from fastapi import APIRouter, Depends, Header, HTTPException
|
||||
from app.features.auth.security import decode_access_token
|
||||
from .deps import get_cart_service
|
||||
from .schema import CartCalculationRequest, CartCalculationResponse
|
||||
from .service import CartService
|
||||
|
||||
router = APIRouter(prefix="/cart", tags=["Cart & Pricing"])
|
||||
|
||||
def optional_user_id(authorization: str | None = Header(default=None)):
|
||||
if not authorization:
|
||||
return None
|
||||
scheme, _, token = authorization.partition(" ")
|
||||
if scheme.lower() != "bearer" or not token:
|
||||
return None
|
||||
try:
|
||||
from uuid import UUID
|
||||
return UUID(decode_access_token(token)["sub"])
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@router.post("/calculate", response_model=CartCalculationResponse)
|
||||
async def calculate_cart_endpoint(payload: CartCalculationRequest, service: CartService = Depends(get_cart_service), user_id=Depends(optional_user_id)) -> CartCalculationResponse:
|
||||
try:
|
||||
return await service.calculate(payload, user_id=user_id)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=f"Calculation error: {exc}") from exc
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.session import get_db_session
|
||||
from .repository import CartRepository
|
||||
from .service import CartService
|
||||
|
||||
def get_cart_repository(session: AsyncSession = Depends(get_db_session)) -> CartRepository:
|
||||
return CartRepository(session)
|
||||
|
||||
def get_cart_service(repository: CartRepository = Depends(get_cart_repository)) -> CartService:
|
||||
return CartService(repository)
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.enums import EntitlementStatus, SubscriptionStatus
|
||||
from app.db.models import AccessPlan, Coupon, Module, UserEntitlement, UserSubscription
|
||||
from app.features.payments.pricing import PricingCoupon, PricingItem
|
||||
|
||||
class CartRepository:
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
@staticmethod
|
||||
def _category(plan: AccessPlan) -> str:
|
||||
metadata = plan.metadata_json or {}
|
||||
if metadata.get("category"):
|
||||
return str(metadata["category"])
|
||||
code = plan.code.upper()
|
||||
if code == "LIFETIME_ALL": return "Lifetime"
|
||||
if code.startswith("POINT"): return "Points"
|
||||
if code.startswith("PATTERN"): return "Pattern"
|
||||
if code.startswith("NUTRITION"): return "Nutrition"
|
||||
if code.startswith("THERAPEUTIC"): return "Therapeutics"
|
||||
return str(metadata.get("access_group") or "General")
|
||||
|
||||
async def get_items(self, codes: list[str], currency: str) -> list[PricingItem]:
|
||||
normalized = [c.strip().upper() for c in codes if c.strip()]
|
||||
rows = (await self.session.execute(select(AccessPlan).where(AccessPlan.code.in_(normalized), AccessPlan.is_active.is_(True)))).scalars().all()
|
||||
by_code = {p.code.upper(): p for p in rows}
|
||||
items: list[PricingItem] = []
|
||||
for code in normalized:
|
||||
plan = by_code.get(code)
|
||||
if not plan:
|
||||
continue
|
||||
metadata = plan.metadata_json or {}
|
||||
prices = metadata.get("prices") if isinstance(metadata, dict) else None
|
||||
if isinstance(prices, dict) and currency.upper() in prices:
|
||||
price = Decimal(str(prices[currency.upper()]))
|
||||
elif plan.currency_code.upper() == currency.upper():
|
||||
price = Decimal(plan.total_fee)
|
||||
else:
|
||||
continue
|
||||
items.append(PricingItem(code=plan.code, name=plan.name, category=self._category(plan), price=price))
|
||||
return items
|
||||
|
||||
async def get_coupon(self, code: str | None, currency: str) -> PricingCoupon | None:
|
||||
if not code:
|
||||
return None
|
||||
now = datetime.now(timezone.utc)
|
||||
coupon = (await self.session.execute(select(Coupon).where(Coupon.code == code.strip().upper(), Coupon.is_active.is_(True), Coupon.start_date <= now, Coupon.end_date >= now))).scalar_one_or_none()
|
||||
if not coupon:
|
||||
return None
|
||||
metadata = getattr(coupon, "metadata_json", {}) if hasattr(coupon, "metadata_json") else {}
|
||||
value = Decimal(coupon.value)
|
||||
if coupon.discount_type == "flat":
|
||||
currency_values = metadata.get("currency_values") if isinstance(metadata, dict) else None
|
||||
if isinstance(currency_values, dict) and currency.upper() in currency_values:
|
||||
value = Decimal(str(currency_values[currency.upper()]))
|
||||
return PricingCoupon(code=coupon.code, category=coupon.coupon_category, discount_type=coupon.discount_type, value=value, description=coupon.description, max_discount_limit=Decimal(coupon.max_discount_limit))
|
||||
|
||||
async def get_owned_categories(self, user_id: UUID) -> list[str]:
|
||||
rows = (await self.session.execute(select(UserEntitlement, Module).join(Module, Module.id == UserEntitlement.module_id).where(UserEntitlement.user_id == user_id, UserEntitlement.status == EntitlementStatus.ACTIVE))).all()
|
||||
result: list[str] = []
|
||||
for _, module in rows:
|
||||
metadata = module.metadata_json or {}
|
||||
category = metadata.get("commerce_category") or metadata.get("category")
|
||||
if category:
|
||||
result.append(str(category))
|
||||
return result
|
||||
|
||||
async def is_first_purchase(self, user_id: UUID) -> bool:
|
||||
exists = (await self.session.execute(select(UserSubscription.id).where(UserSubscription.user_id == user_id, UserSubscription.status == SubscriptionStatus.ACTIVE).limit(1))).scalar_one_or_none()
|
||||
return exists is None
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
from __future__ import annotations
|
||||
from typing import Any
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class CartCalculationRequest(BaseModel):
|
||||
cart_item_codes: list[str] = Field(min_length=1)
|
||||
owned_category_names: list[str] = Field(default_factory=list)
|
||||
coupon_code: str | None = None
|
||||
currency: str = "INR"
|
||||
is_first_purchase: bool = True
|
||||
|
||||
class CartItemResponse(BaseModel):
|
||||
code: str
|
||||
name: str
|
||||
category: str
|
||||
price: float
|
||||
|
||||
class CartCalculationResponse(BaseModel):
|
||||
currency: str
|
||||
base_subtotal: float
|
||||
discount_policy: str
|
||||
bundle_discount_amount: float
|
||||
coupon_applied: str
|
||||
coupon_discount_amount: float
|
||||
total_discounts: float
|
||||
convenience_fee_rate: float
|
||||
convenience_fee: float
|
||||
taxable_amount: float
|
||||
gst_amount: float
|
||||
grand_total: float
|
||||
cart_items: list[CartItemResponse]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
from __future__ import annotations
|
||||
from uuid import UUID
|
||||
from app.features.payments.pricing import PricingEngine
|
||||
from .repository import CartRepository
|
||||
from .schema import CartCalculationRequest, CartCalculationResponse
|
||||
|
||||
class CartService:
|
||||
def __init__(self, repository: CartRepository) -> None:
|
||||
self.repository = repository
|
||||
self.engine = PricingEngine()
|
||||
|
||||
async def calculate(self, request: CartCalculationRequest, user_id: UUID | None = None) -> CartCalculationResponse:
|
||||
currency = request.currency.upper()
|
||||
items = await self.repository.get_items(request.cart_item_codes, currency)
|
||||
if len(items) != len({c.strip().upper() for c in request.cart_item_codes if c.strip()}):
|
||||
resolved = {i.code.upper() for i in items}
|
||||
missing = [c for c in request.cart_item_codes if c.strip().upper() not in resolved]
|
||||
raise ValueError(f"Unknown/inactive plan code or currency mismatch: {', '.join(missing)}")
|
||||
coupon = await self.repository.get_coupon(request.coupon_code, currency)
|
||||
owned = await self.repository.get_owned_categories(user_id) if user_id else request.owned_category_names
|
||||
first = await self.repository.is_first_purchase(user_id) if user_id else request.is_first_purchase
|
||||
return CartCalculationResponse.model_validate(self.engine.calculate(items=items, owned_categories=owned, coupon=coupon, currency=currency, is_first_purchase=first))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
from .api import router
|
||||
__all__ = ["router"]
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
from __future__ import annotations
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from app.db.models import AppUser
|
||||
from app.features.payments import get_razorpay_service
|
||||
from .deps import get_checkout_service, get_current_user
|
||||
from .schema import CheckoutOrderRequest, CheckoutOrderResponse, CheckoutVerifyRequest
|
||||
from .service import CheckoutService
|
||||
router = APIRouter(prefix="/checkout", tags=["Checkout & Payments"])
|
||||
|
||||
@router.get("/config")
|
||||
async def get_checkout_config():
|
||||
try: return {"razorpay_key_id": get_razorpay_service().key_id}
|
||||
except RuntimeError as exc: raise HTTPException(503, detail=str(exc)) from exc
|
||||
|
||||
@router.post("/create-order", response_model=CheckoutOrderResponse)
|
||||
async def create_checkout_order(payload: CheckoutOrderRequest, user: AppUser = Depends(get_current_user), service: CheckoutService = Depends(get_checkout_service)):
|
||||
try: return await service.create_order(user, payload)
|
||||
except ValueError as exc: raise HTTPException(400, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(503, detail=str(exc)) from exc
|
||||
except Exception as exc: raise HTTPException(502, detail=f"Razorpay checkout initialization failed: {exc}") from exc
|
||||
|
||||
@router.post("/verify")
|
||||
async def verify_checkout_payment(payload: CheckoutVerifyRequest, user: AppUser = Depends(get_current_user), service: CheckoutService = Depends(get_checkout_service)):
|
||||
try: return await service.verify(user, payload)
|
||||
except LookupError as exc: raise HTTPException(404, detail=str(exc)) from exc
|
||||
except ValueError as exc: raise HTTPException(400, detail=str(exc)) from exc
|
||||
except RuntimeError as exc: raise HTTPException(503, detail=str(exc)) from exc
|
||||
|
||||
@router.get("/payment/{payment_id}/invoice")
|
||||
async def get_checkout_payment_invoice(payment_id: str, user: AppUser = Depends(get_current_user), service: CheckoutService = Depends(get_checkout_service)):
|
||||
from sqlalchemy import select
|
||||
from app.db.models import PaymentTransaction
|
||||
from app.features.admin.service import AdminService
|
||||
tx = (await service.session.execute(select(PaymentTransaction).where(PaymentTransaction.gateway_transaction_id == payment_id, PaymentTransaction.user_id == user.id))).scalar_one_or_none()
|
||||
if not tx:
|
||||
raise HTTPException(404, detail="Transaction record not found or access denied.")
|
||||
try:
|
||||
url, _, _ = await AdminService(service.session).get_or_create_invoice(payment_id)
|
||||
if not url:
|
||||
raise HTTPException(500, detail="Razorpay invoice does not have a download URL.")
|
||||
return {"short_url": url}
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as exc:
|
||||
raise HTTPException(502, detail=f"Failed to generate invoice from Razorpay: {exc}") from exc
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
from __future__ import annotations
|
||||
from uuid import UUID
|
||||
from fastapi import Depends, Header, HTTPException, status
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.models import AppUser
|
||||
from app.db.session import get_db_session
|
||||
from app.features.auth.security import decode_access_token
|
||||
from app.features.cart.repository import CartRepository
|
||||
from .repository import CheckoutRepository
|
||||
from .service import CheckoutService
|
||||
|
||||
async def get_current_user(authorization: str | None = Header(default=None), session: AsyncSession = Depends(get_db_session)) -> AppUser:
|
||||
if not authorization:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Session token missing. Please register or login.")
|
||||
scheme, sep, token = authorization.partition(" ")
|
||||
if sep != " " or scheme.lower() != "bearer" or not token:
|
||||
raise HTTPException(status_code=401, detail="Invalid session token.")
|
||||
try:
|
||||
user_id = UUID(decode_access_token(token)["sub"])
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=401, detail="Invalid session token.") from exc
|
||||
user = (await session.execute(select(AppUser).where(AppUser.id == user_id, AppUser.is_active.is_(True)))).scalar_one_or_none()
|
||||
if not user:
|
||||
raise HTTPException(status_code=401, detail="User profile not found.")
|
||||
return user
|
||||
|
||||
def get_checkout_repository(session: AsyncSession = Depends(get_db_session)) -> CheckoutRepository:
|
||||
return CheckoutRepository(session)
|
||||
|
||||
def get_checkout_service(repository: CheckoutRepository = Depends(get_checkout_repository)) -> CheckoutService:
|
||||
return CheckoutService(session=repository.session, cart_repository=CartRepository(repository.session))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from __future__ import annotations
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
class CheckoutRepository:
|
||||
"""Feature persistence boundary over the shared four-schema AsyncSession."""
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class CheckoutOrderRequest(BaseModel):
|
||||
cart_item_codes: list[str] = Field(min_length=1)
|
||||
coupon_code: str | None = None
|
||||
currency: str = "INR"
|
||||
|
||||
class CheckoutOrderResponse(BaseModel):
|
||||
razorpay_order_id: str
|
||||
amount: float
|
||||
currency: str
|
||||
receipt: str
|
||||
base_subtotal: float
|
||||
total_discounts: float
|
||||
convenience_fee: float = 0.0
|
||||
convenience_fee_rate: float = 0.0
|
||||
taxable_amount: float
|
||||
gst_amount: float
|
||||
grand_total: float
|
||||
|
||||
class CheckoutVerifyRequest(BaseModel):
|
||||
razorpay_order_id: str
|
||||
razorpay_payment_id: str
|
||||
razorpay_signature: str
|
||||
billing_profile_id: UUID | None = None
|
||||
currency: str = "INR"
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
from __future__ import annotations
|
||||
import uuid
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
from uuid import UUID
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.enums import BillingPeriod, EntitlementStatus, PaymentStatus, SubscriptionStatus
|
||||
from app.db.models import AccessPlan, AccessPlanModule, AppUser, Invoice, PaymentTransaction, UserBillingProfile, UserEntitlement, UserSubscription
|
||||
from app.features.cart.repository import CartRepository
|
||||
from app.features.cart.schema import CartCalculationRequest
|
||||
from app.features.cart.service import CartService
|
||||
from app.features.payments import get_razorpay_service
|
||||
from .schema import CheckoutOrderRequest, CheckoutOrderResponse, CheckoutVerifyRequest
|
||||
|
||||
class CheckoutService:
|
||||
def __init__(self, *, session: AsyncSession, cart_repository: CartRepository) -> None:
|
||||
self.session = session
|
||||
self.cart_service = CartService(cart_repository)
|
||||
|
||||
async def create_order(self, user: AppUser, request: CheckoutOrderRequest) -> CheckoutOrderResponse:
|
||||
calc = await self.cart_service.calculate(CartCalculationRequest(cart_item_codes=request.cart_item_codes, coupon_code=request.coupon_code, currency=request.currency), user_id=user.id)
|
||||
if calc.grand_total <= 0:
|
||||
raise ValueError("Grand total must be greater than zero to checkout.")
|
||||
rzp = get_razorpay_service()
|
||||
if not user.external_ref:
|
||||
try:
|
||||
customer = rzp.create_customer(name=user.display_name or user.email, email=user.email, phone=user.phone_number)
|
||||
user.external_ref = customer.get("id")
|
||||
await self.session.flush()
|
||||
except Exception:
|
||||
pass
|
||||
receipt = f"rcpt_{uuid.uuid4().hex[:12]}"
|
||||
order = rzp.create_order(amount=calc.grand_total, currency=calc.currency, receipt=receipt, notes={"user_id": str(user.id), "cart_item_codes": ",".join(request.cart_item_codes), "coupon_code": request.coupon_code or ""})
|
||||
plans = (await self.session.execute(select(AccessPlan).where(AccessPlan.code.in_([c.upper() for c in request.cart_item_codes]), AccessPlan.is_active.is_(True)))).scalars().all()
|
||||
now = datetime.now(timezone.utc)
|
||||
pricing_meta = {"base_subtotal": calc.base_subtotal, "total_discounts": calc.total_discounts, "grand_total": calc.grand_total, "taxable_amount": calc.taxable_amount, "gst_amount": calc.gst_amount, "currency": calc.currency}
|
||||
for plan in plans:
|
||||
self.session.add(UserSubscription(user_id=user.id, plan_id=plan.id, status=SubscriptionStatus.PENDING, started_at=now, auto_renew=False, payment_provider="razorpay", payment_reference=order["id"], metadata_json=dict(pricing_meta)))
|
||||
await self.session.commit()
|
||||
return CheckoutOrderResponse(razorpay_order_id=order["id"], amount=calc.grand_total, currency=calc.currency, receipt=receipt, base_subtotal=calc.base_subtotal, total_discounts=calc.total_discounts, convenience_fee=calc.convenience_fee, convenience_fee_rate=calc.convenience_fee_rate, taxable_amount=calc.taxable_amount, gst_amount=calc.gst_amount, grand_total=calc.grand_total)
|
||||
|
||||
async def verify(self, user: AppUser, request: CheckoutVerifyRequest) -> dict:
|
||||
rzp = get_razorpay_service()
|
||||
if not rzp.verify_payment_signature(razorpay_order_id=request.razorpay_order_id, razorpay_payment_id=request.razorpay_payment_id, razorpay_signature=request.razorpay_signature):
|
||||
raise ValueError("Payment verification failed: Signature does not match.")
|
||||
payment = rzp.fetch_payment(request.razorpay_payment_id)
|
||||
if payment.get("status") not in {"captured", "authorized"}:
|
||||
raise ValueError(f"Payment is not captured/authorized (status={payment.get('status')}).")
|
||||
existing_tx = (await self.session.execute(select(PaymentTransaction).where(PaymentTransaction.gateway_transaction_id == request.razorpay_payment_id))).scalar_one_or_none()
|
||||
if existing_tx:
|
||||
return {"status": "success", "message": "This transaction was already successfully processed and verified.", "razorpay_payment_id": request.razorpay_payment_id}
|
||||
subs = (await self.session.execute(select(UserSubscription).where(UserSubscription.user_id == user.id, UserSubscription.status == SubscriptionStatus.PENDING, UserSubscription.payment_reference == request.razorpay_order_id))).scalars().all()
|
||||
if not subs:
|
||||
raise LookupError("No pending order subscription record matches this checkout ID.")
|
||||
profile = await self._billing_profile(user, request.billing_profile_id)
|
||||
meta = subs[0].metadata_json or {}
|
||||
gateway_total = Decimal(str(payment.get("amount", 0))) / Decimal("100")
|
||||
final_total = Decimal(str(meta.get("grand_total", gateway_total)))
|
||||
gateway_currency = str(payment.get("currency", request.currency)).upper()
|
||||
expected_subunits = int((final_total * 100).quantize(Decimal("1")))
|
||||
if int(payment.get("amount", -1)) != expected_subunits or gateway_currency != str(meta.get("currency", request.currency)).upper():
|
||||
raise ValueError("Gateway amount/currency does not match the checkout order.")
|
||||
now = datetime.now(timezone.utc)
|
||||
transaction = PaymentTransaction(user_id=user.id, subscription_id=subs[0].id, gateway_name="razorpay", gateway_transaction_id=request.razorpay_payment_id, status=PaymentStatus.SUCCESS, amount=final_total, currency=gateway_currency)
|
||||
self.session.add(transaction)
|
||||
await self.session.flush()
|
||||
plan_names: list[str] = []
|
||||
for sub in subs:
|
||||
plan = (await self.session.execute(select(AccessPlan).where(AccessPlan.id == sub.plan_id))).scalar_one_or_none()
|
||||
sub.status = SubscriptionStatus.ACTIVE
|
||||
sub.started_at = now
|
||||
sub.expires_at = now + timedelta(days=3650 if plan and plan.billing_period == BillingPeriod.LIFETIME else 365)
|
||||
if plan:
|
||||
plan_names.append(plan.name)
|
||||
module_ids = (await self.session.execute(select(AccessPlanModule.module_id).where(AccessPlanModule.plan_id == sub.plan_id))).scalars().all()
|
||||
for module_id in module_ids:
|
||||
active = (await self.session.execute(select(UserEntitlement.id).where(UserEntitlement.user_id == user.id, UserEntitlement.module_id == module_id, UserEntitlement.status == EntitlementStatus.ACTIVE).limit(1))).scalar_one_or_none()
|
||||
if active is None:
|
||||
self.session.add(UserEntitlement(user_id=user.id, module_id=module_id, source_subscription_id=sub.id, source_plan_id=sub.plan_id, status=EntitlementStatus.ACTIVE, granted_at=now, grant_reason="subscription_purchase", expires_at=sub.expires_at))
|
||||
invoice_number, invoice_url = await self._create_invoice(rzp, transaction, profile, payment, plan_names, meta)
|
||||
await self.session.commit()
|
||||
return {"status": "success", "message": "Payment verified. Clinical modules successfully unlocked!", "razorpay_payment_id": request.razorpay_payment_id, "invoice_number": invoice_number, "invoice_url": invoice_url}
|
||||
|
||||
async def _billing_profile(self, user: AppUser, billing_profile_id: UUID | None) -> UserBillingProfile:
|
||||
stmt = select(UserBillingProfile).where(UserBillingProfile.user_id == user.id)
|
||||
if billing_profile_id:
|
||||
stmt = stmt.where(UserBillingProfile.id == billing_profile_id)
|
||||
else:
|
||||
stmt = stmt.where(UserBillingProfile.is_default.is_(True))
|
||||
profile = (await self.session.execute(stmt)).scalar_one_or_none()
|
||||
if profile:
|
||||
return profile
|
||||
profile = UserBillingProfile(user_id=user.id, label="Default Auto-Generated", billing_name=user.display_name or user.email, billing_email=user.email, billing_phone=user.phone_number, address_line1="Not Configured", city="Not Configured", state="Not Configured", postal_code="000000", country=user.country, is_default=True)
|
||||
self.session.add(profile)
|
||||
await self.session.flush()
|
||||
return profile
|
||||
|
||||
async def _create_invoice(self, rzp, tx: PaymentTransaction, profile: UserBillingProfile, payment: dict, plan_names: list[str], meta: dict) -> tuple[str, str | None]:
|
||||
currency = tx.currency.upper()
|
||||
inv_number = f"INV-{datetime.now(timezone.utc).strftime('%Y%m%d')}-{uuid.uuid4().hex[:6].upper()}"
|
||||
inv_url = None
|
||||
try:
|
||||
created = rzp.client.invoice.create(data={"type":"invoice","customer":{"name":profile.billing_name,"email":profile.billing_email, **({"contact": profile.billing_phone} if profile.billing_phone else {})},"line_items":[{"name": (", ".join(plan_names) or "Access Subscription")[:250],"amount": int(Decimal(tx.amount)*100),"currency":currency,"quantity":1}],"email_notify":False,"sms_notify":False,"notes":{"payment_id":tx.gateway_transaction_id}})
|
||||
inv_number = created.get("id") or inv_number
|
||||
inv_url = created.get("short_url")
|
||||
if created.get("status") == "draft":
|
||||
issued = rzp.client.invoice.issue(inv_number)
|
||||
inv_url = issued.get("short_url") or inv_url
|
||||
except Exception:
|
||||
pass
|
||||
base = Decimal(str(meta.get("base_subtotal", tx.amount)))
|
||||
discount = Decimal(str(meta.get("total_discounts", 0)))
|
||||
taxable = Decimal(str(meta.get("taxable_amount", 0)))
|
||||
gst = Decimal(str(meta.get("gst_amount", 0)))
|
||||
self.session.add(Invoice(payment_transaction_id=tx.id, invoice_number=inv_number, billing_name=profile.billing_name, billing_email=profile.billing_email, billing_address=f"{profile.address_line1}, {profile.city}, {profile.state}, {profile.postal_code}, {profile.country}", gstin=profile.gstin, billing_profile_id=profile.id, base_amount=base, discount_amount=discount, taxable_amount=taxable, gst_amount=gst, total_amount=Decimal(tx.amount), currency_code=currency, exchange_rate_to_inr=Decimal("1"), total_amount_inr=Decimal(tx.amount) if currency == "INR" else None))
|
||||
return inv_number, inv_url
|
||||
|
|
@ -1,3 +1 @@
|
|||
from .api import router
|
||||
|
||||
__all__ = ["router"]
|
||||
"""Feature package; import API modules explicitly at composition boundaries."""
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from app.db.schemas import CONTENT_SCHEMA
|
||||
|
||||
|
||||
_SCHEMA_IDENTIFIER_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
|
||||
|
||||
|
||||
def resolve_content_schema(schema: str = CONTENT_SCHEMA) -> str:
|
||||
"""
|
||||
Return a validated PostgreSQL schema identifier for content/search raw SQL.
|
||||
|
||||
Production ownership is ``content``. The optional override is retained only
|
||||
to preserve the repository constructor contract for isolated tests and
|
||||
development schemas.
|
||||
"""
|
||||
candidate = schema.strip()
|
||||
if not _SCHEMA_IDENTIFIER_RE.fullmatch(candidate):
|
||||
raise ValueError(f"Invalid PostgreSQL schema identifier: {schema!r}")
|
||||
return candidate
|
||||
|
||||
|
||||
__all__ = ["CONTENT_SCHEMA", "resolve_content_schema"]
|
||||
|
|
@ -11,7 +11,9 @@ from app.cache.deps import (
|
|||
from app.cache.invalidation import ContentCacheInvalidator
|
||||
from app.cache.service import CacheService
|
||||
from app.db.session import get_db_session
|
||||
from app.core.media_storage import MediaUrlResolver, get_media_url_resolver
|
||||
from app.features.media_storage import MediaUrlResolver, get_media_url_resolver
|
||||
from app.features.search.deps import get_search_repository
|
||||
from app.features.search.repository import SearchRepository
|
||||
|
||||
from .repository import ContentRepository
|
||||
from .service import ContentService
|
||||
|
|
@ -30,6 +32,7 @@ def get_content_service(
|
|||
invalidator: ContentCacheInvalidator = Depends(
|
||||
get_content_cache_invalidator
|
||||
),
|
||||
search_repository: SearchRepository = Depends(get_search_repository),
|
||||
media_url_resolver: MediaUrlResolver = Depends(get_media_url_resolver),
|
||||
) -> ContentService:
|
||||
return ContentService(
|
||||
|
|
@ -37,5 +40,6 @@ def get_content_service(
|
|||
repository=repository,
|
||||
cache=ContentCache(cache_service),
|
||||
invalidator=invalidator,
|
||||
search_projection_writer=search_repository,
|
||||
media_url_resolver=media_url_resolver,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Protocol
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
class SearchProjectionWriter(Protocol):
|
||||
"""Content-side port for synchronizing the derived search projection."""
|
||||
|
||||
async def rebuild_content_projection(self, content_id: UUID) -> None:
|
||||
...
|
||||
|
|
@ -21,6 +21,8 @@ from app.db.models import (
|
|||
ModuleContent,
|
||||
)
|
||||
|
||||
from .db_schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .errors import (
|
||||
ContentNotFoundError,
|
||||
ContentDefinitionSetError,
|
||||
|
|
@ -146,10 +148,10 @@ class ContentRepository:
|
|||
self,
|
||||
session: AsyncSession,
|
||||
*,
|
||||
schema: str = "acu_content",
|
||||
schema: str = CONTENT_SCHEMA,
|
||||
) -> None:
|
||||
self._session = session
|
||||
self._schema = schema
|
||||
self._schema = resolve_content_schema(schema)
|
||||
|
||||
async def get_all_active_modules(
|
||||
self,
|
||||
|
|
@ -1833,7 +1835,7 @@ class ContentRepository:
|
|||
if not content_ids:
|
||||
return {}
|
||||
|
||||
stmt = text("""
|
||||
stmt = text(f"""
|
||||
SELECT
|
||||
cm.id AS id,
|
||||
cm.content_id AS content_id,
|
||||
|
|
@ -1848,8 +1850,8 @@ class ContentRepository:
|
|||
COALESCE(ma.height_px, ma.height) AS height,
|
||||
ma.storage_key AS storage_key,
|
||||
ma.file_path AS file_path
|
||||
FROM acu_content.content_media cm
|
||||
JOIN acu_content.media_assets ma
|
||||
FROM {self._schema}.content_media cm
|
||||
JOIN {self._schema}.media_assets ma
|
||||
ON ma.id = cm.media_asset_id
|
||||
WHERE cm.content_id = ANY(CAST(:content_ids AS uuid[]))
|
||||
AND COALESCE(ma.status, 'active') = 'active'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from uuid import UUID
|
|||
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from app.db.models import ModuleStatus, RecordStatus
|
||||
from app.db.enums import ModuleStatus, RecordStatus
|
||||
|
||||
|
||||
class ContentKind(StrEnum):
|
||||
|
|
|
|||
|
|
@ -9,13 +9,12 @@ from fastapi import HTTPException
|
|||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.media_storage import MediaUrlResolver
|
||||
|
||||
from app.features.search.repository import SearchRepository
|
||||
from app.features.media_storage import MediaUrlResolver
|
||||
|
||||
from app.cache.content_cache import ContentCache
|
||||
from app.cache.invalidation import ContentCacheInvalidator
|
||||
from app.db.models import ContentItem, RecordStatus
|
||||
from app.db.models import ContentItem
|
||||
from app.db.enums import RecordStatus
|
||||
from app.features.content.builder import (
|
||||
AttributeCycleError,
|
||||
AttributeHierarchyError,
|
||||
|
|
@ -25,6 +24,8 @@ from app.features.content.builder import (
|
|||
DuplicateScalarAttributeError,
|
||||
)
|
||||
|
||||
from .ports import SearchProjectionWriter
|
||||
|
||||
from .capabilities import (
|
||||
is_sortable_definition,
|
||||
operators_for_definition,
|
||||
|
|
@ -108,12 +109,14 @@ class ContentService:
|
|||
repository: ContentRepository,
|
||||
cache: ContentCache,
|
||||
invalidator: ContentCacheInvalidator,
|
||||
search_projection_writer: SearchProjectionWriter,
|
||||
media_url_resolver: MediaUrlResolver | None = None,
|
||||
) -> None:
|
||||
self.session = session
|
||||
self.repository = repository
|
||||
self.cache = cache
|
||||
self.invalidator = invalidator
|
||||
self.search_projection_writer = search_projection_writer
|
||||
self.media_url_resolver = media_url_resolver
|
||||
|
||||
async def get_modules(self) -> ModuleListResponse:
|
||||
|
|
@ -634,7 +637,7 @@ class ContentService:
|
|||
# Search is a derived projection, never an authoring source of truth.
|
||||
# Rebuild inside the same transaction so a successfully published row
|
||||
# and its search projection become visible atomically at commit time.
|
||||
await SearchRepository(self.session).rebuild_content_projection(content_id)
|
||||
await self.search_projection_writer.rebuild_content_projection(content_id)
|
||||
|
||||
return PublishContentResponse.model_validate(content)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
from .razorpay import RazorpayService, get_razorpay_service
|
||||
from .pricing import PricingEngine, PricingItem, PricingCoupon
|
||||
|
||||
__all__ = ["RazorpayService", "get_razorpay_service", "PricingEngine", "PricingItem", "PricingCoupon"]
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
from typing import Any
|
||||
|
||||
|
||||
def q(value: Decimal) -> Decimal:
|
||||
return value.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PricingItem:
|
||||
code: str
|
||||
name: str
|
||||
category: str
|
||||
price: Decimal
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PricingCoupon:
|
||||
code: str
|
||||
category: str
|
||||
discount_type: str
|
||||
value: Decimal
|
||||
description: str | None = None
|
||||
max_discount_limit: Decimal = Decimal("0")
|
||||
|
||||
class PricingEngine:
|
||||
"""Preserves the legacy bundle/loyalty/fee rules while sourcing prices from commerce.access_plans."""
|
||||
|
||||
def calculate(self, *, items: list[PricingItem], owned_categories: list[str], coupon: PricingCoupon | None, currency: str, is_first_purchase: bool) -> dict[str, Any]:
|
||||
curr = currency.upper()
|
||||
base = sum((item.price for item in items), Decimal("0"))
|
||||
categories = {item.category for item in items}
|
||||
has_lifetime = any(i.category.lower() == "lifetime" or i.code == "LIFETIME_ALL" for i in items)
|
||||
bundle = Decimal("0")
|
||||
policy = "None"
|
||||
disable_unit = bool(is_first_purchase and coupon and coupon.category == "introductory" and coupon.discount_type == "flat")
|
||||
if has_lifetime:
|
||||
policy = "Lifetime Bulk Package"
|
||||
elif disable_unit:
|
||||
policy = "None (Overridden by New User Event Coupon)"
|
||||
elif is_first_purchase:
|
||||
n = len(categories)
|
||||
rate = Decimal("0.10") if n == 2 else Decimal("0.20") if n == 3 else Decimal("0.30") if n >= 4 else Decimal("0")
|
||||
bundle = base * rate
|
||||
if rate:
|
||||
policy = f"First-time Buy: {n if n < 4 else '4+'} Units ({int(rate * 100)}% Off)"
|
||||
else:
|
||||
n = len(set(owned_categories))
|
||||
if n and items:
|
||||
rate = min(Decimal("0.05") * n, Decimal("0.25"))
|
||||
bundle = base * rate
|
||||
policy = f"Staggered Buy: {n} owned categories ({int(rate * 100)}% Off)"
|
||||
after_bundle = max(Decimal("0"), base - bundle)
|
||||
coupon_discount = Decimal("0")
|
||||
coupon_text = "None"
|
||||
if coupon:
|
||||
coupon_text = f"Code: {coupon.code} - {coupon.description or ''}".rstrip(" -")
|
||||
if coupon.discount_type == "flat":
|
||||
coupon_discount = min(coupon.value, after_bundle)
|
||||
elif coupon.discount_type == "percentage":
|
||||
coupon_discount = after_bundle * (coupon.value / Decimal("100"))
|
||||
if coupon.max_discount_limit > 0:
|
||||
coupon_discount = min(coupon_discount, coupon.max_discount_limit)
|
||||
net = max(Decimal("0"), after_bundle - coupon_discount)
|
||||
fee_rate = Decimal("0.02") if curr == "INR" else Decimal("0.03")
|
||||
fee = q(net * fee_rate)
|
||||
gst = q(fee * Decimal("0.18")) if curr == "INR" else Decimal("0")
|
||||
grand = q(net + fee + gst)
|
||||
return {
|
||||
"currency": curr,
|
||||
"base_subtotal": float(q(base)),
|
||||
"discount_policy": policy,
|
||||
"bundle_discount_amount": float(q(bundle)),
|
||||
"coupon_applied": coupon_text,
|
||||
"coupon_discount_amount": float(q(coupon_discount)),
|
||||
"total_discounts": float(q(bundle + coupon_discount)),
|
||||
"convenience_fee_rate": float(fee_rate * 100),
|
||||
"convenience_fee": float(fee),
|
||||
"taxable_amount": float(fee),
|
||||
"gst_amount": float(gst),
|
||||
"grand_total": float(grand),
|
||||
"cart_items": [{"code": i.code, "name": i.name, "category": i.category, "price": float(q(i.price))} for i in items],
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import hmac
|
||||
import os
|
||||
import time
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
import razorpay
|
||||
|
||||
|
||||
class RazorpayService:
|
||||
def __init__(self) -> None:
|
||||
self.key_id = os.getenv("RAZORPAY_KEY_ID", "")
|
||||
self.key_secret = os.getenv("RAZORPAY_KEY_SECRET", "")
|
||||
self.webhook_secret = os.getenv("RAZORPAY_WEBHOOK_SECRET", "")
|
||||
if not self.key_id or not self.key_secret:
|
||||
raise RuntimeError("RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET must be configured.")
|
||||
self.client = razorpay.Client(auth=(self.key_id, self.key_secret))
|
||||
|
||||
@staticmethod
|
||||
def _to_subunit(amount: Decimal | float, currency: str) -> int:
|
||||
del currency
|
||||
return int((Decimal(str(amount)) * Decimal("100")).quantize(Decimal("1")))
|
||||
|
||||
def create_customer(self, *, name: str, email: str, phone: str | None = None) -> dict[str, Any]:
|
||||
data: dict[str, Any] = {"name": name, "email": email, "fail_existing": 0}
|
||||
if phone:
|
||||
data["contact"] = phone
|
||||
return self.client.customer.create(data=data)
|
||||
|
||||
def create_order(self, *, amount: Decimal | float, currency: str = "INR", receipt: str | None = None, notes: dict[str, Any] | None = None) -> dict[str, Any]:
|
||||
return self.client.order.create(data={
|
||||
"amount": self._to_subunit(amount, currency),
|
||||
"currency": currency.upper(),
|
||||
"receipt": receipt or f"receipt_{int(time.time())}",
|
||||
"notes": notes or {},
|
||||
})
|
||||
|
||||
def fetch_payment(self, payment_id: str) -> dict[str, Any]:
|
||||
return self.client.payment.fetch(payment_id)
|
||||
|
||||
def verify_payment_signature(self, *, razorpay_order_id: str, razorpay_payment_id: str, razorpay_signature: str) -> bool:
|
||||
message = f"{razorpay_order_id}|{razorpay_payment_id}".encode()
|
||||
expected = hmac.new(self.key_secret.encode(), message, hashlib.sha256).hexdigest()
|
||||
return hmac.compare_digest(expected, razorpay_signature)
|
||||
|
||||
def verify_webhook_signature(self, *, payload_body: bytes, signature: str | None) -> bool:
|
||||
if not signature or not self.webhook_secret:
|
||||
return False
|
||||
expected = hmac.new(self.webhook_secret.encode(), payload_body, hashlib.sha256).hexdigest()
|
||||
return hmac.compare_digest(expected, signature)
|
||||
|
||||
def create_refund(self, *, payment_id: str, amount: Decimal | float, currency: str = "INR", notes: dict[str, Any] | None = None) -> dict[str, Any]:
|
||||
return self.client.payment.refund(payment_id, data={
|
||||
"amount": self._to_subunit(amount, currency),
|
||||
"notes": notes or {},
|
||||
})
|
||||
|
||||
|
||||
_service: RazorpayService | None = None
|
||||
|
||||
def get_razorpay_service() -> RazorpayService:
|
||||
global _service
|
||||
if _service is None:
|
||||
_service = RazorpayService()
|
||||
return _service
|
||||
|
|
@ -1,3 +1 @@
|
|||
from .api import router
|
||||
|
||||
__all__ = ["router"]
|
||||
"""Feature package; import API modules explicitly at composition boundaries."""
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from uuid import UUID
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.features.content.db_schema import CONTENT_SCHEMA, resolve_content_schema
|
||||
|
||||
from .domain import FacetDefinitionRecord, FacetMappingRecord, ProjectionValue
|
||||
from .errors import FacetNotFoundError
|
||||
from .schema import FacetFilter, FacetValueMode, FilterLogic, SearchScope
|
||||
|
|
@ -50,9 +52,9 @@ def _flatten_projection_values(value: Any) -> list[str]:
|
|||
|
||||
|
||||
class SearchRepository:
|
||||
def __init__(self, session: AsyncSession, schema: str = "acu_content") -> None:
|
||||
def __init__(self, session: AsyncSession, schema: str = CONTENT_SCHEMA) -> None:
|
||||
self.session = session
|
||||
self.schema = schema
|
||||
self.schema = resolve_content_schema(schema)
|
||||
|
||||
async def list_facets(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
from .api import router
|
||||
__all__ = ["router"]
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
from __future__ import annotations
|
||||
import json
|
||||
from fastapi import APIRouter, Depends, Header, HTTPException, Request
|
||||
from app.features.payments import get_razorpay_service
|
||||
from .deps import get_webhook_service
|
||||
from .service import RazorpayWebhookService
|
||||
|
||||
router = APIRouter(prefix="/webhooks", tags=["Razorpay Webhooks"])
|
||||
|
||||
@router.post("/razorpay")
|
||||
async def razorpay_webhook_listener(request: Request, x_razorpay_signature: str | None = Header(default=None), service: RazorpayWebhookService = Depends(get_webhook_service)):
|
||||
body = await request.body()
|
||||
try:
|
||||
rzp = get_razorpay_service()
|
||||
except RuntimeError as exc:
|
||||
raise HTTPException(503, detail=str(exc)) from exc
|
||||
if not rzp.verify_webhook_signature(payload_body=body, signature=x_razorpay_signature):
|
||||
raise HTTPException(400, detail="Webhook verification failed: X-Razorpay-Signature is invalid.")
|
||||
try:
|
||||
event = json.loads(body.decode("utf-8"))
|
||||
except Exception as exc:
|
||||
raise HTTPException(400, detail="Malformed JSON body.") from exc
|
||||
return await service.handle(event)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.session import get_db_session
|
||||
from .repository import WebhookRepository
|
||||
from .service import RazorpayWebhookService
|
||||
|
||||
def get_webhook_repository(session: AsyncSession = Depends(get_db_session)) -> WebhookRepository:
|
||||
return WebhookRepository(session)
|
||||
|
||||
def get_webhook_service(repository: WebhookRepository = Depends(get_webhook_repository)) -> RazorpayWebhookService:
|
||||
return RazorpayWebhookService(repository.session)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from __future__ import annotations
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
class WebhookRepository:
|
||||
"""Feature persistence boundary over the shared four-schema AsyncSession."""
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from decimal import Decimal
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.enums import BillingPeriod, EntitlementStatus, PaymentStatus, SubscriptionStatus
|
||||
from app.db.models import AccessPlan, AccessPlanModule, Invoice, PaymentTransaction, UserEntitlement, UserSubscription
|
||||
|
||||
|
||||
class RazorpayWebhookService:
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
async def handle(self, event: dict) -> dict[str, str]:
|
||||
event_type = event.get("event")
|
||||
payload = event.get("payload") or {}
|
||||
if event_type == "payment.captured":
|
||||
return await self._payment_captured((payload.get("payment") or {}).get("entity") or {})
|
||||
if event_type in {"subscription.cancelled", "subscription.expired"}:
|
||||
return await self._subscription_ended(event_type, (payload.get("subscription") or {}).get("entity") or {})
|
||||
return {"status": "accepted"}
|
||||
|
||||
async def _payment_captured(self, payment: dict) -> dict[str, str]:
|
||||
order_id = payment.get("order_id")
|
||||
payment_id = payment.get("id")
|
||||
if not order_id or not payment_id:
|
||||
return {"status": "ignored", "reason": "No order_id/payment_id found in payment payload"}
|
||||
|
||||
existing = (await self.session.execute(
|
||||
select(PaymentTransaction.id).where(PaymentTransaction.gateway_transaction_id == payment_id)
|
||||
)).scalar_one_or_none()
|
||||
if existing:
|
||||
return {"status": "accepted"}
|
||||
|
||||
subs = (await self.session.execute(
|
||||
select(UserSubscription).where(
|
||||
UserSubscription.payment_reference == order_id,
|
||||
UserSubscription.status == SubscriptionStatus.PENDING,
|
||||
)
|
||||
)).scalars().all()
|
||||
if not subs:
|
||||
return {"status": "accepted"}
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
amount = Decimal(str(payment.get("amount", 0))) / Decimal("100")
|
||||
currency = str(payment.get("currency", "INR")).upper()
|
||||
main = subs[0]
|
||||
meta = main.metadata_json or {}
|
||||
transaction = PaymentTransaction(
|
||||
user_id=main.user_id,
|
||||
subscription_id=main.id,
|
||||
gateway_name="razorpay",
|
||||
gateway_transaction_id=payment_id,
|
||||
status=PaymentStatus.SUCCESS,
|
||||
amount=amount,
|
||||
currency=currency,
|
||||
)
|
||||
self.session.add(transaction)
|
||||
await self.session.flush()
|
||||
|
||||
for sub in subs:
|
||||
plan = None
|
||||
if sub.plan_id:
|
||||
plan = (await self.session.execute(select(AccessPlan).where(AccessPlan.id == sub.plan_id))).scalar_one_or_none()
|
||||
sub.status = SubscriptionStatus.ACTIVE
|
||||
sub.started_at = now
|
||||
sub.expires_at = now + timedelta(days=3650 if plan and plan.billing_period == BillingPeriod.LIFETIME else 365)
|
||||
module_ids = (await self.session.execute(
|
||||
select(AccessPlanModule.module_id).where(AccessPlanModule.plan_id == sub.plan_id)
|
||||
)).scalars().all()
|
||||
for module_id in module_ids:
|
||||
active = (await self.session.execute(
|
||||
select(UserEntitlement.id).where(
|
||||
UserEntitlement.user_id == sub.user_id,
|
||||
UserEntitlement.module_id == module_id,
|
||||
UserEntitlement.status == EntitlementStatus.ACTIVE,
|
||||
).limit(1)
|
||||
)).scalar_one_or_none()
|
||||
if active is None:
|
||||
self.session.add(UserEntitlement(
|
||||
user_id=sub.user_id,
|
||||
module_id=module_id,
|
||||
source_subscription_id=sub.id,
|
||||
source_plan_id=sub.plan_id,
|
||||
status=EntitlementStatus.ACTIVE,
|
||||
granted_at=now,
|
||||
grant_reason="subscription_purchase",
|
||||
expires_at=sub.expires_at,
|
||||
))
|
||||
|
||||
taxable = Decimal(str(meta.get("taxable_amount", "0")))
|
||||
gst = Decimal(str(meta.get("gst_amount", "0")))
|
||||
base = Decimal(str(meta.get("base_subtotal", amount)))
|
||||
discount = Decimal(str(meta.get("total_discounts", "0")))
|
||||
invoice_number = f"INV-{now.strftime('%Y%m%d')}-{payment_id[-6:].upper()}"
|
||||
self.session.add(Invoice(
|
||||
payment_transaction_id=transaction.id,
|
||||
invoice_number=invoice_number,
|
||||
billing_name=((payment.get("card") or {}).get("name") or payment.get("email") or "Customer"),
|
||||
billing_email=payment.get("email") or "unknown@example.invalid",
|
||||
billing_address="Recorded from Gateway Webhook",
|
||||
base_amount=base,
|
||||
discount_amount=discount,
|
||||
taxable_amount=taxable,
|
||||
gst_amount=gst,
|
||||
total_amount=amount,
|
||||
currency_code=currency,
|
||||
exchange_rate_to_inr=Decimal("1"),
|
||||
total_amount_inr=amount if currency == "INR" else None,
|
||||
))
|
||||
await self.session.commit()
|
||||
return {"status": "accepted"}
|
||||
|
||||
async def _subscription_ended(self, event_type: str, entity: dict) -> dict[str, str]:
|
||||
reference = entity.get("id")
|
||||
if not reference:
|
||||
return {"status": "accepted"}
|
||||
sub = (await self.session.execute(
|
||||
select(UserSubscription).where(UserSubscription.payment_reference == reference)
|
||||
)).scalar_one_or_none()
|
||||
if not sub:
|
||||
return {"status": "accepted"}
|
||||
now = datetime.now(timezone.utc)
|
||||
sub.status = SubscriptionStatus.CANCELLED if event_type == "subscription.cancelled" else SubscriptionStatus.EXPIRED
|
||||
sub.cancelled_at = now
|
||||
sub.cancellation_reason = "gateway_callback"
|
||||
ents = (await self.session.execute(
|
||||
select(UserEntitlement).where(
|
||||
UserEntitlement.source_subscription_id == sub.id,
|
||||
UserEntitlement.status == EntitlementStatus.ACTIVE,
|
||||
)
|
||||
)).scalars().all()
|
||||
for ent in ents:
|
||||
ent.status = EntitlementStatus.REVOKED
|
||||
ent.revoked_at = now
|
||||
ent.revoke_reason = "subscription_expired"
|
||||
await self.session.commit()
|
||||
return {"status": "accepted"}
|
||||
28
app/main.py
28
app/main.py
|
|
@ -9,10 +9,14 @@ from app.features.auth import router as auth_router
|
|||
from app.features.access import router as access_router
|
||||
|
||||
|
||||
# from app.features.content import router as contents_router
|
||||
# from app.features.search import router as global_search_router
|
||||
from app.features.content.api import router as contents_router
|
||||
from app.features.search.api import router as search_router
|
||||
from app.features.cart import router as cart_router
|
||||
from app.features.checkout import router as checkout_router
|
||||
from app.features.admin import router as admin_router
|
||||
from app.features.webhooks import router as webhooks_router
|
||||
|
||||
# from app.cache.health import router as cache_health_router
|
||||
from app.cache.health import router as cache_health_router
|
||||
from app.core.settings import settings
|
||||
from app.db.session import get_db_session
|
||||
from app.lifespan import lifespan
|
||||
|
|
@ -44,17 +48,13 @@ app.add_middleware(
|
|||
# Register API routers
|
||||
app.include_router(auth_router, prefix="/api")
|
||||
app.include_router(access_router, prefix="/api")
|
||||
# app.include_router(content_router, prefix="/api")
|
||||
# app.include_router(taxonomy_router, prefix="/api")
|
||||
# app.include_router(media_router, prefix="/api")
|
||||
# app.include_router(contents_router,prefix="/api")
|
||||
# app.include_router(search_router, prefix="/api")
|
||||
# app.include_router(cart_router)
|
||||
# app.include_router(checkout_router)
|
||||
# app.include_router(admin_router)
|
||||
# app.include_router(webhooks_router)
|
||||
# app.include_router(cache_health_router)
|
||||
# app.include_router(global_search_router, prefix="/api")
|
||||
app.include_router(contents_router,prefix="/api")
|
||||
app.include_router(cart_router, prefix="/api")
|
||||
app.include_router(checkout_router, prefix="/api")
|
||||
app.include_router(admin_router, prefix="/api")
|
||||
app.include_router(webhooks_router, prefix="/api")
|
||||
app.include_router(cache_health_router)
|
||||
app.include_router(search_router, prefix="/api")
|
||||
|
||||
|
||||
# @app.get("/")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,954 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Ren Mai",
|
||||
"code": "ren_mai",
|
||||
"alt_name": [
|
||||
"Conception Vessel",
|
||||
"Directing Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-6"
|
||||
}
|
||||
},
|
||||
"luo_point": {
|
||||
"type": "content_ref",
|
||||
"label": "CV-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-15"
|
||||
}
|
||||
},
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-1"
|
||||
}
|
||||
},
|
||||
"GV-28"
|
||||
],
|
||||
"xi_cleft_point": "",
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Qiao Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_qiao_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"face",
|
||||
"thorax",
|
||||
"abdomen",
|
||||
"genitals",
|
||||
"throat",
|
||||
"chest",
|
||||
"lungs",
|
||||
"endocrine",
|
||||
"urinary system",
|
||||
"digestive system"
|
||||
],
|
||||
"functions": [
|
||||
"Sea of Yin: influences the yin, essence and fluids",
|
||||
"Regulates female cycles, menstruation (irregular, leukorrhea), reproduction",
|
||||
"Effects male genitalia, hernia, sexual desire, impotence",
|
||||
"Gastrointestinal issues, digestion"
|
||||
],
|
||||
"pathway": "Originates at ming men and passes through the uterus and connects with CV-1. Then it follows the ren meridian up to CV-24. Along the path it connects internally with the SP, LV and KI meridians. At CV-24 a second branch rises upwards and encircles the mouth and then rises to the eyes at ST-1. A separate branch originates in the pelvic cavity and rises up along the back.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Ren Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "ren_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Du Mai",
|
||||
"code": "du_mai",
|
||||
"alt_name": [
|
||||
"Governing Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-3"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
"luo_point": "GV-1",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "CV-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": "",
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Qiao Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_qiao_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"Posterior midline especially spinal cord and brain",
|
||||
"nervous system",
|
||||
"muscular system"
|
||||
],
|
||||
"functions": [
|
||||
"Sea of Yang: effects all of the yang meridians",
|
||||
"Brain, marrow and/or spinal cord issues - pain, heaviness, stroke, psychological issues, etc.",
|
||||
"Other facial issues - headache, migraine, pain/swelling in the face/head"
|
||||
],
|
||||
"pathway": "Originates at ming men and descends to the perineum, emerging at CV-1/GV-1. Then it continues to GV-4 where it enters the kidneys. From the kidneys it travels up the interior of the spinal column to GV-12 where it goes laterally to BL-12 and then back to GV-13. From here it continues along the midline of the head to GV-16 where it enters the brain and ends at the frenulum of the upper lip (GV-28).",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Du Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "du_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "chong_mai",
|
||||
"name": "Chong Mai",
|
||||
"alt_name": [
|
||||
"Penetrating Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-11 thru KI-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-11"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "CV-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": "",
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Wei Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_wei_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"Abdomen",
|
||||
"thorax",
|
||||
"genitals",
|
||||
"Heart",
|
||||
"inner thigh",
|
||||
"reproductive system",
|
||||
"digestive system",
|
||||
"respiratory system"
|
||||
],
|
||||
"functions": [
|
||||
"Sea of Blood: menstrual and/or reproductive issues, irregular menstruation, infertility",
|
||||
"Physical and spiritual heart issues - Heart pain, depression",
|
||||
"Balances rebellious Qi - hiccups",
|
||||
"Abdominal stagnation",
|
||||
"Respiratory issues - SOB, asthma"
|
||||
],
|
||||
"pathway": "Originates in the ming men and passes through the uterus and down to CV-1. From here it emerges at ST-30 and continues upwards along the kidney meridian to KI-21. It then flows up the throat, encircles the mouth and continues up to the forehead. A second branch flows from CV-1 inside the spine to the BL-23 area. A third branch flows downwards towards the foot where it splits into 2 branches and follows the KI and SP meridians.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Chong Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "chong_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Dai Mai",
|
||||
"code": "dai_mai",
|
||||
"alt_name": [
|
||||
"Belt Vessel",
|
||||
"Girdle Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-5"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-26",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-26"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-27",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-27"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-28",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-28"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LR-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-13"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": "",
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Wei Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_wei_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"lateral sides of the lumbar area",
|
||||
"gastrointestinal system",
|
||||
"female reproductive system",
|
||||
"muscular skeletal system"
|
||||
],
|
||||
"functions": [
|
||||
"Issues in the middle aspect of the body - abdominal distention, lumbar weakness, muscular weakness in the lumbar and/or lower extremities",
|
||||
"Links the upper and lower halves of the body and helps to move Qi and Blood in the legs - weakness in the legs, walking problems"
|
||||
],
|
||||
"pathway": "Originates at LR-13, continues to and encircles GB-26 and LR-13 and then connects with GB-27 and GB-28.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Dai Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "dai_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yin Qiao Mai",
|
||||
"code": "yin_qiao_mai",
|
||||
"alt_name": [
|
||||
"Yin Heel Vessel",
|
||||
"Yin Motility Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-6"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-8"
|
||||
}
|
||||
},
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Ren Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "ren_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"medial aspect of lower extremities",
|
||||
"genitals",
|
||||
"abdomen",
|
||||
"eyes",
|
||||
"throat",
|
||||
"chest",
|
||||
"lungs",
|
||||
"nervous system",
|
||||
"muscular skeletal system",
|
||||
"digestive system",
|
||||
"respiratory system"
|
||||
],
|
||||
"functions": [
|
||||
"Controls the ascent of fluids and the descent of Qi",
|
||||
"Movement of the body, walking, cold and/or weakness in the lower limbs",
|
||||
"Digestive issues, abdominal issues",
|
||||
"Urogenital problems, retention of urine",
|
||||
"Respiratory issues",
|
||||
"Excessive sleepiness",
|
||||
"Eye issues",
|
||||
"Hot Flashes"
|
||||
],
|
||||
"pathway": "Originates at KI-2, travels upward to KI-6 and then to KI-8. It then continues up the medial aspect of the leg to the inguinal region where it enters the genitals. From the genitals it travels up the anterior abdomen and the chest to ST-12. From ST-12 it travels to ST-9 and along the cheek to BL-1 where it connects with the BL, GV and Yang Qiao Mai vessels. From there it rises upwards and enters the brain.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Qiao Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_qiao_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yang Qiao Mai",
|
||||
"code": "yang_qiao_mai",
|
||||
"alt_name": [
|
||||
"Yang Heel Vessel",
|
||||
"Yang Motility Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-3"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-59",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-59"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-61",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-61"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-20",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-20"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-29",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-29"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-15"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-59",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-59"
|
||||
}
|
||||
},
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Du Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "du_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"back",
|
||||
"neck",
|
||||
"eyes",
|
||||
"nervous system",
|
||||
"muscular skeletal system"
|
||||
],
|
||||
"functions": [
|
||||
"Issues of the eyes and/or face, eye pain (especially inner canthus), redness and/or swelling, headache",
|
||||
"Effects the lateral aspect of the lower limbs, numbness, weakness, spasms",
|
||||
"Excess Yang, insomnia"
|
||||
],
|
||||
"pathway": "Originates at BL-62 and travels behind the heel to BL-61. It continues up the calf to BL-59, up the lateral aspect of the leg to GB-29 and then up to the scapular region at SI-10. It continues to LI-15 and LI-16 and then travels to the face and connects with ST-4, ST-3, ST-1 and BL-1 where it meets with the BL, GV and Yin Qiao meridians. From here it travels over the head and terminates at GB-20.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Qiao Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_qiao_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yin Wei Mai",
|
||||
"code": "yin_wei_mai",
|
||||
"alt_name": [
|
||||
"Yin Linking Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LR-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-15"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "CV-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-22"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "CV-23",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-23"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-9"
|
||||
}
|
||||
},
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Chong Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "chong_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"Medial aspect of the lower limbs",
|
||||
"nervous system",
|
||||
"cardiovascular system",
|
||||
"muscular skeletal system",
|
||||
"digestive system"
|
||||
],
|
||||
"functions": [
|
||||
"Effects the balance of Yin and Yang",
|
||||
"Effects the Blood, Yin and Shen - blood circulation, heart pain, depression, blood deficiency headaches",
|
||||
"Pain in the chest, back, middle and/or lower jiaos - abdominal distention, stomach ache, nausea, rectal prolapse"
|
||||
],
|
||||
"pathway": "Originates at KI-9 and goes up along the medial aspect of the thigh into the abdomen where it enters the spleen meridian at SP-13, SP-15, SP-16. It continues up to LR-14, enters the abdomen and continues upwards through the chest and throat. It then meets the Ren Mai at CV-22 and CV-23.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Wei Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_wei_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yang Wei Mai",
|
||||
"code": "yang_wei_mai",
|
||||
"alt_name": [
|
||||
"Yang Linking Vessel"
|
||||
],
|
||||
"master_point": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-5"
|
||||
}
|
||||
},
|
||||
"coupled_point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
},
|
||||
"luo_point": "",
|
||||
"intersection_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-63",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-63"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-10"
|
||||
}
|
||||
},
|
||||
"GV-15",
|
||||
"GV-16",
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-13 thru GB-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-35",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-35"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SJ-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-15"
|
||||
}
|
||||
}
|
||||
],
|
||||
"xi_cleft_point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-35",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-35"
|
||||
}
|
||||
},
|
||||
"paired_meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Dai Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "dai_mai"
|
||||
}
|
||||
},
|
||||
"areas_of_effect": [
|
||||
"Sides of the body",
|
||||
"hips",
|
||||
"joints",
|
||||
"eyes",
|
||||
"ears",
|
||||
"muscular skeletal system",
|
||||
"immune system"
|
||||
],
|
||||
"functions": [
|
||||
"Shao Yang level illnesses - alternating fever and chills",
|
||||
"Pain and/or distention in the lumbar region"
|
||||
],
|
||||
"pathway": "Originates at BL-63 and ascends along the GB meridian up the leg and sides of the body passing through GB-35. It continues to BL-59 and up to the hip (GB-29). Then it continues along the lateral aspect of the body to LI-14 at the shoulder, to SJ-13, SJ-15 and to GB-21. It then travels down to SI-10, over to GV-15, GV-16 and then to GB-20. It continues downward along the GB meridian from GB-19 through to GB-13 where it ends.",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Wei Mai",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_wei_mai"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Ren Mai (Conception Vessel)",
|
||||
"code": "ren_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Ren Mai (Conception Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "ren_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Du Mai (Governing Vessel)",
|
||||
"code": "du_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Du Mai (Governing Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "du_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Chong Mai (Penetrating Vessel)",
|
||||
"code": "chong_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Chong Mai (Penetrating Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "chong_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Dai Mai (Belt Vessel)",
|
||||
"code": "dai_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Dai Mai (Belt Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "dai_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yin Qiao Mai (Yin Heel Vessel)",
|
||||
"code": "yin_qiao_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Qiao Mai (Yin Heel Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_qiao_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yang Qiao Mai (Yang Heel Vessel)",
|
||||
"code": "yang_qiao_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Qiao Mai (Yang Heel Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_qiao_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yin Wei Mai (Yin Linking Vessel)",
|
||||
"code": "yin_wei_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yin Wei Mai (Yin Linking Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_wei_mai"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Yang Wei Mai (Yang Linking Vessel)",
|
||||
"code": "yang_wei_mai",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yang Wei Mai (Yang Linking Vessel)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_wei_mai"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Points",
|
||||
"sort_order": 0,
|
||||
"content_count": 333,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "template_ref",
|
||||
"label": "Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0002"
|
||||
}
|
||||
},
|
||||
"code": "points"
|
||||
},
|
||||
{
|
||||
"name": "Meridians",
|
||||
"sort_order": 1,
|
||||
"content_count": 14,
|
||||
"content_label": "categories",
|
||||
"link": {
|
||||
"type": "template_ref",
|
||||
"label": "Meridians",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0004"
|
||||
}
|
||||
},
|
||||
"code": "meridians"
|
||||
},
|
||||
{
|
||||
"name": "E.O.V",
|
||||
"sort_order": 2,
|
||||
"content_count": 8,
|
||||
"content_label": "categories",
|
||||
"link": {
|
||||
"type": "template_ref",
|
||||
"label": "E.O.V",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0006"
|
||||
}
|
||||
},
|
||||
"code": "eov"
|
||||
},
|
||||
{
|
||||
"name": "Point Categories",
|
||||
"sort_order": 3,
|
||||
"content_count": 16,
|
||||
"content_label": "categories",
|
||||
"link": {
|
||||
"type": "template_ref",
|
||||
"label": "Point Categories",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0008"
|
||||
}
|
||||
},
|
||||
"code": "point_categories"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Lung",
|
||||
"code": "lung",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Lung",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "lung"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Large Intestine",
|
||||
"code": "large_intestine",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Large Intestine",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "large_intestine"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Stomach",
|
||||
"code": "stomach",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Stomach",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "stomach"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Spleen",
|
||||
"code": "spleen",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Spleen",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "spleen"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Heart",
|
||||
"code": "heart",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Heart",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "heart"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Small Intestine",
|
||||
"code": "small_intestine",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Small Intestine",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "small_intestine"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Bladder",
|
||||
"code": "bladder",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Bladder",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "bladder"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Kidney",
|
||||
"code": "kidney",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Kidney",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "kidney"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Pericardium",
|
||||
"code": "pericardium",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Pericardium",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "pericardium"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "San Jiao (Triple Warmer)",
|
||||
"code": "san_jiao",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "San Jiao (Triple Warmer)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "san_jiao"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Gall Bladder",
|
||||
"code": "gall_bladder",
|
||||
"content_count": 10,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Gall Bladder",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "gall_bladder"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Liver",
|
||||
"code": "liver",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Liver",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "liver"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Ren Channel",
|
||||
"code": "ren_channel",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Ren Channel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "ren_channel"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Du Channel",
|
||||
"code": "du_channel",
|
||||
"content_count": 5,
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Du Channel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "du_channel"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,282 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Back Shu Points",
|
||||
"code": "back-shu",
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-25",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-25"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-21"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-20",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-20"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-15"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-27",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-27"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-28",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-28"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-23",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-23"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-22"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-19",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-19"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-18",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-18"
|
||||
}
|
||||
}
|
||||
],
|
||||
"points": {
|
||||
"Lung": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-13"
|
||||
}
|
||||
},
|
||||
"Large Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-25",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-25"
|
||||
}
|
||||
},
|
||||
"Stomach": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-21"
|
||||
}
|
||||
},
|
||||
"Spleen": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-20",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-20"
|
||||
}
|
||||
},
|
||||
"Heart": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-15",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-15"
|
||||
}
|
||||
},
|
||||
"Small Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-27",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-27"
|
||||
}
|
||||
},
|
||||
"Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-28",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-28"
|
||||
}
|
||||
},
|
||||
"Kidney": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-23",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-23"
|
||||
}
|
||||
},
|
||||
"Pericardium": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-14"
|
||||
}
|
||||
},
|
||||
"Triple Energizer": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-22"
|
||||
}
|
||||
},
|
||||
"Gall Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-19",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-19"
|
||||
}
|
||||
},
|
||||
"Liver": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-18",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-18"
|
||||
}
|
||||
}
|
||||
},
|
||||
"functions": {
|
||||
"deficiency_and_cold_disorders": [
|
||||
"BL-13: cold Lung, Lung atrophy.",
|
||||
"BL-15: Heart qi deficiency in children, frightened and cautious with Heart deficiency.",
|
||||
"BL-19: deficiency taxation.",
|
||||
"BL-20: Spleen qi cold.",
|
||||
"BL-21: Stomach cold and feeble.",
|
||||
"BL-23: Kidney deficiency deafness, the five taxations and the seven injuries, taxation of the five zang, chronic cold of the water (Kidney) zang."
|
||||
],
|
||||
"excess_disorders": [
|
||||
"BL-13: fullness of the chest, difficult breathing on lying down.",
|
||||
"BL-14: oppression of the chest, pain of the chest & diaphragm due to accumulation of qi.",
|
||||
"BL-18: pain and distention of the lateral coastal region, hypogastric fullness and pain, fullness of the chest, much anger, mania-depression disorder, epilepsy."
|
||||
],
|
||||
"sensory_organ_disorders": [
|
||||
"BL-18 is much used for eye disorders.",
|
||||
"BL-23 is much used for ear disorders.",
|
||||
"BL-15 is much used for lack of strength in the root of the tongue."
|
||||
]
|
||||
},
|
||||
"clinical_application": {
|
||||
"diagnosis": [
|
||||
"Often spontaneously tender and/or sensitive upon pressure in disorders of the pertaining Zangfu-Organ."
|
||||
],
|
||||
"therapy": [
|
||||
"Mainly used for disorders of the corresponding Zangfu Organ.",
|
||||
"These points have a tonifying effect for chronic disorders and deficiency syndromes, but can also be used for acute disorders of their pertaining Zangfu-Organ.",
|
||||
"For disorders of the sensory organs, use the Back-Shu point of the pertaining Zangfu-Organ.",
|
||||
"Example: for disorders of the eyes, needle the Back-Shu point of the Liver BL-18.",
|
||||
"For excess syndromes, the Back-Shu points can be needled with reducing needling techniques; for deficiency syndromes, tonifying needling techniques should be applied.",
|
||||
"When Cold signs are present, moxibustion can also be used.",
|
||||
"The needles should not be retained longer than 10 minutes, longer needle retention can have a sedating effect and lead to tiredness."
|
||||
]
|
||||
},
|
||||
"title": "The Back-Shu points of the twelve Zangfu",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Back Shu Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0012",
|
||||
"source_code": "back-shu"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "The Confluent Points",
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SJ-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
}
|
||||
],
|
||||
"confluent_points": [
|
||||
{
|
||||
"point_name": "LU-7 (the Conception vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "conception_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "ren_mai"
|
||||
}
|
||||
},
|
||||
"functions": "The Conception vessel ascends along the anterior midline of the body and is closely related to the uterus and the genitourinary organs. By opening and regulating the flow of qi in the Conception vessel, LU-7 is able to treat retention of the lochia and dead fetus, pain of the genitals and urinary disorders."
|
||||
},
|
||||
{
|
||||
"point_name": "KI-6 (Yin Motility vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-6"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "yin_motility_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_qiao_mai"
|
||||
}
|
||||
},
|
||||
"functions": "The Yin Motility vessel traverses the medial aspect of the leg, throat, brain and inner canthus. KI-6 is important for chronic throat disorders, eye disorders, day-time epilepsy, and tightness and contraction of the inner aspect of the leg."
|
||||
},
|
||||
{
|
||||
"point_name": "PC-6 (The Yin Linking vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "yin_linking_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yin_wei_mai"
|
||||
}
|
||||
},
|
||||
"functions": "According to the Classic of Difficulties, when the Yin Linking vessel is diseased, Heart pain results. PC-6 is a major point for treatment of Heart pain, chest pain, and pain of the lateral costal region."
|
||||
},
|
||||
{
|
||||
"point_name": "SP-4 (The Penetrating vessel) ",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "penetrating_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "chong_mai"
|
||||
}
|
||||
},
|
||||
"functions": "SP-4 treats counter flow qi, abdominal urgency, abdominal distention and pain, rebellion of Stomach qi with vomiting and sudden turmoil disorder. It is also indicated for facial edema."
|
||||
},
|
||||
{
|
||||
"point_name": "SI-3 (the Governing vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-3"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "governing_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "du_mai"
|
||||
}
|
||||
},
|
||||
"functions": "SI-3 is an essential distal point for occipital headache, stiffness and pain of the neck, scapula and spine. It helps dispel febrile disease, malaria, exterior wind-cold or wind-heat, and is important for epilepsy."
|
||||
},
|
||||
{
|
||||
"point_name": "BL-62 (the Yang Motility vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "yang_motility_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_qiao_mai"
|
||||
}
|
||||
},
|
||||
"functions": "BL-62 treats exterior wind with stiff neck and headache, interior wind affecting the brain, lockjaw, opisthotonos, upward staring eyes, deviation of the mouth and eyes, wind-stroke, hemiplegia, epilepsy and insomnia."
|
||||
},
|
||||
{
|
||||
"point_name": "SJ-5 (the Yang Linking vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-5"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "yang_linking_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "yang_wei_mai"
|
||||
}
|
||||
},
|
||||
"functions": "SJ-5 links all yang channels and dispels pathogenic factors from the exterior. It is indicated for temporal, frontal, occipital and vertex headaches."
|
||||
},
|
||||
{
|
||||
"point_name": "GB-41 (the Girdling vessel)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
},
|
||||
"vessel": {
|
||||
"type": "content_ref",
|
||||
"label": "girdling_vessel",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0007",
|
||||
"source_code": "dai_mai"
|
||||
}
|
||||
},
|
||||
"functions": "GB-41 is indicated for breast distention and pain, breast abscess, menstrual disorders and inhibited menstruation, especially where Liver qi stagnation affects the menstrual cycle."
|
||||
}
|
||||
],
|
||||
"description": "The Confluent Points shows the opening points of the eight extraordinary vessels. Activate their respective extraordinary channel",
|
||||
"title": "Confluent Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "The Confluent Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0017",
|
||||
"source_code": "confluent"
|
||||
}
|
||||
},
|
||||
"code": "confluent"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Entry-Exit Points",
|
||||
"code": "entry_exit_points",
|
||||
"description": [],
|
||||
"point_codes": [],
|
||||
"entry_exit_points": {
|
||||
"Lung": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Large Intestine": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-20",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-20"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Stomach": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-11"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-42",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-42"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Spleen": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-21"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Heart": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-9"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Small Intestine": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-19",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-19"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Bladder": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-67",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-67"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Kidney": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-22"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pericardium": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Triple Energizer": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-22"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Gall Bladder": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Liver": {
|
||||
"Entry": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-1"
|
||||
}
|
||||
},
|
||||
"Exit": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-14"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"clinical_significance": {
|
||||
"entry_exit_blocks": "When energy flow is disrupted between channels, it can cause an excess (stagnation) at the exit point and a deficiency at the next channel's entry point, which can be detected via pulse diagnosis.",
|
||||
"treatment": "Practitioners use these points to unblock the flow of Qi, often treating them to restore flow when meridians are obstructed, which can cause symptoms such as pain, emotional frustration, or fatigue."
|
||||
},
|
||||
"title": "Entry/Exit Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Entry-Exit Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0023",
|
||||
"source_code": "entry_exit_points"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,685 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "The five shu points",
|
||||
"code": "five_shu",
|
||||
"point_codes": [],
|
||||
"description": [
|
||||
"The five Shu-points (transporting points) are the Jing-well, Ying-spring, Shu-stream, Jing-river and He-sea points of the twelve primary channels.",
|
||||
"All are located at or distal to the elbow and knee joints.",
|
||||
"They play an important role in acupuncture prescriptions due to the dynamic change in the quality of Qi flowing through these channel sections."
|
||||
],
|
||||
"phases_of_yin_channels": {
|
||||
"Jing-Well": "Wood",
|
||||
"Ying-Spring": "Fire",
|
||||
"Shu-Stream": "Earth",
|
||||
"Jing-River": "Metal",
|
||||
"He-Sea": "Water"
|
||||
},
|
||||
"points_of_yin_channels": {
|
||||
"Lung": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-11"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-10"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-9"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-8"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Spleen": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-5"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-9"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Heart": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-9"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-8"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-7"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-4"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Kidney": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-7"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pericardium": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-9"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-7"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-5"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Liver": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-4"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-8"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"phases_of_yang_channels": {
|
||||
"Jing-Well": "Wood",
|
||||
"Ying-Spring": "Fire",
|
||||
"Shu-Stream": "Earth",
|
||||
"Jing-River": "Metal",
|
||||
"He-Sea": "Water"
|
||||
},
|
||||
"points_of_yang_channels": {
|
||||
"Large Intestine": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-5"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-11"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Stomach": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-45",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-45"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-44",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-44"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-43",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-43"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-41"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Small Intestine": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-5"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Bladder": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-67",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-67"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-66",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-66"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-65",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-65"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-60",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-60"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-40"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Triple Warmer": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-1"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-2"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-3"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-6"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Gall Bladder": {
|
||||
"Jing-Well": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-44",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-44"
|
||||
}
|
||||
},
|
||||
"Ying-Spring": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-43",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-43"
|
||||
}
|
||||
},
|
||||
"Shu-Stream": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
},
|
||||
"Jing-River": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-38",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-38"
|
||||
}
|
||||
},
|
||||
"He-Sea": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"clinical_application": {
|
||||
"according_to_classic_of_difficulties": [
|
||||
"Jing-well points for fullness below the Heart.",
|
||||
"Ying-spring points for heat in the body.",
|
||||
"Shu-stream points for heaviness of the body and pain of the joints.",
|
||||
"Jing-river points for cough and dyspnea, chills and fever.",
|
||||
"He-sea points for counter flow qi and diarrhea."
|
||||
],
|
||||
"according_to_seasons": [],
|
||||
"according_to_symptomatology": []
|
||||
},
|
||||
"jing_well_points": {
|
||||
"actions": [
|
||||
"Clear Heat, restore consciousness, eliminate Heat and excess from the upper end of the channel.",
|
||||
"Treat fullness and Cold below the Heart.",
|
||||
"Treat disorders of the spirit (Shen) for psychological disorders."
|
||||
],
|
||||
"examples": [
|
||||
"LU-11 for acute sore throat",
|
||||
"KI-1 for spasms and unconsciousness",
|
||||
"HT-9 for collapse",
|
||||
"SP-1 for uterine bleeding"
|
||||
]
|
||||
},
|
||||
"ying_spring_points": {
|
||||
"actions": [
|
||||
"Eliminate both external and internal pathogenic factors.",
|
||||
"Clear Heat from the pertaining Zangfu-Organ and channel, especially in the upper half of the body."
|
||||
],
|
||||
"examples": [
|
||||
"LU-10 for acute inflammations of the throat",
|
||||
"ST-44 for acute frontal headaches",
|
||||
"LR-2 for severe temporal headaches"
|
||||
]
|
||||
},
|
||||
"shu_stream_points": {
|
||||
"actions": [
|
||||
"Strengthen Defensive Qi (Wei qi).",
|
||||
"Eliminate pathogenic factors from the respective channel."
|
||||
],
|
||||
"indications": [
|
||||
"Bi-syndromes of the joints.",
|
||||
"Heaviness of the body.",
|
||||
"Shaoyang syndrome with intermittent symptoms."
|
||||
]
|
||||
},
|
||||
"jing_river_points": {
|
||||
"actions": [
|
||||
"Divert external pathogenic factors away from joints, bones and tendons towards the Exterior."
|
||||
],
|
||||
"indications": [
|
||||
"Dyspnea.",
|
||||
"Disorders of the throat.",
|
||||
"Cough.",
|
||||
"Voice disorders.",
|
||||
"Alternating fever and chills.",
|
||||
"Painful joint and tendon disorders."
|
||||
]
|
||||
},
|
||||
"he_sea_points": {
|
||||
"actions": [
|
||||
"Descend counter-flow Qi and stop diarrhea.",
|
||||
"Treat diseases of the fu-Organs."
|
||||
],
|
||||
"indications": [
|
||||
"Gastro-intestinal disorders with vomiting and diarrhea.",
|
||||
"Skin diseases such as those treated with LI-11 and BL-40."
|
||||
]
|
||||
},
|
||||
"title": "Five Shu Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "The five shu points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0014",
|
||||
"source_code": "five_shu"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Points of the Four Seas",
|
||||
"code": "points_of_the_four_seas",
|
||||
"description": [
|
||||
"These points have a particular, supportive effect on their respective Sea.",
|
||||
"The Spiritual Pivot describes four seas in the human body: the sea of qi, the sea of blood, the sea of water and grain, and the sea of marrow."
|
||||
],
|
||||
"four_seas": [
|
||||
{
|
||||
"name": "The Sea of Qi",
|
||||
"points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-17"
|
||||
}
|
||||
},
|
||||
"DU-15",
|
||||
"DU-14"
|
||||
],
|
||||
"excess": [
|
||||
"fullness in the chest",
|
||||
"urgent breathing",
|
||||
"red complexion"
|
||||
],
|
||||
"deficiency": [
|
||||
"scanty energy",
|
||||
"insufficient for speech"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The sea of blood",
|
||||
"points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-11"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-37",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-37"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-39"
|
||||
}
|
||||
}
|
||||
],
|
||||
"excess": [
|
||||
"sensation as if the body were big",
|
||||
"feels disquiet",
|
||||
"does not know what disease there is"
|
||||
],
|
||||
"deficiency": [
|
||||
"sensation of the body being small",
|
||||
"feels reduced",
|
||||
"does not know what could be the illness"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The sea of water and grain",
|
||||
"points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-30",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-30"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
}
|
||||
],
|
||||
"excess": [
|
||||
"abdominal fullness"
|
||||
],
|
||||
"deficiency": [
|
||||
"hunger with inability to eat"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The sea of marrow",
|
||||
"points": [
|
||||
"DU-20",
|
||||
"DU-16"
|
||||
],
|
||||
"excess": [
|
||||
"lightness of the body",
|
||||
"much strength",
|
||||
"self exceeds the normal level"
|
||||
],
|
||||
"deficiency": [
|
||||
"whirling sensation of the brain",
|
||||
"dizziness",
|
||||
"tinnitus",
|
||||
"pain of the lower legs",
|
||||
"impairment of vision",
|
||||
"indolence",
|
||||
"desire to sleep"
|
||||
]
|
||||
}
|
||||
],
|
||||
"title": "Points of the Four Seas",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Points of the Four Seas",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0021",
|
||||
"source_code": "points_of_the_four_seas"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Front Mu Points",
|
||||
"code": "front_mu",
|
||||
"point_codes": [],
|
||||
"front_mu_points": {
|
||||
"Lung": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-1"
|
||||
}
|
||||
},
|
||||
"Large Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-25",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-25"
|
||||
}
|
||||
},
|
||||
"Stomach": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-12"
|
||||
}
|
||||
},
|
||||
"Spleen": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-13"
|
||||
}
|
||||
},
|
||||
"Heart": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-14"
|
||||
}
|
||||
},
|
||||
"Small Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-4"
|
||||
}
|
||||
},
|
||||
"Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-3"
|
||||
}
|
||||
},
|
||||
"Kidney": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-25",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-25"
|
||||
}
|
||||
},
|
||||
"Pericardium": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-17"
|
||||
}
|
||||
},
|
||||
"Triple Energizer": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-5"
|
||||
}
|
||||
},
|
||||
"Gall Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-24",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-24"
|
||||
}
|
||||
},
|
||||
"Liver": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-14",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-14"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": [
|
||||
"The Front-mu points are located on the thorax and abdomen in the area of their pertaining Zangfu-Organs.",
|
||||
"All lie on the anterior of the body except GB-25 which lies at the free end of the twelfth rib.",
|
||||
"Of the twelve points, only three lie on the channel corresponding to their related zang or fu (LU-1 of the Lung, LR-14 of the Liver, and GB-24 of the Gall Bladder).",
|
||||
"The term 'Mu' means to gather or to collect, and the Front-Mu points are where the Qi of the Zangfu gathers and concentrates on the anterior surface of the body.",
|
||||
"They are likely to become tender in response to disharmony of their respective zang and fu and can contribute towards diagnosis.",
|
||||
"They are commonly combined in treatment, for example REN-14 with BL-15 for Heart patterns, and BL-28 with REN-3 for Bladder disorders."
|
||||
],
|
||||
"clinical_application": {
|
||||
"diagnosis": [
|
||||
"Often spontaneously tender or sensitive upon pressure in disorders of the pertaining Zangfu-Organ."
|
||||
],
|
||||
"therapy": [
|
||||
"Used to regulate the pertaining Zangfu-Organ.",
|
||||
"For excess syndromes use reducing needling techniques.",
|
||||
"For deficiency syndromes use tonifying methods.",
|
||||
"Commonly used point combinations: Shu-Mu method.",
|
||||
"For disorders of the fu-Organs: simultaneous needling of the lower He-Sea point and the Front-Mu point of the affected fu-Organ."
|
||||
]
|
||||
},
|
||||
"title": "Front Mu Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Front Mu Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0013",
|
||||
"source_code": "front_mu"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Gao Wu Command Points",
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
}
|
||||
],
|
||||
"gao_wu_command_points": [
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
"clinical_application": "for all disorders of the abdomen"
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
},
|
||||
"clinical_application": "for disorders of the face and mouth"
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"clinical_application": "for disorders of the occiput"
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-40"
|
||||
}
|
||||
},
|
||||
"clinical_application": "for disorders of the back and lumbar region"
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"clinical_application": "for disorders of the thorax"
|
||||
},
|
||||
{
|
||||
"code": "DU-26",
|
||||
"clinical_application": "for restoring consciousness"
|
||||
}
|
||||
],
|
||||
"title": "Gao Wu Command Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Gao Wu Command Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0019",
|
||||
"source_code": "gao_wu_command"
|
||||
}
|
||||
},
|
||||
"code": "gao_wu_command"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Ghost Points",
|
||||
"description": "The thirteen ghost points were listed in the Thousand Ducat Formulas by the 7th century physician Sun Si-Miao for the treatment of mania disorder and epilepsy.",
|
||||
"point_codes": [],
|
||||
"ghost_points": [
|
||||
{
|
||||
"point_name": "Guigong (Ghost Palace)",
|
||||
"point_code": "DU-26"
|
||||
},
|
||||
{
|
||||
"point_name": "Guizhen (Ghost Pillow)",
|
||||
"point_code": "DU-16"
|
||||
},
|
||||
{
|
||||
"point_name": "Guitang (Ghost Hall)",
|
||||
"point_code": "DU-23"
|
||||
},
|
||||
{
|
||||
"point_name": "Guishi (Ghost Market)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-24",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-24"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guixin (Ghost Faith)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-11"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guitui (Ghost Leg)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-11"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guichuang (Ghost's Bed)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-6"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guilei (Ghost Fortress)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guixin (Ghost Heart)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-7"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guicu (Ghost Cave)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guilu (Ghost Path)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"point_name": "Guifeng (Ghost Seal)",
|
||||
"point_code": "Haiquan (Extra)"
|
||||
},
|
||||
{
|
||||
"point_name": "Guicang (Ghost Store)",
|
||||
"point_code": {
|
||||
"type": "content_ref",
|
||||
"label": "Yumentou (Extra) in women / Yinxiafeng (Extra) in men (corresponding to REN-1)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"historical_notes": [
|
||||
"Some authorities considered that Guixin was LU-9 rather than PC-7.",
|
||||
"Some authorities considered that Guilu was PC-5 or PC-8 rather than BL-62."
|
||||
],
|
||||
"gao_wu_alternative_list": {
|
||||
"included": [
|
||||
"DU-24",
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LR-2",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"omitted": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-62",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-62"
|
||||
}
|
||||
},
|
||||
"DU-23",
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-11"
|
||||
}
|
||||
},
|
||||
"Yumentou/Yinxiafeng"
|
||||
]
|
||||
},
|
||||
"title": "Ghost Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Ghost Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0022",
|
||||
"source_code": "ghost"
|
||||
}
|
||||
},
|
||||
"code": "ghost"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Horary Points (Ben points)",
|
||||
"code": "horary",
|
||||
"point_codes": [],
|
||||
"description": [
|
||||
"The shu points having the same element of their pertaining organ's element are called as Horary points.",
|
||||
"Such as the wood point on the wood channel, or the fire point on the fire channel, the water point on the water channel, the earth point on the earth channel, the metal point on the metal channel.",
|
||||
"For example, Lung channel pertains to metal element and on Lung channel LU-8 is metal point as such LU-8 is the Horary point of the Lung channel."
|
||||
],
|
||||
"horary_points": {
|
||||
"Lung": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-8"
|
||||
}
|
||||
},
|
||||
"Large Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-1"
|
||||
}
|
||||
},
|
||||
"Stomach": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
"Spleen": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-3"
|
||||
}
|
||||
},
|
||||
"Heart": "H-8",
|
||||
"Small Intestine": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-5"
|
||||
}
|
||||
},
|
||||
"Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-66",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-66"
|
||||
}
|
||||
},
|
||||
"Kidney": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-10"
|
||||
}
|
||||
},
|
||||
"Pericardium": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
},
|
||||
"Triple Energizer": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-6"
|
||||
}
|
||||
},
|
||||
"Gall Bladder": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-41",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-41"
|
||||
}
|
||||
},
|
||||
"Liver": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": "Horary Points (Ben points)",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Horary Points (Ben points)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0015",
|
||||
"source_code": "horary"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Hui-Meeting Points",
|
||||
"code": "hui_meeting",
|
||||
"description": [
|
||||
"The Qi of a particular tissue, Organ system or substance gathers at the hui-meeting points and can be influenced through these points."
|
||||
],
|
||||
"points": [
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-13"
|
||||
}
|
||||
},
|
||||
"category": "Zang",
|
||||
"description": "LR-13 is both the hui-meeting point of the zang and the front-mu point of the Spleen. The essence of the five zang is all transported from the Spleen. LR-13 is therefore an important point to tonify the Spleen itself as well as all the zang and the body as a whole."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-12"
|
||||
}
|
||||
},
|
||||
"category": "Fu",
|
||||
"description": "REN-12 is both the hui-meeting point of the fu and the front-mu point of the Stomach. As the origin of the post-natal qi, the Stomach and Spleen play a central role among the Zangfu, transforming and distributing the essence of food and drink throughout the body."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "REN-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-17"
|
||||
}
|
||||
},
|
||||
"category": "Qi",
|
||||
"description": "REN-17 is the hui-meeting point of the qi and is also known as Upper Sea of Qi. It strongly influences gathering (Zong) qi and regulates Lung functions of respiration and speech as well as the Heart function of governing blood and vessels."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-17"
|
||||
}
|
||||
},
|
||||
"category": "Blood",
|
||||
"description": "BL-17 is the hui-meeting point of blood and is the single most important acupuncture point for treatment of disorders arising from blood heat, blood stasis or blood deficiency."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
},
|
||||
"category": "Sinew",
|
||||
"description": "GB-34 is the hui-meeting point of the sinews and influences sinews throughout the body. It is used for contraction of sinews, stiffness of muscles and joints, knee pain, hemiplegia, atrophy disorder and painful obstruction."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-9"
|
||||
}
|
||||
},
|
||||
"category": "Vessel",
|
||||
"description": "LU-9 is the hui-meeting point of the pulse and vessels. It harmonizes the relationship between gathering qi and blood circulation and is indicated for blood stasis and disorders of blood vessels."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-11"
|
||||
}
|
||||
},
|
||||
"category": "Bone",
|
||||
"description": "BL-11 is the hui-meeting point of bone and is indicated for bone diseases, rigidity and pain of the neck, spine and lumbar region, and bony painful obstruction."
|
||||
},
|
||||
{
|
||||
"name": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-39"
|
||||
}
|
||||
},
|
||||
"category": "Marrow",
|
||||
"description": "GB-39 is the hui-meeting point of marrow. It benefits the sinews and bones and is indicated for weakness, flaccidity, contraction and pain of the limbs."
|
||||
}
|
||||
],
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LR-13",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-12"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LU-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-11",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-11"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-39"
|
||||
}
|
||||
}
|
||||
],
|
||||
"title": "Hui-Meeting Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Hui-Meeting Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0016",
|
||||
"source_code": "hui_meeting"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Yuan Source",
|
||||
"code": "yuan_source",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yuan Source",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0009",
|
||||
"source_code": "yuan_source"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Luo Connecting",
|
||||
"code": "luo_connecting",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Luo Connecting",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0010",
|
||||
"source_code": "luo_connecting"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Xi Cleft",
|
||||
"code": "xi_cleft",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Xi Cleft",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0011",
|
||||
"source_code": "xi_cleft"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Back-Shu",
|
||||
"code": "back-shu",
|
||||
"content_count": 12,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Back-Shu",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0012",
|
||||
"source_code": "back-shu"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Front-Mu",
|
||||
"code": "front_mu",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Front-Mu",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0013",
|
||||
"source_code": "front_mu"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Five Phase (Five Shu)",
|
||||
"code": "five_phase",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Five Phase (Five Shu)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0014",
|
||||
"source_code": "five_shu"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Horary (Ben)",
|
||||
"code": "horary",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Horary (Ben)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0015",
|
||||
"source_code": "horary"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Hui-Meeting",
|
||||
"code": "hui-meeting",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Hui-Meeting",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0016",
|
||||
"source_code": "hui_meeting"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Confluent",
|
||||
"code": "confluent",
|
||||
"content_count": 8,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Confluent",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0017",
|
||||
"source_code": "confluent"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Lower He-Sea",
|
||||
"code": "lower_he-sea",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Lower He-Sea",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0018",
|
||||
"source_code": "lower_he_sea_points"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Gao Wu Command",
|
||||
"code": "gao_wu_command",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Gao Wu Command",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0019",
|
||||
"source_code": "gao_wu_command"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Window Of Heaven",
|
||||
"code": "window_of_heaven",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Window Of Heaven",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0020",
|
||||
"source_code": "window_of_heaven_points"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Points of Four Seas",
|
||||
"code": "four_seas",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Points of Four Seas",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0021",
|
||||
"source_code": "points_of_the_four_seas"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Ghost Points",
|
||||
"code": "ghost",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Ghost Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0022",
|
||||
"source_code": "ghost"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Entry Exit Points",
|
||||
"code": "entry_exits",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Entry Exit Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0023",
|
||||
"source_code": "entry_exit_points"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Nine Needles for returning yang",
|
||||
"code": "returning_the_yang",
|
||||
"content_count": 10,
|
||||
"content_label": "points",
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Nine Needles for returning yang",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0024",
|
||||
"source_code": "nine_needles_for_returning_the_yang"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Lower He-Sea Points",
|
||||
"code": "lower_he_sea_points",
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-37",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-37"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-39"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-40"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-39"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "",
|
||||
"lower_he_sea_points": [
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Stomach",
|
||||
"indication": [
|
||||
"loss of appetite",
|
||||
"epigastric pain and fullness",
|
||||
"acid reflux",
|
||||
"abdominal pain",
|
||||
"constipation",
|
||||
"diarrhea"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-37",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-37"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Large Intestine",
|
||||
"indication": [
|
||||
"appendicitis",
|
||||
"diarrhea"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-39"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Small Intestine",
|
||||
"indication": [
|
||||
"diarrhea",
|
||||
"abdominal pain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-34"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Gall Bladder",
|
||||
"indication": [
|
||||
"cholecystitis",
|
||||
"vomiting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-40"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Bladder",
|
||||
"indication": [
|
||||
"urinary incontinence",
|
||||
"urinary retention"
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-39",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-39"
|
||||
}
|
||||
},
|
||||
"title": "Lower He-Sea point of the Triple Energizer",
|
||||
"indication": [
|
||||
"urinary incontinence",
|
||||
"urinary retention"
|
||||
]
|
||||
}
|
||||
],
|
||||
"title": "Lower He-Sea Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Lower He-Sea Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0018",
|
||||
"source_code": "lower_he_sea_points"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,383 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "The Luo-connecting points of the channels",
|
||||
"code": "luo_connecting",
|
||||
"title": "The Luo-connecting points of the channels",
|
||||
"point_codes": [],
|
||||
"major_luo_point_of_the_spleen": [
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-21",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-21"
|
||||
}
|
||||
},
|
||||
"description": "SP Great Luo separates at SP 21, spreads through the chest and the lateral costal region."
|
||||
}
|
||||
],
|
||||
"major_luo_point_of_the_stomach": [
|
||||
{
|
||||
"point": "Xu Li",
|
||||
"description": "The Major LUO Collateral of the Stomach penetrates the diaphragm, connect with the Lung & Heart (at CV-17), and exit below the breast (ST-18). It is where Zong (Gathering/Chest) Qi is located. So, for irregular heartbeat, palpitations, chest pain and short of breath, using ST-18 & CV-17 works quite well."
|
||||
}
|
||||
],
|
||||
"treating_disorders_of_their_interiorly_exteriorly_related_channel_or_zangfu": [
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"description": "Treatment of headache, pain of the neck and nape, and wind disorders affecting the head via the Large Intestine channel relationship."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-6"
|
||||
}
|
||||
},
|
||||
"description": "Treatment of acute edema when external wind disrupts Lung regulation of water passages."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-40"
|
||||
}
|
||||
},
|
||||
"description": "Assists transformation of phlegm caused by impaired Spleen transportation and transformation."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"description": "Harmonizes the Stomach and intestines and treats upper and lower abdominal pain."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-7"
|
||||
}
|
||||
},
|
||||
"description": "Regulates and calms the Heart spirit and treats psycho-emotional disorders."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-58",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-58"
|
||||
}
|
||||
},
|
||||
"description": "Treats Kidney deficiency, lower body coldness and weakness, lumbar pain, headache, dizziness and rising yang."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"description": "Treats nausea and vomiting and disorders of the middle Jiao."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-37",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-37"
|
||||
}
|
||||
},
|
||||
"description": "Used in the treatment of eye disorders due to Liver disharmony."
|
||||
}
|
||||
],
|
||||
"treating_disorders_in_regions_reached_b_the_luo_connecting_channel": [
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"description": "Treats thumb disorders."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-6"
|
||||
}
|
||||
},
|
||||
"description": "Treats ear disorders such as tinnitus and deafness."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-40"
|
||||
}
|
||||
},
|
||||
"description": "Treats throat swelling, throat pain, sudden loss of voice and plum-stone throat."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"description": "Treats pain and disharmony of the abdomen, intestines and Stomach."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-5"
|
||||
}
|
||||
},
|
||||
"description": "Treats tongue stiffness and speech impairment, especially after wind-stroke."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-4"
|
||||
}
|
||||
},
|
||||
"description": "Treats palpitations, restlessness, agitation, fullness and vomiting."
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-5"
|
||||
}
|
||||
},
|
||||
"description": "Treats disorders affecting the genital region."
|
||||
}
|
||||
],
|
||||
"treating_psycho_emotional_disorders": [
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-7"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"poor memory",
|
||||
"propensity to laughter"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-40",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-40"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"mania-depression",
|
||||
"mad laughter",
|
||||
"great happiness",
|
||||
"desires to ascend to high places and sing",
|
||||
"discards clothing and runs around",
|
||||
"seeing ghosts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-4"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"mania-depression disorder",
|
||||
"manic raving",
|
||||
"insomnia and restlessness",
|
||||
"Gall Bladder deficiency",
|
||||
"much sighing"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-5"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"frequent yawning and groaning with sadness",
|
||||
"vexation and anger",
|
||||
"sadness and fright",
|
||||
"frequent agitation with burning sensation of the Heart",
|
||||
"depressive disorder"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-7"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"mania-depression",
|
||||
"fear and fright",
|
||||
"sadness and anxiety",
|
||||
"restless zang disorder"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-4"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"palpitations",
|
||||
"restlessness",
|
||||
"dementia",
|
||||
"mental retardation",
|
||||
"somnolence",
|
||||
"propensity to anger",
|
||||
"fright",
|
||||
"fear and unhappiness",
|
||||
"desire to close the door and remain at home"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-6"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"insomnia",
|
||||
"the five types of epilepsy",
|
||||
"mania",
|
||||
"poor memory",
|
||||
"apprehensiveness",
|
||||
"fear and fright",
|
||||
"sadness",
|
||||
"loss of memory following wind stroke"
|
||||
]
|
||||
},
|
||||
{
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-5"
|
||||
}
|
||||
},
|
||||
"indications": [
|
||||
"plum-stone sensation in the throat",
|
||||
"depression",
|
||||
"fright palpitations",
|
||||
"fear and fright",
|
||||
"worried oppression"
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "The Luo-connecting points of the channels",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0010",
|
||||
"source_code": "luo_connecting"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "The 9 Needles for Returning the Yang",
|
||||
"code": "nine_needles_for_returning_the_yang",
|
||||
"description": [
|
||||
"The Song of the Nine Needles for Returning the Yang,",
|
||||
"a chapter in the Glorious Anthology of Acupuncture and Moxibustion,",
|
||||
"lists nine points for the treatment of collapse of yang characterized by loss of consciousness,",
|
||||
"aversion to cold, cold counter-flow of the limbs, purple lips and related symptoms."
|
||||
],
|
||||
"points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-30",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-30"
|
||||
}
|
||||
},
|
||||
"DU-15",
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-36"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "KI-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "PC-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "GB-30",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-30"
|
||||
}
|
||||
},
|
||||
"DU-15",
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-12",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"title": "The 9 Needles for Returning the Yang",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "The 9 Needles for Returning the Yang",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0024",
|
||||
"source_code": "nine_needles_for_returning_the_yang"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Window of Heaven Points",
|
||||
"code": "window_of_heaven_points",
|
||||
"window_of_heaven_points": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LU-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-18",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-18"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "PC-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SJ-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-22"
|
||||
}
|
||||
},
|
||||
"DU-16"
|
||||
],
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LU-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-18",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-18"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "PC-1",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SJ-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-16",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-17",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "BL-10",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "REN-22",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "CV-22"
|
||||
}
|
||||
},
|
||||
"DU-16"
|
||||
],
|
||||
"description": [
|
||||
"Eight of the Window of Heaven points are located in the neck region (exceptions are LU-3 on the upper arm and PC-1 on the thorax).",
|
||||
"These points regulate the Qi flow between the head and the body.",
|
||||
"According to Ming dynasty physician Ma Shi, SI-17 should be replaced by GB-9."
|
||||
],
|
||||
"clinical_application": {
|
||||
"disorders_of_the_qi_flow": [
|
||||
"LU-3, LI-18, REN-22 for counter-flow Qi causing cough, wheezing, etc.",
|
||||
"PC-1 for counter-flow Lung Qi with copious Phlegm.",
|
||||
"ST-9 for counter-flow Lung and Stomach Qi.",
|
||||
"BL-10 treats dizziness, headaches and stiffness of the occiput.",
|
||||
"DU-16 for internal Liver Wind."
|
||||
],
|
||||
"goiter_swellings_pain_and_qi_stagnation_in_the_occiput_and_neck": [
|
||||
"Especially indicated if these occur locally."
|
||||
],
|
||||
"disorders_with_an_acute_onset": [
|
||||
"LI-18 for acute aphonia.",
|
||||
"ST-9 for acute diarrhea.",
|
||||
"SI-16 for acute aphonia following a stroke.",
|
||||
"BL-10 for epilepsy.",
|
||||
"SJ-16 for acute hearing loss.",
|
||||
"REN-22 for acute dyspnea.",
|
||||
"DU-16 for acute aphasia following a stroke."
|
||||
],
|
||||
"psychological_disorders": [
|
||||
"LU-3 for somnolence, grief, disorientation, forgetfulness, insomnia.",
|
||||
"SI-16 for manic agitation and bipolar disorder.",
|
||||
"BL-10 for mania, hallucinations, epilepsy, childhood convulsions.",
|
||||
"SJ-16 for vivid dreaming.",
|
||||
"DU-16 for mania, grief, anxiety with anxiety-induced palpitations."
|
||||
],
|
||||
"disorders_of_the_sensory_organs": [
|
||||
"LU-3 for nose bleeding, blurry vision, myopia.",
|
||||
"ST-9 for blurry vision.",
|
||||
"SI-16 for deafness, tinnitus, ear pain.",
|
||||
"SI-17 for tinnitus and deafness.",
|
||||
"BL-10 for eye pain, blurry vision, excessive tearing, speech disorders, blocked nasal passages, loss of sense of smell.",
|
||||
"SJ-16 for hearing disorders, visual disorders, eye pain, excessive tearing, loss of sense of smell, blocked nasal passages.",
|
||||
"DU-16 for speech disorders following a stroke, blurry vision, nosebleeds.",
|
||||
"REN-22 for speech disorders."
|
||||
]
|
||||
},
|
||||
"title": "Window of Heaven Points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Window of Heaven Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0020",
|
||||
"source_code": "window_of_heaven_points"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Xi-Cleft Points",
|
||||
"code": "xi_cleft",
|
||||
"point_codes": [],
|
||||
"xi_cleft_points_of_the_twelve_channels": {
|
||||
"LU-6": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-6"
|
||||
}
|
||||
},
|
||||
"value": "LU-6 is an important point both for acute diseases of the Lung and for disorders of blood. It was traditionally indicated for attack by exterior pathogenic wind-heat or wind-dryness giving rise to febrile disease, acute cough and wheezing, swelling and pain of the throat and loss of voice and for coughing blood due to any etiology. In modern clinical practice the principal use of this point is in the treatment of acute cough, wheezing or asthma of any pattern."
|
||||
},
|
||||
"LI-7": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LI-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-7"
|
||||
}
|
||||
},
|
||||
"value": "LI-7 is indicated in the treatment of acute disorders and pain affecting the Large Intestine channel, and can clear heat and detoxify poison in cases of clove sores, carbuncle and furuncle, throat painful obstruction, and heat and swelling of the face."
|
||||
},
|
||||
"ST-34": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "ST-34",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-34"
|
||||
}
|
||||
},
|
||||
"value": "ST-34 is unique among the xi-cleft points of the twelve channels in being located proximal to the knee or elbow. The Stomach channel passes through the breast and nipple, and ST-34 is traditionally indicated for acute disorders such as breast pain and breast abscess. In modern clinical practice it is also used for acute epigastric pain."
|
||||
},
|
||||
"SP-8": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-8"
|
||||
}
|
||||
},
|
||||
"value": "SP-8 has an important action on resolving blood stasis in the uterus and lower abdomen and is indicated in the treatment of dysmenorrhea (especially when acute), irregular menstruation and abdominal masses in women due to this pathology."
|
||||
},
|
||||
"HT-6": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "HT-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-6"
|
||||
}
|
||||
},
|
||||
"value": "HT-6 is indicated for severe and unbearable Heart pain due to blood stasis, and for bleeding disorders due to excessive heat agitating the blood. In current practice, however, PC-4 (the xi-cleft point of the Pericardium channel) is more used for acute Heart pain. The relationship of HT-6 to blood is also expressed via its effect on treating disorders of sweating."
|
||||
},
|
||||
"SI-6": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-6"
|
||||
}
|
||||
},
|
||||
"value": "SI-6 is indicated for pain of the shoulder, scapula and arm that is so severe that it feels as if they are broken or dislocated. It is also used as a distal point for acute contraction and sprain of the lumbar region."
|
||||
},
|
||||
"BL-63": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-63",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-63"
|
||||
}
|
||||
},
|
||||
"value": "BL-63 is indicated for sudden onset of Shan disorder, sudden turmoil disorder (acute vomiting and diarrhea) with cramps, epilepsy and white tiger joint pain (intense pain due to painful obstruction)."
|
||||
},
|
||||
"KI-5": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-5",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-5"
|
||||
}
|
||||
},
|
||||
"value": "KI-5 is indicated for a variety of menstrual disorders such as amenorrhea, irregular menstruation, dysmenorrhea and delayed menstruation, characterized either by deficiency of blood or stasis of blood."
|
||||
},
|
||||
"PC-4": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-4"
|
||||
}
|
||||
},
|
||||
"value": "PC-4 is the primary point for treating acute stasis of blood in the chest and Heart, giving rise to pain. It is also indicated for hot reckless bleeding in the upper Jiao manifesting as nosebleed, and vomiting or coughing of blood."
|
||||
},
|
||||
"SJ-7": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SJ-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "TE-7"
|
||||
}
|
||||
},
|
||||
"value": "SJ-7 has no relevant indications and seems to have been little used in classical practice."
|
||||
},
|
||||
"GB-36": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-36",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-36"
|
||||
}
|
||||
},
|
||||
"value": "GB-36 is indicated for painful skin associated with painful obstruction and atrophy disorder, as well as for rabies."
|
||||
},
|
||||
"LR-6": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LR-6",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LR-6"
|
||||
}
|
||||
},
|
||||
"value": "LR-6 is indicated for stasis of blood in the uterus, Shan disorder and lower abdominal pain."
|
||||
}
|
||||
},
|
||||
"xi_cleft_points_of_extraordinary_channels": {
|
||||
"BL-59": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "BL-59",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "BL-59"
|
||||
}
|
||||
},
|
||||
"value": "BL-59 is the xi-cleft point of the Yang Motility vessel but has few relevant indications."
|
||||
},
|
||||
"KI-8": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-8",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-8"
|
||||
}
|
||||
},
|
||||
"value": "KI-8 is the xi-cleft point of the Yin Motility vessel and is indicated for irregular menstruation, dysmenorrhea, amenorrhea, and especially for uterine bleeding."
|
||||
},
|
||||
"GB-35": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB-35",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-35"
|
||||
}
|
||||
},
|
||||
"value": "GB-35 is the xi-cleft point of the Yang Linking vessel but has few relevant indications."
|
||||
},
|
||||
"KI-9": {
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "KI-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "KI-9"
|
||||
}
|
||||
},
|
||||
"value": "KI-9 is the xi-cleft point of the Yin Linking vessel and is traditionally indicated for acute and severe mental disorders such as madness, mania, mania depression disorder, raving, fury and cursing, vomiting of foamy saliva and tongue thrusting."
|
||||
}
|
||||
},
|
||||
"clinical_application": {
|
||||
"diagnosis": [
|
||||
"They provide information about disorders affecting their pertaining channel or Zangfu-Organ",
|
||||
"Excess: acute, intense pain upon pressure or redness and swelling in the area of the point",
|
||||
"Deficiency: dull, mild pain upon pressure or presence of a depression in the area of the point"
|
||||
],
|
||||
"therapy": [
|
||||
"Mainly used for acute and/or therapy-resistant disorders, especially for excess conditions and pain of the affected channel and/or pertaining Zangfu-Organ. In patients with a robust constitution use reducing needling techniques.",
|
||||
"Add the xi-cleft points of the Yin channels for disorders of the Blood.",
|
||||
"In order to increase the therapeutic effect, the xi-cleft point may be combined with a relevant hui-meeting point."
|
||||
]
|
||||
},
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Xi-Cleft Points",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0011",
|
||||
"source_code": "xi_cleft"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"name": "Yuan Source",
|
||||
"code": "yuan_source",
|
||||
"point_codes": [
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LU-9",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "LI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "ST-42",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-42"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SP-3",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "HT-7",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "content_ref",
|
||||
"label": "SI-4",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source_point": [
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Lung (LU)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "lung"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LU 9 (Taiyuan)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LU-9"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Large Intestine (LI)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "large_intestine"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "LI 4 (Hegu)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "LI-4"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Stomach (ST)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "stomach"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "ST 42 (Chongyang)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "ST-42"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Spleen (SP)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "spleen"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SP 3 (Taibai)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SP-3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Heart (HT)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "heart"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "HT 7 (Shenmen)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "HT-7"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Small Intestine (SI)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "small_intestine"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "SI 4 (Wangu)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "SI-4"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": "Urinary Bladder (UB)",
|
||||
"point": "UB 64 (Jinggu)"
|
||||
},
|
||||
{
|
||||
"meridian": "Kidney (KD)",
|
||||
"point": "KD 3 (Taixi)"
|
||||
},
|
||||
{
|
||||
"meridian": {
|
||||
"type": "content_ref",
|
||||
"label": "Pericardium (PC)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0005",
|
||||
"source_code": "pericardium"
|
||||
}
|
||||
},
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "PC 7 (Daling)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "PC-7"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": "Triple Heater (TH/SJ)",
|
||||
"point": "TH 4 (Yangchi)"
|
||||
},
|
||||
{
|
||||
"meridian": "Gallbladder (GB)",
|
||||
"point": {
|
||||
"type": "content_ref",
|
||||
"label": "GB 40 (Qiuxu)",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0003",
|
||||
"source_code": "GB-40"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"meridian": "Liver (LV)",
|
||||
"point": "LV 3 (Taichong)"
|
||||
}
|
||||
],
|
||||
"key_clinical_feature": [
|
||||
"Always located at or near the wrist or ankle joints, which is where the meridian Qi is dynamic."
|
||||
],
|
||||
"yin_vs_yang": "On Yin meridians, the Yuan Source point is the same as the Shu-Stream point. On Yang meridians, the Yuan Source point is a separate point, often the 4th or 5th point on the channel.",
|
||||
"functions": [
|
||||
"Used to treat disorders of their related organs.",
|
||||
"Frequently paired with the Luo-Connecting point of the coupled meridian (e.g., LU9 with LI6) to treat interior-exterior pairings.",
|
||||
"Yuan Source points (Original Qi points) are specialized acupuncture points located near the wrists and ankles where the body's primordial Qi (Yuan Qi) pools and surfaces.",
|
||||
"Each of the 12 meridians has one Yuan Source point used to diagnose, tonify, or regulate the functional activities of the internal organs.",
|
||||
"Crucial for treating chronic conditions, particularly in tonifying Yin organs or reducing excess in Yang organs."
|
||||
],
|
||||
"diagnostic_utility": [
|
||||
"These points often become painful or show physical changes (hardness, depressions) when the associated organ has a significant energy imbalance."
|
||||
],
|
||||
"title": "Yuan Source points",
|
||||
"images": [
|
||||
{
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
}
|
||||
],
|
||||
"default_image": {
|
||||
"image_name": "",
|
||||
"image_path": ""
|
||||
},
|
||||
"link": {
|
||||
"type": "content_ref",
|
||||
"label": "Yuan Source",
|
||||
"target": {
|
||||
"module_code": "M0001",
|
||||
"template_code": "M0001_CT0009",
|
||||
"source_code": "yuan_source"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue