2021-07-01 00:49:05 +02:00
|
|
|
interface ValueTypes {
|
|
|
|
medicalProducts: string;
|
|
|
|
countryCodes: string;
|
|
|
|
manufacturers: string;
|
2021-07-09 03:05:57 +02:00
|
|
|
testResults: string;
|
|
|
|
testTypes: string;
|
2021-07-01 00:49:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ValueSets {
|
|
|
|
private static VALUE_SET_BASE_URL: string = 'https://raw.githubusercontent.com/ehn-dcc-development/ehn-dcc-valuesets/main/';
|
|
|
|
private static VALUE_TYPES: ValueTypes = {
|
|
|
|
medicalProducts: 'vaccine-medicinal-product.json',
|
|
|
|
countryCodes: 'country-2-codes.json',
|
|
|
|
manufacturers: 'vaccine-mah-manf.json',
|
2021-07-09 03:05:57 +02:00
|
|
|
testResults: 'test-result.json',
|
|
|
|
testTypes: 'test-type.json',
|
2021-07-01 00:49:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
medicalProducts: object;
|
|
|
|
countryCodes: object;
|
|
|
|
manufacturers: object;
|
2021-07-09 03:05:57 +02:00
|
|
|
testResults: object;
|
|
|
|
testTypes: object;
|
2021-07-01 00:49:05 +02:00
|
|
|
|
2021-07-09 03:05:57 +02:00
|
|
|
private constructor(
|
|
|
|
medicalProducts: object,
|
|
|
|
countryCodes: object,
|
|
|
|
manufacturers: object,
|
|
|
|
testResults: object,
|
|
|
|
testTypes: object
|
|
|
|
) {
|
2021-07-01 00:49:05 +02:00
|
|
|
this.medicalProducts = medicalProducts;
|
|
|
|
this.countryCodes = countryCodes;
|
|
|
|
this.manufacturers = manufacturers;
|
2021-07-09 03:05:57 +02:00
|
|
|
this.testResults = testResults;
|
|
|
|
this.testTypes = testTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static async fetchValueSet(file: string): Promise<object> {
|
|
|
|
return await (await fetch(ValueSets.VALUE_SET_BASE_URL + file)).json();
|
2021-07-01 00:49:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static async loadValueSets(): Promise<ValueSets> {
|
|
|
|
// Load all Value Sets from GitHub
|
2021-07-09 03:05:57 +02:00
|
|
|
let [medicalProducts, countryCodes, manufacturers, testResults, testTypes] = await Promise.all([
|
|
|
|
ValueSets.fetchValueSet(ValueSets.VALUE_TYPES.medicalProducts),
|
|
|
|
ValueSets.fetchValueSet(ValueSets.VALUE_TYPES.countryCodes),
|
|
|
|
ValueSets.fetchValueSet(ValueSets.VALUE_TYPES.manufacturers),
|
|
|
|
ValueSets.fetchValueSet(ValueSets.VALUE_TYPES.testResults),
|
|
|
|
ValueSets.fetchValueSet(ValueSets.VALUE_TYPES.testTypes)
|
|
|
|
]);
|
2021-07-01 00:49:05 +02:00
|
|
|
|
2021-07-09 03:05:57 +02:00
|
|
|
return new ValueSets(
|
|
|
|
medicalProducts['valueSetValues'],
|
|
|
|
countryCodes['valueSetValues'],
|
|
|
|
manufacturers['valueSetValues'],
|
|
|
|
testResults['valueSetValues'],
|
|
|
|
testTypes['valueSetValues']
|
|
|
|
);
|
2021-07-01 00:49:05 +02:00
|
|
|
}
|
2021-07-09 03:05:57 +02:00
|
|
|
}
|