Package com.krminc.phr.domain

Examples of com.krminc.phr.domain.User


    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public UserConverter get() {
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            User user = null;
            if (username != null) {
                user = getEntityByUsername();
            } else {
                user = getEntity();
            }
View Full Code Here


            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            User updatedUser = getEntity();
            updatedUser.setPassword(password);
            updatedUser.setRequiresReset(Boolean.TRUE);
            updateEntity(getEntity(), updatedUser);
            persistenceSvc.commitTx();
        } finally {
            persistenceSvc.close();
        }
View Full Code Here

                throw new WebApplicationException(new Throwable("Cannot remove items from addresses"));
            }
        }
        for (Address value : addressesNew) {
            if (!addresses.contains(value)) {
                User oldEntity = value.getUser();
                value.setUser(entity);
                if (oldEntity != null && !oldEntity.equals(entity)) {
                    oldEntity.getAddresses().remove(value);
                }
            }
        }
        return entity;
    }
View Full Code Here

     * @param newEntity the entity containing the new data
     * @return the updated entity
     */
    protected HealthRecord updateEntity(HealthRecord entity, HealthRecord newEntity) {
        EntityManager em = PersistenceService.getInstance().getEntityManager();
        User user = entity.getUser();
        User userNew = newEntity.getUser();
        entity = em.merge(newEntity);
        if (user != null && !user.equals(userNew)) {
            user.getHealthRecords().remove(entity);
        }
        if (userNew != null && !userNew.equals(user)) {
            userNew.getHealthRecords().add(entity);
        }
        return entity;
    }
View Full Code Here

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        byte[] image = null;
        final String staticDirectory = "./static/images/avatars/";
        final String maleAvatar = "default_avatar_male_126x126.jpg";
        final String femaleAvatar = "default_avatar_female_126x126.jpg";
        User user = null;
        HealthRecord hr = null;

       //logger.error("Attempting to serve user image!");

        try {
            persistenceSvc.beginTx();
            hr = getEntity();
            user = hr.getUser();
            image = user.getUserImage();
        } finally {
            persistenceSvc.close();
        }

        if (image != null && image.length > 0) {
View Full Code Here

    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    public JSONObject getPatientProfile() {

        HealthRecord hr = null;
        User usr = null;
        Address adrs = null;
        JSONObject jSONObject = new JSONObject();

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            hr = getEntity();
            usr =  hr.getUser();
            adrs = usr.getAddresses().get(0);
            jSONObject.put("firstName",usr.getFirstName());
            jSONObject.put("middleName", usr.getMiddleName());
            jSONObject.put("lastName", usr.getLastName());
            jSONObject.put("gender", hr.getFullGender());
            jSONObject.put("dateOfBirth", hr.getDateOfBirthString());
            jSONObject.put("maritalStatus", hr.getMaritalStatus());
            jSONObject.put("email", usr.getEmail());
            jSONObject.put("faxNum", usr.getFaxnum());
            jSONObject.put("telnumHome", usr.getTelnumHome());
            jSONObject.put("telnumMobile", usr.getTelnumMobile());
            jSONObject.put("telnumWork", usr.getTelnumWork());
            jSONObject.put("address1", adrs.getAddress1());
            jSONObject.put("address2", adrs.getAddress2());
            jSONObject.put("address3", adrs.getAddress3());
            jSONObject.put("city", adrs.getCity());
            jSONObject.put("state", adrs.getState());
View Full Code Here

    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    public JSONObject getUserAccount() {

        HealthRecord hr = null;
        User usr = null;
        JSONObject jSONObject = new JSONObject();

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            hr = getEntity();
            usr =  hr.getUser();
            //username, last login, number of logins, preferred name, date account created, and email address
            jSONObject.put("username",usr.getUsername());
            jSONObject.put("lastLogin", usr.getLastLogin());
            jSONObject.put("numLogins", usr.getTotalLogin());
            jSONObject.put("preferredName", usr.getPreferredName());
            jSONObject.put("dateCreated", usr.getDateCreated());
            jSONObject.put("email", usr.getEmail());
        } catch (JSONException ex) {
        } finally {
            PersistenceService.getInstance().close();
        }
View Full Code Here

            try {
                if (! securityContext.isUserInRole(UserConfig.ROLE_PATIENT)) throw new Exception("Not in patient role for removing access");
               
                EntityManager em = PersistenceService.getInstance().getEntityManager();
                User userToDisallow = null;
                User removingUser = null;

                try {
                    persistenceSvc.beginTx();

                    //get user
                     userToDisallow = getUserById(userId);
                     removingUser = getAuthenticatedUser();

                     //TODO check we are owner of HR
                     //if HR owner == removingUser

                     //find the correct hr
                     List<HealthRecord> healthRecords = userToDisallow.getHealthRecords();
                     boolean shouldRemove = false;
                     HealthRecord toRemove = null;

                    //make sure we aren't removing ourself
                    if (removingUser.getUserId().compareTo(userId) == 0) {
                        shouldRemove = false;
                        logger.debug("Preventing self-removal attempt id1 {} id2 {}", userToDisallow.getUserId(), userId);
                    } else {
                        for (HealthRecord hr : healthRecords) {
                            //prepare to remove link
View Full Code Here

            }

            if (foundRequests) {
                for (HealthrecordRequest request : requests) {
                    try {
                        User u = (User) em.createNamedQuery("User.findByUserId")
                            .setParameter("userId", request.getUserIdRequestor())
                            .setMaxResults(1)
                            .getSingleResult();

                        if (u != null) {
                            requestingUsers.add(u.getFullName());
                            requestIds.add(request.getRequestId());
                        }
                    }
                    catch (NoResultException ex) {
                        logger.error("Unable to find a user who requested hrid access");
View Full Code Here

            //ensure we are linking a request that is of our own record
            if (approvedRequest.getRecIdRequested() == getEntity().getHealthRecordId()) {

                //find the user we are giving access to hr for
                User approvedUser = em.find(
                        User.class,
                        new Long(approvedRequest.getUserIdRequestor())
                    );
               
                //find the hrid we want to give access to
                HealthRecord approvedRecord = em.find(
                        HealthRecord.class,
                        new Long(approvedRequest.getRecIdRequested())
                    );

                //add the healthrecord to user object
                List<HealthRecord> currentRecords = approvedUser.getHealthRecords();
                currentRecords.add(approvedRecord);
                approvedUser.setHealthRecords(currentRecords);

                //delete the request now that it is satisfied
                em.remove(approvedRequest);
            }
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.