Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions .github/workflows/build-on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
name: Build On Pull Request
name: Build and Static Code Analysis On Pull Request
on:
pull_request:
branches: [ "master","develop" ]

branches: [ "develop" ]
jobs:
Build:
Build_and_analyse:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Setup JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
- name: Build with Maven
run: mvn clean install
- name: Setup JDK 8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'

- name: Test with Maven
run: mvn test

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: Java

- name: Build with Maven
run: mvn clean install

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions .github/workflows/sast-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
run: mvn clean install -DENV_VAR=${{ env.ENV_VAR }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
languages: Java

Packaging:
needs: codeql
Expand All @@ -46,6 +44,8 @@ jobs:
with:
java-version: 8
distribution: 'adopt'
- name: Test with maven
run: mvn test
- name: Create WAR file
run: mvn -B package --file pom.xml
- name: Upload WAR file as artifact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.lang.reflect.Type;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -31,6 +32,7 @@
import javax.persistence.NoResultException;
import javax.persistence.QueryTimeoutException;

import com.iemr.common.identity.dto.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -313,6 +315,32 @@ public class IdentityController {
return response;
}

// search beneficiary by lastModDate and districtID
@CrossOrigin(origins = { "*commonapi*" })
// @PostMapping(path = "/searchByDistrictId", headers = "Authorization")
@PostMapping(path = "/searchByDistrictId")
public @ResponseBody String searchBeneficiaryByBlockIdAndLastModDate(
@ApiParam(value = "\"String\"") @RequestBody String object) {
logger.info("IdentityController.getBeneficiary - start. search object = " + object);
String response;
try {

JsonElement json = new JsonParser().parse(object);

SearchSyncDTO search = InputMapper.getInstance().gson().fromJson(json, SearchSyncDTO.class);
List<BeneficiariesDTO> list = svc.searchBeneficiaryByBlockIdAndLastModifyDate(search.getBlockID(), new Timestamp(search.getLastModifDate()));

response = getSuccessResponseString(list, 200, "success", "getIdentityByAgent");

logger.info("IdentityController.getBeneficiary - end");
} catch (Exception e) {
logger.error("error in beneficiary search by Family Id : " + e.getLocalizedMessage());
response = getErrorResponseString("error in beneficiary search by block Id : " + e.getLocalizedMessage(),
5000, "failure", "");
}
return response;
}

@CrossOrigin(origins = { "*commonapi*" })
@ApiOperation(value = "Search beneficiary based on government identity number")
@PostMapping(path = "/searhByGovIdentity", headers = "Authorization")
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/iemr/common/identity/dto/SearchSyncDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.identity.dto;

import lombok.Data;

@Data
public class SearchSyncDTO {

private Long lastModifDate;
private Integer blockID;

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package com.iemr.common.identity.repo;

import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
Expand Down Expand Up @@ -125,4 +126,10 @@ public List<Object[]> getBenMappingByBenDetailsIds(@Param("benDetailsIds") List<
public List<Object[]> getBenMappingByVanSerialNo(@Param("benMapIds") BigInteger benMapIds,
@Param("vanID") Integer vanID);

@Query(value = "select m from MBeneficiarymapping m where m.mBeneficiaryaddress.permVillageId = :blockID and (m.mBeneficiaryAccount.lastModDate > :lastModDate "
+ "or m.mBeneficiaryaddress.lastModDate > :lastModDate or m.mBeneficiaryconsent.lastModDate > :lastModDate "
+ "or m.mBeneficiarycontact.lastModDate > :lastModDate or m.mBeneficiarydetail.lastModDate > :lastModDate ) "
+ "order by m.benMapId Desc")
List<MBeneficiarymapping> findByBeneficiaryDetailsByBlockIDAndLastModifyDate(@Param("blockID") int blockID, @Param("lastModDate") Timestamp lastModDate);

}
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,29 @@ public List<BeneficiariesDTO> searhBeneficiaryByFamilyId(String familyId)
return beneficiaryList;
}

public List<BeneficiariesDTO> searchBeneficiaryByBlockIdAndLastModifyDate(Integer blockID, Timestamp lastModDate) {

List<BeneficiariesDTO> beneficiaryList = new ArrayList<BeneficiariesDTO>();
try {
// find benmap ids
List<MBeneficiarymapping> benMappingsList = mappingRepo.findByBeneficiaryDetailsByBlockIDAndLastModifyDate(blockID, lastModDate);
if (benMappingsList == null || benMappingsList.size() == 0){
return beneficiaryList;
}
else {
for (MBeneficiarymapping benMapOBJ : benMappingsList) {
beneficiaryList.add(this.getBeneficiariesDTO(benMapOBJ));
}
}

} catch (Exception e) {
e.printStackTrace();
logger.error(
"error in beneficiary search for familyId : " + blockID + " error : " + e.getLocalizedMessage());
}
return beneficiaryList;
}

public List<BeneficiariesDTO> searhBeneficiaryByGovIdentity(String identity)
throws NoResultException, QueryTimeoutException, Exception {
List<BeneficiariesDTO> beneficiaryList = new ArrayList<BeneficiariesDTO>();
Expand Down