Добавлено конвертирование xml результата в pdf
Some checks failed
Build And Push / publish (push) Failing after 55s
Some checks failed
Build And Push / publish (push) Failing after 55s
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "HospitalAssistantBackend"
|
name = "HospitalAssistantBackend"
|
||||||
version = "1.5.1"
|
version = "1.5.2"
|
||||||
description = "Backend for Hospital Assistant"
|
description = "Backend for Hospital Assistant"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13,<3.14"
|
requires-python = ">=3.13,<3.14"
|
||||||
|
|||||||
@ -116,8 +116,9 @@ async def get_vaccs_report_download(
|
|||||||
if file is None:
|
if file is None:
|
||||||
raise e.BadRequestException
|
raise e.BadRequestException
|
||||||
|
|
||||||
file_bytes = base64.b64decode(file.content)
|
|
||||||
filename = f'vaccs_report_{resultId or user.vita_id}.doc'
|
filename = f'vaccs_report_{resultId or user.vita_id}.doc'
|
||||||
|
xml_model = s.ClinicalDocument.from_xml(file.content.encode('utf-8'))
|
||||||
|
inner_base64 = xml_model.component.non_xml_body.text.content.strip()
|
||||||
|
|
||||||
temp_link_token = token_urlsafe(32)
|
temp_link_token = token_urlsafe(32)
|
||||||
await cache.set(
|
await cache.set(
|
||||||
@ -125,8 +126,8 @@ async def get_vaccs_report_download(
|
|||||||
dumps(
|
dumps(
|
||||||
{
|
{
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'content_type': 'application/msword',
|
'content_type': 'application/pdf',
|
||||||
'data': base64.b64encode(file_bytes).decode('utf-8'),
|
'data': inner_base64,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
ex=600,
|
ex=600,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
from pydantic_xml import BaseXmlModel, attr, element
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -35,5 +36,26 @@ class Complaints(BaseModel):
|
|||||||
complaints: str
|
complaints: str
|
||||||
|
|
||||||
|
|
||||||
|
NS = 'urn:hl7-org:v3'
|
||||||
|
|
||||||
|
|
||||||
|
class TextElement(BaseXmlModel, tag='text', ns=NS):
|
||||||
|
representation: str = attr()
|
||||||
|
media_type: str = attr(name='mediaType')
|
||||||
|
content: str
|
||||||
|
|
||||||
|
|
||||||
|
class NonXMLBody(BaseXmlModel, tag='nonXMLBody', ns=NS):
|
||||||
|
text: TextElement = element()
|
||||||
|
|
||||||
|
|
||||||
|
class Component(BaseXmlModel, tag='component', ns=NS):
|
||||||
|
non_xml_body: NonXMLBody = element(tag='nonXMLBody')
|
||||||
|
|
||||||
|
|
||||||
|
class ClinicalDocument(BaseXmlModel, tag='ClinicalDocument', ns=NS):
|
||||||
|
component: Component = element()
|
||||||
|
|
||||||
|
|
||||||
class DownloadFile(BaseModel):
|
class DownloadFile(BaseModel):
|
||||||
link: str
|
link: str
|
||||||
|
|||||||
Reference in New Issue
Block a user