Package com.krminc.phr.domain

Examples of com.krminc.phr.domain.User


        @FormParam("redirectUri") String redirectUri,
        @FormParam("asHealthRecord") Boolean asHR
    ) {
        String status = "unknown";
        String hrid = null;
        User user = null;
       
        if (!newPassword.equals(newPassword2)) {
            //passwords do not match
            status = "nomatch";
        } else if (!ServiceUtils.isPassword(newPassword)) {
            //new password invalid
            status = "invalid";
        } else {
            PersistenceService persistenceSvc = PersistenceService.getInstance();
            if (asHR == null) asHR = false;
            try {
                persistenceSvc.beginTx();
                EntityManager em = persistenceSvc.getEntityManager();

                if (asHR) {
                    user = em.find(HealthRecord.class, userId).getUser();
                } else {
                    user = em.find(User.class, userId);
                }

                if (user == null) throw new Exception("Unable to locate user entity");

                if (user.isPatient()) {
                    if (hrid == null) {
                        if (asHR) {
                            hrid = userId.toString();
                        } else {
                            hrid = user.getPrimaryHealthRecord().getHealthRecordId().toString();
                            //hrid = user.getHealthRecords().get(0).getHealthRecordId().toString();
                        }
                    }

                    // patients will pass in their own redirect URL using own HRID generally
                    if (redirectUri == null || redirectUri.isEmpty()) {
                        redirectUri = "." + AppConfig.PATH_PATIENT_ROOT + "/" + hrid + "/account";
                    }
                }

                if (user.testPassword(currentPassword) == false) {
                    throw new Exception("Incorrect password");
                } else if (user.getUsername().equalsIgnoreCase(newPassword)) {
                    //error if setting password with username
                    throw new Exception("Password matches username");
                }
                user.setPassword(newPassword);
                user.setRequiresReset(Boolean.FALSE);
                em.merge(user);
                persistenceSvc.commitTx();
                status = "updated";
            } catch (Exception e) {
                logger.error("Password Update Failed - " + e.getMessage());
                status = "failed";
            } finally {
                persistenceSvc.close();
            }
        }
        //mirror getFirstLogin() in Main.java here
        if ("updated".equals(status) && redirectUri.contains("passwordchange")) {
            //password has been updated on first login/forced change
            HttpSession session = req.getSession(); //create session if none exists
            if (session != null)
                session.setAttribute("needsreset", "false");
                if (req.isUserInRole(UserConfig.ROLE_PATIENT) || req.isUserInRole(UserConfig.ROLE_CARETAKER)) {
                    if (hrid != null) {
                        session.setAttribute("healthRecordId", hrid);
                        if (req.isUserInRole(UserConfig.ROLE_PATIENT)) {
                            UserPreferences pref = user.getPrimaryHealthRecord().getPreferences();
                            boolean showCN;
                            if (pref != null) {
                                showCN = (pref.getShowCarenotebook() == true) ? true : false;
                            } else {
                                showCN = false;
View Full Code Here


     * Returns the resolved Address entity.
     *
     * @return an resolved entity
     */
    public Address resolveEntity(EntityManager em) {
        User user = entity.getUser();
        if (user != null) {
            entity.setUser(em.getReference(User.class, user.getUserId()));
        }
        return entity;
    }
View Full Code Here

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            EntityManager em = persistenceSvc.getEntityManager();
            User user = em.find(HealthRecord.class, healthRecordId).getUser();

            if (!user.getEmail().equals(email)) {
                user.setEmail(email);
            }

            if (!preferredName.isEmpty() && !user.getPreferredName().equals(preferredName)) {
                user.setPreferredName(preferredName);
            }

            em.merge(user);
            persistenceSvc.commitTx();
            status = "updated";
View Full Code Here

TOP

Related Classes of com.krminc.phr.domain.User

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.