โ ๏ธ KMEHR 1.40.2 testing (Draft)
Why ?โ
In a upcoming future, the Medication Scheme specifications are going to be updated with a new KMEHR version, more authorized values, ... . So a testing plan could be handy to prepare your software to that.
Prerequisitesโ
- Clone the Github project, e.g.
git clone https://github.com/smals-jy/KMEHR-tests
- Node.JS LTS
- Install Github project dependancies, e.g.
npm install
Stepsโ
- Update the
template file
to use the new KMEHR version
TEMPLATES/PARTIAL.xml (Before)
<!-- KMEHR 1.28.0 version id -->
<cd S="CD-STANDARD" SV="1.4">20161201</cd>
TEMPLATES/PARTIAL.xml (After)
<!-- KMEHR 1.40.2 version id -->
<cd S="CD-STANDARD" SV="1.4">20231110</cd>
- To generate the resulting XML file(s) in
output/ms
folder :
npm start
-
Check that each testing scenario explained on the documentation still work for you with these updated files
-
Create following new test scenarios in
configurations/ms
folder
๐ถ Administration units
configurations/ms/BK-01-CD-ADMINISTRATIONUNIT.ts
import type { Configuration, AdministrationUnit } from "../../src/config";
// Same expected results that https://smals-jy.github.io/KMEHR-tests/docs/tests/ms/read/ts-03#expected-results , but with these values
export default function (): Configuration {
// List of administration-unit
const ADMINISTRATION_UNITS: AdministrationUnit[] = [
// @ts-ignore
"ampoule",
// @ts-ignore
"bandage",
// @ts-ignore
"bottle",
// @ts-ignore
"box",
// @ts-ignore
"effervescent-tablet",
// @ts-ignore
"iu",
// @ts-ignore
"liter",
// @ts-ignore
"meq",
// @ts-ignore
"micrograms",
// @ts-ignore
"miu",
// @ts-ignore
"mmol",
// @ts-ignore
"piece",
// @ts-ignore
"syringe",
// @ts-ignore
"syringe-ampoule"
];
// Generate ADMINISTRATION UNIT entries
return {
transactions: ADMINISTRATION_UNITS.map((unit, idx) => {
return {
id: idx + 2,
drug: {
drugType: "compoundprescription",
compoundprescriptionText: `${unit}`,
temporality: "chronic",
periodicity: "D",
regimen: [
// To test singular case
{
quantity: 1.0,
timeOfDay: {
dayPeriod: "morning",
},
unit: unit,
},
// To test plural case
{
quantity: 5.0,
timeOfDay: {
dayPeriod: "beforedinner",
},
unit: unit,
},
],
},
};
}),
};
}
โ๏ธ Authors
configurations/ms/BK-03-CD-HCPARTY.ts
// Similar results that https://smals-jy.github.io/KMEHR-tests/docs/tests/ms/read/ts-12/#expected-results , but with these values
import type {
Configuration,
TransactionConfig,
AuthorConfig,
OrganizationConfig
} from "../../src/config";
// To generate a number to a minimal length
function numberToPaddedString(num: number, minLength: number = 3): string {
const str = num.toString();
const paddingLength = Math.max(0, minLength - str.length);
const padding = "0".repeat(paddingLength);
return padding + str;
}
// Some organizations
const ORGANIZATIONS : OrganizationConfig[] = [
"orgretirementhome",
"orgrevalidationcenter",
"orgshelteredliving",
"orgpsychiatriccarehome",
"orgpolyclinic",
"orgpharmacyinvoicingoffice",
"deptpsychogeriatry"
].map(kind => ({
type: kind,
name: `${kind} case`
}))
// Some authors
const DEFAULT_AUTHOR : AuthorConfig = {
familyname: "Duck",
firstname: "Donald",
ssin: "XXXXXXXXXXX",
type: "persphysician",
nihdi: "11186375004"
}
const AUTHORS : AuthorConfig[] = [
"persappliedpsychbachelor",
"persfamilysciencebachelor",
"persgerontologymaster",
"persorthopedagogistmaster",
"perspsychomotortherapymaster",
"persreadaptationbachelor",
"perspedagogybachelor",
"persoptometrist",
"persmobilityimprover",
"persbandagistorthosiologist",
"persprosthesiologist",
"persshoetechnologist"
].map( (kind, index) => ({
familyname: "Mouse",
firstname: `Mickey ${index + 1}`,
type: kind
}) );
// Generate a dummy transaction so that I don't put n times the same stuff
type SimpleTransactionConfig = Partial<TransactionConfig>;
function generateTransaction(
config: SimpleTransactionConfig,
): TransactionConfig {
return {
id: config.id || 2,
drug: {
drugType: "compoundprescription",
compoundprescriptionText: `Drug ${numberToPaddedString(config.id || 2, 4)}`,
temporality: "chronic",
periodicity: "D",
posologyFreeText: "Free text posology",
beginmoment: "2020-01-01",
medicationuse: config.drug?.medicationuse || "Test case scenario",
},
author: config.author,
};
}
// Generate transactions
const organizationTransactions : TransactionConfig[] = ORGANIZATIONS.map( (org, idx) => generateTransaction({
id: idx + 2,
author: {
...DEFAULT_AUTHOR,
org: org
}
}));
const startingIndex = 2 + organizationTransactions.length
const authorsTransactions : TransactionConfig[] = AUTHORS.map( (aut, idx) => generateTransaction({
id: startingIndex + idx,
author: aut
}));
// Generate
export default function (): Configuration {
return {
// Medication last author was me, without software info
author: DEFAULT_AUTHOR,
transactions: [
// First, the organizations case
...organizationTransactions,
// Second, the new HC-PARTY
...authorsTransactions
],
};
}
๐ Routes of administration
configurations/ms/BK-04-CD-DRUG-ROUTE.ts
import type { Configuration, DrugRoute } from "../../src/config";
// Same expected results that https://smals-jy.github.io/KMEHR-tests/docs/tests/ms/read/ts-05/#expected-results , but with these values
export default function (): Configuration {
const routes: DrugRoute[] = [
// Codes that are prohibited from cookbook
/*
"00003",
"00004",
"00006",
"00007",
"00014",
"00015",
"00016",
"00017",
"00018",
"00019",
"00020",
"00021",
"00022",
"00023",
"00024",
"00025",
"00026",
"00027",
"00028",
"00029",
"00030",
"00031",
"00032",
"00036",
"00037",
"00038",
"00039",
"00040",
"00041",
"00042",
"00043",
"00044",
"00047",
"00048",
"00050",
"00057",
"00058",
"00059",
"00061",
"00062",
"00063",
"00065",
"00069",
*/
// Codes that aren't listed in cookbook but possible
"both_ears",
"both_eyes",
"both_nostrils",
"cutaneous_injection",
"derm",
"dermal_injection",
"ear_left",
"ear_right",
"eye_left",
"eye_right",
"hyperdermoclyse",
"icut",
"ider",
"larter",
"nose_left",
"nose_right",
"oft",
"transdermal",
"vitreal_injection",
];
return {
transactions: routes.map((r, idx) => ({
id: idx + 2,
drug: {
drugType: "compoundprescription",
compoundprescriptionText: `${r}`,
temporality: "chronic",
periodicity: "D",
posologyFreeText: `...`,
route: r,
},
})),
};
}
- To generate the resulting XML file(s) in
output/ms
folder :
npm start
- Check that each testing scenario explained in step 4 work for you with the new files