Skip to content

Commit

Permalink
Merge pull request #46 from srishtigrp78/feature/autopatch/anthropometry
Browse files Browse the repository at this point in the history
AMM-603 | Adding changes to auto-patch height in nurse module
  • Loading branch information
ravishanigarapu authored Jun 25, 2024
2 parents a8d1e55 + 336e958 commit 8e4167b
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
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();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,13 @@ public ArrayList<Object[]> getBenAnthropometryDetailForGraphtrends(
+ " WHERE beneficiaryRegID=:benRegID ORDER By ID DESC LIMIT 1 ")
public Double getBenLatestHeight(@Param("benRegID") Long benRegID);

@Query(nativeQuery = true, value = " SELECT visitCode FROM t_benvisitdetail "
+ " WHERE beneficiaryRegID=:benRegID ORDER By benvisitid desc limit 1 ")
public Long getBenLatestVisitCode(@Param("benRegID") Long benRegID);

@Query(nativeQuery = true, value = " SELECT Height_cm from ( "
+ " (select Height_cm from t_phy_anthropometry where visitCode=:visitCode)"
+ " union "
+"(select Height_cm from t_cancervitals where visitCode=:visitCode))a")
public Double getBenLatestHeightDetails(@Param("visitCode") Long visitCode);
}
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);

}
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);
}
}

0 comments on commit 8e4167b

Please sign in to comment.