diff --git a/package.json b/package.json
index 77c486a..8d60cf9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ctm-document-builder",
- "version": "1.2.2",
+ "version": "1.3.0",
"description": "CTM Document Builder — Electron + React with cloud PocketBase",
"author": "Wirediv",
"license": "MIT",
@@ -28,7 +28,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.3",
- "electron": "^33.2.0",
+ "electron": "^33.4.11",
"electron-builder": "^24.13.3",
"vite": "^5.4.11",
"vite-plugin-electron": "^0.29.0",
@@ -75,5 +75,9 @@
],
"artifactName": "${productName}_${version}.${ext}"
}
+ },
+ "allowScripts": {
+ "electron@33.4.11": true,
+ "esbuild@0.21.5": true
}
}
\ No newline at end of file
diff --git a/src/lib/buildVaccinationRecordHtml.js b/src/lib/buildVaccinationRecordHtml.js
index 70cb79b..7288532 100644
--- a/src/lib/buildVaccinationRecordHtml.js
+++ b/src/lib/buildVaccinationRecordHtml.js
@@ -351,7 +351,7 @@ export function buildVaccinationRecordHtml({
| Date |
- Product brand |
+ Product Brand |
${diseaseHeaders}
diff --git a/src/lib/vaccinationRecordDiseases.js b/src/lib/vaccinationRecordDiseases.js
index 1054851..81db104 100644
--- a/src/lib/vaccinationRecordDiseases.js
+++ b/src/lib/vaccinationRecordDiseases.js
@@ -13,7 +13,8 @@ export const DISEASE_OPTIONS = [
{ key: 'cholera', value: 'ETEC-Cholera' },
{ key: 'tdap', value: 'TdaP' },
{ key: 'rabies', value: 'Rabies' },
- { key: 'meningococcal', value: 'Meningococcal' },
+ { key: 'men-groups', value: 'Meningococcal (Groups A,C,Y,W)' },
+ { key: 'men-c-c', value: 'Meningococcal C-C' },
{ key: 'yellow-fever', value: 'Yellow Fever' },
{ key: 'hpv', value: 'HPV' },
{ key: 'polio', value: 'Polio' },
diff --git a/src/lib/vaccinationRecordMetadata.js b/src/lib/vaccinationRecordMetadata.js
index ccbbdf4..f14fe97 100644
--- a/src/lib/vaccinationRecordMetadata.js
+++ b/src/lib/vaccinationRecordMetadata.js
@@ -5,9 +5,12 @@ import {
} from './vaccinationRecordDiseases.js'
export const VR_METADATA_MARKER = 'CTM_VR'
-export const VR_METADATA_LATEST_VERSION = 1
+export const VR_METADATA_LATEST_VERSION = 2
const DISEASE_KEYS = new Set(DISEASE_OPTIONS.map((d) => d.key))
+const LEGACY_DISEASE_KEY_MAP = {
+ meningococcal: 'men-groups',
+}
const METADATA_RE = /CTM_VR:(\d+):([A-Za-z0-9_-]+)/
function encodeBase64Url(str) {
@@ -36,7 +39,7 @@ function str(value) {
return value == null ? '' : String(value)
}
-function buildV1Payload({ patientName, dateOfBirth, notes, rows }) {
+function buildLatestPayload({ patientName, dateOfBirth, notes, rows }) {
const normalizedRows = (rows ?? [])
.slice(0, VACCINATION_RECORD_MAX_ROWS)
.map((row) => {
@@ -61,7 +64,7 @@ function buildV1Payload({ patientName, dateOfBirth, notes, rows }) {
}
}
-function parseV1Payload(raw) {
+function parsePayload(raw, { migrateLegacyKeys = false } = {}) {
if (!raw || typeof raw !== 'object') {
throw new Error('Invalid vaccination record metadata payload.')
}
@@ -82,9 +85,12 @@ function parseV1Payload(raw) {
if (!row || typeof row !== 'object') {
throw new Error(`Invalid row at index ${index} in vaccination record metadata.`)
}
- const diseaseKey = str(row.diseaseKey)
+ const rawDiseaseKey = str(row.diseaseKey)
+ const diseaseKey = migrateLegacyKeys
+ ? (LEGACY_DISEASE_KEY_MAP[rawDiseaseKey] ?? rawDiseaseKey)
+ : rawDiseaseKey
if (!DISEASE_KEYS.has(diseaseKey)) {
- throw new Error(`Invalid disease key at row ${index}: ${diseaseKey}`)
+ throw new Error(`Invalid disease key at row ${index}: ${rawDiseaseKey}`)
}
const date = str(row.date)
if (date && !isValidIsoDate(date)) {
@@ -102,15 +108,24 @@ function parseV1Payload(raw) {
return { patientName, dateOfBirth, notes, rows }
}
+function parseV1Payload(raw) {
+ return parsePayload(raw, { migrateLegacyKeys: true })
+}
+
+function parseV2Payload(raw) {
+ return parsePayload(raw, { migrateLegacyKeys: false })
+}
+
const VERSION_PARSERS = {
1: parseV1Payload,
+ 2: parseV2Payload,
}
/**
* @param {{ patientName?: string, dateOfBirth?: string, notes?: string, rows?: object[] }} data
*/
export function buildEncodedVaccinationRecordMetadata(data) {
- const payload = buildV1Payload(data)
+ const payload = buildLatestPayload(data)
const encoded = encodeBase64Url(JSON.stringify(payload))
return `${VR_METADATA_MARKER}:${VR_METADATA_LATEST_VERSION}:${encoded}`
}