felicity-lims/felicity/lims/seeds/setup_person.py

24 lines
707 B
Python
Raw Normal View History

2024-06-24 00:27:04 +08:00
import logging
from felicity.apps.patient import schemas
from felicity.core.config import get_settings
2024-07-24 04:30:01 +08:00
from felicity.apps.patient.services import IdentificationService
2024-06-24 00:27:04 +08:00
from .data import get_seeds
2024-07-24 04:30:01 +08:00
2024-06-24 00:27:04 +08:00
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-07-24 04:30:01 +08:00
identification_service = IdentificationService()
2024-06-24 00:27:04 +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)