I'm a beginner in working with fhir server data with Java. And what I'm working on now, is to retrieve say a patient's information and display the information in Java's jframe gui.

I have no experience working on java applications that performs GET,CREATE and UPDATE operations with a server. Could anyone please elaborate on what i would need in order to facilitate the interaction between the jframe and server?

I can perform simple operations such as lookup of patient's information on a plain Java class, but when it comes to implementation in jframe, i couldn't just toss the code i used in the class into a button function and display the result in a label do i?

I googled about this but I'm getting tutorials on displaying database data, but nothing much on retrieving and displaying information from a server. Would appreciate some guidance on what i should have and tools I'm required to use.

1 Answers

0
vincenzopalazzo On

I state that I don't know the fhir server but I can give you an idea on how to do it with swing

If you already know how to do operations on your server then your problem is service location and how to structure a swing application.

First of all, the JFrame is used to coordinate the various scenarios, so a JFrame usually associates one or more panels that exchange, then for the moment using a JFrame and a Panel.

Using a Singleton for the service location we can ask him when we need a JPanel-like component or an action.

So the components we need to create your application are - A service location component and we use an app concept where we declare everything we need and our app contains the main. - A Jframe that we use as a container for one or more panels - a JPanel that we go out to render patient information - an Action that serves to perform operations on your server

This could be a code prototype

the frame

public class Frame extends javax.swing.JFrame {

   private void init(){
    //inti yout component
    setContentPane(App.getInstance().getPannello);

    setLocationRelativeTo(null);
    pack();
    setVisible(true);
   }

}

The panel

public class PanelPatient extends JPanel{

    private JButton youButton;

    private void init(){
        //init your component
    }

    private setAction(){
        youButton.setAction(App.getInstance().getActionSelect());
    }

    public void setPatient(Patient patient){
        textFiele.setText(patient.getName());
        //another information
    }
}

The Action

public class ActionSelect extends AbstractAction{

    public void actionPerformed(ActionEvent event){
        // your select and get patient to server

        App.getInstance().getPanel().setPatient(patient);
    }
}

The singleton whit main

public class App {

    private static final App SINGLETON = new App();

    public static App getInstance(){
        return SINGLETON;
    }

    private App(){}

    private Frame frame = new Frame();
    private PanelPatient panel = new PanelPatient();
    private Action actionSelect = new ActionSelect();

    public PanelPatient getPanel(){
        return panel;
    }

    public Action getActionSelect(){
        return actionSelect;
    }


    private void init(){

        panel.init();

        frame.init();

    }


    public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable{
            SINGLETON.init();
       });
    }
}

I hope you were helpful and sorry my bad English but I'm learning