2024-06-24 00:27:04 +08:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from felicity.apps.patient import schemas
|
2024-07-28 03:52:31 +08:00
|
|
|
from felicity.apps.patient.services import IdentificationService
|
2024-06-24 00:27:04 +08:00
|
|
|
from felicity.core.config import get_settings
|
|
|
|
|
|
|
|
from .data import get_seeds
|
|
|
|
|
|
|
|
settings = get_settings()
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
async def seed_person() -> None:
|
|
|
|
logger.info("Setting up person .....")
|
|
|
|
data = get_seeds("person")
|
2024-09-25 00:12:10 +08:00
|
|
|
if not data:
|
|
|
|
logger.error("Failed to load person seed data")
|
2024-09-25 00:39:46 +08:00
|
|
|
return
|
2024-09-25 00:12:10 +08:00
|
|
|
|
2024-07-24 04:30:01 +08:00
|
|
|
identification_service = IdentificationService()
|
2024-06-24 00:27:04 +08:00
|
|
|
|
2024-09-25 00:12:10 +08:00
|
|
|
for id_type in data.get("identifiers", []):
|
2024-07-24 04:30:01 +08:00
|
|
|
if not (await identification_service.get(name=id_type)):
|
2024-06-24 00:27:04 +08:00
|
|
|
inst_type_in = schemas.IdentificationCreate(name=id_type)
|
2024-07-24 04:30:01 +08:00
|
|
|
await identification_service.create(inst_type_in)
|