@ampath/esm-reports-app 1.0.0-next.114 → 1.0.0-next.115

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.
@@ -14,11 +14,11 @@ import { ReportPage } from '../../common/report-page';
14
14
 
15
15
  const MOH713Component: React.FC = () => {
16
16
  const [moh713Data, setMoh713Data] = useState<any>(() => {
17
- const saved = sessionStorage.getItem('moh711Data');
17
+ const saved = sessionStorage.getItem('moh713Data');
18
18
  return saved ? JSON.parse(saved) : [];
19
19
  });
20
20
 
21
- const { isForCurrentLocation, hasLocationChanged, markGenerated } = useGeneratedLocation('moh711Location');
21
+ const { isForCurrentLocation, hasLocationChanged, markGenerated } = useGeneratedLocation('moh713Location');
22
22
  const isReportGenerated = hasReportData(moh713Data) && isForCurrentLocation;
23
23
  const [isLoading, setIsLoading] = useState<boolean>(false);
24
24
  const [startDate, setStartDate] = useState<string>(() => {
@@ -26,7 +26,7 @@ const MOH713Component: React.FC = () => {
26
26
  });
27
27
 
28
28
  const [endDate, setEndDate] = useState<string>(() => {
29
- return sessionStorage.getItem('moh711EndDate') || '';
29
+ return sessionStorage.getItem('moh713EndDate') || '';
30
30
  });
31
31
  useEffect(() => {
32
32
  sessionStorage.setItem('moh711Data', JSON.stringify(moh713Data));
@@ -49,7 +49,7 @@ const MOH713Component: React.FC = () => {
49
49
  const reportMonth = startDate ? dayjs(startDate).format('MMMM') : '';
50
50
  const reportYear = startDate ? dayjs(startDate).format('YYYY') : '';
51
51
 
52
- const fetchMoh711ReportData = async ({ startDate, endDate }: ReportPeriod) => {
52
+ const fetchMoh713ReportData = async ({ startDate, endDate }: ReportPeriod) => {
53
53
  setIsLoading(true);
54
54
  setStartDate(startDate);
55
55
  setEndDate(endDate);
@@ -68,15 +68,15 @@ const MOH713Component: React.FC = () => {
68
68
  } catch (error) {
69
69
  setIsLoading(false);
70
70
  setIsLoading(false);
71
- showReportError('the MOH-711 report', error);
71
+ showReportError('the MOH-713 report', error);
72
72
  }
73
73
  };
74
74
  return (
75
75
  <>
76
76
  <ReportFiltersComponent
77
- reportName="MOH-711 Report"
77
+ reportName="MOH-713 Report"
78
78
  mode="both"
79
- onGenerate={fetchMoh711ReportData}
79
+ onGenerate={fetchMoh713ReportData}
80
80
  isLoading={isLoading}
81
81
  isReportGenerated={isReportGenerated}
82
82
  generatedPeriod={{ startDate, endDate }}
@@ -62,3 +62,29 @@ export async function getMoh368Register(params: PatientListParams): Promise<Pati
62
62
  throw new Error(`An error occurred while fetching the MOH-368 Register: ${error.message}`);
63
63
  }
64
64
  }
65
+
66
+ export async function getMoh409Register(params: PatientListParams): Promise<PatientListPage> {
67
+ const url = await buildEtlUrl('moh-409-register', {
68
+ locationUuids: params.locationUuids || '',
69
+ startDate: params.startDate || '',
70
+ endDate: params.endDate || '',
71
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
72
+ reportName: params.reportName || '',
73
+ ...pageParams(params),
74
+ });
75
+
76
+ try {
77
+ const response = await openmrsFetch(url);
78
+
79
+ if (!response.ok) {
80
+ const errorText = await response.text();
81
+
82
+ throw new Error(`Failed to fetch moh-409: ${response.status} - ${errorText}`);
83
+ }
84
+
85
+ const data = await response.json();
86
+ return toPatientListPage(data?.data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
87
+ } catch (error: any) {
88
+ throw new Error(`An error occurred while fetching the MOH-409 Register: ${error.message}`);
89
+ }
90
+ }
@@ -73,6 +73,7 @@ import MOH713Component from './reports/moh-713/moh-713.component';
73
73
  import MOH368Component from './registers/moh-368/moh-368.component';
74
74
  import Moh301Register from './reports/moh-718/registers/moh-301/moh-301.register';
75
75
  import Moh740Linelist from './reports/moh-740/line-list/moh-740-line-list.component';
76
+ import Moh409Component from './registers/moh-409/moh-409.component';
76
77
 
77
78
  const RootComponent: React.FC = () => {
78
79
  const baseName = window.getOpenmrsSpaBase() + 'home/reports';
@@ -176,6 +177,7 @@ const RootComponent: React.FC = () => {
176
177
  <Route path="/moh-713" element={<MOH713Component />} />
177
178
  <Route path="/moh-368-register" element={<MOH368Component />} />
178
179
  <Route path="/moh-301-register" element={<Moh301Register />} />
180
+ <Route path="/moh-409-register" element={<Moh409Component />} />
179
181
  </Routes>
180
182
  </div>
181
183
  </BrowserRouter>