forked from PSMRI/Identity-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBenMappingRepo.java
More file actions
136 lines (110 loc) · 7.45 KB
/
BenMappingRepo.java
File metadata and controls
136 lines (110 loc) · 7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 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.repo;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.iemr.common.identity.domain.MBeneficiaryaddress;
import com.iemr.common.identity.domain.MBeneficiarycontact;
import com.iemr.common.identity.domain.MBeneficiarydetail;
import com.iemr.common.identity.domain.MBeneficiarymapping;
import com.iemr.common.identity.domain.MBeneficiaryregidmapping;
@Repository
public interface BenMappingRepo extends CrudRepository<MBeneficiarymapping, BigInteger>, BenMappingRepoCustom {
MBeneficiarymapping findByBenMapIdOrderByBenMapIdAsc(BigInteger benMapId);
MBeneficiarymapping findByBenRegIdOrderByBenMapIdAsc(BigInteger benRegId);
MBeneficiarymapping findByMBeneficiarycontactOrderByBenMapIdAsc(MBeneficiarycontact mBeneficiarycontact);
List<MBeneficiarymapping> findByMBeneficiaryregidmappingOrderByBenMapIdAsc(
MBeneficiaryregidmapping mBeneficiaryregidmapping);
List<MBeneficiarymapping> findByMBeneficiarydetailOrderByBenMapIdAsc(MBeneficiarydetail mBeneficiarydetail);
List<MBeneficiarymapping> findByMBeneficiarydetailAndMBeneficiaryaddressOrderByBenMapIdAsc(
MBeneficiarydetail mBeneficiarydetail, MBeneficiaryaddress mBeneficiaryaddress);
List<MBeneficiarymapping> findByMBeneficiarydetailAndMBeneficiaryaddressAndMBeneficiarycontactOrderByBenMapIdAsc(
MBeneficiarydetail mBeneficiarydetail, MBeneficiaryaddress mBeneficiaryaddress,
MBeneficiarycontact mBeneficiarycontact);
@Query("select m from MBeneficiarymapping m where m.mBeneficiarydetail.beneficiaryDetailsId = :beneficiaryDetailsId"
+ " order by m.benMapId Asc")
MBeneficiarymapping findByBeneficiaryDetailsId(@Param("beneficiaryDetailsId") BigInteger beneficiaryDetailsId);
@Query(value = "select m from MBeneficiarymapping m where (m.mBeneficiarycontact.preferredPhoneNum = :phoneNum "
+ "or m.mBeneficiarycontact.phoneNum1 = :phoneNum or m.mBeneficiarycontact.phoneNum2 = :phoneNum "
+ "or m.mBeneficiarycontact.phoneNum3 = :phoneNum or m.mBeneficiarycontact.phoneNum4 = :phoneNum "
+ "or m.mBeneficiarycontact.phoneNum5 = :phoneNum) order by m.benMapId Desc")
List<MBeneficiarymapping> findByBeneficiaryDetailsByPhoneNumber(@Param("phoneNum") String phoneNum);
@Query("select m from MBeneficiarymapping m where m.benRegId in :benRegIds order by m.benMapId Asc")
List<MBeneficiarymapping> findAllByBenRegIdOrderByBenMapIdAsc(@Param("benRegIds") List<BigInteger> benRegIds);
@Query("select t from MBeneficiarymapping t where t.benRegId = :benRegID")
MBeneficiarymapping getBenImageIdByBenRegID(@Param("benRegID") BigInteger benRegID);
@Transactional
@Modifying
@Query(" UPDATE MBeneficiarymapping set vanSerialNo = :benMapId WHERE benMapId = :benMapId")
int updateVanSerialNo(@Param("benMapId") BigInteger benMapId);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.benRegId = :benRegID ORDER BY t.benMapId Desc ")
public List<Object[]> getBenMappingByRegID(@Param("benRegID") BigInteger benRegID);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.benContactsId IN :contactIDList ORDER BY t.benMapId Desc ")
public List<Object[]> getBenMappingByBenContactIdList(@Param("contactIDList") List<BigInteger> contactIDList);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.benContactsId =:benContactId AND t.vanID = :vanID ")
public List<Object[]> getBenMappingByBenContactIdListNew(@Param("benContactId") BigInteger benContactId,
@Param("vanID") Integer vanID);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.benRegId IN :benRegIDList ORDER BY t.benMapId Desc ")
public List<Object[]> getBenMappingByRegIDList(@Param("benRegIDList") List<BigInteger> benRegIDList);
@Query("SELECT t FROM MBeneficiarymapping t WHERE t.benRegId =:benRegId")
public MBeneficiarymapping getBenDetailsId(@Param("benRegId") BigInteger benRegId);
@Query("SELECT t.benRegId FROM MBeneficiarymapping t WHERE t.benDetailsId =:benDetailsId AND vanID = :vanID")
public BigInteger getBenRegId(@Param("benDetailsId") BigInteger benDetailsId, @Param("vanID") Integer vanID);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.benDetailsId IN :benDetailsIds AND t.vanID = :vanID ")
public List<Object[]> getBenMappingByBenDetailsIds(@Param("benDetailsIds") List<BigInteger> benDetailsIds,
@Param("vanID") Integer vanID);
@Query("SELECT t.benMapId, t.benAddressId, t.benConsentId, t.benContactsId, t.benDetailsId, "
+ " t.benRegId, t.benImageId, t.benAccountID, t.vanID, t.vanSerialNo, "
+ " t.createdBy, t.createdDate FROM MBeneficiarymapping t "
+ " WHERE t.vanSerialNo =:benMapIds AND t.vanID = :vanID ")
public List<Object[]> getBenMappingByVanSerialNo(@Param("benMapIds") BigInteger benMapIds,
@Param("vanID") Integer vanID);
@Query("SELECT m FROM MBeneficiarymapping m where m.mBeneficiaryaddress.permVillageId IN :villageIDs AND" +
" GREATEST(m.mBeneficiaryaddress.lastModDate, m.mBeneficiarycontact.lastModDate, m.mBeneficiarydetail.lastModDate) > :lastModDate " +
"ORDER BY GREATEST(m.mBeneficiaryaddress.lastModDate, m.mBeneficiarycontact.lastModDate, m.mBeneficiarydetail.lastModDate) ASC ")
Page<MBeneficiarymapping> findBeneficiaryByVillageIDAndLastModifiedDatePaginated(@Param("villageIDs") List<Integer> villageID,
@Param("lastModDate") Timestamp lastModifiedDate, Pageable pageable);
}