protocol.ts 563 Bytes
Newer Older
1
import sequence from './sequence.js';
2
3

/**
Panagiotis Skarvelis's avatar
cleanup    
Panagiotis Skarvelis committed
4
5
6
7
 * Generate a new protocol number 
 * in the format sequence/date
 * each day a new sequence is generated
 * @param protocol_path
8
 * @returns string
9
 */
Panagiotis Skarvelis's avatar
cleanup    
Panagiotis Skarvelis committed
10
11
12
13
14
15
const protocol = (protocol_path: string) => {
    const protocol_date = new Date().toISOString().split('T')[0];
    const path = `${protocol_path}/${protocol_date}.protocol.sequence`;
    const protocol_sequence = sequence(path, path);//Protocol starts from 1 each day.
    let pn = protocol_sequence + "/" + protocol_date;
    return pn;
16
17
18
}

export default protocol;