Skip to content

Commit

Permalink
more work on calculated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 committed Jul 7, 2023
1 parent 7033d08 commit a8940ec
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const CalculatedValue: React.FC<CalculatedValueProps> = () => {
name: "",
operations: [
{
id : null,
type: 'TEST_RESULT',
value: "",
sampleId: null
Expand Down Expand Up @@ -108,6 +109,7 @@ const CalculatedValue: React.FC<CalculatedValueProps> = () => {
const addOperation = (index: number, type: OperationType) => {

var operation: OperationModel = {
id : null,
type: type,
value: '',
sampleId: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export interface CalculatedValueFormModel {
export type OperationType = 'TEST_RESULT' | 'MATH_FUNCTION' | 'INTEGER' | 'PATIENT_ATTRIBUTE' | '';

export interface OperationModel {
id : number
type: OperationType
value: number|string
value: string|number
sampleId : number
}

Expand All @@ -19,6 +20,7 @@ export const CalculatedValueFormValues:CalculatedValueFormModel = {
name: "",
operations: [
{
id : null,
type: 'TEST_RESULT',
value: "",
sampleId: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openelisglobal.testcalculated.dao.rest;
package org.openelisglobal.testcalculated.controller.rest;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.openelisglobal.testcalculated.dao;

import org.openelisglobal.common.dao.BaseDAO;
import org.openelisglobal.testcalculated.valueholder.Calculation;

public interface TestCalculationDAO extends BaseDAO<Calculation, Integer> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.openelisglobal.testcalculated.daoimpl;

import javax.transaction.Transactional;

import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.testcalculated.dao.TestCalculationDAO;
import org.openelisglobal.testcalculated.valueholder.Calculation;
import org.springframework.stereotype.Component;

@Component
@Transactional
public class TestCalculationDAOImpl extends BaseDAOImpl<Calculation, Integer> implements TestCalculationDAO{

public TestCalculationDAOImpl() {
super(Calculation.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.openelisglobal.testcalculated.service;

import org.openelisglobal.common.service.BaseObjectService;
import org.openelisglobal.testcalculated.valueholder.Calculation;


public interface TestCalculationService extends BaseObjectService<Calculation , Integer>{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.openelisglobal.testcalculated.service;

import org.openelisglobal.common.service.BaseObjectServiceImpl;
import org.openelisglobal.testcalculated.dao.TestCalculationDAO;
import org.openelisglobal.testcalculated.valueholder.Calculation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TestCalculationServiceImpl extends BaseObjectServiceImpl<Calculation, Integer> implements TestCalculationService {
@Autowired
TestCalculationDAO testCalculationDAOdao;

public TestCalculationServiceImpl() {
super(Calculation.class);
}

@Override
protected TestCalculationDAO getBaseObjectDAO() {
return testCalculationDAOdao;
}

}
Original file line number Diff line number Diff line change
@@ -1,71 +1,84 @@
package org.openelisglobal.testcalculated.valueholder;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.openelisglobal.common.valueholder.BaseObject;

@Entity
@Table(name = "calculation")
public class Calculation extends BaseObject<Integer>{

public class Calculation extends BaseObject<Integer> {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "calculation_generator")
@SequenceGenerator(name = "calculation_generator", sequenceName = "calculation_seq", allocationSize = 1)
@Column(name = "id")
private Integer id;

@Column(name = "name")
private String name;

private Integer sampleId ;

private Integer testId ;

@Column(name = "sample_id")
private Integer sampleId;

@Column(name = "test_id")
private Integer testId;

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "calculation_id", referencedColumnName = "id")
private Set<Operation> operations;

@Override
public Integer getId() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getId'");
return id;
}

@Override
public void setId(Integer id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setId'");
this.id = id ;
}


public String getName() {
return name;
}


public void setName(String name) {
this.name = name;
}


public Integer getSampleId() {
return sampleId;
}


public void setSampleId(Integer sampleId) {
this.sampleId = sampleId;
}


public Integer getTestId() {
return testId;
}


public void setTestId(Integer testId) {
this.testId = testId;
}

public Set<Operation> getOperations() {
return operations;
}

public void setOperations(Set<Operation> operations) {
this.operations = operations;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,88 @@
package org.openelisglobal.testcalculated.valueholder;

import java.util.stream.Stream;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "calculation_opearation")
public class Operation {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "calculation_opearation_generator")
@SequenceGenerator(name = "calculation_opeartion_generator", sequenceName = "calculation_opearation_seq", allocationSize = 1)
@Column(name = "id")
private Integer id;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private OperationType type;

@Column(name = "value")
private String value;;

@Column(name = "sampleId")
private Integer sampleId;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public OperationType getType() {
return type;
}

public void setType(OperationType type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public Integer getSampleId() {
return sampleId;
}

public void setSampleId(Integer sampleId) {
this.sampleId = sampleId;
}

public enum OperationType {

TEST_RESULT("Test Result"),
MATH_FUNCTION("Math Function"),
INTEGER("Integer"),
PATIENT_ATTRIBUTE("Patient Attribute");

private String displayName;

private OperationType(String displayName) {
this.displayName = displayName;
}

public String getDisplayName() {
return this.displayName;
}

public static Stream<OperationType> stream() {
return Stream.of(OperationType.values());
}
}
}

0 comments on commit a8940ec

Please sign in to comment.