import _ from "lodash" import React from "react" import AquagenxCBTDisplaySVGString from "./AquagenxCBTDisplaySVG" import { getHealthRiskString } from "./aquagenxCBTUtils" import ImageDisplayComponent from "../ImageDisplayComponent" import { InnerFormContext } from "../formContext" export interface AquagenxCBTDisplayComponentProps { value?: any questionId: string onEdit?: any imageManager?: any formCtx: InnerFormContext } export default class AquagenxCBTDisplayComponent extends React.Component { handleClick = () => { if (this.props.onEdit) { return this.props.onEdit() } } renderStyle() { const mainId = `#cbtDisplay${this.props.questionId}` const cbtValues = this.props.value.cbt const compartmentValues = [cbtValues.c1, cbtValues.c2, cbtValues.c3, cbtValues.c4, cbtValues.c5] const compartmentColors = _.map(compartmentValues, function (c) { if (c) { return "#32a89b" } else { return "#ebe7c2" } }) return ( ) } renderInfo() { const cbtValues = this.props.value.cbt let { mpn } = cbtValues if (mpn === 100) { mpn = ">100" } return (
{this.props.formCtx.T("MPN/100ml") + ": "}{mpn}
{this.props.formCtx.T("Upper 95% Confidence Interval/100ml") + ": "}{cbtValues.confidence}
{this.props.formCtx.T("Health Risk Category Based on MPN and Confidence Interval") + ": "} {getHealthRiskString(cbtValues.healthRisk, this.props.formCtx.T)}
) } renderPhoto() { // Displays an image if (this.props.value.image && this.props.imageManager) { return (
{React.createElement(ImageDisplayComponent, { image: this.props.value.image, imageManager: this.props.imageManager, T: this.props.formCtx.T })}
) } return null } render() { // Can't display if not set if (!this.props.value?.cbt) { return null } return (
{this.renderStyle()}
{this.renderInfo()} {this.renderPhoto()}
) } }