Skip to content

Commit

Permalink
added barcde printing inside sample, on sample listing and inside wor…
Browse files Browse the repository at this point in the history
…ksheet
  • Loading branch information
aurthurm committed Dec 27, 2023
1 parent b83e641 commit cfdfc24
Show file tree
Hide file tree
Showing 32 changed files with 506 additions and 589 deletions.
94 changes: 43 additions & 51 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions felicity/api/gql/billing/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from api.gql.permissions import IsAuthenticated
from api.gql.types import PageInfo, BytesScalar
from apps.billing import models
from apps.billing.invoicing.utils import generate_invoice
from apps.impress.invoicing.utils import impress_invoice
from utils import has_value_or_is_truthy


Expand Down Expand Up @@ -97,7 +97,7 @@ async def bill_invoice(self, info, invoice_uid: str) -> Optional[types.TestBillI
@strawberry.field(permission_classes=[IsAuthenticated])
async def bill_invoice_create(self, info, bill_uid: str) -> BytesScalar | None:
bill = await models.TestBill.get(uid=bill_uid)
return await generate_invoice(bill)
return await impress_invoice(bill)

@strawberry.field(permission_classes=[IsAuthenticated])
async def price_for_profile(self, info, profile_uid: str) -> Optional[types.ProfilePriceType]:
Expand Down
43 changes: 38 additions & 5 deletions felicity/api/gql/impress/query.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import io
import logging
from functools import lru_cache
from typing import List

import strawberry # noqa
from PyPDF2 import PdfWriter

from api.gql.impress.types import ReportImpressType
from api.gql.permissions import IsAuthenticated
from api.gql.types import BytesScalar
from apps.impress.models import ReportImpress

from PyPDF2 import PdfWriter
from apps.client import Client
from apps.impress.barcode.schema import BarCode, BarCodeMeta
from apps.impress.barcode.utils import impress_barcodes
from apps.impress.sample.models import ReportImpress
from apps.storage.models import Sample

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -18,13 +23,13 @@
class ReportImpressQuery:
@strawberry.field(permission_classes=[IsAuthenticated])
async def impress_reports_meta(
self, info, uids: List[str]
self, info, uids: List[str]
) -> List[ReportImpressType]:
return await ReportImpress.get_all(sample_uid__in=uids)

@strawberry.field(permission_classes=[IsAuthenticated])
async def impress_reports_download(
self, info, uids: List[str]
self, info, uids: List[str]
) -> BytesScalar | None:
"""Fetch Latest report given sample id"""
items = await ReportImpress.get_all(sample_uid__in=uids)
Expand Down Expand Up @@ -74,3 +79,31 @@ async def impress_report_download(self, info, uid: str) -> BytesScalar | None:

# io.BytesIO()
return report.pdf_content

@strawberry.field(permission_classes=[IsAuthenticated])
async def barcode_samples(self, info, sample_uids: list[str]) -> BytesScalar | None:
samples = await Sample.get_all(uid__in=sample_uids)

@lru_cache
async def _client_name(uid: str) -> str: return (await Client.get(uid=uid)).name

barcode_metas = [
BarCode(
barcode=_s.sample_id,
metadata=[
BarCodeMeta(
label="CRID",
value=_s.analysis_request.client_request_id
),
BarCodeMeta(
label="Sample Type",
value=_s.sample_type.name
),
BarCodeMeta(
label="Client",
value=_s.analysis_request.client.name # await _client_name(_s.analysis_request.client_uid)
)
]
) for _s in samples
]
return await impress_barcodes(barcode_metas)
15 changes: 0 additions & 15 deletions felicity/api/gql/setup/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
)
from api.gql.setup.types.department import DepartmentType
from api.gql.types import OperationError
from apps.job import models as job_models
from apps.job import schemas as job_schemas
from apps.job.conf import actions, categories, priorities, states
from apps.setup import models, schemas

logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -202,18 +199,6 @@ async def update_laboratory_setting(
obj_in = schemas.LaboratorySettingUpdate(**lab_setting.to_dict())
lab_setting = await lab_setting.update(obj_in)

if lab_setting.allow_billing:
job_schema = job_schemas.JobCreate(
action=actions.BILLING_INIT,
category=categories.BILLING,
priority=priorities.MEDIUM,
creator_uid=felicity_user.uid,
job_id=None,
status=states.PENDING,
data={"profiles": [], "analyses": []},
)
await job_models.Job.create(job_schema)

return LaboratorySettingType(**lab_setting.marshal_simple())

@strawberry.mutation(permission_classes=[IsAuthenticated])
Expand Down
Loading

0 comments on commit cfdfc24

Please sign in to comment.