<commit_before>package gov.nih.nci.cabig.caaers.domain;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Embeddable;
import javax.persistence.AttributeOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import java.math.BigDecimal;

/**
 * @author Kulasekaran
 * @version 1.0
 */
@Entity
@Table(name = "participant_histories")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "seq_participant_histories_id") })
public class ParticipantHistory extends AbstractExpeditedReportSingleChild {
    private String baselinePerformanceStatus;

    private Measure height;

    private Measure weight;

    @AttributeOverrides( {
            @AttributeOverride(name = "quantity", column = @Column(name = "height")),
            @AttributeOverride(name = "unit", column = @Column(name = "height_unit")) })
    public Measure getHeight() {
        if (height == null) setHeight(new Measure());
        return height;
    }

    public void setHeight(Measure height) {
        this.height = height;
    }

    @AttributeOverrides( {
            @AttributeOverride(name = "quantity", column = @Column(name = "weight")),
            @AttributeOverride(name = "unit", column = @Column(name = "weight_unit")) })
    public Measure getWeight() {
        if (weight == null) setWeight(new Measure());
        return weight;
    }

    public void setWeight(Measure weight) {
        this.weight = weight;
    }

    public String getBaselinePerformanceStatus() {
        return baselinePerformanceStatus;
    }

    public void setBaselinePerformanceStatus(String baselinePerformance) {
        this.baselinePerformanceStatus = baselinePerformance;
    }

    @Transient
    public double getBodySurfaceArea() {
        if (weight == null || height == null) return 0;
        if (weight.quantity == null || height.quantity == null) return 0;
        if (weight.unit == null || height.unit == null) return 0;

        double wt = (weight.unit.equalsIgnoreCase("Pound")) ? weight.quantity.doubleValue() / 2.20462262185
                        : weight.quantity.doubleValue();
        double ht = (height.unit.equalsIgnoreCase("Inch")) ? height.quantity.doubleValue() * 2.54
                        : height.quantity.doubleValue();
        return Math.sqrt((wt * ht) / 3600);
    }

    @Embeddable
    public static class Measure {
        private BigDecimal quantity;

        private String unit;

        public BigDecimal getQuantity() {
            return quantity;
        }

        public void setQuantity(BigDecimal quantity) {
            this.quantity = quantity;
        }

        public String getUnit() {
            return unit;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }
    }
}
<commit_msg>adding method<commit_after>package gov.nih.nci.cabig.caaers.domain;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author Kulasekaran
 * @version 1.0
 */
@Entity
@Table(name = "participant_histories")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = {@Parameter(name = "sequence", value = "seq_participant_histories_id")})
public class ParticipantHistory extends AbstractExpeditedReportSingleChild {
    private String baselinePerformanceStatus;

    private Measure height;

    private Measure weight;

    @AttributeOverrides({
    @AttributeOverride(name = "quantity", column = @Column(name = "height")),
    @AttributeOverride(name = "unit", column = @Column(name = "height_unit"))})
    public Measure getHeight() {
        if (height == null) setHeight(new Measure());
        return height;
    }

    public void setHeight(Measure height) {
        this.height = height;
    }

    @AttributeOverrides({
    @AttributeOverride(name = "quantity", column = @Column(name = "weight")),
    @AttributeOverride(name = "unit", column = @Column(name = "weight_unit"))})
    public Measure getWeight() {
        if (weight == null) setWeight(new Measure());
        return weight;
    }

    public void setWeight(Measure weight) {
        this.weight = weight;
    }

    public String getBaselinePerformanceStatus() {
        return baselinePerformanceStatus;
    }

    public void setBaselinePerformanceStatus(String baselinePerformance) {
        this.baselinePerformanceStatus = baselinePerformance;
    }

    @Transient
    public double getBodySurfaceArea() {
        if (weight == null || height == null) return 0;
        if (weight.quantity == null || height.quantity == null) return 0;
        if (weight.unit == null || height.unit == null) return 0;

        double wt = (weight.unit.equalsIgnoreCase("Pound")) ? weight.quantity.doubleValue() / 2.20462262185
                : weight.quantity.doubleValue();
        double ht = (height.unit.equalsIgnoreCase("Inch")) ? height.quantity.doubleValue() * 2.54
                : height.quantity.doubleValue();
        return Math.sqrt((wt * ht) / 3600);
    }

    @Embeddable
    public static class Measure {
        private BigDecimal quantity;

        private String unit;

        public BigDecimal getQuantity() {
            return quantity;
        }

        public void setQuantity(BigDecimal quantity) {
            this.quantity = quantity;
        }

        public String getUnit() {
            return unit;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }
    }

    /**
     * Will calculate the body surface area using Mosteller formula
     */
    @Transient
    public static double bodySuraceArea(double height, String heightUOM, double weight, String weightUOM) {

        ParticipantHistory participantHistory = new ParticipantHistory();
        ParticipantHistory.Measure ht = new ParticipantHistory.Measure();
        ht.setQuantity(new BigDecimal(height));
        ht.setUnit(heightUOM);

        participantHistory.setHeight(ht);

        ParticipantHistory.Measure wt = new ParticipantHistory.Measure();
        wt.setQuantity(new BigDecimal(weight));
        wt.setUnit(weightUOM);

        participantHistory.setWeight(wt);

        return participantHistory.getBodySurfaceArea();
    }
}

{'fraction_non_alphanumeric': 0.10446868928411299, 'fraction_numerical': 0.007173815573157973, 'mean_word_length': 2.5862808145766345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2280829', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1705, 'n_words': 414}