Добавлено конвертирование 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:
@ -116,8 +116,9 @@ async def get_vaccs_report_download(
|
||||
if file is None:
|
||||
raise e.BadRequestException
|
||||
|
||||
file_bytes = base64.b64decode(file.content)
|
||||
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)
|
||||
await cache.set(
|
||||
@ -125,8 +126,8 @@ async def get_vaccs_report_download(
|
||||
dumps(
|
||||
{
|
||||
'filename': filename,
|
||||
'content_type': 'application/msword',
|
||||
'data': base64.b64encode(file_bytes).decode('utf-8'),
|
||||
'content_type': 'application/pdf',
|
||||
'data': inner_base64,
|
||||
}
|
||||
),
|
||||
ex=600,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from pydantic_xml import BaseXmlModel, attr, element
|
||||
from typing import TypedDict
|
||||
|
||||
from pydantic import BaseModel
|
||||
@ -35,5 +36,26 @@ class Complaints(BaseModel):
|
||||
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):
|
||||
link: str
|
||||
|
||||
Reference in New Issue
Block a user