Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5364 gis scanner handling #5382

Merged
merged 13 commits into from
Nov 13, 2024
Merged

5364 gis scanner handling #5382

merged 13 commits into from
Nov 13, 2024

Conversation

jmbrunskill
Copy link
Contributor

@jmbrunskill jmbrunskill commented Nov 12, 2024

Fixes #5364
Fixes #4757

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Adds a new endpoint to parse the human readable GS1 AI format data for assets. (NOTE: This is actually an incorrect understanding of how the barcode is structured)
Adds an ability to scan a GS1 formatted barcode and create an asset with pre-populated data.

This is good enough to demo and test the capability, but not the final solution see follow up issue below.

πŸ’Œ Any notes for the reviewer?

Follow up issues

πŸ§ͺ Testing

  • Using either Android (with camera), or Desktop (with 2d Barcode Scanner)
  • Open the cold chain equipment section, and click the Scan button (this doesn't show on web)
  • Scan one of the barcodes below
  • You should be prompted to create a new asset
  • If you accept, it should show a new asset with the serial number, asset type, and Warenty date populated
  • The Installation date should default to today
  • Scanning the same barcode again, should navigate you to the right asset (once it has been created)

NOTE, scanning these 2d Matrixes in github dark mode or with a black background doesn't work well...

2d Matrix examples:

Here's an example raw string you can use to create new QR Code using https://barcode.tec-it.com/en/DataMatrix

(01)00012345600012(11)241007(21)S12345678(241)E003/002(3121)82(3131)67(3111)63(8013)HBD 116(90)001(91)241007-310101(92){"pqs":"https://apps.who.int/immunization_standards/vaccine_quality/pqs_catalogue/LinkPDF.aspx?UniqueID=3bf9439f-3316-49b4-845e-d50360f8280f&TipoDoc=DataSheet&ID=0”}

PQS Asset Type: E003/002
Serial Number: S1
barcode (1)

PQS Asset Type: E003/002
Serial Number: S2
barcode (2)

PQS Asset Type: E004/055
Serial Number S1
barcode (4)

πŸ“ƒ Documentation

  • Part of an epic: documentation will be completed for the feature as a whole
  • No documentation required: no user facing changes or a bug fix which isn't a change in behaviour
  • These areas should be updated or checked:
    1.
    2.

@github-actions github-actions bot added this to the V2.4.0 milestone Nov 12, 2024
@github-actions github-actions bot added enhancement New feature or request Epic Team Piwakawaka James, LachΓ©, Carl feature: GAPS labels Nov 12, 2024
Copy link

github-actions bot commented Nov 12, 2024

Bundle size difference

Comparing this PR to main

Old size New size Diff
4.96 MB 4.96 MB 1.62 KB (0.03%)

@jmbrunskill jmbrunskill marked this pull request as ready for review November 12, 2024 23:17
onConfirm: () => {
if (newAssetData.current) {
saveNewAsset(newAssetData.current)
.catch(e => error(t('error.unable-to-save-asset', { error: e }))())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This catch doesn't work for some reason!
I tired adding throw e into the useAssets.document.insert(); useMutation:onError but that didn't work.
Help please!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to work fine for me? Though you'd need to add {{ error }} to the 'error.unable-to-save-asset' translation for the error message to show... not entirely sure it should though!

The only time I can seem to see where it doesn't show a message is when newAssetData.current isn't defined.... I think somewhere we have an example of passing data into confirm (so we can pass directly from handleScanResult, and skip the ref thing completely) - but I can't find right now, and I know we're on a time crunch to get something for RC!

Can be a clean up for another PR, maybe as part of that other issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the catch below the .then() though! If saveNewAsset errors, we don't want to catch, and then try do the insertLog/redirect, should throw to below that

.catch(e => error(t('error.unable-to-save-asset', { error: e }))())
.then(async () => {
if (newAssetData.current) {
await insertLog({
Copy link
Contributor Author

@jmbrunskill jmbrunskill Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated functionality as the add new asset modal does this too.
Would be nice to consolidate in #5392

Copy link
Contributor

@lache-melvin lache-melvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry James, seem to be getting CCE not found with id errors rather than the create modal? Looks like this is because it is not the expected GS1 format... I thought these data matrices should work though? Otherwise everything behaving as expected - so sorry I'm so late on review πŸ™ˆ

let repository = AssetRepository::new(&ctx.connection);

let mut result =
repository.query_by_filter(AssetFilter::new().id(EqualFilter::equal_to(id)))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: but any reason to use query_by_filter rather than just find_one_by_id off the row repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't find deleted items, but I guess either way is ok? If its been deleted what should be the behaviour?

}

pub fn gtin(&self) -> Option<String> {
self.gs1.get("01").cloned()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to add a comment with link to spec for where you got these from? Though if this is all about to change then maybe fine 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all changing...

onConfirm: () => {
if (newAssetData.current) {
saveNewAsset(newAssetData.current)
.catch(e => error(t('error.unable-to-save-asset', { error: e }))())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to work fine for me? Though you'd need to add {{ error }} to the 'error.unable-to-save-asset' translation for the error message to show... not entirely sure it should though!

The only time I can seem to see where it doesn't show a message is when newAssetData.current isn't defined.... I think somewhere we have an example of passing data into confirm (so we can pass directly from handleScanResult, and skip the ref thing completely) - but I can't find right now, and I know we're on a time crunch to get something for RC!

Can be a clean up for another PR, maybe as part of that other issue?

onConfirm: () => {
if (newAssetData.current) {
saveNewAsset(newAssetData.current)
.catch(e => error(t('error.unable-to-save-asset', { error: e }))())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the catch below the .then() though! If saveNewAsset errors, we don't want to catch, and then try do the insertLog/redirect, should throw to below that

@lache-melvin
Copy link
Contributor

Merge it! We can clean up in RC2 πŸ™

@jmbrunskill jmbrunskill merged commit 8c3928c into develop Nov 13, 2024
6 checks passed
@jmbrunskill jmbrunskill deleted the 5364-GIS-scanner-handling branch November 13, 2024 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Epic feature: GAPS Team Piwakawaka James, LachΓ©, Carl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GAPS 2D scanner -- parse text stream on server GAPS: Register new asset by scanning 2D DataMatrix
3 participants