I have a program that displays diagnosis codes that can be assigned to a person. I imported a few diagnosis codes into a mssql table. Within the program all the codes display correctly. The end user would select the appropriate code and click save. Then the code is saved or updated into the diagnosis code column within the person table.
I’m trying to understand logically how this can done.
IPerson.java
@Entity
@Getter
@NoArgsConstructor(force = true)
@Data
@Table(name = "patients")
public class IPatientModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "patientID", nullable = false)
private final Integer patientID;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "gen_diagnosis")
private String genDiagnosis;
IDiagnosis.java
@Setter
@Getter
@Data
@NoArgsConstructor(force = true)
@Entity
@Table(name="diagnosis_code")
public class IDiagnosisModel {
@Id
@Column(name="code")
private String code;
@Column(name = "description")
private String description;
DiagnosisCodeController.java
@Controller
@EnableJpaRepositories
public class NewDiagnosisCodeController implements Initializable {
@Autowired
ConfigurableApplicationContext applicationContext;
@Autowired
DiagnosisService diagnosisService;
@Autowired
PatientService patientService;
public TableView<IDiagnosisModel> newDiagCodeTable;
public TableColumn<IDiagnosisModel, String> codeCol;
public TableColumn<IDiagnosisModel, String> descripCol;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
codeCol.setCellValueFactory((new PropertyValueFactory<>("Code")));
descripCol.setCellValueFactory((new PropertyValueFactory<>("Description")));
newDiagCodeTable.getColumns().setAll(codeCol, descripCol);
newDiagCodeTable.setItems(FXCollections.observableArrayList(diagnosisService.findAll()));
}
@FXML
public void onSaveDiagCode(ActionEvent event) {
IDiagnosisModel diagCode = newDiagCodeTable.getSelectionModel().getSelectedItem();
diagCode.setGenDiagnosis(codeCol.getText());
diagnosisService.save(diagCode);
}
}
Essentially – this loads a table with two columns, code and description. The dagnosis_code tables has several diagnosis codes that are displayed. The end user can select a code, click save and it needs to update the patient table and column gen_diagnosis. I’m unsure how to properly update one table’s data to another table.