Examples of Height


Examples of com.krminc.phr.domain.vitals.Height

    public boolean hasError = false;

    /** Creates a new instance of HeightConverter */
    public HeightConverter() {
        entity = new Height();
    }
View Full Code Here

Examples of com.krminc.phr.domain.vitals.Height

    public JSONObject getPatientStats() {
        JSONObject jSONObject = new JSONObject();

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        Weight latestWeight = null;
        Height latestHeight = null;
        Boolean calculateBMI = true;
        try {
            EntityManager em = PersistenceService.getInstance().getEntityManager();

            persistenceSvc.beginTx();
            Long healthRecordId = getEntity().getHealthRecordId();
            try {
                latestHeight = (Height)em.createNamedQuery("Height.getLatestByHealthRecordId")
                    .setParameter("healthRecordId", healthRecordId)
                    .setMaxResults(1)
                    .getSingleResult();
            }
            catch (NoResultException ex) {
                calculateBMI = false;
            }

            try {
                latestWeight = (Weight)em.createNamedQuery("Weight.getLatestByHealthRecordId")
                    .setParameter("healthRecordId", healthRecordId)
                    .setMaxResults(1)
                    .getSingleResult();
            }
            catch (NoResultException ex) {
                calculateBMI = false;
            }

        }
        catch (Exception ex) {
            calculateBMI = false;
        } finally {
            PersistenceService.getInstance().close();
        }

        double bmi = 0;
        if (calculateBMI) {
            int inches = 1; //avoid div by 0
            double pounds = 0;
            try {
                inches = (latestHeight.getFeet() * 12) + latestHeight.getInches();
            }
            catch(Exception ex) {
                inches = 1;
            }
            try {
                if (latestWeight.getUnit().equalsIgnoreCase("lbs")) {
                    pounds = latestWeight.getWeight().intValue();
                } else if (latestWeight.getUnit().equalsIgnoreCase("kgs")) {
                    //convert kgs to pounds
                    pounds = latestWeight.getWeight().doubleValue() * 2.20462262;
                } else {
                    throw new Exception();
                }
            }
            catch(Exception ex) {
                pounds = 0;
            }

            if (inches>0 && pounds>0) {
                //bmi formula http://www.whathealth.com/bmi/formula.html
                bmi = pounds * 703;
                bmi = bmi / (inches * inches);
            }
        }

        try {
            if (bmi>0) {
                DecimalFormat twoDForm = new DecimalFormat("#.##");
                jSONObject.put("bmi", Double.valueOf(twoDForm.format(bmi)));
            }
        } catch (JSONException ex) {
            logger.warn( "Error creating BMI JSONObject", ex);
        }

        try {
            if (latestWeight != null) {
                jSONObject.put("weight", latestWeight.getWeight().toString().concat(" ").concat(latestWeight.getUnit().toLowerCase()));
                DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
                jSONObject.put("weightDate", df.format(latestWeight.getObservedDate()));
            }
        } catch (JSONException ex) {
            logger.warn( "Error creating Weight JSONObject", ex);
        }

        try {
            if (latestHeight != null) {
                String strHeight = latestHeight.getFeet().toString().concat("' ");
                if (latestHeight.getInches() > 0) {
                    strHeight = strHeight.concat(latestHeight.getInches().toString().concat("\""));
                }
                jSONObject.put("height", strHeight);
                DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
                jSONObject.put("heightDate", df.format(latestHeight.getObservedDate()));
            }
        } catch (JSONException ex) {
            logger.warn( "Error creating Height JSONObject", ex);
        }

View Full Code Here

Examples of com.krminc.phr.domain.vitals.Height

                throw new WebApplicationException(Response.Status.PRECONDITION_FAILED);
            }
           
            persistenceSvc.beginTx();
            EntityManager em = persistenceSvc.getEntityManager();
            Height entity = data.resolveEntity(em);
            createEntity(data.resolveEntity(em));
            persistenceSvc.commitTx();
            return Response.created(uriInfo.getAbsolutePath().resolve(entity.getHeightId() + "/")).build();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(255);
        setBiomeName("Marsh");
        temperature = BiomeGenBase.swampland.temperature;
        rainfall = BiomeGenBase.swampland.rainfall;
        this.setHeight(new Height(-0.2F, 0.2F));
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0x305A85);
        setBiomeName("Tundra");
        temperature = 0.0F;
        rainfall = 0.0F;
        this.setHeight(new Height(0.1F, 0.1F));
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0x0BD626);
        setBiomeName("Rainforest");
        temperature = 1.1F;
        rainfall = 1.4F;
        this.setHeight(new Height(0.85F, 0.45F));
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0x9E7C41);
        setBiomeName("Wasteland");
        temperature = BiomeGenBase.desert.temperature;
        rainfall = BiomeGenBase.desert.rainfall;
        this.setHeight(new Height(0.1F, 0.0F));
        waterColorMultiplier = 0xF08000;
       
        spawnableCreatureList.clear();
       
        setDisableRain();
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0x5BA68D);
        setBiomeName("Snow Forest");
        temperature = BiomeGenBase.taigaHills.temperature;
        rainfall = BiomeGenBase.taigaHills.rainfall;
        this.setHeight(new Height(0.3F, 0.2F));
        setEnableSnow();
       
        spawnableCreatureList.add(new SpawnListEntry(net.minecraft.entity.passive.EntityWolf.class, 5, 4, 4));
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0xB6659);
        setBiomeName("Mountain Taiga");
        temperature = 0.0F;
        rainfall = BiomeGenBase.taigaHills.rainfall;
        this.setHeight(new Height(0.75F, 0.45F));
       
        spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 8, 4, 4));
    }
View Full Code Here

Examples of net.minecraft.world.biome.BiomeGenBase.Height

       
        setColor(0x4AC758);
        setBiomeName("Lush Redwoods");
        temperature = 1.1F;
        rainfall = 1.4F;
        this.setHeight(new Height(1.2F, 0.3F));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.