From b68ed9d9d820bd6224b24c1703f31fb2aabe9639 Mon Sep 17 00:00:00 2001 From: Alessandro Dell'Oste Date: Thu, 18 Jan 2024 14:44:56 +0100 Subject: [PATCH] feat: [IOCOM-922] Remove medical prescription (#5407) ## Short description This PR removes Medical prescription from the project ## List of changes proposed in this pull request - removed Medical prescription related files - removed translation keys ## How to test Tests should be solved correctly --------- Co-authored-by: Cristiano Tofani Co-authored-by: Andrea --- locales/de/index.yml | 18 - locales/en/index.yml | 18 - locales/it/index.yml | 18 - scripts/api-config.json | 1 - ts/features/messages/__mocks__/message.ts | 18 - .../components/MessageDetail/CtaBar.tsx | 4 - .../MessageDetail/HeaderDueDateBar.tsx | 47 +- .../MedicalPrescriptionAttachments.tsx | 105 - .../MedicalPrescriptionDueDateBar.tsx | 124 - ...edicalPrescriptionIdentifiersComponent.tsx | 75 - .../components/MessageDetail/MessageTitle.tsx | 24 - .../MedicalPrescriptionAttachments.test.tsx | 93 - .../MedicalPrescriptionDueDateBar.test.tsx | 96 - ...dicalPrescriptionAttachments.test.tsx.snap | 919 ------ ...edicalPrescriptionDueDateBar.test.tsx.snap | 2644 ----------------- .../components/MessageDetail/index.tsx | 30 +- .../__test__/MessageDetail.test.tsx | 60 +- .../messages/store/reducers/transformers.ts | 30 - ts/features/messages/types/index.ts | 8 - ts/features/messages/utils/messages.ts | 34 - 20 files changed, 21 insertions(+), 4345 deletions(-) delete mode 100644 ts/features/messages/components/MessageDetail/MedicalPrescriptionAttachments.tsx delete mode 100644 ts/features/messages/components/MessageDetail/MedicalPrescriptionDueDateBar.tsx delete mode 100644 ts/features/messages/components/MessageDetail/MedicalPrescriptionIdentifiersComponent.tsx delete mode 100644 ts/features/messages/components/MessageDetail/MessageTitle.tsx delete mode 100644 ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionAttachments.test.tsx delete mode 100644 ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionDueDateBar.test.tsx delete mode 100644 ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionAttachments.test.tsx.snap delete mode 100644 ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionDueDateBar.test.tsx.snap diff --git a/locales/de/index.yml b/locales/de/index.yml index 34f075c9316..53cc3e64d84 100644 --- a/locales/de/index.yml +++ b/locales/de/index.yml @@ -1688,13 +1688,6 @@ messages: expiredAlert: block1: "Abgelaufen am " block2: "um " - prescription: - expiringOrValidAlert: - block1: "Verfällt am " - block2: "um " - expiredAlert: - block1: "Abgelaufen am " - block2: "um " pay: "Bezahle {{amount}} €" onlyPay: "Bezahlen" paid: "Bezahlt" @@ -1740,17 +1733,6 @@ messages: emptyMessage: title: "Du hast keine Fälligkeiten." subtitle: "Über die Schaltfläche oben kannst du die bereits abgelaufenen Fristen einsehen." - medical: - not_available: "N/A" - prescription: "Elektronische Verschreibung" - memo: "Erinnerung für die betreute Person" - nre: "Elektronische Verschreibungsnummer" - iup: "Eindeutige Buchungsnummer" - patient_fiscal_code: "Steuernummer der betreuten Person" - prescriber_fiscal_code: "Steuernummer des Arztes" - barcodes: "Barcodes" - nationalService: "Nationaler Gesundheitsdienst" - note: "ausgestellt im Sinne des Art. 11, Abs. 16 des Gesetzesdekretes vom 31. Mai 2010, Nr. 78 und des Art. 1, Abs. 4 des Ministerialdekretes vom 2 November 2011" pagination: migration: started: "Bitte warte, wir aktualisieren den Mitteilungsbereich" diff --git a/locales/en/index.yml b/locales/en/index.yml index fa3e96c50eb..6424837dac6 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -1821,13 +1821,6 @@ messages: expiredAlert: block1: Expired on block2: at - prescription: - expiringOrValidAlert: - block1: Expiring on - block2: at - expiredAlert: - block1: Expired on - block2: at pay: Pay € {{amount}} onlyPay: Pay paid: Paid @@ -1873,17 +1866,6 @@ messages: emptyMessage: title: You haven't any scheduled deadline. subtitle: Use the button above to check out past deadlines. - medical: - not_available: "n/a" - prescription: Electronic prescription - memo: Reminder for the recipient - nre: Electronic prescription number - iup: Unique booking identifier - patient_fiscal_code: Patient's fiscal code - prescriber_fiscal_code: Doctor's fiscal code - barcodes: Barcodes - nationalService: National Health Service - note: "Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011" pagination: migration: started: Please wait, we are updating the Messages section. diff --git a/locales/it/index.yml b/locales/it/index.yml index 8f9c8e2a76b..e90b8de05b3 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -1821,13 +1821,6 @@ messages: expiredAlert: block1: Scaduto il block2: alle ore - prescription: - expiringOrValidAlert: - block1: Scade il - block2: alle - expiredAlert: - block1: Scaduta il - block2: alle pay: Paga € {{amount}} onlyPay: Paga paid: Pagato @@ -1873,17 +1866,6 @@ messages: emptyMessage: title: Non hai scadenze in programma. subtitle: Usa il pulsante qui sopra per vedere le scadenze già trascorse. - medical: - not_available: "n/a" - prescription: Ricetta elettronica - memo: Promemoria per l'assistito - nre: Numero Ricetta Elettronica - iup: Identificativo Unico Prenotazione - patient_fiscal_code: Codice Fiscale dell'assistito - prescriber_fiscal_code: Codice fiscale del medico - barcodes: Codici a barre - nationalService: Servizio Sanitario Nazionale - note: "Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011" pagination: migration: started: "Attendi, stiamo aggiornando la sezione messaggi" diff --git a/scripts/api-config.json b/scripts/api-config.json index bcd49c53c63..0d2f6dc39be 100644 --- a/scripts/api-config.json +++ b/scripts/api-config.json @@ -14,7 +14,6 @@ "paymentInvalidAfterDueDateWithExpiredDueDateCount": 1, "paymentWithValidDueDateCount": 1, "paymentWithExpiredDueDateCount": 1, - "medicalCount": 1, "withCTA": true, "withEUCovidCert": true, "withValidDueDateCount": 1, diff --git a/ts/features/messages/__mocks__/message.ts b/ts/features/messages/__mocks__/message.ts index e843221e37a..5a77b7449b1 100644 --- a/ts/features/messages/__mocks__/message.ts +++ b/ts/features/messages/__mocks__/message.ts @@ -22,24 +22,6 @@ export const message_1: CreatedMessageWithContentAndAttachments = { sender_service_id: service_1.service_id }; -export const medicalPrescription: CreatedMessageWithContentAndAttachments = { - created_at: "2021-11-23T13:29:49.771Z", - fiscal_code: "TAMMRA80A41H501I", - id: "00000000000000000000000013", - sender_service_id: "service2", - time_to_live: 3600, - content: { - subject: "💊 medical prescription - 1", - markdown: - "\n# H1 \n\n## H2 \n\n### H3 \n\n#### H4\n\n-----\n\n### an image\n![A cat](data:image/jpg;base64,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)\n\n-----\n\n### item list\n\n- item1\n- item2 \n- item3 \n- item4 \n- item5 \n- item6 \n\n-----\n\n### enumerated list\n\n1. item1\n1. item2 \n1. item3 \n1. item4 \n1. item5 \n1. item6 \n\n-----\n\n### formatted text\nÈ universalmente **riconosciuto** che un _lettore_ che **osserva** il layout di una pagina viene distratto dal contenuto testuale se questo è leggibile. Lo scopo dell’utilizzo del Lorem Ipsum è che offre una normale distribuzione delle lettere (al contrario di quanto avviene se si utilizzano brevi frasi ripetute, ad esempio “testo qui”), apparendo come un normale blocco di testo leggibile. Molti software di impaginazione e di web design utilizzano Lorem Ipsum come testo modello. Molte versioni del testo sono state prodotte negli anni, a volte casualmente, a volte di proposito (ad esempio inserendo passaggi ironici).\n\n| copia e incolla il seguente link: `https://verylongurl.com/verylong_very_long_very_long_very_long_very_long_very_long_very_long_very_long_very_long_very_long_very_long_very_long_`\n\n-----\n\n### external links\n\na link must **always** include the protocol (`http://` or `https://`)\n\n[Google](https://www.google.it)\n\n[Invalid link -1](www.google.it)\n\n[Invalid link -2](google.it)\n\n-----\n\n### Internal navigation\n\n[BONUS_AVAILABLE_LIST](ioit://BONUS_AVAILABLE_LIST)\n\n[BONUS_CTA_ELIGILITY_START](ioit://BONUS_CTA_ELIGILITY_START)\n\n[MESSAGES_HOME](ioit://MESSAGES_HOME)\n\n[PROFILE_PREFERENCES_HOME](ioit://PROFILE_PREFERENCES_HOME)\n\n[SERVICES_HOME](ioit://SERVICES_HOME)\n\n[PROFILE_MAIN](ioit://PROFILE_MAIN)\n\n[PROFILE_PRIVACY](ioit://PROFILE_PRIVACY)\n\n[PROFILE_PRIVACY_MAIN](ioit://PROFILE_PRIVACY_MAIN)\n\n[WALLET_HOME](ioit://WALLET_HOME)\n\n[WALLET_LIST](ioit://WALLET_LIST)\n\n[PAYMENTS_HISTORY_SCREEN](ioit://PAYMENTS_HISTORY_SCREEN)\n\n[WALLET_HOME con parametri](ioit://WALLET_HOME?param1=a¶m2=b¶m3=c¶m4=100)\n\n[SERVICE WEBVIEW](ioit://SERVICE_WEBVIEW?url=https://www.google.com)\n\n[LINK CORROTTO](ioit://WRONG&$)\n\n### Handled link\n[http - google](iohandledlink://http://www.google.com)\n\n[https - google](iohandledlink://https://www.google.com)\n\n[clipboard](iohandledlink://copy:textcopy)\n\n[sms](iohandledlink://sms:+123456789)\n\n[tel](iohandledlink://tel:+123456789)\n\n[mailto](iohandledlink://mailto:name.surname@email.com)\n\n", - prescription_data: { - nre: "050A00854698121", - iup: "0000X0NFM", - prescriber_fiscal_code: "TAMMRA80A41H501I" - } - } -} as any; - export const paymentValidInvalidAfterDueDate: CreatedMessageWithContentAndAttachments = { created_at: "2021-11-23T13:29:54.771Z", diff --git a/ts/features/messages/components/MessageDetail/CtaBar.tsx b/ts/features/messages/components/MessageDetail/CtaBar.tsx index acc740a49db..d581c8ce534 100644 --- a/ts/features/messages/components/MessageDetail/CtaBar.tsx +++ b/ts/features/messages/components/MessageDetail/CtaBar.tsx @@ -110,10 +110,6 @@ const CtaBar = ({ } }, [isPNOptIn, shoulCheckForPNOptInMessage]); - // in case of medical prescription, we shouldn't render the CtaBar - if (messageDetails.prescriptionData !== undefined) { - return null; - } const expirationInfo = getPaymentExpirationInfo(messageDetails); const paymentButton = renderPaymentButton(paymentData, messageDetails.id); diff --git a/ts/features/messages/components/MessageDetail/HeaderDueDateBar.tsx b/ts/features/messages/components/MessageDetail/HeaderDueDateBar.tsx index 203c03d82d6..cd1f9167ba0 100644 --- a/ts/features/messages/components/MessageDetail/HeaderDueDateBar.tsx +++ b/ts/features/messages/components/MessageDetail/HeaderDueDateBar.tsx @@ -1,45 +1,26 @@ -import * as React from "react"; +import React from "react"; import { UIMessageDetails } from "../../types"; import { getPaymentExpirationInfo } from "../../utils"; import DueDateBar from "./DueDateBar"; -import MedicalPrescriptionDueDateBar from "./MedicalPrescriptionDueDateBar"; -import MedicalPrescriptionIdentifiersComponent from "./MedicalPrescriptionIdentifiersComponent"; -type Props = { +type HeaderDueDateBarProps = { messageDetails: UIMessageDetails; hasPaidBadge: boolean; }; -/** - * Groups all the possible combination of DueDate bars based (or not) on the prescriptionData - * @param props - * @constructor - */ -export const HeaderDueDateBar = (props: Props): React.ReactElement => { - const paymentExpirationInfo = getPaymentExpirationInfo(props.messageDetails); +export const HeaderDueDateBar = ({ + hasPaidBadge, + messageDetails +}: HeaderDueDateBarProps) => { + if (messageDetails.dueDate === undefined) { + return null; + } return ( - <> - {props.messageDetails.prescriptionData && ( - - )} - - {props.messageDetails.dueDate !== undefined && - (props.messageDetails.prescriptionData === undefined ? ( - - ) : ( - - ))} - + ); }; diff --git a/ts/features/messages/components/MessageDetail/MedicalPrescriptionAttachments.tsx b/ts/features/messages/components/MessageDetail/MedicalPrescriptionAttachments.tsx deleted file mode 100644 index bc6fc3fd7d7..00000000000 --- a/ts/features/messages/components/MessageDetail/MedicalPrescriptionAttachments.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import * as O from "fp-ts/lib/Option"; -import * as React from "react"; -import { View, StyleSheet } from "react-native"; -import { SvgXml } from "react-native-svg"; - -import { VSpacer } from "@pagopa/io-app-design-system"; -import { PrescriptionData } from "../../../../../definitions/backend/PrescriptionData"; -import I18n from "../../../../i18n"; -import { Attachment } from "../../types"; -import { getPrescriptionDataFromName } from "../../utils/messages"; -import { Body } from "../../../../components/core/typography/Body"; -import { IOStyles } from "../../../../components/core/variables/IOStyles"; -import ItemSeparatorComponent from "../../../../components/ItemSeparatorComponent"; - -type Props = Readonly<{ - prescriptionData?: PrescriptionData; - prescriptionAttachments: ReadonlyArray; - organizationName?: string; -}>; - -const BARCODE_HEIGHT = 52; - -const styles = StyleSheet.create({ - customHeader: { - marginBottom: -4 - } -}); - -export const svgXml = "image/svg+xml"; - -const Item = ({ - prescriptionData, - item, - idx -}: { - prescriptionData?: PrescriptionData; - item: Attachment; - idx: number; -}) => { - const value = getPrescriptionDataFromName(prescriptionData, item.name); - const xml = Buffer.from(item.content, "base64").toString("ascii"); - return ( - - - - {I18n.t(`messages.medical.${item.name}`, { - defaultValue: I18n.t("messages.medical.not_available") - }).toUpperCase()} - - {xml && } - {O.isSome(value) && ( - - - {I18n.t("global.symbols.asterisk")} - {value.value} - {I18n.t("global.symbols.asterisk")} - - - )} - - - ); -}; - -const MedicalPrescriptionAttachments = ({ - prescriptionAttachments, - organizationName, - prescriptionData -}: Props) => ( - - - - - {I18n.t("messages.medical.nationalService").toUpperCase()} - - - {organizationName && {organizationName.toUpperCase()}} - - - - - {prescriptionAttachments - .filter(_ => _.mimeType === svgXml) - .map((prescriptionAttachment, index) => ( - - - - - ))} - - - - - - - {I18n.t("messages.medical.note")} - - -); - -export default MedicalPrescriptionAttachments; diff --git a/ts/features/messages/components/MessageDetail/MedicalPrescriptionDueDateBar.tsx b/ts/features/messages/components/MessageDetail/MedicalPrescriptionDueDateBar.tsx deleted file mode 100644 index e7aa0e64c51..00000000000 --- a/ts/features/messages/components/MessageDetail/MedicalPrescriptionDueDateBar.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { capitalize } from "lodash"; -import React from "react"; -import { View, StyleSheet } from "react-native"; -import { IOColors, HSpacer, VSpacer } from "@pagopa/io-app-design-system"; -import I18n from "../../../../i18n"; -import customVariables from "../../../../theme/variables"; -import { formatDateAsDay, formatDateAsMonth } from "../../../../utils/dates"; -import { isExpired, MessagePaymentExpirationInfo } from "../../utils/messages"; -import { UIMessageDetails } from "../../types"; -import { localeDateFormat } from "../../../../utils/locale"; -import { IOStyles } from "../../../../components/core/variables/IOStyles"; -import { Label } from "../../../../components/core/typography/Label"; -import CalendarIconComponent from "./CalendarIconComponent"; -import CalendarEventButton from "./CalendarEventButton"; - -type Props = { - dueDate: Date; - - messageDetails: UIMessageDetails; - - /* A message can carry both medical data and a payment */ - paymentExpirationInfo?: MessagePaymentExpirationInfo; -}; - -const styles = StyleSheet.create({ - container: { - paddingVertical: customVariables.appHeaderPaddingHorizontal - } -}); - -/** - * Show detailed info about the due date of a prescription. - * Note that payment-related data is used to infer a due date and its 'expire status'. - * - * TODO: - * - update with medical prescription due date (if different from the message due date) - * - if due date is different, check what to pass to CalendarEventButton - */ -const MedicalPrescriptionDueDateBar = ({ - dueDate, - messageDetails, - paymentExpirationInfo -}: Props) => { - const isPrescriptionExpired = paymentExpirationInfo - ? isExpired(paymentExpirationInfo) - : false; - const time = localeDateFormat( - dueDate, - I18n.t("global.dateFormats.timeFormat") - ); - const date = localeDateFormat( - dueDate, - I18n.t("global.dateFormats.shortFormat") - ); - - const bannerStyle = isPrescriptionExpired - ? { backgroundColor: IOColors.bluegrey } - : { backgroundColor: IOColors.greyUltraLight }; - - if (isPrescriptionExpired) { - return ( - - - - - - - - - ); - } - - return ( - - - - - - - - - - - - ); -}; - -export default MedicalPrescriptionDueDateBar; diff --git a/ts/features/messages/components/MessageDetail/MedicalPrescriptionIdentifiersComponent.tsx b/ts/features/messages/components/MessageDetail/MedicalPrescriptionIdentifiersComponent.tsx deleted file mode 100644 index f1c8b0b63c1..00000000000 --- a/ts/features/messages/components/MessageDetail/MedicalPrescriptionIdentifiersComponent.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { pipe } from "fp-ts/lib/function"; -import * as O from "fp-ts/lib/Option"; -import * as React from "react"; -import { View, StyleSheet } from "react-native"; -import { IOColors, VSpacer } from "@pagopa/io-app-design-system"; -import { PrescriptionData } from "../../../../../definitions/backend/PrescriptionData"; -import I18n from "../../../../i18n"; -import CopyButtonComponent from "../../../../components/CopyButtonComponent"; -import { Body } from "../../../../components/core/typography/Body"; -import { H3 } from "../../../../components/core/typography/H3"; -import { IOStyles } from "../../../../components/core/variables/IOStyles"; - -type Props = Readonly<{ - prescriptionData: PrescriptionData; -}>; - -const styles = StyleSheet.create({ - container: { - backgroundColor: IOColors.greyUltraLight, - borderBottomWidth: 1, - borderBottomColor: IOColors.white - }, - centerContent: { - alignContent: "center" - } -}); - -export default class MedicalPrescriptionIdentifiersComponent extends React.PureComponent { - private renderItem = (label: string, value: string) => ( - - {label} - -

- {value} -

- -
-
- ); - - public render() { - const { prescriptionData } = this.props; - const iup = pipe( - prescriptionData.iup, - O.fromNullable, - O.fold( - () => I18n.t("messages.medical.not_available"), - s => s - ) - ); - const prescriberFiscalCode = pipe( - prescriptionData.prescriber_fiscal_code, - O.fromNullable, - O.fold( - () => I18n.t("messages.medical.not_available"), - s => s as string - ) - ); - - return ( - - - {this.renderItem(I18n.t("messages.medical.nre"), prescriptionData.nre)} - - {this.renderItem(I18n.t("messages.medical.iup"), iup)} - - {this.renderItem( - I18n.t("messages.medical.patient_fiscal_code"), - prescriberFiscalCode - )} - - - ); - } -} diff --git a/ts/features/messages/components/MessageDetail/MessageTitle.tsx b/ts/features/messages/components/MessageDetail/MessageTitle.tsx deleted file mode 100644 index 80294d5f4ed..00000000000 --- a/ts/features/messages/components/MessageDetail/MessageTitle.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import * as React from "react"; -import { H1 } from "../../../../components/core/typography/H1"; -import I18n from "../../../../i18n"; -import { Body } from "../../../../components/core/typography/Body"; - -type Props = { - title: string; - isPrescription: boolean; -}; - -/** - * Render a title for a message - * @param props - * @constructor - */ -export const MessageTitle = (props: Props): React.ReactElement => - props.isPrescription ? ( - <> -

{I18n.t("messages.medical.prescription")}

- {I18n.t("messages.medical.memo")} - - ) : ( -

{props.title}

- ); diff --git a/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionAttachments.test.tsx b/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionAttachments.test.tsx deleted file mode 100644 index 2bbf1d76d04..00000000000 --- a/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionAttachments.test.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React from "react"; -import { render } from "@testing-library/react-native"; - -import MedicalPrescriptionAttachments, { - svgXml -} from "../MedicalPrescriptionAttachments"; - -describe("MedicalPrescriptionAttachments component", () => { - const organizationName = "WHO"; - - describe("with default properties", () => { - it("should render", () => { - const component = render( - - ); - expect(component.toJSON()).toMatchSnapshot(); - }); - }); - - describe("when the organization name is defined", () => { - it("should render it", () => { - expect( - render( - - ).toJSON() - ).toMatchSnapshot(); - }); - }); - - describe("when an attachment is present", () => { - const attachment = { - name: "prescription", - content: "up, down, strange, charm, bottom, top", - mimeType: "text/plain" - }; - - it("should render it", () => { - expect( - render( - - ).toJSON() - ).toMatchSnapshot(); - }); - - describe(`and has mimeType=${svgXml}`, () => { - const svgAttachment = { - name: "barcodes", - // Icon made from http://www.onlinewebfonts.com/icon is licensed by CC BY 3.0 - content: `PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gU3ZnIFZlY3RvciBJY29ucyA6IGh0dHA6Ly93d3cub25saW5ld2ViZm9udHMuY29tL2ljb24gLS0+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTAwMCAxMDAwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxMDAwIDEwMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPG1ldGFkYXRhPiBTdmcgVmVjdG9yIEljb25zIDogaHR0cDovL3d3dy5vbmxpbmV3ZWJmb250cy5jb20vaWNvbiA8L21ldGFkYXRhPg0KPGc+PHBhdGggZD0iTTk3My43LDI2My4yQzk0MSwxNjUuMiw4MzQuOCw5MS43LDcyMC41LDkxLjdjLTg5LjgsMC0xNzEuNSw0OS0yMjAuNSwxMjIuNUM0NTEsMTQwLjcsMzY5LjMsOTEuNywyNzkuNSw5MS43Yy0xMTQuMywwLTIxMi4zLDczLjUtMjQ1LDE3MS41QzEwLDMwNCwxMCwzNDQuOCwxMCw0MDJjMTYuMywxNjMuMywxNzEuNSwzNDMsNDY1LjUsNDk4LjJjOC4yLDAsMTYuMyw4LjIsMjQuNSw4LjJzOC4yLDAsMTYuMywwQzUzMi43LDkwMC4yLDk2NS41LDY4Ny44LDk5MCw0MDJDOTkwLDM0NC44LDk5MCwzMDQsOTczLjcsMjYzLjIiLz48L2c+DQo8L3N2Zz4= - `, - mimeType: svgXml - }; - - it("should render the SVG", () => { - expect( - render( - - ).toJSON() - ).toMatchSnapshot(); - }); - }); - - describe("and prescriptionData is present", () => { - const attachmentWithPrescriptionData = { - ...attachment, - name: "nre" - }; - - it("should render it", () => { - expect( - render( - - ).toJSON() - ).toMatchSnapshot(); - }); - }); - }); -}); diff --git a/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionDueDateBar.test.tsx b/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionDueDateBar.test.tsx deleted file mode 100644 index 32d78582fc9..00000000000 --- a/ts/features/messages/components/MessageDetail/__tests__/MedicalPrescriptionDueDateBar.test.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import React from "react"; -import configureMockStore from "redux-mock-store"; - -import { applicationChangeState } from "../../../../../store/actions/application"; -import { appReducer } from "../../../../../store/reducers"; -import { toUIMessageDetails } from "../../../store/reducers/transformers"; -import { GlobalState } from "../../../../../store/reducers/types"; -import { MessagePaymentExpirationInfo } from "../../../utils/messages"; -import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper"; -import { paymentValidInvalidAfterDueDate } from "../../../__mocks__/message"; -import MedicalPrescriptionDueDateBar from "../MedicalPrescriptionDueDateBar"; -import { MESSAGES_ROUTES } from "../../../navigation/routes"; - -jest.useFakeTimers(); - -const uiMessageDetails = toUIMessageDetails(paymentValidInvalidAfterDueDate); -const dueDate = uiMessageDetails.dueDate!; // new Date("2021-11-17T12:32:14.497Z"); -const defaultProps: React.ComponentProps = - { - dueDate, - messageDetails: uiMessageDetails, - paymentExpirationInfo: { - kind: "EXPIRABLE", - expireStatus: "EXPIRED", - dueDate - } - }; - -describe("MedicalPrescriptionDueDateBar component", () => { - describe("when payment info is expired", () => { - it("should match the snapshot", () => { - expect( - renderComponent(defaultProps).component.toJSON() - ).toMatchSnapshot(); - }); - }); - - describe("when payment info is expiring", () => { - it("should match the snapshot", () => { - expect( - renderComponent({ - ...defaultProps, - paymentExpirationInfo: { - ...defaultProps.paymentExpirationInfo, - expireStatus: "EXPIRING" - } as MessagePaymentExpirationInfo - }).component.toJSON() - ).toMatchSnapshot(); - }); - }); - - describe("when payment info is valid", () => { - it("should match the snapshot", () => { - expect( - renderComponent({ - ...defaultProps, - paymentExpirationInfo: { - ...defaultProps.paymentExpirationInfo, - expireStatus: "VALID" - } as MessagePaymentExpirationInfo - }).component.toJSON() - ).toMatchSnapshot(); - }); - }); - - describe("when payment info is not expirable", () => { - it("should match the snapshot", () => { - expect( - renderComponent({ - ...defaultProps, - paymentExpirationInfo: { - kind: "UNEXPIRABLE" - } - }).component.toJSON() - ).toMatchSnapshot(); - }); - }); -}); - -const renderComponent = ( - props: React.ComponentProps -) => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const mockStore = configureMockStore(); - const store: ReturnType = mockStore(globalState); - - return { - component: renderScreenWithNavigationStoreContext( - () => , - MESSAGES_ROUTES.MESSAGE_DETAIL, - {}, - store - ), - store - }; -}; diff --git a/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionAttachments.test.tsx.snap b/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionAttachments.test.tsx.snap deleted file mode 100644 index 700bd3fdfeb..00000000000 --- a/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionAttachments.test.tsx.snap +++ /dev/null @@ -1,919 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MedicalPrescriptionAttachments component when an attachment is present and has mimeType=image/svg+xml should render the SVG 1`] = ` - - - - - NATIONAL HEALTH SERVICE - - - - WHO - - - - - - - - - BARCODES - - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - -" - xmlSpace="preserve" - xmlns="http://www.w3.org/2000/svg" - xmlnsXlink="http://www.w3.org/1999/xlink" - y="0px" - > - - - - - - - - - - - - - - - - Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011 - - - -`; - -exports[`MedicalPrescriptionAttachments component when an attachment is present and prescriptionData is present should render it 1`] = ` - - - - - NATIONAL HEALTH SERVICE - - - - WHO - - - - - - - - - - Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011 - - - -`; - -exports[`MedicalPrescriptionAttachments component when an attachment is present should render it 1`] = ` - - - - - NATIONAL HEALTH SERVICE - - - - WHO - - - - - - - - - - Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011 - - - -`; - -exports[`MedicalPrescriptionAttachments component when the organization name is defined should render it 1`] = ` - - - - - NATIONAL HEALTH SERVICE - - - - WHO - - - - - - - - - - Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011 - - - -`; - -exports[`MedicalPrescriptionAttachments component with default properties should render 1`] = ` - - - - - NATIONAL HEALTH SERVICE - - - - - - - - - - - Rilasciato ai sensi dell'art.11, comma 16 del DL 31 mag 2010, n.78 e dell’art.1, comma 4 del DM 2 nov 2011 - - - -`; diff --git a/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionDueDateBar.test.tsx.snap b/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionDueDateBar.test.tsx.snap deleted file mode 100644 index 38be0dd2fdc..00000000000 --- a/ts/features/messages/components/MessageDetail/__tests__/__snapshots__/MedicalPrescriptionDueDateBar.test.tsx.snap +++ /dev/null @@ -1,2644 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MedicalPrescriptionDueDateBar component when payment info is expired should match the snapshot 1`] = ` - - - - - - - - - - - - - MESSAGE_DETAIL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Expired on - - 01/12/2021 - - at - - 13:29 - - - - - - - - - - - - - - -`; - -exports[`MedicalPrescriptionDueDateBar component when payment info is expiring should match the snapshot 1`] = ` - - - - - - - - - - - - - MESSAGE_DETAIL - - - - - - - - - - - - - - - - - - - - Expiring on - - 01/12/2021 - - at - - 13:29 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reminder - - - - - - - - - - - - - - -`; - -exports[`MedicalPrescriptionDueDateBar component when payment info is not expirable should match the snapshot 1`] = ` - - - - - - - - - - - - - MESSAGE_DETAIL - - - - - - - - - - - - - - - - - - - - Expiring on - - 01/12/2021 - - at - - 13:29 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reminder - - - - - - - - - - - - - - -`; - -exports[`MedicalPrescriptionDueDateBar component when payment info is valid should match the snapshot 1`] = ` - - - - - - - - - - - - - MESSAGE_DETAIL - - - - - - - - - - - - - - - - - - - - Expiring on - - 01/12/2021 - - at - - 13:29 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reminder - - - - - - - - - - - - - - -`; diff --git a/ts/features/messages/components/MessageDetail/index.tsx b/ts/features/messages/components/MessageDetail/index.tsx index ad1ee27e05b..31a2bf26c1d 100644 --- a/ts/features/messages/components/MessageDetail/index.tsx +++ b/ts/features/messages/components/MessageDetail/index.tsx @@ -30,6 +30,7 @@ import { UIService } from "../../../../store/reducers/entities/services/types"; import variables from "../../../../theme/variables"; import { cleanMarkdownFromCTAs } from "../../utils/messages"; import OrganizationHeader from "../../../../components/OrganizationHeader"; +import { H1 } from "../../../../components/core/typography/H1"; import { H2 } from "../../../../components/core/typography/H2"; import { AppParamsList, @@ -40,9 +41,7 @@ import { MESSAGES_ROUTES } from "../../navigation/routes"; import CtaBar from "./CtaBar"; import { RemoteContentBanner } from "./RemoteContentBanner"; import { HeaderDueDateBar } from "./HeaderDueDateBar"; -import { MessageTitle } from "./MessageTitle"; import MessageContent from "./Content"; -import MedicalPrescriptionAttachments from "./MedicalPrescriptionAttachments"; import MessageMarkdown from "./MessageMarkdown"; const styles = StyleSheet.create({ @@ -133,17 +132,7 @@ const MessageDetailsComponent = ({ // This is used to make sure that no attachments are shown before the // markdown content has rendered const [isContentLoadCompleted, setIsContentLoadCompleted] = useState(false); - // Note that it is not possibile for a message to have both medical - // prescription attachments and third party data. That is why, later in the - // code, the UI rendering is guarded by opposite checks on prescription and - // third party attachments - const { - prescriptionAttachments, - markdown, - prescriptionData, - hasRemoteContent - } = messageDetails; - const isPrescription = prescriptionData !== undefined; + const { markdown, hasRemoteContent } = messageDetails; const { id: messageId, title } = message; const thirdPartyDataPot = useIOSelector(state => @@ -212,7 +201,7 @@ const MessageDetailsComponent = ({ - +

{messageTitle}

@@ -231,19 +220,6 @@ const MessageDetailsComponent = ({ - {prescriptionAttachments && - !hasThirdPartyDataAttachments && - isContentLoadCompleted && ( - <> - - - - )} - {hasRemoteContent && isContentLoadCompleted ? ( <> diff --git a/ts/features/messages/components/__test__/MessageDetail.test.tsx b/ts/features/messages/components/__test__/MessageDetail.test.tsx index 3df3385ea4e..f121661fad8 100644 --- a/ts/features/messages/components/__test__/MessageDetail.test.tsx +++ b/ts/features/messages/components/__test__/MessageDetail.test.tsx @@ -3,7 +3,7 @@ import configureMockStore from "redux-mock-store"; import I18n from "../../../../i18n"; import { applicationChangeState } from "../../../../store/actions/application"; import { - medicalPrescription, + message_1, paymentValidInvalidAfterDueDate } from "../../__mocks__/message"; import { service_1 } from "../../__mocks__/messages"; @@ -26,8 +26,8 @@ const add8Days = (dueDate: Date) => const defaultProps: React.ComponentProps = { hasPaidBadge: false, - message: toUIMessage(medicalPrescription), - messageDetails: toUIMessageDetails(medicalPrescription), + message: toUIMessage(message_1), + messageDetails: toUIMessageDetails(message_1), onServiceLinkPress: jest.fn(), service: toUIService(service_1), serviceMetadata: { phone: "+123333", email: "hola@vpn.com" } as any @@ -42,7 +42,7 @@ describe("MessageDetail component", () => { }); }); - describe("when a message doesn't contain prescription data but has a due date", () => { + describe("when a message has a due date", () => { const props = { ...defaultProps, messageDetails: toUIMessageDetails({ @@ -70,58 +70,6 @@ describe("MessageDetail component", () => { }); }); }); - - describe("when a message contains prescription data", () => { - it("should render the medical prescription identifiers", () => { - const { component } = renderComponent(defaultProps); - expect( - component.queryByText(I18n.t("messages.medical.nre")) - ).not.toBeNull(); - expect( - component.queryByText(I18n.t("messages.medical.iup")) - ).not.toBeNull(); - expect( - component.queryByText(I18n.t("messages.medical.patient_fiscal_code")) - ).not.toBeNull(); - }); - - it("should not render the CTA bar", () => { - const { component } = renderComponent(defaultProps); - expect(component.queryByTestId("CtaBar_withCTA")).toBeNull(); - expect(component.queryByTestId("CtaBar_withFooter")).toBeNull(); - }); - - it("should render the custom title", () => { - const { component } = renderComponent(defaultProps); - expect( - component.queryByText(I18n.t("messages.medical.prescription")) - ).not.toBeNull(); - expect( - component.queryByText(I18n.t("messages.medical.memo")) - ).not.toBeNull(); - }); - - describe("and has a due date more than 7 days in the future with payment data", () => { - // Please note that medical data can also carry a payment - const props = { - ...defaultProps, - messageDetails: toUIMessageDetails({ - ...medicalPrescription, - content: { - ...medicalPrescription.content, - payment_data: paymentValidInvalidAfterDueDate.content.payment_data, - due_date: add8Days(new Date()) - } - }) - }; - it("should render the medical prescription due date", () => { - const { component } = renderComponent(props); - expect( - component.queryByTestId("MedicalPrescriptionDueDate_valid") - ).not.toBeNull(); - }); - }); - }); }); const renderComponent = (props: React.ComponentProps) => { diff --git a/ts/features/messages/store/reducers/transformers.ts b/ts/features/messages/store/reducers/transformers.ts index 799e24bda66..c6a3aaabaaf 100644 --- a/ts/features/messages/store/reducers/transformers.ts +++ b/ts/features/messages/store/reducers/transformers.ts @@ -11,10 +11,8 @@ import { ThirdPartyMessageWithContent } from "../../../../../definitions/backend import { apiUrlPrefix } from "../../../../config"; import { ContentTypeValues } from "../../types/contentType"; import { - Attachment, EUCovidCertificate, PaymentData, - PrescriptionData, UIAttachment, UIAttachmentId, UIMessage, @@ -53,17 +51,6 @@ export const toUIMessage = ( }; }; -const getPrescriptionAttachments = ({ - attachments -}: CreatedMessageWithContentAndAttachments["content"]): - | ReadonlyArray - | undefined => - attachments?.map(({ name, content, mime_type }) => ({ - name, - content, - mimeType: mime_type - })); - const getPaymentData = ({ payment_data }: CreatedMessageWithContentAndAttachments["content"]): @@ -81,21 +68,6 @@ const getPaymentData = ({ return undefined; }; -const getPrescriptionData = ({ - prescription_data -}: CreatedMessageWithContentAndAttachments["content"]): - | PrescriptionData - | undefined => { - if (prescription_data) { - return { - nre: prescription_data.nre, - iup: prescription_data.iup, - prescriberFiscalCode: prescription_data.prescriber_fiscal_code - }; - } - return undefined; -}; - const getEUCovidCertificate = ({ eu_covid_cert }: CreatedMessageWithContentAndAttachments["content"]): @@ -122,8 +94,6 @@ export const toUIMessageDetails = ( return { id: id as UIMessageId, - prescriptionData: getPrescriptionData(content), - prescriptionAttachments: getPrescriptionAttachments(content), markdown: content.markdown, dueDate, diff --git a/ts/features/messages/types/index.ts b/ts/features/messages/types/index.ts index 2903895d572..7c8fd6d587a 100644 --- a/ts/features/messages/types/index.ts +++ b/ts/features/messages/types/index.ts @@ -47,8 +47,6 @@ export type UIMessage = WithUIMessageId<{ export type UIMessageDetails = WithUIMessageId<{ subject: string; serviceId: ServiceId; - prescriptionData?: PrescriptionData; - prescriptionAttachments?: ReadonlyArray; markdown: MessageBodyMarkdown; dueDate?: Date; paymentData?: PaymentData; @@ -59,12 +57,6 @@ export type UIMessageDetails = WithUIMessageId<{ raw: CreatedMessageWithContentAndAttachments; }>; -export type PrescriptionData = { - nre: string; - iup?: string; - prescriberFiscalCode?: FiscalCode; -}; - export type EUCovidCertificate = { authCode: string }; export type PaymentData = { diff --git a/ts/features/messages/utils/messages.ts b/ts/features/messages/utils/messages.ts index b0bb3e3024b..4ac4b5902aa 100644 --- a/ts/features/messages/utils/messages.ts +++ b/ts/features/messages/utils/messages.ts @@ -8,10 +8,8 @@ import { Predicate } from "fp-ts/lib/Predicate"; import { identity, pipe } from "fp-ts/lib/function"; import FM from "front-matter"; import { Linking } from "react-native"; -import { CreatedMessageWithContent } from "../../../../definitions/backend/CreatedMessageWithContent"; import { CreatedMessageWithContentAndAttachments } from "../../../../definitions/backend/CreatedMessageWithContentAndAttachments"; import { MessageBodyMarkdown } from "../../../../definitions/backend/MessageBodyMarkdown"; -import { PrescriptionData } from "../../../../definitions/backend/PrescriptionData"; import { ServiceId } from "../../../../definitions/backend/ServiceId"; import { ServiceMetadata } from "../../../../definitions/backend/ServiceMetadata"; import { ServicePublic } from "../../../../definitions/backend/ServicePublic"; @@ -104,10 +102,6 @@ export const handleCtaAction = ( } }; -export const hasPrescriptionData = ( - message: CreatedMessageWithContent -): boolean => pipe(message.content.prescription_data, O.fromNullable, O.isSome); - type MessagePaymentUnexpirable = { kind: "UNEXPIRABLE"; expireStatus?: ExpireStatus; @@ -195,34 +189,6 @@ export const isExpired = ( messagePaymentExpirationInfo: MessagePaymentExpirationInfo ) => messagePaymentExpirationInfo.expireStatus === "EXPIRED"; -/** - * given a name, return the relative prescription data value if it corresponds to a field - * @param prescriptionData - * @param name it should be a string nre | iup | prescriber_fiscal_code - */ -export const getPrescriptionDataFromName = ( - prescriptionData: PrescriptionData | undefined, - name: string -): O.Option => - pipe( - prescriptionData, - O.fromNullable, - O.fold( - () => O.none, - pd => { - switch (name.toLowerCase()) { - case "nre": - return O.some(pd.nre); - case "iup": - return O.fromNullable(pd.iup); - case "prescriber_fiscal_code": - return O.fromNullable(pd.prescriber_fiscal_code); - } - return O.none; - } - ) - ); - const hasMetadataTokenName = (metadata?: ServiceMetadata): boolean => metadata?.token_name !== undefined;