/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *  
 * Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services.  All rights reserved.
 *  
 */
package gov.hhs.fha.nhinc.mpi.adapter.component;

import gov.hhs.fha.nhinc.mpilib.Patients;
import gov.hhs.fha.nhinc.patientdb.model.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author rayj
 */
public class CommonChecks {

    // MPI XML Checks

    public static boolean isSingleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() == 1));
    }

    public static boolean isMultipleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() > 1));
    }

    public static boolean isZeroSearchResult(Patients patients) {
        return ((patients == null) || (patients.size() == 0));
    }

    // MPI DB Checks

    public static boolean isSinglePerAASearchResult(List<Patient> patients) {
        boolean result = true;

        Map testMap = new HashMap();
        if (patients != null) {
            for (Patient patient : patients) {
                if (patient.getIdentifiers() != null &&
                        patient.getIdentifiers().size() > 0 &&
                        patient.getIdentifiers().get(0) != null) {
                    String orgId = patient.getIdentifiers().get(0).getOrganizationId();
                    if (testMap.containsKey(orgId)) {
                        result = false;
                        break;
                    }
                }
            }
        }

        return result;
    }

    public static boolean isZeroPerAASearchResult(List<Patient> patients) {
        return ((patients == null) || (patients.size() == 0));
    }

}

@@ -316,123 +316,8 @@
 nts;
-%0Aimport gov.hhs.fha.nhinc.patientdb.model.*;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;
 %0A%0A/*
@@ -374,31 +374,8 @@
  %7B%0A%0A
-    // MPI XML Checks%0A%0A
     
@@ -639,32 +639,32 @@
 ) %3E 1));%0A    %7D%0A%0A
+
     public stati
@@ -787,894 +787,6 @@
  %7D%0A%0A
-    // MPI DB Checks%0A%0A    public static boolean isSinglePerAASearchResult(List%3CPatient%3E patients) %7B%0A        boolean result = true;%0A%0A        Map testMap = new HashMap();%0A        if (patients != null) %7B%0A            for (Patient patient : patients) %7B%0A                if (patient.getIdentifiers() != null &&%0A                        patient.getIdentifiers().size() %3E 0 &&%0A                        patient.getIdentifiers().get(0) != null) %7B%0A                    String orgId = patient.getIdentifiers().get(0).getOrganizationId();%0A                    if (testMap.containsKey(orgId)) %7B%0A                        result = false;%0A                        break;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    public static boolean isZeroPerAASearchResult(List%3CPatient%3E patients) %7B%0A        return ((patients == null) %7C%7C (patients.size() == 0));%0A    %7D%0A%0A
 %7D%0A

CONNECT MPI Adapter - DB implementation - reverted: implemented MPI DB Checks; no longer needed