From 3c8b263c1a840fb2ceeed1f58572c43d842e2419 Mon Sep 17 00:00:00 2001 From: Mehdi-BOUYAHIA <63298037+Mehdi-BOUYAHIA@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:49:48 +0200 Subject: [PATCH] refactor: change of route composition by documentreference Ref gestion-de-projet#1489 * refactor: WIP on change of route Composition by DocumentReference Ref gestion-de-projet#1489 * refactor: Change of route Composition by DocumentReference Ref gestion-de-projet#1489 * refactor: Change of route Composition by DocumentReference Ref gestion-de-projet#1489 --- package-lock.json | 223 ++++++++++++------ package.json | 1 + .../CriteriaCardContent.tsx | 4 +- .../DocumentsForm/DocumentsForm.tsx | 2 +- .../DataTable/DataTableComposition.tsx | 24 +- src/components/DataTable/DataTableTopBar.tsx | 2 +- .../DocumentViewer/DocumentViewer.tsx | 23 +- src/services/README.md | 2 +- src/services/aphp/callApi.ts | 29 ++- src/services/aphp/serviceCohorts.ts | 39 +-- src/services/aphp/servicePatients.ts | 38 ++- src/state/patient.ts | 12 +- src/types.ts | 18 +- src/utils/cohortCreation.ts | 4 +- 14 files changed, 288 insertions(+), 133 deletions(-) diff --git a/package-lock.json b/package-lock.json index a0b0a2714..0ae2c109c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "cohort360_react", - "version": "2.21.0", + "version": "2.22.0-SNAPSHOT", "dependencies": { "@apollo/client": "^3.7.10", "@apollo/react-hooks": "^4.0.0", @@ -23,6 +23,7 @@ "ace-builds": "^1.16.0", "apollo-boost": "^0.4.9", "axios": "^0.27.2", + "buffer": "^6.0.3", "client-oauth2": "^4.3.3", "clsx": "^1.1.1", "d3": "^7.8.2", @@ -346,15 +347,6 @@ "@babel/core": "^7.0.0" } }, - "node_modules/@babel/helper-compilation-targets/node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "dependencies": { - "yallist": "^3.0.2" - } - }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -364,12 +356,6 @@ "semver": "bin/semver.js" } }, - "node_modules/@babel/helper-compilation-targets/node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true - }, "node_modules/@babel/helper-create-class-features-plugin": { "version": "7.21.4", "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.4.tgz", @@ -6954,6 +6940,25 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -7162,6 +7167,29 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -11424,6 +11452,25 @@ "node": ">=4" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -13433,15 +13480,6 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, - "node_modules/jest-runtime/node_modules/strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-serializer": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-27.5.1.tgz", @@ -14464,15 +14502,12 @@ } }, "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" + "yallist": "^3.0.2" } }, "node_modules/lz-string": { @@ -18256,6 +18291,24 @@ "node": ">=10" } }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -18795,12 +18848,12 @@ } }, "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/strip-comments": { @@ -19512,6 +19565,15 @@ "json5": "lib/cli.js" } }, + "node_modules/tsconfig-paths/node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/tslib": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", @@ -20780,9 +20842,9 @@ } }, "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, "node_modules/yaml": { @@ -21040,26 +21102,11 @@ "semver": "^6.3.0" }, "dependencies": { - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "requires": { - "yallist": "^3.0.2" - } - }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true - }, - "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true } } }, @@ -25930,6 +25977,11 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, "batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", @@ -26099,6 +26151,15 @@ "node-int64": "^0.4.0" } }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -29272,6 +29333,11 @@ "harmony-reflect": "^1.4.6" } }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, "ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -30845,12 +30911,6 @@ "graceful-fs": "^4.2.9", "picomatch": "^2.2.3" } - }, - "strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "dev": true } } }, @@ -31684,12 +31744,12 @@ } }, "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, "requires": { - "yallist": "^4.0.0" + "yallist": "^3.0.2" } }, "lz-string": { @@ -34250,6 +34310,23 @@ "dev": true, "requires": { "lru-cache": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } } }, "send": { @@ -34707,9 +34784,9 @@ } }, "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true }, "strip-comments": { @@ -35249,6 +35326,12 @@ "requires": { "minimist": "^1.2.0" } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true } } }, @@ -36240,9 +36323,9 @@ "dev": true }, "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, "yaml": { diff --git a/package.json b/package.json index 48a546f5c..c42d1a2c3 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "ace-builds": "^1.16.0", "apollo-boost": "^0.4.9", "axios": "^0.27.2", + "buffer": "^6.0.3", "client-oauth2": "^4.3.3", "clsx": "^1.1.1", "d3": "^7.8.2", diff --git a/src/components/CreationCohort/DiagramView/components/CriteriaCard/components/CriteriaCardContent/CriteriaCardContent.tsx b/src/components/CreationCohort/DiagramView/components/CriteriaCard/components/CriteriaCardContent/CriteriaCardContent.tsx index 6ad58b7f2..e55327dcc 100644 --- a/src/components/CreationCohort/DiagramView/components/CriteriaCard/components/CriteriaCardContent/CriteriaCardContent.tsx +++ b/src/components/CreationCohort/DiagramView/components/CriteriaCard/components/CriteriaCardContent/CriteriaCardContent.tsx @@ -331,13 +331,13 @@ const CriteriaCardContent: React.FC = ({ currentCriter label={ Contient "{_currentCriteria.search}" dans le - {_currentCriteria.searchBy === SearchByTypes.title && ' titre du'} document + {_currentCriteria.searchBy === SearchByTypes.description && ' titre du'} document } diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx index 21d17961a..1b19128fe 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx @@ -170,7 +170,7 @@ const CompositionForm: React.FC = (props) => { label="Rechercher dans :" > Corps du document - Titre du document + Titre du document diff --git a/src/components/DataTable/DataTableComposition.tsx b/src/components/DataTable/DataTableComposition.tsx index 0f5fc9fdb..24ab34f0b 100644 --- a/src/components/DataTable/DataTableComposition.tsx +++ b/src/components/DataTable/DataTableComposition.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' import clsx from 'clsx' +import { Buffer } from 'buffer' import { CircularProgress, Chip, Grid, IconButton, Typography, TableRow, TableCell } from '@mui/material' @@ -131,16 +132,25 @@ const DataTableCompositionLine: React.FC<{ const [open, setOpen] = useState(null) const documentId = document.id - const title = document.title + const title = document.description const status = document.status - const event = document.event + const event = document.content[0].attachment.url const ipp = deidentified ? document.idPatient : document.IPP const nda = document.NDA ?? '-' const serviceProvider = document.serviceProvider ?? 'Non renseigné' const docType = docTypes.docTypes.find( ({ code }) => code === (document.type?.coding && document.type?.coding[0] ? document.type?.coding[0].code : '-') ) - const section = searchMode ? document.section : [] + + const documentContent = + document && + document.content && + document.content[1] && + document.content[1].attachment && + document.content[1].attachment.data + ? Buffer.from(document.content[1].attachment.data, 'base64').toString('utf-8') + : '' + const date = document.date ? new Date(document.date).toLocaleDateString('fr-FR') : '' const hour = document.date ? new Date(document.date).toLocaleTimeString('fr-FR', { @@ -212,14 +222,10 @@ const DataTableCompositionLine: React.FC<{ - {section && section.length > 0 && ( + {documentContent && searchMode && ( - {section.map((section) => ( - - - - ))} + {documentContent} )} diff --git a/src/components/DataTable/DataTableTopBar.tsx b/src/components/DataTable/DataTableTopBar.tsx index 651dec84b..eb77de44d 100644 --- a/src/components/DataTable/DataTableTopBar.tsx +++ b/src/components/DataTable/DataTableTopBar.tsx @@ -220,7 +220,7 @@ const DataTableTopBar: React.FC = ({ loading, tabs, result style={{ height: 42 }} > Corps du document - Titre du document + Titre du document )} diff --git a/src/components/DocumentViewer/DocumentViewer.tsx b/src/components/DocumentViewer/DocumentViewer.tsx index 84b269e38..ad63a4122 100644 --- a/src/components/DocumentViewer/DocumentViewer.tsx +++ b/src/components/DocumentViewer/DocumentViewer.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react' +import { Buffer } from 'buffer' -import { IComposition_Section } from '@ahryman40k/ts-fhir-types/lib/R4' +import { IDocumentReference } from '@ahryman40k/ts-fhir-types/lib/R4' import Button from '@mui/material/Button' import CircularProgress from '@mui/material/CircularProgress' @@ -28,7 +29,7 @@ type DocumentViewerProps = { } const DocumentViewer: React.FC = ({ deidentified, open, handleClose, documentId }) => { - const [documentContent, setDocumentContent] = useState(null) + const [documentContent, setDocumentContent] = useState(null) const [numPages, setNumPages] = useState(1) const [loading, setLoading] = useState(false) @@ -60,6 +61,15 @@ const DocumentViewer: React.FC = ({ deidentified, open, han margin: 'auto' } + const documentContentDecode = + documentContent && + documentContent.content && + documentContent.content[1] && + documentContent.content[1].attachment && + documentContent.content[1].attachment.data + ? Buffer.from(documentContent.content[1].attachment.data, 'base64').toString('utf-8') + : '' + return ( @@ -71,13 +81,8 @@ const DocumentViewer: React.FC = ({ deidentified, open, han ) : (
- {documentContent && documentContent.length > 0 ? ( - documentContent.map((section: any) => ( - <> - {section.title} - - - )) + {documentContentDecode ? ( + {documentContentDecode} ) : ( Le contenu du document est introuvable. )} diff --git a/src/services/README.md b/src/services/README.md index 1eb3b7b0c..01ac81210 100644 --- a/src/services/README.md +++ b/src/services/README.md @@ -340,7 +340,7 @@ export interface IServiceCohorts { ) => Promise<{ totalDocs: number totalAllDocs: number - documentsList: IComposition[] + documentsList: IDocumentReference[] }> fetchDocumentContent: (compositionId: string) => Promise diff --git a/src/services/aphp/callApi.ts b/src/services/aphp/callApi.ts index 1ce0bc724..dd83ccdaf 100644 --- a/src/services/aphp/callApi.ts +++ b/src/services/aphp/callApi.ts @@ -4,8 +4,8 @@ import { CohortComposition, SearchByTypes, FHIR_API_Response, IScope } from 'typ import { IBinary, IClaim, - IComposition, ICondition, + IDocumentReference, IEncounter, IGroup, IMedicationAdministration, @@ -220,7 +220,20 @@ type fetchCompositionProps = { 'patient.identifier'?: string facet?: ('class' | 'visit-year-month-gender-facet')[] uniqueFacet?: 'patient'[] - _elements?: ('status' | 'type' | 'subject' | 'encounter' | 'date' | 'title' | 'event')[] + _elements?: ( + | 'docstatus' + | 'status' + | 'type' + | 'subject' + | 'encounter' + | 'date' + | 'title' + | 'event' + | 'content' + | 'context' + | 'text' + | 'description' + )[] } export const fetchComposition = async (args: fetchCompositionProps) => { const { @@ -258,8 +271,8 @@ export const fetchComposition = async (args: fetchCompositionProps) => { if (_sort) options = [...options, `_sort=${_sortDirection}${_sort},id`] // eslint-disable-line if (type) options = [...options, `type=${type}`] // eslint-disable-line if (_text) - options = [...options, `${searchBy === SearchByTypes.text ? `_text` : 'title'}=${encodeURIComponent(_text)}`] // eslint-disable-line - if (status) options = [...options, `status=${status}`] // eslint-disable-line + options = [...options, `${searchBy === SearchByTypes.text ? `_text` : 'description'}=${encodeURIComponent(_text)}`] // eslint-disable-line + if (status) options = [...options, `docstatus=${status}`] // eslint-disable-line if (patient) options = [...options, `patient=${patient}`] // eslint-disable-line if (patientIdentifier) options = [...options, `patient.identifier=${patientIdentifier}`] // eslint-disable-line if (encounter) options = [...options, `encounter=${encounter}`] // eslint-disable-line @@ -273,8 +286,8 @@ export const fetchComposition = async (args: fetchCompositionProps) => { if (uniqueFacet && uniqueFacet.length > 0) options = [...options, `uniqueFacet=${uniqueFacet.reduce(reducer)}`] // eslint-disable-line if (_elements && _elements.length > 0) options = [...options, `_elements=${_elements.reduce(reducer)}`] // eslint-disable-line - const response = await apiFhir.get>( - `/Composition?${options.reduce(optionsReducer)}`, + const response = await apiFhir.get>( + `/DocumentReference?${options.reduce(optionsReducer)}`, { signal: signal } ) @@ -290,9 +303,9 @@ export const fetchCheckDocumentSearchInput = async (searchInput: string, signal? } export const fetchCompositionContent = async (compositionId: string) => { - const documentResp = await apiFhir.get(`/Composition/${compositionId}`) + const documentResp = await apiFhir.get(`/DocumentReference/${compositionId}`) - return documentResp.data.section ?? [] + return documentResp.data ?? [] } /** diff --git a/src/services/aphp/serviceCohorts.ts b/src/services/aphp/serviceCohorts.ts index bcd3631d9..37b523d22 100644 --- a/src/services/aphp/serviceCohorts.ts +++ b/src/services/aphp/serviceCohorts.ts @@ -12,13 +12,7 @@ import { searchInputError, errorDetails } from 'types' -import { - IPatient, - IComposition, - IComposition_Section, - PatientGenderKind, - IIdentifier -} from '@ahryman40k/ts-fhir-types/lib/R4' +import { IPatient, PatientGenderKind, IIdentifier, IDocumentReference } from '@ahryman40k/ts-fhir-types/lib/R4' import { getGenderRepartitionMapAphp, getEncounterRepartitionMapAphp, @@ -148,7 +142,7 @@ export interface IServiceCohorts { totalAllDocs: number totalPatientDocs: number totalAllPatientDocs: number - documentsList: IComposition[] + documentsList: IDocumentReference[] }> /** @@ -171,7 +165,7 @@ export interface IServiceCohorts { * Retourne: * - IComposition_Section: Contenu du document */ - fetchDocumentContent: (compositionId: string) => Promise + fetchDocumentContent: (compositionId: string) => Promise /** * Permet de récupérer le contenu d'un document (/Binary) @@ -415,7 +409,22 @@ const servicesCohorts: IServiceCohorts = { _sort: sortBy, sortDirection: sortDirection === 'desc' ? 'desc' : 'asc', status: 'final', - _elements: searchInput ? [] : ['status', 'type', 'subject', 'encounter', 'date', 'title', 'event'], + _elements: searchInput + ? [] + : [ + 'docstatus', + 'status', + 'type', + 'subject', + 'encounter', + 'date', + 'title', + 'event', + 'context', + 'content', + 'text', + 'description' + ], _list: groupId ? [groupId] : [], _text: searchInput, type: selectedDocTypes.length > 0 ? selectedDocTypes.join(',') : '', @@ -776,18 +785,18 @@ export default servicesCohorts const getDocumentInfos: ( deidentifiedBoolean: boolean, - documents?: IComposition[], + documents?: IDocumentReference[], groupId?: string, signal?: AbortSignal ) => Promise = async (deidentifiedBoolean: boolean, documents, groupId, signal) => { const cohortDocuments = (documents as CohortComposition[]) ?? [] const listePatientsIds = cohortDocuments - .map((e) => e.subject?.display?.substring(8)) + .map((e) => e.subject?.reference?.substring(8)) .filter((item, index, array) => array.indexOf(item) === index) .join() const listeEncounterIds = cohortDocuments - .map((e) => e.encounter?.display?.substring(10)) + .map((e) => e.context?.encounter?.[0]?.reference?.substring(10)) .filter((item, index, array) => array.indexOf(item) === index) .join() @@ -821,7 +830,7 @@ const getDocumentInfos: ( for (const document of cohortDocuments) { for (const patient of listePatients) { - if (document.subject?.display?.substring(8) === patient.id) { + if (document.subject?.reference?.substring(8) === patient.id) { document.idPatient = patient.id document.IPP = patient.id ?? 'Inconnu' @@ -835,7 +844,7 @@ const getDocumentInfos: ( } for (const encounter of listeEncounters) { - if (document.encounter?.display?.substring(10) === encounter.id) { + if (document.context?.encounter?.[0].reference?.substring(10) === encounter.id) { document.encounterStatus = encounter.status if (encounter.serviceProvider) { diff --git a/src/services/aphp/servicePatients.ts b/src/services/aphp/servicePatients.ts index e27c7625f..7ed5b2b82 100644 --- a/src/services/aphp/servicePatients.ts +++ b/src/services/aphp/servicePatients.ts @@ -23,7 +23,7 @@ import { IMedicationRequest, IMedicationAdministration, IEncounter, - IComposition, + IDocumentReference, IObservation } from '@ahryman40k/ts-fhir-types/lib/R4' import { @@ -252,7 +252,7 @@ export interface IServicePatients { groupId?: string, signal?: AbortSignal ) => Promise<{ - docsList: IComposition[] + docsList: IDocumentReference[] docsTotal: number }> @@ -598,7 +598,21 @@ const servicesPatients: IServicePatients = { size: documentLines, offset: page ? (page - 1) * documentLines : 0, status: 'final', - _elements: !searchInput ? ['status', 'type', 'encounter', 'date', 'title', 'event'] : [], + _elements: !searchInput + ? [ + 'docstatus', + 'status', + 'type', + 'encounter', + 'date', + 'title', + 'event', + 'content', + 'context', + 'text', + 'description' + ] + : [], _text: searchInput, type: selectedDocTypes.join(','), 'encounter.identifier': nda, @@ -747,7 +761,21 @@ export const getEncounterDocuments = async ( const documentsResp = await fetchComposition({ encounter: encountersIdList.join(','), - _elements: ['status', 'type', 'subject', 'encounter', 'date', 'title', 'event'], + _elements: [ + 'docstatus', + 'status', + 'type', + 'subject', + 'encounter', + 'date', + 'title', + 'event', + 'content', + 'context', + 'text', + 'description', + 'title' + ], status: 'final', _list: groupId ? groupId.split(',') : [] }) @@ -756,7 +784,7 @@ export const getEncounterDocuments = async ( for (const encounter of _encounters) { const currentDocuments = documents?.filter( - (document) => encounter.id === document.encounter?.display?.replace('Encounter/', '') + (document) => encounter.id === document.context?.encounter?.[0].reference?.replace('Encounter/', '') ) const currentDetails = encountersDetail?.filter( (encounterDetail) => encounter.id === encounterDetail?.partOf?.reference?.replace('Encounter/', '') diff --git a/src/state/patient.ts b/src/state/patient.ts index 4cbbc22fd..b3a105718 100644 --- a/src/state/patient.ts +++ b/src/state/patient.ts @@ -5,7 +5,7 @@ import { RootState } from 'state' import { IPatient, IClaim, - IComposition, + IDocumentReference, IProcedure, IEncounter, ICondition, @@ -402,7 +402,7 @@ const fetchDocuments = createAsyncThunk