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

(feat) O3-3521: Add configurable ability to print multiple stickers on the same page #1934

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

jnsereko
Copy link
Contributor

@jnsereko jnsereko commented Jul 22, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR adds the following configurability

  • specifying the size of the ID sticker on the printed page.
  • specifying the number of column and rows on each printing page.
  • specifying the number of ID stickers to be printed

This PR also adds ability to preview rows and columns before printing.
cc @denniskigen @vasharma05 @ibacher @pirupius

Screenshots

Video Preview

Screenshot 2024-11-13 at 14 32 53 Screenshot 2024-11-13 at 14 33 17 Screenshot 2024-11-13 at 14 33 41

Related Issue

https://openmrs.atlassian.net/browse/O3-3521

Other

With a configuration like below

{
  "@openmrs/esm-patient-banner-app": {
    "printPatientSticker": {
      "printStickerFields": {
        "fields": [
          "name",
          "dob",
          "gender",
          "identifier",
          "age"
        ],
        "fieldsTableGroups": [
          [
            "age",
            "dob",
            "gender"
          ]
        ],
        "fieldsContainerStyleOverrides": {
          "grid-template-columns": "auto"
        }
      }
    }
  }
}

you get the following result
Screenshot 2024-11-13 at 14 35 58
Screenshot 2024-11-13 at 14 36 48

@pirupius pirupius changed the title Add configurable ability to print multiple stickers on the same page (feat) O3-3521 Add configurable ability to print multiple stickers on the same page Jul 23, 2024
@jnsereko jnsereko force-pushed the O3-3521 branch 2 times, most recently from 3fd3ae9 to 67b180a Compare July 28, 2024 19:12
package.json Outdated Show resolved Hide resolved
@denniskigen denniskigen force-pushed the O3-3521 branch 2 times, most recently from a815733 to 245d57a Compare August 20, 2024 21:20
Comment on lines 26 to 48
if (numberOfLabelColumns < 1 || numberOfLabelRowsPerPage < 1 || labels.length < 1) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be validated properly, that we always have at least 1 sticker to print, min value of the fields must be set to 1

Comment on lines 45 to 46
gridTemplateColumns: `repeat(${numberOfLabelColumns}, 1fr)`,
gridTemplateRows: `repeat(${numberOfLabelRowsPerPage}, auto)`,
Copy link
Member

Choose a reason for hiding this comment

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

What if the pagesize provided by the user is not able to accommodate the provided count, what will/should happen in such cases?
Thanks!

@ibacher
Copy link
Member

ibacher commented Aug 28, 2024

Why did we revert out the CSS property stuff? I also don't really understand the reversion to 2.x instead of 3.x...

@jnsereko
Copy link
Contributor Author

reversion to 2.x instead of 3.x...

@ibacher i have created a separate ticket to track the migration here since the API was changing and there are many other printing spots around the patient chart beyond the Identifier-Sticker

Why did we revert out the CSS property stuff?

Sorry @ibacher, I forgot to share here. Styles for some un-known reason were not being loaded into the print preview. For that reason, i was only able to print only a single page instead of 2 or more depending on the number of stickers per page and the number of rows and columns.
Also columns were wrapping in case 4 or more columns were specified.
@denniskigen shared that this is something he experienced some time back with the library so i created a ticket to debug that here

Supplying styles directly

Screen.Recording.2024-08-28.at.19.15.31.mov

Supplying styles indirectly using CSS file

Screen.Recording.2024-08-28.at.19.17.47.mov

@denniskigen denniskigen changed the title (feat) O3-3521 Add configurable ability to print multiple stickers on the same page (feat) O3-3521: Add configurable ability to print multiple stickers on the same page Sep 3, 2024
@denniskigen
Copy link
Member

denniskigen commented Oct 8, 2024

@jnsereko can we fix the conflicts now that #2022 is in.

@brandones
Copy link
Contributor

Ping @jnsereko , is it clear to you how to move forward?

jnsereko and others added 27 commits December 3, 2024 12:12
…openmrs#2103)

(feat) O3-4072: Improve Start Visit Form to Support Default Visit Type
@brandones
Copy link
Contributor

@jnsereko is this ready for re-review? Please request re-reviews when it is.

@jnsereko
Copy link
Contributor Author

jnsereko commented Dec 5, 2024

@jnsereko is this ready for re-review? Please request re-reviews when it is.

i surely will @brandones.
This is working but needs some improvements before we can move forward.
The main problem right now is the delay, like i had shared here, html-to-image is taking a-lot of time to render images causing a delay. At the same time the barcode is not at its best quality.

The best option is to pass a json schema as config and render the sticker as a pdf. I have logic for the first part but haven't found a good library to translate html to pdf. Such a library should have the following qualities.

  1. support multiple languages
  2. maintain a good quality of images so that a barcode is easily readable
  3. have no delays
  4. support multiple page sizes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants