-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from srishtigrp78/feature/autopatch/anthropometry
AMM-603 | Adding changes to auto-patch height in nurse module
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/main/java/com/iemr/mmu/controller/nurse/vitals/AnthropometryVitalsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.iemr.mmu.controller.nurse.vitals; | ||
|
||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
||
import com.iemr.mmu.service.nurse.vitals.AnthropometryVitalsService; | ||
import com.iemr.mmu.utils.response.OutputResponse; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
|
||
@RestController | ||
@CrossOrigin | ||
@RequestMapping(value = "/anthropometryVitals", headers = "Authorization", consumes = "application/json", produces = "application/json") | ||
public class AnthropometryVitalsController { | ||
|
||
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); | ||
|
||
@Autowired | ||
private AnthropometryVitalsService anthropometryVitalsService; | ||
|
||
//Auto-patching height in anthropometry details | ||
@CrossOrigin() | ||
@Operation(summary = "Get beneficiary height details") | ||
@PostMapping(value = { "/getBenHeightDetailsFrmNurse" }) | ||
public String getBenHeightDetailsFrmNurse( | ||
@Param(value = "{\"benRegID\":\"Long\"}") @RequestBody String comingRequest) { | ||
OutputResponse response = new OutputResponse(); | ||
|
||
logger.info("Request object for beneficiary height data fetching :" + comingRequest); | ||
try { | ||
JSONObject obj = new JSONObject(comingRequest); | ||
if (obj.has("benRegID")) { | ||
Long benRegID = obj.getLong("benRegID"); | ||
|
||
String res = anthropometryVitalsService.getBeneficiaryHeightDetails(benRegID); | ||
response.setResponse(res); | ||
} else { | ||
logger.info("Invalid request"); | ||
response.setError(5000, "Invalid request"); | ||
} | ||
logger.info("Beneficiary height data fetching Response:" + response); | ||
} catch (Exception e) { | ||
response.setError(5000, "Error while getting beneficiary height data"); | ||
logger.error("Error while getting beneficiary height data :" + e); | ||
} | ||
return response.toString(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/com/iemr/mmu/service/nurse/vitals/AnthropometryVitalsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.iemr.mmu.service.nurse.vitals; | ||
|
||
public interface AnthropometryVitalsService { | ||
|
||
String getBeneficiaryHeightDetails(Long benRegID); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/iemr/mmu/service/nurse/vitals/AnthropometryVitalsServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.iemr.mmu.service.nurse.vitals; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.google.gson.Gson; | ||
import com.iemr.mmu.repo.nurse.BenAnthropometryRepo; | ||
|
||
@Service | ||
public class AnthropometryVitalsServiceImpl implements AnthropometryVitalsService { | ||
|
||
@Autowired | ||
private BenAnthropometryRepo benAnthropometryRepo; | ||
|
||
@Override | ||
public String getBeneficiaryHeightDetails(Long benRegID) { | ||
// TODO Auto-generated method stub | ||
Long visitCode = benAnthropometryRepo.getBenLatestVisitCode(benRegID); | ||
if(visitCode==null) | ||
{ | ||
return "Visit code is not found"; | ||
} | ||
Double benHeight = benAnthropometryRepo.getBenLatestHeightDetails(visitCode); | ||
if(benHeight == null) | ||
return "No data found"; | ||
|
||
return new Gson().toJson(benHeight); | ||
} | ||
} |