๐งฌ๐ Merge of MS configurations
Why ?โ
- Inject only once multiple test scenarios, instead of swapping several times the data of a patient
 - Combine multiple small tests into a big one
 - ...
 
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โ
- Create a new 
tsfile inconfigurations/msfolder, that requires the others.
Here is an example. Adapt it to fit your needs : 
import type { MSConfiguration } from "@smals-jy/kmehr-tests";
type TransactionConfig = MSConfiguration['transactions'][number];
import TS04CDDAYPERIOD from "./TS-04-CD-DAYPERIOD";
import TS06CDPERIODICITY from "./TS-06-CD-PERIODICITY";
import TS07BEGIN_END_CONDITIONS from "./TS-07-BEGIN_END_CONDITIONS";
import TS08THERAPEUTIC_SUSPENSIONS from "./TS-08-THERAPEUTIC_SUSPENSIONS";
// If you want JSON files, don't forget
// "resolveJsonModule": true in your tsconfig file
//import TS01 from "./TS-01-identifiers.json"
//import TS02 from "./TS-02-posologies.json";
// Payload
export default function (): MSConfiguration {
    
    let updatedTransactions = [
        //(TS01 as MSConfiguration).transactions,
        //(TS02 as MSConfiguration).transactions,
        TS04CDDAYPERIOD().transactions,
        TS06CDPERIODICITY().transactions,
        TS07BEGIN_END_CONDITIONS().transactions,
        TS08THERAPEUTIC_SUSPENSIONS().transactions
    ].reduce( (acc, currentTransactions) => {
        // Starting index
        // At first iteration, it will be : 2
        // At second iteration, it will be : 2 + length of previous array
        let startingIdx = 2 + acc.length
        // Update current transactions
        let newTransactions = currentTransactions.map( (transaction, idx) => {
            // Update ID according to that new position in array
            transaction.id = startingIdx + idx;
            // Update suspension reference, if present
            if (transaction.suspensionReference) {
                // Why minus 2 ? because index starts at 2 in all configuration
                transaction.suspensionReference = startingIdx + transaction.suspensionReference - 2;
            }
            // Return modified object
            return transaction;
        });
        return [...acc, ...newTransactions]
    }, [] as TransactionConfig[])
    return {
        transactions: updatedTransactions
    }
}
- To generate the resulting XML file(s) in 
output/msfolder : 
npm start