Package ke.go.moh.oec

Examples of ke.go.moh.oec.Person


    @Test
    public void testNotifyPersonChanged() {
        System.out.println("Testing Nofify Person Changed");
        int requestTypeId = RequestTypeId.NOTIFY_PERSON_CHANGED;
        PersonRequest requestData = new PersonRequest();
        Person p = new Person();
        List<PersonIdentifier> personIdentifierList = new ArrayList<PersonIdentifier>();
        PersonIdentifier personIdentifier = new PersonIdentifier();
        personIdentifier.setIdentifier("14080-05284/2007");
        personIdentifier.setIdentifierType(PersonIdentifier.Type.cccLocalId);
        personIdentifierList.add(personIdentifier);
        p.setPersonIdentifierList(personIdentifierList);
        p.setFirstName("Caroline");
        p.setMiddleName("Nasubo");
        p.setLastName("Nyegenye");
        p.setSex(Person.Sex.F);
//        p.setExpectedDeliveryDate(parseDate("2011-06-02"));
//        p.setPregnancyEndDate(parseDate("2011-06-02"));
//        p.setPregnancyOutcome(Person.PregnancyOutcome.multipleBirths);
//        p.setAliveStatus(Person.AliveStatus.no);
//        p.setDeathdate(parseDate("2011-09-11"));
        p.setVillageName("Tebs");
        p.setPreviousVillageName("Tengecha");
        p.setLastMoveDate(parseDate("2011-09-01"));
        Visit visit = new Visit();
        visit.setAddress("ke.go.moh.facility.14080.mch.reception");
        visit.setVisitDate(new Date());
        p.setLastRegularVisit(visit);
        requestData.setPerson(p);
        requestData.setDestinationName("Clinical Document Store");
        requestData.setDestinationAddress("ke.go.moh.facility.14080.cds");
        mediator.getData(requestTypeId, requestData);
       
View Full Code Here


        RequestDispatcher.dispatch(personRequest, kisumuHdssRequestResult,
                RequestDispatcher.DispatchType.FIND, Server.KISUMU_HDSS);
        if (kisumuHdssRequestResult.isSuccessful()) {
            List<Person> searchPersonList = (List<Person>) kisumuHdssRequestResult.getData();
            if (!searchPersonList.isEmpty()) {
                Person searchPerson = searchPersonList.get(0);
                for (RelatedPerson relatedPerson : searchPerson.getHouseholdMembers()) {
                    householdMemberList.add(relatedPerson.getPerson());
                }
            }
            return new SearchProcessResult(SearchProcessResult.Type.LIST, new SearchServerResponse(Server.KISUMU_HDSS, householdMemberList));
        } else {
View Full Code Here

        if (rejectedMPICandidateList == null) {
            rejectedMPICandidateList = new ArrayList<Person>();
        }
        rejectedMPICandidateList.clear();
        for (Person person : mpiPersonList) {
            Person p = new Person();
            p.setPersonGuid(person.getPersonGuid());
            rejectedMPICandidateList.add(p);
        }
        session.setRejectedMPICandidateList(rejectedMPICandidateList);
    }
View Full Code Here

        if (rejectedLPICandidateList == null) {
            rejectedLPICandidateList = new ArrayList<Person>();
        }
        rejectedLPICandidateList.clear();
        for (Person person : lpiPersonList) {
            Person p = new Person();
            p.setPersonGuid(person.getPersonGuid());
            rejectedLPICandidateList.add(p);
        }
        session.setRejectedLPICandidateList(rejectedLPICandidateList);
    }
View Full Code Here

        String sourceAddress = req.getSourceAddress();
        String messageId = req.getRequestReference();
        if (sourceAddress != null && messageId != null) { // Could be null for a local test, in which case don't log.
            Connection conn = Sql.connect();
            String addressId = Sql.getAddressId(conn, sourceAddress);
            Person p = req.getPerson();
            String linkedId = null;
            String sql = "SELECT max(search_history_id) as id FROM search_history WHERE address_id = " + addressId
                    + " and message_id = " + Sql.quote(messageId);
            ResultSet rs = Sql.query(conn, sql);
            try {
                if (rs.next()) {
                    int id = rs.getInt("id");
                    if (id != 0) {
                        linkedId = Integer.toString(id);
                    }
                }
                Sql.close(rs);
            } catch (SQLException ex) {
                Logger.getLogger(SearchHistory.class.getName()).log(Level.SEVERE,
                        "create() error getting max(search_history_id) for address_id = "
                        + addressId + " and message_id = " + messageId, ex);
            }
            String sex = ValueMap.SEX.getDb().get(p.getSex());
            sql = "INSERT INTO search_history (address_id, message_id, linked_search_id, search_datetime,\n"
                    + "s_first_name, s_middle_name, s_last_name, s_birthdate, s_sex, s_clan_name,\n"
                    + "s_village_name, s_site_name, s_guid) VALUES ("
                    + addressId + ", "
                    + Sql.quote(messageId) + ", "
                    + Sql.quote(linkedId) + ", "
                    + "NOW(),\n"
                    + Sql.quote(p.getFirstName()) + ", "
                    + Sql.quote(p.getMiddleName()) + ", "
                    + Sql.quote(p.getLastName()) + ", "
                    + Sql.quote(p.getBirthdate()) + ", "
                    + Sql.quote(sex) + ", "
                    + Sql.quote(p.getClanName()) + ",\n"
                    + Sql.quote(p.getVillageName()) + ", "
                    + Sql.quote(p.getSiteName()) + ", "
                    + Sql.quote(p.getPersonGuid()) + ")";
            try {
                Sql.execute(conn, sql);
            } catch (Exception ex) {
                Logger.getLogger(SearchHistory.class.getName()).log(Level.SEVERE,
                        "Error inserting into search_history:\n" + sql, ex);
                Sql.close(conn);
                return;
            }
            String searchHistoryId = Sql.getLastInsertId(conn);
            List<PersonIdentifier> piList = p.getPersonIdentifierList();
            if (piList != null) {
                for (PersonIdentifier pi : piList) {
                    PersonIdentifier.Type piType = pi.getIdentifierType();
                    String dbType = ValueMap.PERSON_IDENTIFIER_TYPE.getDb().get(piType);
                    sql = "INSERT INTO search_history_person_identifier (search_history_id, identifier_type_id, identifier) VALUES (\n"
                            + searchHistoryId + ", "
                            + Sql.quote(dbType) + ", "
                            + Sql.quote(pi.getIdentifier()) + ")";
                    try {
                        Sql.execute(conn, sql);
                    } catch (Exception ex) {
                        Logger.getLogger(SearchHistory.class.getName()).log(Level.SEVERE,
                                "Error inserting into search_history_person_identifier:\n" + sql, ex);
                        Sql.close(conn);
                        return;
                    }
                    Sql.execute(conn, sql);
                }
            }
            List<Fingerprint> fList = p.getFingerprintList();
            if (fList != null) {
                for (Fingerprint f : fList) {
                    Fingerprint.Type fType = f.getFingerprintType();
                    String dbType = ValueMap.FINGERPRINT_TYPE.getDb().get(fType);
                    sql = "INSERT INTO search_history_fingerprint (search_history_id, fingerprint_type_id,\n"
View Full Code Here

            if (linkedId != null) {
                if (pm == null) { // No person, so the user did not pick one of the candidates:
                    sql = "UPDATE search_history SET outcome = 0, m_datetime = NOW() WHERE address_id = " + addressId
                            + " and message_id = " + Sql.quote(messageId);
                } else { // The user picked a candidate. The user might also be changing some of the
                    Person p = pm.getPerson();
                    String sex = ValueMap.SEX.getDb().get(p.getSex());
                    sql = "UPDATE search_history SET outcome = 1, m_datetime = NOW()"
                            + ", m_person_id = " + pm.getDbPersonId()
                            + ", m_first_name = " + Sql.quote(p.getFirstName())
                            + ", m_middle_name = " + Sql.quote(p.getMiddleName())
                            + ", m_last_name = " + Sql.quote(p.getLastName())
                            + ", m_birthdate = " + Sql.quote(p.getBirthdate())
                            + ", m_sex = " + Sql.quote(sex)
                            + ", m_clan_name = " + Sql.quote(p.getClanName())
                            + ", m_village_name = " + Sql.quote(p.getVillageName())
                            + " WHERE address_id = " + addressId
                            + " and message_id = " + Sql.quote(messageId);
                }
                try {
                    Sql.execute(conn, sql);
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 newPerson = req.getPerson();//person containing modified data
        if (newPerson == null) {
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, "MODIFY PERSON called with no person data.");
            return returnData;
        }
        // For modify, we should have either a local person GUID or a HDSSID to reference the existing (old) entry.
        PersonMatch oldPersonMatch = null;
        String personGuid = newPerson.getPersonGuid();
        if (personGuid != null) {
            oldPersonMatch = this.get(personGuid);
            if (oldPersonMatch == null) {
                Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, "MODIFY PERSON GUID {0} not found.", personGuid);
                return returnData;
            }
        } else {
            List<PersonIdentifier> piList = newPerson.getPersonIdentifierList();
            if (piList != null && !piList.isEmpty()) {
                for (PersonIdentifier pi : piList) {
                    if (pi.getIdentifierType() == PersonIdentifier.Type.kisumuHdssId) {
                        String hdssId = pi.getIdentifier();
                        if (hdssId != null && !hdssId.isEmpty()) {
                            oldPersonMatch = hdssIdMap.get(hdssId);
                            if (oldPersonMatch != null) {
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (oldPersonMatch == null) {
            Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, "MODIFY PERSON called with no person GUID or matching HDSSID.");
            return returnData;
        }
        SearchHistory.update(req, oldPersonMatch, newPerson); // Log the search result (if any) BEFORE modifying the person.
        int dbPersonId = oldPersonMatch.getDbPersonId();
        Person oldPerson = oldPersonMatch.getPerson();
        Connection conn = Sql.connect();
        String sex = ValueMap.SEX.getDb().get(newPerson.getSex());
        String villageId = Sql.getVillageId(conn, newPerson.getVillageName());
        String maritalStatusId = Sql.getMaritalStatusId(conn, newPerson.getMaritalStatus());
        String consentSigned = ValueMap.CONSENT_SIGNED.getDb().get(newPerson.getConsentSigned());
        int columnCount = 0;
        String sql = "UPDATE person SET\n";
        if (newPerson.getFirstName() != null) {
            if (newPerson.getFirstName().isEmpty()) {
                sql += (separate(columnCount) + "first_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "first_name = " + Sql.quote(newPerson.getFirstName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getMiddleName() != null) {
            if (newPerson.getMiddleName().isEmpty()) {
                sql += (separate(columnCount) + "middle_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "middle_name = " + Sql.quote(newPerson.getMiddleName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getLastName() != null) {
            if (newPerson.getLastName().isEmpty()) {
                sql += (separate(columnCount) + "last_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "last_name = " + Sql.quote(newPerson.getLastName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getOtherName() != null) {
            if (newPerson.getOtherName().isEmpty()) {
                sql += (separate(columnCount) + "other_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "other_name = " + Sql.quote(newPerson.getOtherName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getClanName() != null) {
            if (newPerson.getClanName().isEmpty()) {
                sql += (separate(columnCount) + "clan_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "clan_name = " + Sql.quote(newPerson.getClanName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getSex() != null) {
            sql += (separate(columnCount) + "sex = " + Sql.quote(sex) + "\n");
            columnCount++;
        }
        if (newPerson.getBirthdate() != null) {
            sql += (separate(columnCount) + "birthdate = " + Sql.quote(newPerson.getBirthdate()) + "\n");
            columnCount++;
        }
        if (newPerson.getDeathdate() != null) {
            sql += (separate(columnCount) + "deathdate = " + Sql.quote(newPerson.getDeathdate()) + "\n");
            columnCount++;
        }
        if (newPerson.getMothersFirstName() != null) {
            if (newPerson.getMothersFirstName().isEmpty()) {
                sql += (separate(columnCount) + "mothers_first_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "mothers_first_name = " + Sql.quote(newPerson.getMothersFirstName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getMothersMiddleName() != null) {
            if (newPerson.getMothersMiddleName().isEmpty()) {
                sql += (separate(columnCount) + "mothers_middle_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "mothers_middle_name = " + Sql.quote(newPerson.getMothersMiddleName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getMothersLastName() != null) {
            if (newPerson.getMothersLastName().isEmpty()) {
                sql += (separate(columnCount) + "mothers_last_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "mothers_last_name = " + Sql.quote(newPerson.getMothersLastName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getFathersFirstName() != null) {
            if (newPerson.getFathersFirstName().isEmpty()) {
                sql += (separate(columnCount) + "fathers_first_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "fathers_first_name = " + Sql.quote(newPerson.getFathersFirstName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getFathersMiddleName() != null) {
            if (newPerson.getFathersMiddleName().isEmpty()) {
                sql += (separate(columnCount) + "fathers_middle_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "fathers_middle_name = " + Sql.quote(newPerson.getFathersMiddleName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getFathersLastName() != null) {
            if (newPerson.getFathersLastName().isEmpty()) {
                sql += (separate(columnCount) + "fathers_last_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "fathers_last_name = " + Sql.quote(newPerson.getFathersLastName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getCompoundHeadFirstName() != null) {
            if (newPerson.getCompoundHeadFirstName().isEmpty()) {
                sql += (separate(columnCount) + "compoundhead_first_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "compoundhead_first_name = " + Sql.quote(newPerson.getCompoundHeadFirstName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getCompoundHeadMiddleName() != null) {
            if (newPerson.getCompoundHeadMiddleName().isEmpty()) {
                sql += (separate(columnCount) + "compoundhead_middle_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "compoundhead_middle_name = " + Sql.quote(newPerson.getCompoundHeadMiddleName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getCompoundHeadLastName() != null) {
            if (newPerson.getCompoundHeadLastName().isEmpty()) {
                sql += (separate(columnCount) + "compoundhead_last_name = NULL\n");
            } else {
                sql += (separate(columnCount) + "compoundhead_last_name = " + Sql.quote(newPerson.getCompoundHeadLastName()) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getVillageName() != null) {
            if (newPerson.getVillageName().isEmpty()) {
                sql += (separate(columnCount) + "village_id = NULL\n");
            } else {
                sql += (separate(columnCount) + "village_id = " + Sql.quote(villageId) + "\n");
            }
            columnCount++;
        }
        if (newPerson.getMaritalStatus() != null) {
            sql += (separate(columnCount) + "marital_status = " + Sql.quote(maritalStatusId) + "\n");
            columnCount++;
        }
        if (newPerson.getConsentSigned() != null) {
            sql += (separate(columnCount) + "consent_signed = " + Sql.quote(consentSigned) + "\n");
            columnCount++;
        }
        sql += " WHERE person_id = " + dbPersonId;
        if (columnCount != 0) {//some 'real' mpi data has changed and needs to be updated
            Sql.startTransaction(conn);
            Sql.execute(conn, sql);
            List<PersonIdentifier> pList = PersonIdentifierList.update(conn, dbPersonId, newPerson.getPersonIdentifierList(), oldPerson.getPersonIdentifierList());
            newPerson.setPersonIdentifierList(pList);
            List<Fingerprint> fList = FingerprintList.update(conn, dbPersonId, newPerson.getFingerprintList(), oldPerson.getFingerprintList());
            newPerson.setFingerprintList(fList);
            VisitList.update(conn, Sql.REGULAR_VISIT_TYPE_ID, dbPersonId, newPerson.getLastRegularVisit());
            VisitList.update(conn, Sql.ONE_OFF_VISIT_TYPE_ID, dbPersonId, newPerson.getLastOneOffVisit());
            if (newPerson.getLastRegularVisit() == null) {
                newPerson.setLastRegularVisit(oldPerson.getLastRegularVisit());
            }
            if (newPerson.getLastOneOffVisit() == null) {
                newPerson.setLastOneOffVisit(oldPerson.getLastOneOffVisit());
            }
            Sql.commit(conn);
        }
        Sql.close(conn);
        if (newPerson.getLastMoveDate() != null) {
            newPerson.setPreviousVillageName(oldPerson.getVillageName());
        }
        Person mergedPerson = merge(newPerson, oldPersonMatch.getPerson());//merge old and new person
        PersonMatch newPersonMatch = new PersonMatch(mergedPerson);
        newPersonMatch.setDbPersonId(dbPersonId);
        this.remove(oldPersonMatch); // Remove old person from our in-memory list.
        this.add(newPersonMatch); // Add new person to our in-memory list.
        Notifier.notify(mergedPerson);
View Full Code Here

     * @param newPerson new Person object
     * @param oldPerson old Person object
     * @return merged Person object
     */
    private Person merge(Person newPerson, Person oldPerson) {
        Person mergedPerson = new Person();
        Class personClass = Person.class;
        Field[] personFields = personClass.getDeclaredFields();
        for (Field field : personFields) {
            try {
                field.setAccessible(true);
                Object p1FieldValue = field.get(newPerson);
                Object p2FieldValue = field.get(oldPerson);
                if (!(p1FieldValue == null && p2FieldValue == null)) {
                    Object p3FieldValue = null;
                    if (p1FieldValue != null && p2FieldValue != null) {
                        p3FieldValue = p1FieldValue;
                    } else {
                        if (p1FieldValue != null && p2FieldValue == null) {
                            p3FieldValue = p1FieldValue;
                        } else if (p1FieldValue == null && p2FieldValue != null) {
                            p3FieldValue = p2FieldValue;
                        }
                    }
                    field.set(mergedPerson, p3FieldValue);
                }
            } catch (IllegalArgumentException ex) {
                Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        mergedPerson.setPersonIdentifierList(mergePersonIdentifierLists(newPerson.getPersonIdentifierList(),
                oldPerson.getPersonIdentifierList()));
        return mergedPerson;
    }
View Full Code Here

    public void testNotifyPersonChanged() {
        System.out.println("Testing Nofify Person Changed");
        int requestTypeId = RequestTypeId.NOTIFY_PERSON_CHANGED;
        PersonRequest requestData = new PersonRequest();
        Person p = new Person();
        List<PersonIdentifier> personIdentifierList = new ArrayList<PersonIdentifier>();
        PersonIdentifier personIdentifier = new PersonIdentifier();
        personIdentifier.setIdentifier("14080-05284/2007");
        personIdentifier.setIdentifierType(PersonIdentifier.Type.cccLocalId);
        personIdentifierList.add(personIdentifier);
        p.setPersonIdentifierList(personIdentifierList);
        p.setFirstName("Caroline");
        p.setMiddleName("Nasubo");
        p.setBirthdate(parseDate("1970-06-02"));
        p.setLastName("Nyegenye");
        p.setSex(Person.Sex.F);
//        p.setExpectedDeliveryDate(parseDate("2011-06-02"));
//        p.setPregnancyEndDate(parseDate("2011-06-02"));
//        p.setPregnancyOutcome(Person.PregnancyOutcome.multipleBirths);
        p.setAliveStatus(Person.AliveStatus.no);
        p.setDeathdate(parseDate("2011-09-11"));
        p.setVillageName("Tebs");
        p.setPreviousVillageName("Tengecha");
        p.setLastMoveDate(parseDate("2011-09-01"));
        Visit visit = new Visit();
        visit.setAddress("ke.go.moh.facility.14080.tb.reception");
        visit.setVisitDate(new Date());
        p.setLastRegularVisit(visit);
        requestData.setPerson(p);
        requestData.setDestinationName("Clinical Document Store");
        requestData.setDestinationAddress("ke.go.moh.facility.14080.cds");
        mediator.getData(requestTypeId, requestData);
        System.exit(0);
View Full Code Here

     * @param searchTerms complete set of search terms for the person
     * @return the set of site names, or null if not applicable.
     */
    public Set<SiteCandidate> findIfNeeded(PersonMatch searchTerms) {
        Set<SiteCandidate> siteCandidateSet = null;
        Person person = searchTerms.getPerson();
        List<PersonIdentifier> personIdentifierList = person.getPersonIdentifierList();
        String searchSiteName = person.getSiteName();
        if (searchSiteName != null && !searchSiteName.isEmpty() && personIdentifierList != null) {
            for (PersonIdentifier pi : personIdentifierList) {
                if (PersonMatch.identifierNeedsSite(pi)) {
                    siteCandidateSet = find(searchSiteName, pi.getIdentifier());
                    break;
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.