How to do Corona Test on Patient USING SAP ABAP

Introduction:

 This Corona test application is used to test the critical values of the patient. With the help of this application, one can figure out if the patient has Corona Virus. The critical laboratory parameters of the Corona Virus are controlled using the Administrator user interface. The virus details can also be stored in this application. The corona virus symptoms and the patient symptoms are compared in this program. The patient personal details are also entered in this Application.

Data Dictionary:

The first and foremost step in building any application is understanding the type of data involved in the program. The corona virus must be differentiated from other types of virus. Each virus is unique, and it needs to be differentiated using an Id and description. The critical Laboratory parameters of the corona virus in the patient are WBC values, … These parameters must be uniquely identified using an Id, name. Its value determines whether the patient has Corona virus. The lower limit and higher limit of the Laboratory parameters are critical in detecting the corona virus. The symptoms of the corona virus are tracked in the symptom Id and description.

It can be uniquely identified using Id number. So every main entity here has an Id. For example, the entities such as virus, symptom, patient has an unique Id. The following table shows the properties of each entity.

VirusSymptomPatientVirus lab parameter
Virus Id Virus DescriptionSymptom Id Symptom DescriptionPatient Id Patient name Patient age Patient addressParameter Id Parameter name Parameter Critical values

We have successfully identified the critical data in our corona test application. Now we have to Build the ABAP Data Dictionary using the critical data.

Let us create the following Data elements.

  1. Virus entity
  2. Virus Id – ZDE_Virus_Id – > Datatype – Numc03
  3. Virus Description – ZDE_Virus_desc -> Datatype – String
  4. Virus Symptoms
  5. Symptom Id – ZDE_Symptom_Id – Domain -> Numc03 Datatype
  6. Symptom Description – ZDE_Symptom_desc -> Datatype – String
  7. Patient Entity
  8. Patient Id – ZDE_Patient_Id -> Datatype – Numc03
  9. Patient Age – ZDE_Patient_age -> Datatype – Numc02
  10. Patient Name – ZDE_Patient_name -> Datatype – String
  11. Patient Address – ZDE_Patient_address -> Datatype – String
  12. Virus Lab Parameter
  13. Parameter Id – ZDE_Parameter_Id -> Datatype – Numc03
  14. Parameter name – ZDE_Parameter_name -> Datatype – String

Let us now create the following Data tables.

  1. ZTT_Virus_DB => Data table

Field 1 à Virus_Id => ZDE_Virus_Id

Field 2 à Virus_description => ZDE_Virus_desc

  • ZTT_Symptoms => Data table

Field 1 à Symptom_Id => ZDE_Symptom_Id

Field 2 à Symptom_description => ZDE_Symptom_desc

  • ZTT_Patient => Data table

Field 1 àPatient_Id => ZDE_Patient_Id

Field 2 à Patient_name => ZDE_Patient_name

Field 3 à Patient_age => ZDE_Patient_age

Field 4 à Patient_address => ZDE_Patient_address

  • ZTT_Lab_Parameter => Data table

Field 1 àLab_para_Id => ZDE_lab_para_Id

Field 2 à Lab_para_name => ZDE_lab_para_name

Field 3 à Lab_para_low_value => ZDE_lab_para_low_value

Field 4 à Lab_para_high_value => ZDE_lab_para_high_value

Object oriented Branch details

        I.            First branch

First Branch in creating the object-oriented model for corona test application.

     II.            Second Branch

Second branch in the corona test application for the corona symptoms.

    III.            Third Branch

Third Branch in the corona test application for the patient details.

   IV.            Fourth Branch

Fourth Branch for the patient lab test values.

Description of Interfaces and methods.

Interface: One of the key concepts which can be considered as the Skeleton of the object oriented model. Let us consider the following interfaces to implement the corona test application.

  1. ZIF_VIR_DETAILS
  2. ZIF_LAB_ATTRIBUTE_NAME
  3. ZIF_LAB_ATTRIBUTE_VALUE
  4. ZIF_SYMPTOMS
  5. ZIF_PATIENT

Now, Let us look at the definition of each Interfaces.

  1. INTERFACE zif_vir_details

PUBLIC.

METHODS set_vir_details

IMPORTING i_virus_id TYPE zde_virus_id

           i_virus_desc TYPE zde_virus_desc.

METHODS get_vir_details

IMPORTING i_virus_id TYPE zde_virus_id

EXPORTING e_virus_desc TYPE zde_virus_desc.

ENDINTERFACE.

  1. INTERFACE zif_lab_attribute_name

PUBLIC .

METHODS set_attribute_name

IMPORTING i_lab_attribute_name TYPE zde_parameter_name              

                       i_lab_attribute_id TYPE zde_parameter_id

           i_virus_id TYPE zde_virus_id.

METHODS get_attribute_name

IMPORTING i_lab_attribute_id TYPE zde_parameter_id

i_virus_id TYPE zde_virus_id

EXPORTING e_lab_attribute_name TYPE zde_paramete_name.

ENDINTERFACE.

  1. INTERFACE zif_lab_attribute_value

PUBLIC.

METHODS set_lab_attribute_value

IMPORTING i_lab_attribute_id TYPE zde_parameter_id

i_virus_id TYPE zde_virus_id

i_lab_para_low_value TYPE ZDE_lab_para_low_value

i_lab_para_high_value TYPE ZDE_lab_para_high_value.

METHODS get_lab_attribute_value

IMPORTING i_lab_attribute_id TYPE zde_parameter_id

EXPORTING e_lab_para_value TYPE int4

ENDINTERFACE.

  1. INTERFACE ZIF_SYMPTOMS

PUBLIC.

METHODS set_symptoms

IMPORTING i_symptom_id TYPE zde_symptom_id

           i_symptom_desc TYPE zde_symptom_desc.

METHODS get_symptoms.

EXPORTING et_symptoms TYPE ztt_symptom_ty.

ENDINTERFACE.

INTERFACE zif_patient

PUBLIC.

METHODS set_patient_details

IMPORTING i_patient_id TYPE zde_patient_id

           i_patient_name TYPE zde_patient_name

           i_patient_age TYPE num02

                      i_patient_address TYPE zde_patient_address.

METHODS get_patient_details

IMPORTING i_patient_id TYPE zde_patient_id

EXPORTING e_patient_name TYPE zde_patient_name

e_patient_age TYPE num02

e_patient_address TYPE zde_patient_address.

METHODS set_patient_symptoms

IMPORTING i_symptom_desc TYPE zde_symptom_desc

i_patient_id TYPE zde_patient_id.

METHODS get_patient_symptoms.

IMPORTING i_patient_id TYPE zde_patient_id

EXPORTING et_symptom_desc TYPE ztt_symptom_desc.

METHODS set_patient_lab para_values.

IMPORTING i_patient_id TYPE zde_patient_id

i_lab_para_id TYPE zde_parameter_id

i_lab_para_value TYPE int4.

METHODS get_patient_lab_para_values.

IMPORTING i_patient_id TYPE zde_patient_id   

                       i_lab_para_id TYPE zde_parameter_id

EXPORTING e_lab_para_value TYPE int4.

ENDINTERFACE.

Now we have discussed about the data, Data tables, Object branches, skeleton of the system (Interface).

User Interface

The front end helps us to understand the whole process easily. So lets begin with the user interface for the virology expert team.

User Interface for Virology expert Team

Figure 1 Admin User Interface

The user interface depicts the input elements of the virus information systems. The data which is entered in these textboxes, must be stored in the Database.

Classes and objects

The data from the user interface elements are passed through the classes and objects. These Sar_Covid 19, virus lab parameters, lab limits objects carry the data from the user interface and insert the data into the database. The very next step would be to create objects. Now we will investigate the creation of these classes. We discussed about the different object oriented branches in the beginning. Now we will look in detail about the code for each of these branches.

Picture below depicts the different classes between the UI and Database.

Figure 2 Virus Branch

First Object oriented branch for virus data

Now let’s see the code directly in the above classes.

a)      zcl_Sars_Covid_19

CLASS zcl_sars_covid_19 DEFINITION

 PUBLIC

ABSTRACT CREATE PUBLIC.

PUBLIC SECTION.

 INTERFACES zif_vir_details.

INTERFACES zif_lab_attribute_name.

 INTERFACES zif_lab_attributevalue.

INTERFACES zif_symptoms.

METHODS constructor

IMPORTING i_virus_id TYPE zde_virus_id

i virus_desc TYPE zdevirusdesc.

PROTECTED SECTION.

DATA m_virus_id TYPE zde_virus_id.

DATA m_virus_desc TYPE zde_virusdesc.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_sars_covid_19 IMPLEMENTATION.

METHOD constructor.

m_virus_id = i_virus_id.

m_virus_desc = i_virus_desc.

ENDMETHOD.

METHOD zif_vir_details~set_vir_details.

ENDMETHOD.

METHOD zif_virdetails~getvirdetails.

ENDMETHOD.

METHOD zif_labattribute_name~set_attribute_name.

ENDMETHOD.

METHOD zif_lab_attribute_name~get_attributename.

ENDMETHOD.

METHOD zif_lab_attribute_value-set_lab_attribute_value.

ENDMETHOD.

 METHOD zif_lab_attribute_value~get_lab_attributevalue.

ENDMETHOD.

METHOD zif_symptoms~set_symptoms.

ENDMETHOD.

METHOD zif_symptoms~get_symptoms.

ENDMETHOD.

ENDCLASS.

b)     zcl_virus_lab_parameters

CLASS zcl_virus_lab_parameters DEFINITION INHERITING FROM zcl_sars_covid_19

PUBLIC ABSTRACT

CREATE PUBLIC.

PUBLIC SECTION.

 METHODS zif_lab_attribute_name~set_attribute_name REDEFINITION. METHODS zif_lab_attribute_name~get_attribute_name REDEFINITION. METHODS constructor

IMPORTING i_virus_id TYPE zde_virus_id

i_virus_desc TYPE zde_virus_desc

i_lab_para_id TYPE zde_lab_para_id

i_lab_para_name TYPE zde_lab_para_name.

PROTECTED SECTION.

DATA m_lab_para_id TYPE zde_lab_para_id.

DATA m_lab_para_name TYPE zde_lab_para_name.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_virus_lab_parameters IMPLEMENTATION.

METHOD constructor.

 super->constructor( i_virus_id = i_virus_id

   i_virus_desc = i_virus_desc ).

m_lab_para_id = i_lab_para_id.

m_lab_para_name = i_lab_para_name.

ENDMETHOD.

METHOD zif_lab_attribute_name~set_attribute_name.

DATA lt_lab_parameters TYPE STANDARD TABLE OF ztt_lab_para.

DATA ls_lab_parameters LIKE LINE OF lt_lab_parameters.

ls_lab_parameters-parameter_id = i_lab_attribute_id.

ls_lab_parameters-parameter_name = i_lab_attribute_name.

ls_lab_parameters-virus_id = i_virus_id.

SELECT SINGLE * FROM ztt_lab_para INTO ls_lab_parameters WHERE  

                                                           parameter_id = i_lab_attribute_id.

IF sy-subrc <> O.

INSERT INTO ztt_lab_para VALUES ls_lab_parameters.

ENDIF.

ENDMETHOD.

METHOD zif_lab_attribute_name~get_attribute_name.

DATA lt_lab_parameters TYPE STANDARD TABLE OF ztt_lab_para.

FIELD-SYMBOLS <fs_param> LIKE LINE OF lt_lab_parameters.

SELECT * FROM ztt_lab_para INTO TABLE lt_lab_parameters WHERE

Parameter_id = i_lab_attribute_id AND virus id = i_virus_id.

IF sy-subrc = 0.

READ TABLE lt_lab_parameters INDEX 1 ASSIGNING <fs_param>.

IF sy-subrc = 0.

e_lab_attribute_name = <fs_param>-parameter_name.

     ENDIF.

            ENDIF.

ENDMETHOD.

ENDCLASS.

c)      Zcl_lab_limits

CLASS zcl_lab_limits DEFINITION INHERITING FROM zcl_virus_lab_parameters

PUBLIC ABSTRACT

CREATE PUBLIC .

PUBLIC SECTION.

METHODS zif_lab_attribute_value~set_lab_attribute_value REDEFINITION. METHODS zif_lab_attribute_value~get_lab_attribute_value REDEFINITION. METHODS constructor

IMPORTING i_virus_id TYPE zde_virus_id

i_virus_desc TYPE zde_virus_desc

i_lab_para_id TYPE zde_parameter_id

i_lab_para_name TYPE zde_parameter_name

i_lab_para_low_value TYPE int4

i_lab_para_high_value TYPE int4.

PROTECTED SECTION.

DATA m_lab_para_low_value TYPE int4.

DATA m_lab para_bigh_value TYPE int4.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_lab_limits IMPLEMENTATION.

METHOD constructor.

super->constructor( i_virus_id = i_virus_id

i_virus_desc = i_virus_desc

i_lab_para_id = i_lab_para_id

i_lab_para_name = i_lab_para_name).

m_lab_para_low_value = i_lab_para_low_value.

m_lab_para_high_value = i_lab_para_high_value.

ENDMETHOD.

METHOD zif_lab_attribute_value~set_lab_attribute_value.

DATA lt_lab_para_values TYPE STANDARD TABLE OF ztt_lab_para_val. DATA lt_lab_para_values LIKE LINE OF lt_lab_para_values.

DATA lt_lab_para TYPE STANDARD TABLE OF ztt_lab_para.

DATA ls_lab_para LIKE LINE OF lt_lab_para.

SELECT SINGLE * FROM ztt_lab_para INTO Is_lab_para WHERE

                                                   parameter_id = i_lab_attribute_id.

IF sy-subrc = 0.

is_lab_para_values-parameter_name = ls_lab_para-parameter_name. is_lab_para_values-parameter_id = ls_lab_para-parameter_id. is_lab_para_values-para_low_value = i_lab_para_low_value. ls_lab_para_values-para_high_value = i_lab_para_high_value.

                        ENDIF.

INSERT INTO ztt_lab_para_val VALUES lt_lab_para_values. ENDMETHOD.

METHOD zif_lab_attribute_value~get_lab_attribute_value.

DATA lt_lab_para_values TYPE STANDARD TABLE OF ztt_lab_para_val. FIELD-SYMBOLS <fs_param> LIKE LINE OF lt_lab_para_values.

SELECT * FROM ztt_lab_para_val INTO TABLE lt_lab_para_values  

                                       WHERE parameter_id = i_lab_attribute_id.

IF sy-subrc = 0.

      READ TABLE lt_lab_para_values INDEX 1 ASSIGNING <fs_param>.

      IF sy-subrc = 0.

e_lab_para_low_value = <fs_param>-para_low_value. e_lab_para_high_value = <fs_param>-para_high_value.

     ENDIF.

ENDIF.

ENDMETHOD.

ENDCLASS.

d)     Zcl_viro_expert

CLASS zcl_viro_expert DEFINITION INHERITING FROM zcl_lab_limits

PUBLIC FINAL

CREATE PUBLIC .

PUBLIC SECTION.

METHODS zif_vir_details~set_vir_details REDEFINITION.

METHODS zif_vir_details~get_vir_details REDEFINITION.

METHODs constructor

IMPORTING i_virus_id TYPE zde_virus_id

i_virus_desc TYPE zde_virus_desc

i_lab_para_id TYPE zde_parameter_id

i_lab_para_name TYPE zde_parameter_name

i_lab_para_low value TYPE int4

i_lab_para_high_value TYPE int4.

METHODS set_all_virus_values.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_viro_expert IMPLEMENTATION.

METHOD constructor.

super->constructor( i_virus_id= i_virus_id

        i_virus_desc = i_virus_desc

        i_lab_para_id = i_lab_para_id

        i_lab_para_name = i_lab_para_name

        i_lab_para_low_value = i_lab_para_low_value

        i_lab_para_high_value = i_lab_para_high_value ).

ENDMETHOD.

METHOD set_all_virus_values.

zif_vir_details~set_vir_details( i_virus_id = m_virus_id

   i_virus_desc = m_virus_desc ).

zif_lab_attribute_name~set_attribute_name(

i_lab_attribute_id = m lab_para_id

i_lab_attribute_name = m_lab_para_name

i_virus_id = m_virus_id ).

zif_lab_attribute_value~set_lab_attribute_value(

i_lab_attribute_id = m_lab_para_id

i_virus_id = m virus_id

i_lab_para_low value = m_lab_para_low_value

i_lab_para_high_value = m_lab_para_high_value ).

ENDMETHOD.

METHOD zif_vir_details~set_vir_details.

DATA lt_virus TYPE STANDARD TABLE OF ztt_virus_db.

DATA is_virus LIKE LINE OF lt_virus.

is_virus-virus_id = i_virus_id.

ls_virus-virus_desc = i_virus_desc.

SELECT * FROM ztt_virus_db INTO table lt_virus WHERE virus_id = i_virus_id.

IF sy-subrc <> 0.

INSERT INTO ztt_virus_db VALUES ls_virus.

      ENDIF.

ENDMETHOD.

METHOD zif_vir_details~get_vir_details.

DATA lt_virus_db TYPE STANDARD TABLE OF ztt_virus_db.

FIELD-SYMBOLS <fs_vir> LIKE LINE OF lt_virus_db.

SELECT * FROM ztt_virus_db INTO TABLE lt_virus_db WHERE

virus_id = i_virus_id.

IF sy-subrc = 0.

READ TABLE lt_virus_db ASSIGNING <fs_vir> INDEX 1.

E_virus_desc = <fs_vir>-virus_desc.

ENDIF.

ENDMETHOD.

ENDCLASS.

Second Branch to handle the corona virus symptoms.

Key Member VariablesClass HierarchyDefinition
Virus_Id Virus_descZCL_Sars_Covid_19PUBLIC ABSTRACT
Symptom_IdZCL_SymptomsPUBLIC
 ZCL_Med_ExpertPUBLIC

a)      Zcl_sars_covid_19

This class creation is already discussed in the first branch

b)     Zcl_symptoms

CLASS zcl_symptoms DEFINITION INHERITING FROM zcl_sars_covid_19

 PUBLIC

 CREATE PUBLIC .

 PUBLIC SECTION.

  METHODS zif_symptoms~set_symptoms REDEFINITION.

  METHODS zif_symptoms~get_symptoms REDEFINITION.

 PROTECTED SECTION.

 PRIVATE SECTION.

 ENDCLASS.

CLASS zcl_symptoms IMPLEMENTATION.

 METHOD zif_symptoms~set_symptoms.

  DATA it_symptoms TYPE STANDARD TABLE OF ztt_symptom.

  DATA is_symptoms LIKE LINE OF lt_symptoms.

  SELECT * FROM ztt_symptom INTO TABLE lt_symptoms WHERE virus_id = m_virus_id AND symptom_id = i_symptom_id.

  IF sy-subrc <> 0.

   ls_symptoms-virus_id = m_virus_id.

   ls_symptoms-symptom_id = i_symptom_id.

   ls_symptoms-symptom_desc = i_symptom_desc.

   INSERT INTO ztt_symptom VALUES ls_symptoms.

  ENDIF.

 ENDMETHOD.

 METHOD zif_symptoms~get_symptoms.

  DATA lt_symptoms TYPE STANDARD TABLE OF ztt_symptom.

  SELECT * FROM ztt_symptom INTO table lt_symptoms WHERE virus_id = m_virus_id.

  LOOP AT lt_symptoms into DATA(ls_symptoms).

    APPEND ls_symptoms TO et_symptoms.

  ENDLOOP.

 ENDMETHOD.

ENDCLASS.

c)      Zcl_med _expert

CLASS zcl_med_expert DEFINITION PUBLIC INHERITING FROM zcl_symptoms

FINAL CREATE PUBLIC .

PUBLIC SECTION.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_med_expert IMPLEMENTATION.

ENDCLASS.

User interface for the corona virus symptoms

Figure 3 Corona Virus Symptoms

Third Branch for patient details and patient corona symptoms

Key AttributesClass HierarchyDescription
 ZCL_PatientPUBLIC ABSTRACT
 ZCL_Patient_DetPUBLIC
 ZCL_Patient_SymptomPUBLIC
  1. Zcl_patient

CLASS zcl_patient DEFINITION

 PUBLIC

 abstract

 CREATE PUBLIC .

 PUBLIC SECTION.

  INTERFACES zif_patient.

  METHODS constructor.

 PROTECTED SECTION.

 PRIVATE SECTION.

ENDCLASS.

CLASS zcl_patient IMPLEMENTATION.

 METHOD constructor.

 ENDMETHOD.

 METHOD zif_patient~get_patient_details.

 ENDMETHOD.

 METHOD zif_patient~get_patient_symptoms.

 ENDMETHOD.

 METHOD zif_patient~set_patient_details.

 ENDMETHOD.

 METHOD zif_patient~set_patient_symptoms.

 ENDMETHOD.

 METHOD zif_patient~set_patient_lab_para_values.

 ENDMETHOD.

 METHOD zif_patient~get_patient_lab_para_values.

 ENDMETHOD.

ENDCLASS.

  • Zcl_patient_det

CLASS zcl_patient_det DEFINITION INHERITING FROM zcl_patient

PUBLIC

CREATE PUBLIC .

PUBLIC SECTION.

METHODS zif_patient~set_patient_detalis REDEFINITION.

METHODS zif_patient~get_patient_details REDEFINITION.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_patient_det IMPLEMENTATION.

METHOD zif_patient~set_patient_details.

DATA it_patient TYPE STANDARD TABLE OF ztt_patient_det.

DATA ls_patient LIKE LINE OF it_patient.

ls_patient-patient_id = i_patient_id.

ls_patient-patient_name = i_patient_name.

ls_patient-patient_age = i_patient_age.

ls_patient-patient_address = i_patient_address.

SELECT * FROM ztt_patient_det INTO TABLE it_patient WHERE patient_id = i_patient_id.

IF sy-subrc <> 0.

            INSERT INTO ztt_patient_det VALUES ls_patient.

ENDIF.

ENDMETHOD.

METHOD zif_patient~get_patient_details.

DATA lt_patient TYPE STANDARD TABLE OF ztt_patient_det.

FIELD-SYMBOLS <fs_patient> LIKE LINE OF lt_patient.

SELECT * FROM ztt_patient_det INTO TABLE it_patient WHERE patient_id = i_patient_id.

IF sy-subrc = 0.

READ TABLE it_patient ASSIGNING <fs_patient> INDEX 1.

e_patient_name = <fs_patient>-patient_name.

e_patient_age = <fs_patient>-patient_age.

e_patient_address = <fs_patient>-patient_address.

ENDIF.

ENDMETHOD.

ENDCLASS.

Figure 4 User interface for Patient Details

  • Zcl_patient_symptom

CLASS zcl_patient_symptom DEFINITION INHERITING FROM zcl_patient_det

PUBLIC

CREATE PUBLIC .

PUBLIC SECTION.

METHODS zif_patient~set_patient_symptoms REDEFINITION.

METHODS zif_patient~get_patient_symptoms REDEFINITION.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS zcl_patient_symptom IMPLEMENTATION.

METHOD zif_patient~get_patient_symptoms.

DATA lt_patient_sym TYPE STANDARD TABLE OF ztt_patient_sym.

DATA ls_patient_sym LIKE LINE OF lt_patient_sym.

DATA lt_symptom TYPE STANDARD TABLE OF ztt_symptom.

SELECT * FROM ztt_patient_sym INTO TABLE lt_patient_sym WHERE patient_id = i_patient_id.

IF sy-subrc = 0.

LOOP AT lt_patient_sym INTO ls_patient_sym.

            SELECT * FROM ztt_symptom INTO TABLE lt_symptom WHERE symptom_id = ls_patient_sym-symptom_id.

            LOOP AT lt_symptom INTO DATA(ls_symptom).

                        APPEND ls_symptom-symptom_desc TO et_symptom_desc.

            ENDLOOP.

ENDLOOP.

ENDIF.

ENDMETHOD.

METHOD zif_patient~set_patient_symptoms.

DATA lt_patient_sym TYPE STANDARD TABLE OF ztt_patient_sym.

DATA is_patient_sym LIKE LINE OF lt_patient_sym.

DATA it_symptom TYPE STANDARD TABLE OF ztt_symptom.

DATA 1_max TYPE num02.

SELECT * FROM ztt_symptom INTO TABLE lt_symptom WHERE symptom_desc LIKE i_symptom_desc.

LOOP AT it_symptom INTO DATA(ls_symptom).

ls_patient_sym-patient_id = i_patient_id.

ls_patient_sym-symptom_id = ls_symptom-symptom_id.

SELECT MAX( symptom_record ) INTO 1_max FROM ztt_patient_sym WHERE patient_id = i_patient_id.

ls_patient_sym-symptom_record = 1_max + 01.

INSERT INTO ztt_patient_sym VALUES ls_patient_sym.

ENDLOOP.

ENDMETHOD.

ENDCLASS.

Figure 5 Corona Patient Symptoms

Fourth Branch for Corona patient lab values and corona test

Key AttributesClass NameDefinition
 ZCL_PatientPUBLIC ABSTRACT
 ZCL_Patient_Lab_ValuesPUBLIC
 ZCL_Corona_TestPUBLIC FINAL
  1. Zcl_patient

This class is already discussed in the third branch

  • zcl_patient_lab_values

CLASS zcl_patient_lab_values DEFINITION INHERITING FROM zcl_patient

 PUBLIC

 CREATE PUBLIC .

PUBLIC SECTION.

  METHODS zif_patient~set_patient_lab_para_values REDEFINITION.

  METHODS zif_patient~get_patient_lab_para_values REDEFINITION.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS zcL_patient_lab_values IMPLEMENTATION.

METHOD zif_patient~set_patient_lab_para_values.

 DATA lt_patient_lab TYPE STANDARD TABLE OF ztt_patient_lab.

 DATA ls_patient_lab LIKE LINE OF lt_patient_lab.

 ls_patient_lab-patient_id = i_patient_id.

 ls_patient_lab-lab_para_id = i_lab_para_id.

 ls_patient_lab-pati_lab_para_value = i_lab_para_value.

 SELECT * FROM ztt_patient_lab INTO TABLE lt_patient_lab WHERE patient_id = i_patient id AND lab_para_id = i_lab_para_id.

 IF sy-subrc <> 0.

  INSERT INTO ztt_patient_lab VALUES ls_patient_lab.

 ENDIF.

ENDMETHOD.

METHOD zif_patient~get_patient_lab_para_values.

 DATA lt_patient_lab TYPE STANDARD TABLE OF ztt_patient_lab.

 FIELD-SYMBOLS <fs_patient_lab> LIKE LINE OF lt_patient_lab.

 SELECT * FROM ztt_patient_lab INTO TABLE lt_patient_lab WHERE patient_id = i_patient_id AND lab_para_id = i_lab_para_id.

 IF sy-subrc = 0.

  READ TABLE lt_patient_lab ASSIGNING <fs_patient_lab> INDEX 1.

  e_lab_para_value = <fs_patient_lab>-pati_lab_para_value.

  ENDIF.

ENDMETHOD.

ENDCLASS.

Figure 6 Patient Lab Values

  • Zcl_corona_test

CLASS zcl_corona_test DEFINITION INHERITING FROM zcl_patient_lab_values

 PUBLIC

 FINAL

 CREATE PUBLIC .

 PUBLIC SECTION.

  METHODS get_patient_object EXPORTING rr_patient TYPE REF TO zif_patient.

  METHODS check_patient_symptoms IMPORTING i_patient_id TYPE zde_virus_id    EXPORTING e_corona_symptom TYPE abap_bool.

  METHODS get_patient_corona_test IMPORTING i_patient_id TYPE zde_virus_id    RETURNING VALUE(e_patient_corona_test) TYPE abap_bool.

  METHODS check_lab_value IMPORTING i_patient_lab_value TYPE int4 i_lab_para_id TYPE zde_virus_id RETURNING VALUE(r_wbc_critical) TYPE abap_bool.

 PROTECTED SECTION.

 PRIVATE SECTION.

ENDCLASS.

CLASS zcl_corona_test IMPLEMENTATION.

 METHOD get_patient_object.

  rr_patient = NEW zcl_patient_symptom( ).

 ENDMETHOD.

 METHOD check_patient_symptoms.

  get_patient_object( IMPORTING rr_patient = DATA(lr_patient) ).

  lr_patient->get_patient_symptoms( EXPORTING i_patient_id = i_patient_id IMPORTING et_symptom_desc = DATA(lt_symptom_desc) ).

  IF lines( lt_symptom_desc ) > 2.

  e_corona_symptom = abap_true.

  ELSE.

  e_corona_symptom = abap_false.

  ENDIF.

 ENDMETHOD.

Business Logic:

METHOD get_patient_corona_test.

 DATA(lr_patient) = NEW zcl_patient_lab_values( ).

 lr_patient->zif_patient~get_patient_lab_para_values( EXPORTING i_patient_id = i_patient_id i_lab_para_id = ‘500’

                                                                             IMPORTING e_lab_para_value = DATA(l_wbc_value) ).

 lr_patient->zif_patient~get_patient_lab_para_values( EXPORTING i_patient_id = i_patient_id i_lab_para_id = ‘501’

                                                                            IMPORTING e_lab_para_value = DATA(l_neu_value) ).

 lr_patient->zif_patient~get_patient_lab_para_values( EXPORTING i_patient_id = i_patient_id i_lab_para_id = ‘502’

                                                                             IMPORTING e_lab_para_value = DATA(l_lym_value) ).

 lr_patient->zif_patient~get_patient_lab_para_values( EXPORTING i_patient_id = i_patient_id i_lab_para_id = ‘503’

                                                                 IMPORTING e_lab_para_value = DATA(1_ast_value) ).

 IF check_lab_value( i_patient_lab_value = l_wbc_value i_lab_para_id = ‘500’) = abap_true

  AND

  check_lab_value( i_patient_lab_value = l_neu_value i_lab_para_id = ‘501’) = abap_true

  AND

  check_lab_value( i_patient_lab_value = l_lym_value i_lab_para_id = ‘502’) = abap_true

  AND

  check_lab_value( i_patient_lab_value = l_ast_value i_lab_para_id = ‘503’) = abap_true.

  e_patient_corona_test = abap_true.

 else.

  e_patient_coron7test = abap_false.

 endif.

 ENDMETHOD.

Business rule

METHOD check_lab_value.

 DATA(lr_lab_para) = NEW zcl_viro_expert( i_virus_id = 001

                                                             i_virus_desc = ‘ ‘

                                                             i_lab_para_id = i_lab_para_id

                                                             i_lab_para_name = ‘ ‘

                                                             i_lab_para_low_value = ‘ ‘

                                                             i_lab_para_high_value =’ ‘ ).

 lr_lab_para->zif_1ab_attribute_value—get_lab_attribute_value(

                                                EXPORTING i_1ab_attribute_id = i_lab_para_id

                                                IMPORTING e_lab_para_low_value = DATA(l_lab_para_low_value)

                                                e_lab_para_high_value = DATA(l_lab_para_high_value)

  IF i_patient_lab_value >= l_lab_para_low_value AND

    i_patient_lab_value <= 1_1ab_para_high_value.

   r wbc_critical = abap_true.

  ENDIF.

 ENDMETHOD.

ENDCLASS.

Button click events:

The picture below shows button click events which occurs in the user interface.

The below code is used to take the input values of the corona test from the user interface elements of the application.

REPORT zvir_program.

DATA lr_virus TYPE REF TO zcl_viro_expert.

DATA lr_med_expert TYPE REF TO zcl_med_expert.

DATA lr_corona_test TYPE REF TO zcl_corona_test.

DATA lr_patient_det TYPE REF TO zcl_patient_det.

DATA lr_patient TYPE REF TO zif_patient.

lr_virus = NEW zcl_viro_expert( i_virus_id = 001

                                               i_virus_desc = ‘SARS COVID 19’

                                               i_lab_para_id = 500

                                               i_lab_para_name =

                                               i_lab_para_value = 3000 ).

1r_med_expert = NEW zcl_med_expert( i_virus_id = 001 i_virus_desc = ‘SARS COVID 19’ ).

lr_med_expert->zif_symptoms~set_symptoms( i_symptom_id = 200 i_symptom_desc = ‘Fever’ ).

lr_corona_test = NEW zcl_corona_test( ).

lr_corona_test->get_patient_object( IMPORTING rr_patient = lr_patient ).

1r_patient->set_patient_details( i_patient_id = 300

                                                i_patient_age = 31

                                                i_patient_name = ‘Mahesh’

                                                i_patient_address = ‘No.22 old madras road’ ).

lr_patient->set_patient_symptoms( i_patient_id = 300 i_symptom_desc = ‘Fever’).

lr_coronatest->zif_patient~set_patient_lab_para_values( i_patient_id = 300

                                                                                   i_lab_para_id = 500

                                                                                   i_lab_para_value = 6800 ).

DATA(r_corona_test_result) = lr_corona_test->get_patient_corona_test( i_patient_id = 300 ).

if r_corona_test_result = abap_true.

            WRITE: / ‘Patient corona test is positive’.

else.

            write: / ‘Patient corona test is negative’.

endif.

Conclusion:

The developed Corona test application is used to test the Critical Medical parameters of the patient. The Corona Symptoms are compared to the patient symptoms. The corona test is evaluated based on the values of the laboratory parameters. The different Laboratory parameter can also be administered centrally in the system.