Skip to content

Commit 68e4130

Browse files
authored
Add facility hierarchy creation with village and parent-child mapping (#121)
* fix:changed the pom xml * fix: added facilty type master change * feat: created facility creation * fix: rabiit review fix * fix: rabiit review fix * fix: rabiit review fix * fix: pom version
1 parent ea22db4 commit 68e4130

16 files changed

Lines changed: 768 additions & 64 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.iemr.admin</groupId>
77
<artifactId>admin-api</artifactId>
8-
<version>3.6.2</version>
8+
<version>3.8.1</version>
99
<packaging>war</packaging>
1010
<name>Admin-API</name>
1111
<description>Admin Page</description>

src/main/java/com/iemr/admin/controller/facilitytype/FacilitytypeController.java

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@
2828
import org.slf4j.Logger;
2929
import org.slf4j.LoggerFactory;
3030
import org.springframework.beans.factory.annotation.Autowired;
31-
31+
import org.springframework.web.bind.annotation.GetMapping;
3232
import org.springframework.web.bind.annotation.RequestBody;
3333
import org.springframework.web.bind.annotation.RequestMapping;
3434
import org.springframework.web.bind.annotation.RequestMethod;
3535
import org.springframework.web.bind.annotation.RestController;
3636

3737
import com.iemr.admin.data.facilitytype.M_facilitytype;
38+
import com.iemr.admin.data.store.M_FacilityLevel;
3839
import com.iemr.admin.service.facilitytype.M_facilitytypeInter;
3940
import com.iemr.admin.utils.mapper.InputMapper;
4041
import com.iemr.admin.utils.response.OutputResponse;
4142

4243
import io.swagger.v3.oas.annotations.Operation;
4344

44-
4545
@RestController
4646
public class FacilitytypeController {
4747
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
@@ -186,4 +186,100 @@ public String checkFacilityTypeCode(@RequestBody String deleteManufacturer) {
186186
return response.toString();
187187

188188
}
189+
190+
@Operation(summary = "Get facility types by rural/urban")
191+
@RequestMapping(value = "/getFacilityTypesByRuralUrban", headers = "Authorization", method = {
192+
RequestMethod.POST }, produces = { "application/json" })
193+
public String getFacilityTypesByRuralUrban(@RequestBody String request) {
194+
195+
OutputResponse response = new OutputResponse();
196+
197+
try {
198+
199+
M_facilitytype facilityDetails = InputMapper.gson().fromJson(request, M_facilitytype.class);
200+
201+
ArrayList<M_facilitytype> facilityData = m_facilitytypeInter
202+
.getFacilityTypesByRuralUrban(facilityDetails.getProviderServiceMapID(),
203+
facilityDetails.getRuralUrban());
204+
205+
response.setResponse(facilityData.toString());
206+
207+
} catch (Exception e) {
208+
209+
logger.error("Unexpected error:", e);
210+
response.setError(e);
211+
212+
}
213+
214+
return response.toString();
215+
}
216+
217+
@Operation(summary = "Get all facility levels")
218+
@RequestMapping(value = "/getFacilityLevels", headers = "Authorization", method = {
219+
RequestMethod.GET }, produces = { "application/json" })
220+
public String getFacilityLevels() {
221+
222+
OutputResponse response = new OutputResponse();
223+
try {
224+
ArrayList<M_FacilityLevel> data = m_facilitytypeInter.getFacilityLevels();
225+
response.setResponse(data.toString());
226+
} catch (Exception e) {
227+
logger.error("Unexpected error:", e);
228+
response.setError(e);
229+
}
230+
return response.toString();
231+
}
232+
233+
@Operation(summary = "Get facility types by block")
234+
@RequestMapping(value = "/getFacilityTypesByBlock", headers = "Authorization", method = {
235+
RequestMethod.POST }, produces = { "application/json" })
236+
public String getFacilityTypesByBlock(@RequestBody String request) {
237+
238+
OutputResponse response = new OutputResponse();
239+
try {
240+
M_facilitytype facilityDetails = InputMapper.gson().fromJson(request, M_facilitytype.class);
241+
ArrayList<M_facilitytype> data = m_facilitytypeInter.getFacilityTypesByBlock(facilityDetails.getBlockID());
242+
response.setResponse(data.toString());
243+
} catch (Exception e) {
244+
logger.error("Unexpected error:", e);
245+
response.setError(e);
246+
}
247+
return response.toString();
248+
}
249+
250+
@Operation(summary = "Get facility types by state")
251+
@RequestMapping(value = "/getFacilityTypesByState", headers = "Authorization", method = {
252+
RequestMethod.POST }, produces = { "application/json" })
253+
public String getFacilityTypesByState(@RequestBody String request) {
254+
255+
OutputResponse response = new OutputResponse();
256+
try {
257+
M_facilitytype facilityDetails = InputMapper.gson().fromJson(request, M_facilitytype.class);
258+
ArrayList<M_facilitytype> data = m_facilitytypeInter.getFacilityTypesByState(facilityDetails.getStateID());
259+
response.setResponse(data.toString());
260+
} catch (Exception e) {
261+
logger.error("Unexpected error:", e);
262+
response.setError(e);
263+
}
264+
return response.toString();
265+
}
266+
267+
@Operation(summary = "Check if facility type name exists in state")
268+
@RequestMapping(value = "/checkFacilityTypeName", headers = "Authorization", method = {
269+
RequestMethod.POST }, produces = { "application/json" })
270+
public String checkFacilityTypeName(@RequestBody String request) {
271+
272+
OutputResponse response = new OutputResponse();
273+
try {
274+
M_facilitytype facilityDetails = InputMapper.gson().fromJson(request, M_facilitytype.class);
275+
boolean exists = m_facilitytypeInter.checkFacilityTypeNameExists(
276+
facilityDetails.getFacilityTypeName(), facilityDetails.getStateID());
277+
response.setResponse(String.valueOf(exists));
278+
} catch (Exception e) {
279+
logger.error("Unexpected error:", e);
280+
response.setError(e);
281+
}
282+
return response.toString();
283+
}
284+
189285
}

src/main/java/com/iemr/admin/controller/store/StoreController.java

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.springframework.web.bind.annotation.RequestMethod;
3636
import org.springframework.web.bind.annotation.RestController;
3737

38+
import com.iemr.admin.data.store.FacilityHierarchyRequest;
39+
import com.iemr.admin.data.store.FacilityVillageMapping;
3840
import com.iemr.admin.data.store.M_Facility;
3941
import com.iemr.admin.data.store.M_facilityMap;
4042
import com.iemr.admin.data.store.V_FetchFacility;
@@ -286,6 +288,23 @@ public String getMapStore(@RequestBody V_FetchFacility facilitymap) {
286288

287289
}
288290

291+
@Operation(summary = "Get facilities by block/taluk")
292+
@RequestMapping(value = "/getFacilitiesByBlock", headers = "Authorization", method = { RequestMethod.POST }, produces = {
293+
"application/json" })
294+
public String getFacilitiesByBlock(@RequestBody String request) {
295+
296+
OutputResponse response = new OutputResponse();
297+
try {
298+
M_Facility facility = InputMapper.gson().fromJson(request, M_Facility.class);
299+
ArrayList<M_Facility> data = storeService.getFacilitiesByBlock(facility.getBlockID());
300+
response.setResponse(data.toString());
301+
} catch (Exception e) {
302+
logger.error("Unexpected error:", e);
303+
response.setError(e);
304+
}
305+
return response.toString();
306+
}
307+
289308
@Operation(summary = "Check store code")
290309
@RequestMapping(value = "/checkStoreCode", headers = "Authorization", method = { RequestMethod.POST }, produces = {
291310
"application/json" })
@@ -311,4 +330,110 @@ public String checkStoreCode(@RequestBody String deleteManufacturer) {
311330
return response.toString();
312331

313332
}
333+
334+
@Operation(summary = "Get facilities by block and facility level")
335+
@RequestMapping(value = "/getFacilitiesByBlockAndLevel", headers = "Authorization", method = {
336+
RequestMethod.POST }, produces = { "application/json" })
337+
public String getFacilitiesByBlockAndLevel(@RequestBody String request) {
338+
339+
OutputResponse response = new OutputResponse();
340+
try {
341+
com.iemr.admin.data.facilitytype.M_facilitytype reqObj = InputMapper.gson().fromJson(request,
342+
com.iemr.admin.data.facilitytype.M_facilitytype.class);
343+
ArrayList<M_Facility> data = storeService.getFacilitiesByBlockAndLevel(reqObj.getBlockID(),
344+
reqObj.getFacilityLevelID());
345+
response.setResponse(data.toString());
346+
} catch (Exception e) {
347+
logger.error("Unexpected error:", e);
348+
response.setError(e);
349+
}
350+
return response.toString();
351+
}
352+
353+
@Operation(summary = "Create facility with hierarchy mapping")
354+
@RequestMapping(value = "/createFacilityWithHierarchy", headers = "Authorization", method = {
355+
RequestMethod.POST }, produces = { "application/json" })
356+
public String createFacilityWithHierarchy(@RequestBody String request) {
357+
358+
OutputResponse response = new OutputResponse();
359+
try {
360+
FacilityHierarchyRequest reqObj = InputMapper.gson().fromJson(request, FacilityHierarchyRequest.class);
361+
M_Facility savedFacility = storeService.createFacilityWithHierarchy(reqObj.getFacility(),
362+
reqObj.getVillageIDs(), reqObj.getChildFacilityIDs());
363+
response.setResponse(savedFacility.toString());
364+
} catch (Exception e) {
365+
logger.error("Unexpected error:", e);
366+
response.setError(e);
367+
}
368+
return response.toString();
369+
}
370+
371+
@Operation(summary = "Get village IDs already mapped to facilities in a block")
372+
@RequestMapping(value = "/getMappedVillageIDs", headers = "Authorization", method = {
373+
RequestMethod.POST }, produces = { "application/json" })
374+
public String getMappedVillageIDs(@RequestBody String request) {
375+
376+
OutputResponse response = new OutputResponse();
377+
try {
378+
M_Facility facility = InputMapper.gson().fromJson(request, M_Facility.class);
379+
List<Integer> mappedIDs = storeService.getMappedVillageIDs(facility.getBlockID());
380+
response.setResponse(mappedIDs.toString());
381+
} catch (Exception e) {
382+
logger.error("Unexpected error:", e);
383+
response.setError(e);
384+
}
385+
return response.toString();
386+
}
387+
388+
@Operation(summary = "Get village mappings for a facility")
389+
@RequestMapping(value = "/getVillageMappingsByFacility", headers = "Authorization", method = {
390+
RequestMethod.POST }, produces = { "application/json" })
391+
public String getVillageMappingsByFacility(@RequestBody String request) {
392+
393+
OutputResponse response = new OutputResponse();
394+
try {
395+
M_Facility facility = InputMapper.gson().fromJson(request, M_Facility.class);
396+
ArrayList<FacilityVillageMapping> mappings = storeService.getVillageMappingsByFacility(facility.getFacilityID());
397+
response.setResponse(mappings.toString());
398+
} catch (Exception e) {
399+
logger.error("Unexpected error:", e);
400+
response.setError(e);
401+
}
402+
return response.toString();
403+
}
404+
405+
@Operation(summary = "Get child facilities by parent facility ID")
406+
@RequestMapping(value = "/getChildFacilitiesByParent", headers = "Authorization", method = {
407+
RequestMethod.POST }, produces = { "application/json" })
408+
public String getChildFacilitiesByParent(@RequestBody String request) {
409+
410+
OutputResponse response = new OutputResponse();
411+
try {
412+
M_Facility facility = InputMapper.gson().fromJson(request, M_Facility.class);
413+
ArrayList<M_Facility> children = storeService.getChildFacilitiesByParent(facility.getFacilityID());
414+
response.setResponse(children.toString());
415+
} catch (Exception e) {
416+
logger.error("Unexpected error:", e);
417+
response.setError(e);
418+
}
419+
return response.toString();
420+
}
421+
422+
@Operation(summary = "Update facility with hierarchy mapping")
423+
@RequestMapping(value = "/updateFacilityWithHierarchy", headers = "Authorization", method = {
424+
RequestMethod.POST }, produces = { "application/json" })
425+
public String updateFacilityWithHierarchy(@RequestBody String request) {
426+
427+
OutputResponse response = new OutputResponse();
428+
try {
429+
FacilityHierarchyRequest reqObj = InputMapper.gson().fromJson(request, FacilityHierarchyRequest.class);
430+
M_Facility updatedFacility = storeService.updateFacilityWithHierarchy(reqObj.getFacility(),
431+
reqObj.getVillageIDs(), reqObj.getChildFacilityIDs());
432+
response.setResponse(updatedFacility.toString());
433+
} catch (Exception e) {
434+
logger.error("Unexpected error:", e);
435+
response.setError(e);
436+
}
437+
return response.toString();
438+
}
314439
}

0 commit comments

Comments
 (0)