Skip to content

Commit

Permalink
AC-1104: Migrate PatientRoomDAO to Kotlin (#1023)
Browse files Browse the repository at this point in the history
* Rename .java to .kt

* AC-1104: Migrate PatientRoomDAO to Kotlin
  • Loading branch information
shubhamsgit committed Aug 27, 2023
1 parent 31ec37c commit 5fdb0ac
Showing 1 changed file with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,36 @@
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package com.openmrs.android_sdk.library.dao

package com.openmrs.android_sdk.library.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.openmrs.android_sdk.library.databases.entities.PatientEntity;

import java.util.List;

import io.reactivex.Single;
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.openmrs.android_sdk.library.databases.entities.PatientEntity
import io.reactivex.Single

/**
* The interface Patient room dao.
*/
@Dao
public interface PatientRoomDAO {
interface PatientRoomDAO {
/**
* Add patient long.
*
* @param patientEntity the patient entity
* @return the long
*/
@Insert
long addPatient(PatientEntity patientEntity);
fun addPatient(patientEntity: PatientEntity): Long

/**
* Delete patient.
*
* @param id the id
*/
@Query("DELETE FROM patients WHERE _id = :id")
void deletePatient(long id);
fun deletePatient(id: Long)

/**
* Update patient int.
Expand All @@ -54,15 +49,15 @@ public interface PatientRoomDAO {
* @return the int
*/
@Update
int updatePatient(PatientEntity patientEntity);
fun updatePatient(patientEntity: PatientEntity): Int

/**
* Gets all patients.
*
* @return the all patients
*/
@Query("SELECT * FROM patients")
Single<List<PatientEntity>> getAllPatients();
fun getAllPatients(): Single<List<PatientEntity>>

/**
* Find patient by uuid single.
Expand All @@ -71,15 +66,15 @@ public interface PatientRoomDAO {
* @return the single
*/
@Query("SELECT * FROM patients WHERE uuid = :uuid")
Single<PatientEntity> findPatientByUUID(String uuid);
fun findPatientByUUID(uuid: String): Single<PatientEntity>

/**
* Gets unsynced patients.
*
* @return the unsynced patients
*/
@Query("SELECT * FROM patients WHERE synced = 0")
Single<List<PatientEntity>> getUnsyncedPatients();
fun getUnsyncedPatients(): Single<List<PatientEntity>>

/**
* Find patient by id single.
Expand All @@ -88,5 +83,5 @@ public interface PatientRoomDAO {
* @return the single
*/
@Query("SELECT * FROM patients WHERE _id = :id")
Single<PatientEntity> findPatientByID(String id);
}
fun findPatientByID(id: String): Single<PatientEntity>
}

0 comments on commit 5fdb0ac

Please sign in to comment.