[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.common.patientcorrelationfacade.dte.helpers;
|
---|
| 6 |
|
---|
| 7 | import gov.hhs.fha.nhinc.common.connectionmanager.dao.AssigningAuthorityHomeCommunityMappingDAO;
|
---|
| 8 | import java.util.ArrayList;
|
---|
| 9 | import java.util.List;
|
---|
| 10 | import org.apache.commons.logging.Log;
|
---|
| 11 | import org.apache.commons.logging.LogFactory;
|
---|
| 12 | import gov.hhs.fha.nhinc.nhinclib.NullChecker;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | *
|
---|
| 16 | * @author rayj
|
---|
| 17 | */
|
---|
| 18 | public class AssigningAuthorityHomeCommunityMappingHelper {
|
---|
| 19 |
|
---|
| 20 | private static Log log = LogFactory.getLog(AssigningAuthorityHomeCommunityMappingDAO.class);
|
---|
| 21 |
|
---|
| 22 | public static List<String> lookupAssigningAuthorities(String homeCommunityId) {
|
---|
| 23 | log.info("converting homeCommunityId [" + homeCommunityId + "] to assigning authority");
|
---|
| 24 | AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
|
---|
| 25 | //this really should be a list returned, not a single value
|
---|
| 26 | String assigningAuthorityId = mappingDao.getAssigningAuthority(homeCommunityId);
|
---|
| 27 | log.info("found assigning authority? [" + assigningAuthorityId + "]");
|
---|
| 28 |
|
---|
| 29 | List<String> assigningAuthorityIds = new ArrayList<String>();
|
---|
| 30 | assigningAuthorityIds.add(assigningAuthorityId);
|
---|
| 31 | return assigningAuthorityIds;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public static List<String> lookupAssigningAuthorities(List<String> homeCommunityIds) {
|
---|
| 35 | List<String> fullListOfAssigningAuthorities=null;
|
---|
| 36 | if (NullChecker.isNotNullish(homeCommunityIds)) {
|
---|
| 37 | log.info("converting homeCommunityIds [count=" + homeCommunityIds.size() + "] to assigning authorities");
|
---|
| 38 | fullListOfAssigningAuthorities = new ArrayList<String>();
|
---|
| 39 |
|
---|
| 40 | List<String> partialListOfAssigningAuthorities;
|
---|
| 41 |
|
---|
| 42 | for (String homeCommunity : homeCommunityIds) {
|
---|
| 43 | partialListOfAssigningAuthorities = lookupAssigningAuthorities(homeCommunity);
|
---|
| 44 | combineLists(fullListOfAssigningAuthorities, partialListOfAssigningAuthorities);
|
---|
| 45 | }
|
---|
| 46 | log.info("converted homeCommunityIds [count=" + homeCommunityIds.size() + "] to assigning authorities [count=" + fullListOfAssigningAuthorities.size() + "]");
|
---|
| 47 | }
|
---|
| 48 | return fullListOfAssigningAuthorities;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | private static List<String> combineLists(List<String> a, List<String> b) {
|
---|
| 52 | if (a == null) {
|
---|
| 53 | a = new ArrayList<String>();
|
---|
| 54 | }
|
---|
| 55 | a.addAll(b);
|
---|
| 56 | return a;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|