openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/library/dao/EncounterDAO.java
/**
     * Save last vitals encounter.
     *
     * @param encounter   the encounter
     * @param patientUUID the patient uuid
     */
Save last vitals encounter.
@param encounter   the encounter
@param patientUUID the patient uuid
Save last vitals encounter . @param encounter the encounter @param patientUUID the patient uuid
public void saveLastVitalsEncounter(Encounter encounter, String patientUUID) {
        if (null != encounter) {
            encounter.setPatientUUID(patientUUID);
            long oldLastVitalsEncounterID;
            try {
                oldLastVitalsEncounterID = encounterRoomDAO.getLastVitalsEncounterID(patientUUID).blockingGet();
            } catch (Exception e) {
                oldLastVitalsEncounterID = 0;
            }
            if (0 != oldLastVitalsEncounterID) {
                for (Observation obs : new ObservationDAO().findObservationByEncounterID(oldLastVitalsEncounterID)) {
                    ObservationEntity observationEntity = AppDatabaseHelper.convert(obs, 1L);
                    observationRoomDAO.deleteObservation(observationEntity);
                }
                encounterRoomDAO.deleteEncounterByID(oldLastVitalsEncounterID);
            }
            long encounterID = saveEncounter(encounter, null);
            for (Observation obs : encounter.getObservations()) {
                ObservationEntity observationEntity = AppDatabaseHelper.convert(obs, encounterID);
                observationRoomDAO.addObservation(observationEntity);
            }
        }
    }
public void saveLastVitalsEncounter ( Encounter encounter , String patientUUID ) { if ( null != encounter ) { encounter . setPatientUUID ( patientUUID ) ; long oldLastVitalsEncounterID ; try { oldLastVitalsEncounterID = encounterRoomDAO . getLastVitalsEncounterID ( patientUUID ) . blockingGet ( ) ; } catch ( Exception e ) { oldLastVitalsEncounterID = 0 ; } if ( 0 != oldLastVitalsEncounterID ) { for ( Observation obs : new ObservationDAO ( ) . findObservationByEncounterID ( oldLastVitalsEncounterID ) ) { ObservationEntity observationEntity = AppDatabaseHelper . convert ( obs , 1L ) ; observationRoomDAO . deleteObservation ( observationEntity ) ; } encounterRoomDAO . deleteEncounterByID ( oldLastVitalsEncounterID ) ; } long encounterID = saveEncounter ( encounter , null ) ; for ( Observation obs : encounter . getObservations ( ) ) { ObservationEntity observationEntity = AppDatabaseHelper . convert ( obs , encounterID ) ; observationRoomDAO . addObservation ( observationEntity ) ; } } }
Save last vitals encounter.
Save last vitals encounter .