提交
This commit is contained in:
1 parent
f90726927e
commit
6eea13370c
103 files changed
+38401
-32231
No files matched your search
@@ -180,6 +180,8 @@ class ProtocolCreateBody(BaseModel):
|
||||
protocol_no_id: Optional[str] = Field(None, alias="protocolNoId")
|
||||
protocol_status: str = Field("dsx", alias="protocolStatus")
|
||||
protocol_attachments: Optional[str] = Field(None, alias="protocolAttachments")
|
||||
consent_form_urls: Optional[str] = Field(None, alias="consentFormUrls")
|
||||
health_survey_form_urls: Optional[str] = Field(None, alias="healthSurveyFormUrls")
|
||||
register_date: Optional[str] = Field(None, alias="registerDate")
|
||||
collector_user_id: Optional[str] = Field(None, alias="collectorUserId")
|
||||
remark: Optional[str] = None
|
||||
@@ -189,6 +191,8 @@ class ProtocolCreateBody(BaseModel):
|
||||
payment: Optional[dict] = Field(None, alias="payment")
|
||||
payment_details: Optional[list] = Field(None, alias="paymentDetails")
|
||||
attachments: Optional[list] = Field(None, alias="attachments")
|
||||
consent_attachments: Optional[list] = Field(None, alias="consentAttachments")
|
||||
health_survey_attachments: Optional[list] = Field(None, alias="healthSurveyAttachments")
|
||||
storage_cert: Optional[dict] = Field(None, alias="storageCert")
|
||||
|
||||
|
||||
@@ -198,6 +202,8 @@ class ProtocolUpdateBody(BaseModel):
|
||||
protocol_no: Optional[str] = Field(None, alias="protocolNo")
|
||||
protocol_status: Optional[str] = Field(None, alias="protocolStatus")
|
||||
protocol_attachments: Optional[str] = Field(None, alias="protocolAttachments")
|
||||
consent_form_urls: Optional[str] = Field(None, alias="consentFormUrls")
|
||||
health_survey_form_urls: Optional[str] = Field(None, alias="healthSurveyFormUrls")
|
||||
register_date: Optional[str] = Field(None, alias="registerDate")
|
||||
effective_time: Optional[str] = Field(None, alias="effectiveTime")
|
||||
effective_desc: Optional[str] = Field(None, alias="effectiveDesc")
|
||||
@@ -216,6 +222,8 @@ class ProtocolUpdateBody(BaseModel):
|
||||
payment: Optional[dict] = Field(None, alias="payment")
|
||||
payment_details: Optional[list] = Field(None, alias="paymentDetails")
|
||||
attachments: Optional[list] = Field(None, alias="attachments")
|
||||
consent_attachments: Optional[list] = Field(None, alias="consentAttachments")
|
||||
health_survey_attachments: Optional[list] = Field(None, alias="healthSurveyAttachments")
|
||||
storage_cert: Optional[dict] = Field(None, alias="storageCert")
|
||||
|
||||
|
||||
@@ -229,6 +237,26 @@ def _resolve_protocol_attachments(
|
||||
return protocol_attachments
|
||||
|
||||
|
||||
def _resolve_consent_form_urls(
|
||||
consent_form_urls: Optional[str],
|
||||
consent_attachments: Optional[list],
|
||||
) -> Optional[str]:
|
||||
from_urls = cp_svc.attachments_to_urls(consent_attachments)
|
||||
if from_urls:
|
||||
return from_urls
|
||||
return consent_form_urls
|
||||
|
||||
|
||||
def _resolve_health_survey_form_urls(
|
||||
health_survey_form_urls: Optional[str],
|
||||
health_survey_attachments: Optional[list],
|
||||
) -> Optional[str]:
|
||||
from_urls = cp_svc.attachments_to_urls(health_survey_attachments)
|
||||
if from_urls:
|
||||
return from_urls
|
||||
return health_survey_form_urls
|
||||
|
||||
|
||||
def _persist_protocol_sub_resources(
|
||||
db: Session,
|
||||
protocol_id: str,
|
||||
@@ -277,6 +305,14 @@ async def create_collection_protocol(
|
||||
body.protocol_attachments,
|
||||
body.attachments,
|
||||
)
|
||||
consent_form_urls = _resolve_consent_form_urls(
|
||||
body.consent_form_urls,
|
||||
body.consent_attachments,
|
||||
)
|
||||
health_survey_form_urls = _resolve_health_survey_form_urls(
|
||||
body.health_survey_form_urls,
|
||||
body.health_survey_attachments,
|
||||
)
|
||||
collector = (body.collector_user_id or "").strip()
|
||||
if not collector:
|
||||
collector = user_id
|
||||
@@ -286,6 +322,8 @@ async def create_collection_protocol(
|
||||
protocol_no_id=body.protocol_no_id,
|
||||
protocol_status=body.protocol_status,
|
||||
protocol_attachments=protocol_attachments,
|
||||
consent_form_urls=consent_form_urls,
|
||||
health_survey_form_urls=health_survey_form_urls,
|
||||
register_date=body.register_date,
|
||||
collector_user_id=collector,
|
||||
remark=body.remark,
|
||||
@@ -325,7 +363,8 @@ async def update_collection_protocol(
|
||||
payload = body.model_dump(exclude_unset=True, by_alias=False)
|
||||
sub_keys = {
|
||||
"party_customer", "collection_info", "samples",
|
||||
"payment", "payment_details", "attachments", "storage_cert",
|
||||
"payment", "payment_details", "attachments",
|
||||
"consent_attachments", "health_survey_attachments", "storage_cert",
|
||||
}
|
||||
main_payload = {k: v for k, v in payload.items() if k not in sub_keys}
|
||||
if body.attachments is not None:
|
||||
@@ -335,6 +374,20 @@ async def update_collection_protocol(
|
||||
)
|
||||
if resolved is not None:
|
||||
main_payload["protocol_attachments"] = resolved
|
||||
if body.consent_attachments is not None:
|
||||
resolved = _resolve_consent_form_urls(
|
||||
main_payload.get("consent_form_urls"),
|
||||
body.consent_attachments,
|
||||
)
|
||||
if resolved is not None:
|
||||
main_payload["consent_form_urls"] = resolved
|
||||
if body.health_survey_attachments is not None:
|
||||
resolved = _resolve_health_survey_form_urls(
|
||||
main_payload.get("health_survey_form_urls"),
|
||||
body.health_survey_attachments,
|
||||
)
|
||||
if resolved is not None:
|
||||
main_payload["health_survey_form_urls"] = resolved
|
||||
obj = cp_svc.update_collection_protocol(
|
||||
db,
|
||||
protocol_id,
|
||||
|
||||
Reference in new issue
Block a user