From 9cd82c1234ca966aff9fd9372150e42a5ce18853 Mon Sep 17 00:00:00 2001 From: ggrund-tsi <80682839+ggrund-tsi@users.noreply.github.com> Date: Wed, 2 Jun 2021 10:09:15 +0200 Subject: [PATCH] Fix/test type (#87) * set cert expiration from service or recovery * add value set 4 test type Co-authored-by: Gordon Grund --- src/api.tsx | 18 +++++++++++++++++ src/assets/json-res/test-type.json | 20 +++++++++++++++++++ src/components/pdf-generater.component.tsx | 7 ++++--- .../record-test-cert-data.component.tsx | 6 +++--- src/misc/ShowCertificateData.tsx | 5 +++-- 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/assets/json-res/test-type.json diff --git a/src/api.tsx b/src/api.tsx index 216aafc..60db374 100644 --- a/src/api.tsx +++ b/src/api.tsx @@ -30,6 +30,7 @@ import VaccineManufacturers from './assets/json-res/vaccine-mah-manf.json'; import Vaccines from './assets/json-res/vaccine-prophylaxis.json'; import TestManufacturers from './assets/json-res/test-manf.json'; import TestResult from './assets/json-res/test-result.json'; +import TestType from './assets/json-res/test-type.json'; interface IValue { active: boolean, @@ -116,6 +117,23 @@ export const useGetVaccines = () => { return vaccines; } +// TestType +export const useGetTestType = () => { + + const [testType, setTestType] = React.useState(); + + React.useEffect(() => { + // get object via api + // const testManufacturers = getApiData('/testManufacturers'); + + // get object via public + const testType = TestType.valueSetValues; + setTestType(testType); + }, []) + + return testType; +} + // TestManufacturers export const useGetTestManufacturers = () => { diff --git a/src/assets/json-res/test-type.json b/src/assets/json-res/test-type.json new file mode 100644 index 0000000..092b0b5 --- /dev/null +++ b/src/assets/json-res/test-type.json @@ -0,0 +1,20 @@ +{ + "valueSetId": "covid-19-lab-test-type", + "valueSetDate": "2021-04-27", + "valueSetValues": { + "LP6464-4": { + "display": "Nucleic acid amplification with probe detection", + "lang": "en", + "active": true, + "version": "2.69", + "system": "http://loinc.org" + }, + "LP217198-3": { + "display": "Rapid immunoassay", + "lang": "en", + "active": true, + "version": "2.69", + "system": "http://loinc.org" + } + } +} \ No newline at end of file diff --git a/src/components/pdf-generater.component.tsx b/src/components/pdf-generater.component.tsx index 069124f..662eaa1 100644 --- a/src/components/pdf-generater.component.tsx +++ b/src/components/pdf-generater.component.tsx @@ -35,7 +35,7 @@ import folding_instruction from '../assets/images/folding-instruction.png'; import { EUDGC, RecoveryEntry, TestEntry, VaccinationEntry } from '../generated-files/dgc-combined-schema'; import { useGetDiseaseAgents, useGetVaccineManufacturers, useGetVaccines, - useGetVaccinMedicalData, useGetTestManufacturers, useGetTestResult + useGetVaccinMedicalData, useGetTestManufacturers, useGetTestResult, useGetTestType } from '../api'; import { getValueSetDisplay, convertDateToOutputFormat } from '../misc/ShowCertificateData'; // import pdfParams from '../pdf-settings.json'; @@ -97,6 +97,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi const vaccines = useGetVaccines(); const testManufacturersValueSet = useGetTestManufacturers(); const testResultValueSet = useGetTestResult(); + const testTypeValueSet = useGetTestType(); //A4 210 x 297 mm or 2480 x 3508 pixels or 595 × 842 points //A6 105 x 74 mm or 1240 x 1748 pixels or 298 × 420 points @@ -727,7 +728,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi y = printVerticalBlock(x, y, t('translation:pdfTypeOfTest'), french.translation.pdfTypeOfTest, - testSet.tt, + getValueSetDisplay(testSet.tt, testTypeValueSet), lineHeight, true); y = printVerticalBlock(x, y, @@ -804,7 +805,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudgcProp: EUDGC | undefi y = printVerticalBlockRotated(x, y, t('translation:pdfTypeOfTest'), french.translation.pdfTypeOfTest, - testSet.tt, + getValueSetDisplay(testSet.tt, testTypeValueSet), lineHeight, true); y = printVerticalBlockRotated(x, y, diff --git a/src/components/record-test-cert-data.component.tsx b/src/components/record-test-cert-data.component.tsx index 6b78a16..5ec5837 100644 --- a/src/components/record-test-cert-data.component.tsx +++ b/src/components/record-test-cert-data.component.tsx @@ -32,7 +32,7 @@ import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import { EUDGC, TestEntry } from '../generated-files/dgc-combined-schema'; -import { useGetDiseaseAgents, useGetTestManufacturers, useGetTestResult } from '../api'; +import { useGetDiseaseAgents, useGetTestManufacturers, useGetTestResult, useGetTestType } from '../api'; import schema from '../generated-files/DGC.combined-schema.json'; import { Validator } from 'jsonschema'; @@ -214,11 +214,11 @@ const RecordTestCertData = (props: any) => { /> {/* testType input */} - setTestType(evt.target.value)} required - maxLength={50} + valueSet={useGetTestType} /> {/* testName input */} diff --git a/src/misc/ShowCertificateData.tsx b/src/misc/ShowCertificateData.tsx index 4407a9d..d66087d 100644 --- a/src/misc/ShowCertificateData.tsx +++ b/src/misc/ShowCertificateData.tsx @@ -3,7 +3,7 @@ import i18n from 'i18next' import { IValueSet } from '../api'; import moment from 'moment'; import utils from './utils'; -import { useGetDiseaseAgents, useGetVaccineManufacturers, useGetVaccines, useGetVaccinMedicalData, useGetTestManufacturers, useGetTestResult } from '../api'; +import { useGetDiseaseAgents, useGetVaccineManufacturers, useGetVaccines, useGetVaccinMedicalData, useGetTestManufacturers, useGetTestResult, useGetTestType } from '../api'; import React from 'react'; import { Card } from 'react-bootstrap'; @@ -28,6 +28,7 @@ export const ShowCertificateData = (props: any) => { const vaccines = useGetVaccines(); const testManufacturersValueSet = useGetTestManufacturers(); const testResultValueSet = useGetTestResult(); + const testTypeValueSet = useGetTestType(); const [eudgc, setEudgc] = React.useState(); const [vaccinationSet, setVaccinationSet] = React.useState(); @@ -124,7 +125,7 @@ export const ShowCertificateData = (props: any) => { title: i18n.t('translation:test-data'), entries: [ { label: i18n.t('translation:disease-agent'), data: getValueSetDisplay(testSet?.tg, diseaseAgentsData) || defaultString }, - { label: i18n.t('translation:testType'), data: testSet?.tt || defaultString }, + { label: i18n.t('translation:testType'), data: getValueSetDisplay(testSet?.tt, testTypeValueSet) || defaultString }, { label: i18n.t('translation:testName'), data: testSet?.nm || defaultString }, { label: i18n.t('translation:testManufacturers'), data: getValueSetDisplay(testSet?.ma, testManufacturersValueSet) || defaultString } ]