Package ke.go.moh.oec

Examples of ke.go.moh.oec.Person


     * @param req Request containing the search terms to look for.
     * @return The response data to the request.
     */
    public Object find(PersonRequest req) {
        PersonResponse resp = new PersonResponse();
        Person p = req.getPerson();
        if (p == null) {
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, "FIND PERSON called with no person data.");
            return resp;
        }
        PersonMatch searchTerms = new PersonMatch(p);
        CandidateSet candidateSet = new CandidateSet();
        Set<SiteCandidate> siteCandidateSet = siteList.findIfNeeded(searchTerms);
        searchTerms.setSiteCandidateSet(siteCandidateSet);
        DateMatch.setToday();
        //
        // Make a special case if we are searching by GUID and not trying to match fingerprints.
        // In this case, just look to see if we have person matching the GUID search term.
        // If we do, then we are done. If not, then we test for matching the usual way...
        //
        PersonMatch guidMatch = null;
        if (p.getPersonGuid() != null
                && (p.getFingerprintList() == null || p.getFingerprintList().isEmpty())) {
            guidMatch = this.get(p.getPersonGuid());
            //TODO: Fix logic.
            if (guidMatch != null) {
                final double GUID_MATCH_SCORE = 1.0;
                final double GUID_MATCH_WEIGHT = 1.0;
                Scorecard s = new Scorecard();
                s.addScore(GUID_MATCH_SCORE, GUID_MATCH_WEIGHT);
                candidateSet.add(guidMatch, s);
                if (Mediator.testLoggerLevel(Level.FINEST)) {
                    Mediator.getLogger(PersonList.class.getName()).log(Level.FINEST,
                            "Score {0},{1} total {2},{3} comparing GUID {4} with {5}",
                            new Object[]{GUID_MATCH_SCORE, GUID_MATCH_WEIGHT, s.getTotalScore(), s.getTotalWeight(),
                                p.getPersonGuid(), guidMatch.getPerson().getPersonGuid()});
                }
            }
        }
        int personMatchCount = personList.size();
        if (guidMatch == null && personMatchCount > 0) { // Skip if matched already, or if MPI is empty
View Full Code Here


        PersonResponse returnData = null;
        if (req.isResponseRequested()) {    // Has the client requested a response?
            returnData = new PersonResponse();
            returnData.setSuccessful(false); // Until we succeed, assume that we failed.
        }
        Person p = req.getPerson().clone(); // Clone because we may modify our copy below.
        if (p == null) {
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, "CREATE PERSON called with no person data.");
            return returnData;
        }
        //Check to see if this person's hdssid, if available, already exists in the mpi. Log error if it does.
        String existingId = null;
        if (p.getPersonIdentifierList() != null
                && !p.getPersonIdentifierList().isEmpty()) {
            for (PersonIdentifier personIdentifier : p.getPersonIdentifierList()) {
                if (personIdentifier.getIdentifierType() == PersonIdentifier.Type.kisumuHdssId) {
                    String pi = personIdentifier.getIdentifier();
                    if (pi != null && !pi.isEmpty()) {
                        if (hdssIdMap.containsKey(pi)) {
                            existingId = pi;
                            break;
                        }
                    }
                }
            }
        }
        if (existingId != null) {
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,
                    "CREATE PERSON called with existing kisumuhdssid person identifier {0}.", existingId);
            return returnData;
        }
        Connection conn = Sql.connect();
        ResultSet rs = Sql.query(conn, "SELECT UUID() AS uuid");
        String guid = null;
        try {
            rs.next();
            guid = rs.getString("uuid");
            Sql.close(rs);
        } catch (SQLException ex) { // Won't happen
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, null, ex);
        }
        p.setPersonGuid(guid);

        String sex = ValueMap.SEX.getDb().get(p.getSex());
        String villageId = Sql.getVillageId(conn, p.getVillageName());
        String maritalStatusId = Sql.getMaritalStatusId(conn, p.getMaritalStatus());
        String consentSigned = ValueMap.CONSENT_SIGNED.getDb().get(p.getConsentSigned());
        String sql = "INSERT INTO person (person_guid, first_name, middle_name, last_name,\n"
                + "       other_name, clan_name, sex, birthdate, deathdate,\n"
                + "       mothers_first_name, mothers_middle_name, mothers_last_name,\n"
                + "       fathers_first_name, fathers_middle_name, fathers_last_name,\n"
                + "       compoundhead_first_name, compoundhead_middle_name, compoundhead_last_name,\n"
                + "       village_id, marital_status, consent_signed, date_created) values (\n   "
                + Sql.quote(guid) + ", "
                + Sql.quote(p.getFirstName()) + ", "
                + Sql.quote(p.getMiddleName()) + ", "
                + Sql.quote(p.getLastName()) + ",\n   "
                + Sql.quote(p.getOtherName()) + ", "
                + Sql.quote(p.getClanName()) + ", "
                + Sql.quote(sex) + ", "
                + Sql.quote(p.getBirthdate()) + ", "
                + Sql.quote(p.getDeathdate()) + ",\n   "
                + Sql.quote(p.getMothersFirstName()) + ", "
                + Sql.quote(p.getMothersMiddleName()) + ", "
                + Sql.quote(p.getMothersLastName()) + ",\n   "
                + Sql.quote(p.getFathersFirstName()) + ", "
                + Sql.quote(p.getFathersMiddleName()) + ", "
                + Sql.quote(p.getFathersLastName()) + ",\n   "
                + Sql.quote(p.getCompoundHeadFirstName()) + ", "
                + Sql.quote(p.getCompoundHeadMiddleName()) + ", "
                + Sql.quote(p.getCompoundHeadLastName()) + ",\n   "
                + villageId + ", "
                + maritalStatusId + ", "
                + consentSigned + ", "
                + "NOW()"
                + ");";
        Sql.startTransaction(conn);
        boolean successful = Sql.execute(conn, sql);
        if (successful) {
            int dbPersonId = Integer.parseInt(Sql.getLastInsertId(conn));
            PersonIdentifierList.update(conn, dbPersonId, p.getPersonIdentifierList(), null);
            FingerprintList.update(conn, dbPersonId, p.getFingerprintList(), null);
            VisitList.update(conn, Sql.REGULAR_VISIT_TYPE_ID, dbPersonId, p.getLastRegularVisit());
            VisitList.update(conn, Sql.ONE_OFF_VISIT_TYPE_ID, dbPersonId, p.getLastOneOffVisit());
            PersonMatch newPer = new PersonMatch(p.clone()); // Clone to protect from unit test modifications.
            newPer.setDbPersonId(dbPersonId);
            this.add(newPer);
            SearchHistory.update(req, null, null); // Update search history showing that no candidate was selected.
        }
        Sql.commit(conn);
View Full Code Here

        this.mediator = mediator;
    }

    public void processNotifyPersonChanged(PersonRequest personRequest) {
        Mediator.getLogger(Cds.class.getName()).log(Level.FINER, "NOTIFY_PERSON_CHANGED");
        Person person = personRequest.getPerson();
        if (person != null) {
            Visit lastRegularVisit = person.getLastRegularVisit();
            if (lastRegularVisit != null) {
                String visitAddress = lastRegularVisit.getAddress();
                String xml = personRequest.getXml();
                Mediator.getLogger(Cds.class.getName()).log(Level.FINER, "Notify");
                Connection notifyConn = Sql.connect();
View Full Code Here

     */
    @Test
    public void testFindPersonLPI() {
        System.out.println("JUnit Test getData - findPerson in the LPI");
        PersonRequest requestData = new PersonRequest();
        Person p = new Person();
        requestData.setPerson(p);
        Object result;
        PersonResponse pr;
        List<Person> pList;

        PersonIdentifier pi = new PersonIdentifier();
        pi.setIdentifier("00007/2004");
        pi.setIdentifierType(PersonIdentifier.Type.cccLocalId);
        List<PersonIdentifier> piList = new ArrayList<PersonIdentifier>();
        piList.add(pi);
        p.setPersonIdentifierList(piList);
        p.setSiteName("Siaya");
        requestData.setPerson(p);
        pr = callFindPerson(requestData);
        assertNotNull(pr);
        if (pr != null) {
            pList = pr.getPersonList();
View Full Code Here

     */
    @Test
    public void testModifyPerson() {
        System.out.println("testModifyPerson");
        PersonRequest requestData = new PersonRequest();
        Person p;
        List<Person> pList;
        PersonIdentifier pi;
        List<PersonIdentifier> piList;
        int pCount;
        Object result;
        PersonResponse pr;

        // Modify the person (will not exist) -- just to test QueueManager
        p = new Person();
        requestData.setPerson(p);
        pi = new PersonIdentifier();
        piList = new ArrayList<PersonIdentifier>();
        pi.setIdentifier("33333-44444");
        pi.setIdentifierType(PersonIdentifier.Type.patientRegistryId);
        piList.add(pi);
        p.setPersonIdentifierList(piList);
       
        Visit v = new Visit();
        v.setVisitDate(new Date());
        v.setAddress("ke.go.moh.test.address");
        v.setFacilityName("Test Facility");
        p.setLastRegularVisit(v);
       
        pr = (PersonResponse) mediator.getData(RequestTypeId.MODIFY_PERSON_MPI, requestData);
        try {
            Thread.sleep(10*1000); // Sleep 10 seconds.
        } catch (InterruptedException ex) {
View Full Code Here

            Visit v = p.getLastRegularVisit();
            if (v != null) {
                String address = v.getAddress();
                if (address != null) {
                    if (p.getLastMoveDate() != null) {
                        Person per = p.clone();
                        // Remove any other possible alert data, so this alert is for one purpose only:
                        per.setExpectedDeliveryDate(null);
                        per.setPregnancyEndDate(null);
                        per.setDeathdate(null);
                        // Send the alert (notification):
                        sendNotify(per, address);
                        // Remove this data from our in-memory person, so we don't keep sending the same alert next time.
                        p.setLastMoveDate(null);
                    }
                    if (p.getExpectedDeliveryDate() != null) {
                        Person per = p.clone();
                        // Remove any other possible alert data, so this alert is for one purpose only:
                        per.setLastMoveDate(null);
                        per.setPregnancyEndDate(null);
                        per.setDeathdate(null);
                        // Send the alert (notification):
                        sendNotify(per, address);
                        // Remove this data from our in-memory person, so we don't keep sending the same alert next time.
                        p.setExpectedDeliveryDate(null);
                    }
                    if (p.getPregnancyEndDate() != null) {
                        Person per = p.clone();
                        // Remove any other possible alert data, so this alert is for one purpose only:
                        per.setLastMoveDate(null);
                        per.setExpectedDeliveryDate(null);
                        per.setDeathdate(null);
                        // Send the alert (notification):
                        sendNotify(per, address);
                        // Remove this data from our in-memory person, so we don't keep sending the same alert next time.
                        p.setPregnancyEndDate(null);
                    }
                    if (p.getDeathdate() != null) {
                        Person per = p.clone();
                        // Remove any other possible alert data, so this alert is for one purpose only:
                        per.setLastMoveDate(null);
                        per.setExpectedDeliveryDate(null);
                        per.setPregnancyEndDate(null);
                        // Send the alert (notification):
                        sendNotify(per, address);
                        // Remove this data from our in-memory person, so we don't keep sending the same alert next time.
                        p.setDeathdate(null);
                    }
View Full Code Here

                    "packGenericPersonRequestMessage() - Expected data class PersonRequest, got {0}",
                    m.getMessageData().getClass().getName());
            return doc;
        }
        if (m.getXml() == null) { // Skip the following if we have pre-formed XML:
            Person p = null;
            PersonRequest personRequest = (PersonRequest) m.getMessageData();
            p = personRequest.getPerson();
            packPerson(personNode, p);
            if (personRequest.isResponseRequested()) {
                packTagValue(root, "acceptAckCode", "AL"); // Request "ALways" acknowedge.
View Full Code Here

                    "packGenericPersonResponseMessage() - Expected data class PersonResponse, got {0}",
                    m.getMessageData().getClass().getName());
            return doc;
        }
        if (m.getXml() == null) { // Skip the following if we have pre-formed XML:
            Person p = null;
            PersonResponse personResponse = (PersonResponse) m.getMessageData();
            List<Person> personList = personResponse.getPersonList();
            if (personList != null && !personList.isEmpty()) { // Are we responding with person data?
                p = personResponse.getPersonList().get(0)// Yes, get the person data to return.
            } else {
                p = new Person();   // No, return an empty person (needed to clear the default template values.)
            }
            packPerson(personNode, p);
        }
        return doc;
    }
View Full Code Here

                    "packFindPersonMessage() - Expected data class PersonRequest, got {0}",
                    m.getMessageData().getClass().getName());
        }
        if (m.getXml() == null) { // Skip the following if we have pre-formed XML:
            PersonRequest personRequest = (PersonRequest) m.getMessageData();
            Person p = personRequest.getPerson();
            packPersonName(q, p, "livingSubjectName");
            packTagValueAttribute(q, "livingSubjectAdministrativeGender", "code", packEnum(p.getSex()));
            packTagValueAttribute(q, "livingSubjectBirthTime", "value", packDate(p.getBirthdate()));
            packTagValueAttribute(q, "livingSubjectDeceasedTime", "value", packDate(p.getDeathdate()));
            packLivingSubjectId(q, OID_OTHER_NAME, p.getOtherName());
            packLivingSubjectId(q, OID_CLAN_NAME, p.getClanName());
            packLivingSubjectId(q, OID_ALIVE_STATUS, packEnum(p.getAliveStatus())); // (Used only on findPerson.)
            packLivingSubjectId(q, OID_MOTHERS_FIRST_NAME, p.getMothersFirstName());
            packLivingSubjectId(q, OID_MOTHERS_MIDDLE_NAME, p.getMothersMiddleName());
            packLivingSubjectId(q, OID_MOTHERS_LAST_NAME, p.getMothersLastName());
            packLivingSubjectId(q, OID_FATHERS_FIRST_NAME, p.getFathersFirstName());
            packLivingSubjectId(q, OID_FATHERS_MIDDLE_NAME, p.getFathersMiddleName());
            packLivingSubjectId(q, OKD_FATHERS_LAST_NAME, p.getFathersLastName());
            packLivingSubjectId(q, OID_COMPOUND_HEAD_FIRST_NAME, p.getCompoundHeadFirstName());
            packLivingSubjectId(q, OID_COMPOUND_HEAD_MIDDLE_NAME, p.getCompoundHeadMiddleName());
            packLivingSubjectId(q, OID_COMPOUND_HEAD_LAST_NAME, p.getCompoundHeadLastName());
            packLivingSubjectId(q, OID_MARITAL_STATUS, packEnum(p.getMaritalStatus()));
            packLivingSubjectId(q, OID_CONSENT_SIGNED, packEnum(p.getConsentSigned()));
            packLivingSubjectId(q, OID_SITE_NAME, p.getSiteName()); // (Used only on findPerson.)
            packLivingSubjectId(q, OID_VILAGE_NAME, p.getVillageName());
            packLivingSubjectPersonIdentifiers(q, p, OID_PATIENT_REGISTRY_ID, PersonIdentifier.Type.patientRegistryId);
            packLivingSubjectPersonIdentifiers(q, p, OID_MASTER_PATIENT_REGISTRY_ID, PersonIdentifier.Type.masterPatientRegistryId);
            packLivingSubjectPersonIdentifiers(q, p, OID_CCC_UNIVERSAL_UNIQUE_ID, PersonIdentifier.Type.cccUniqueId);
            packLivingSubjectPersonIdentifiers(q, p, OID_CCC_LOCAL_PATIENT_ID, PersonIdentifier.Type.cccLocalId);
            packLivingSubjectPersonIdentifiers(q, p, KISUMU_HDSS_ID, PersonIdentifier.Type.kisumuHdssId);
View Full Code Here

        List<Person> personList = null;
        if (!candidateSet.isEmpty() || !fingerprintMatchedSet.isEmpty()) {
            candidateSet.addAll(fingerprintMatchedSet);
            personList = new ArrayList<Person>();
            for (Candidate c : candidateSet) {
                Person p = c.getPersonMatch().getPerson().clone();
                p.setMatchScore(c.getScore());
                p.setSiteName(c.getSiteName());
                p.setFingerprintMatched(c.isFingerprintMatched());
                personList.add(p);
            }
        }
        return personList;
    }
View Full Code Here

TOP

Related Classes of ke.go.moh.oec.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.