@ampath/esm-reports-app 1.0.0-next.88 → 1.0.0-next.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/249.js +1 -1
- package/dist/249.js.map +1 -1
- package/dist/ampath-esm-reports-app.js +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/reports/moh-729b/moh-729b-form.component.tsx +31 -12
- package/src/reports/moh-729b/moh-729b-linelist.component.tsx +77 -4
- package/src/reports/moh-729b/moh-729b-summary.component.tsx +2 -2
- package/src/reports/moh-729b/moh-729b-summary.config.ts +67 -5
- package/src/reports/moh-729b/moh-729b.component.tsx +6 -2
- package/src/reports/moh-729b/moh-729b.config.ts +8 -2
- package/src/reports/moh-729b/moh-729b.types.ts +79 -13
|
@@ -48,7 +48,19 @@ export interface Moh729bRow {
|
|
|
48
48
|
tb_screening_date?: string | null;
|
|
49
49
|
tb_screening_result?: string | null;
|
|
50
50
|
ipt_start_date?: string | null;
|
|
51
|
-
/**
|
|
51
|
+
/** Universal prophylaxis only: the plan at the client's latest visit of the month on that drug */
|
|
52
|
+
prophylaxis_plan?: string | null;
|
|
53
|
+
/** Cryptococcal Meningitis (first CM visit of the month) and universal prophylaxis (latest visit on the drug) */
|
|
54
|
+
location?: string | null;
|
|
55
|
+
encounter_type?: string | null;
|
|
56
|
+
encounter_date?: string | null;
|
|
57
|
+
current_treatment?: string | null;
|
|
58
|
+
treatment_phase?: string | null;
|
|
59
|
+
treatment_start_date?: string | null;
|
|
60
|
+
treatment_plan?: string | null;
|
|
61
|
+
art_deferred_for_crypto?: string | null;
|
|
62
|
+
/** Adult, Paediatric, PMTCT, PrEP, PEP for Adults, PEP for Children, Hepatitis B, TPT HIV Positive,
|
|
63
|
+
Cryptococcal Meningitis, Universal prophylaxis or PMTCT Infants */
|
|
52
64
|
client_group?: string | null;
|
|
53
65
|
/** e.g. TDF + 3TC + DTG */
|
|
54
66
|
regimen?: string | null;
|
|
@@ -56,39 +68,91 @@ export interface Moh729bRow {
|
|
|
56
68
|
regimen_code?: string | null;
|
|
57
69
|
/** children only, as the form heads the bands, e.g. 10-13.9kg */
|
|
58
70
|
weight_band?: string | null;
|
|
71
|
+
/** PMTCT infants only: the HEI number, age and feeding at the visit, and the form's age band, e.g. 7- 9 months */
|
|
72
|
+
hei_number?: string | null;
|
|
73
|
+
infant_age?: string | null;
|
|
74
|
+
feeding?: string | null;
|
|
75
|
+
age_band?: string | null;
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
/** The PEP regimen codes (PA… for adults, PC3A/PC3C/PC4X for children -- not the infants' PC7, PC8, PC1X) */
|
|
62
79
|
export const PEP_CODES = new Set(PEP.flatMap((group) => group.rows.map(([code]) => code)));
|
|
63
80
|
|
|
64
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* One count on the form: a regimen code, narrowed to a weight band or a line
|
|
83
|
+
* where the form splits it. `ALL_ON_ART` instead of a code is every client on
|
|
84
|
+
* ART (adult, paediatric and PMTCT), narrowed by sex and MOH 731 age band, for
|
|
85
|
+
* the Summary's table laid out as MOH 731 3.2 Currently on ART.
|
|
86
|
+
*/
|
|
65
87
|
export interface Moh729bCell {
|
|
66
88
|
code: string;
|
|
67
89
|
band?: string;
|
|
68
90
|
line?: number;
|
|
91
|
+
/** M or F */
|
|
92
|
+
sex?: string;
|
|
93
|
+
/** a key of `ART_AGE_BANDS` */
|
|
94
|
+
age?: string;
|
|
69
95
|
}
|
|
70
96
|
|
|
97
|
+
/** Every client counted under ART, whatever the regimen */
|
|
98
|
+
export const ALL_ON_ART = '*ART';
|
|
99
|
+
|
|
100
|
+
const ART_GROUPS = ['Adult', 'Paediatric', 'PMTCT'];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* MOH 731's age bands, by key: the label and the ages in it, tested as MOH 731
|
|
104
|
+
* tests them -- `age < 1` for the first (an infant's age is a fraction, e.g.
|
|
105
|
+
* 0.5), then `BETWEEN min AND max`, and `>= 25` for the last.
|
|
106
|
+
*/
|
|
107
|
+
export const ART_AGE_BANDS: Record<string, { label: string; min?: number; max?: number; below?: number }> = {
|
|
108
|
+
less_1: { label: '<1', below: 1 },
|
|
109
|
+
'1_4': { label: '1–4', min: 1, max: 4 },
|
|
110
|
+
'5_9': { label: '5–9', min: 5, max: 9 },
|
|
111
|
+
'10_14': { label: '10–14', min: 10, max: 14 },
|
|
112
|
+
'15_19': { label: '15–19', min: 15, max: 19 },
|
|
113
|
+
'20_24': { label: '20–24', min: 20, max: 24 },
|
|
114
|
+
'25_above': { label: '25+', min: 25 },
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const inAgeBand = (age: unknown, key: string) => {
|
|
118
|
+
const band = ART_AGE_BANDS[key];
|
|
119
|
+
const years = Number(age);
|
|
120
|
+
return Boolean(band) && age !== null && age !== '' && Number.isFinite(years)
|
|
121
|
+
? band.below !== undefined
|
|
122
|
+
? years < band.below
|
|
123
|
+
: years >= (band.min ?? 0) && (band.max === undefined || years <= band.max)
|
|
124
|
+
: false;
|
|
125
|
+
};
|
|
126
|
+
|
|
71
127
|
/**
|
|
72
128
|
* The form prints TAF + 3TC + DTG as AS2G among the adult 1st line regimens;
|
|
73
129
|
* its own list of codes (page 3) calls it AF2G, which is what the ETL returns.
|
|
74
130
|
*/
|
|
75
131
|
export const countedCode = (printed: string) => (printed === 'AS2G' ? 'AF2G' : printed);
|
|
76
132
|
|
|
77
|
-
export const inCell = (row: Moh729bRow, { code, band, line }: Moh729bCell) =>
|
|
78
|
-
row.regimen_code === countedCode(code) &&
|
|
79
|
-
(band === undefined || row.weight_band === band) &&
|
|
80
|
-
(line === undefined || Number(row.arv_line) === line)
|
|
133
|
+
export const inCell = (row: Moh729bRow, { code, band, line, sex, age }: Moh729bCell) =>
|
|
134
|
+
(code === ALL_ON_ART ? ART_GROUPS.includes(row.client_group ?? '') : row.regimen_code === countedCode(code)) &&
|
|
135
|
+
(band === undefined || (row.weight_band ?? row.age_band) === band) &&
|
|
136
|
+
(line === undefined || Number(row.arv_line) === line) &&
|
|
137
|
+
(sex === undefined || row.gender === sex) &&
|
|
138
|
+
(age === undefined || inAgeBand(row.age, age));
|
|
81
139
|
|
|
82
140
|
/** A client in any of several counts (a total of counts that never overlap) */
|
|
83
141
|
export const inCells = (row: Moh729bRow, cells: Moh729bCell[]) => cells.some((cell) => inCell(row, cell));
|
|
84
142
|
|
|
85
|
-
/** A count in a link: `AF2E`, `CF2G~20-24.9kg`, `PM12~~2` */
|
|
86
|
-
export const encodeCell = ({ code, band, line }: Moh729bCell) =>
|
|
87
|
-
[code, band ?? '', line ?? ''].join('~').replace(/~+$/, '');
|
|
143
|
+
/** A count in a link: `AF2E`, `CF2G~20-24.9kg`, `PM12~~2`, `*ART~~~F~25_above` */
|
|
144
|
+
export const encodeCell = ({ code, band, line, sex, age }: Moh729bCell) =>
|
|
145
|
+
[code, band ?? '', line ?? '', sex ?? '', age ?? ''].join('~').replace(/~+$/, '');
|
|
88
146
|
|
|
89
147
|
export const decodeCell = (value: string): Moh729bCell => {
|
|
90
|
-
const [code, band, line] = value.split('~');
|
|
91
|
-
return {
|
|
148
|
+
const [code, band, line, sex, age] = value.split('~');
|
|
149
|
+
return {
|
|
150
|
+
code,
|
|
151
|
+
band: band || undefined,
|
|
152
|
+
line: Number(line) || undefined,
|
|
153
|
+
sex: sex || undefined,
|
|
154
|
+
age: age || undefined,
|
|
155
|
+
};
|
|
92
156
|
};
|
|
93
157
|
|
|
94
158
|
/** The regimen a code stands for on the form, for a linelist's heading */
|
|
@@ -101,9 +165,11 @@ export const REGIMEN_NAMES: Record<string, string> = Object.fromEntries(
|
|
|
101
165
|
const ORDINALS = ['', '1st', '2nd', '3rd'];
|
|
102
166
|
|
|
103
167
|
/** e.g. `AF2E TDF + 3TC + DTG`, `CF2G ABC+3TC+DTG · 20-24.9kg`, `PM12 … · 1st Line` */
|
|
104
|
-
export const describeCell = ({ code, band, line }: Moh729bCell) =>
|
|
168
|
+
export const describeCell = ({ code, band, line, sex, age }: Moh729bCell) =>
|
|
105
169
|
[
|
|
106
|
-
`${countedCode(code)} ${REGIMEN_NAMES[countedCode(code)] ?? ''}`.trim(),
|
|
170
|
+
code === ALL_ON_ART ? 'Currently on ART' : `${countedCode(code)} ${REGIMEN_NAMES[countedCode(code)] ?? ''}`.trim(),
|
|
171
|
+
age ? ART_AGE_BANDS[age]?.label : undefined,
|
|
172
|
+
sex ? (sex === 'M' ? 'Male' : 'Female') : undefined,
|
|
107
173
|
band,
|
|
108
174
|
line ? `${ORDINALS[line] ?? line} Line` : undefined,
|
|
109
175
|
]
|