91 lines
4.2 KiB
JavaScript
91 lines
4.2 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.updateInsertIdConditionRepo = exports.getDataCondition = void 0;
|
|
const db_1 = require("./../../../../db");
|
|
const database_handler_1 = require("./../../../../db/database.handler");
|
|
const time_1 = require("./../../../../middlewares/time");
|
|
const getDataCondition = (limit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const getDataPasien = yield db_1.prismaDb1.$queryRaw `
|
|
select
|
|
registrasi.registrasi_id Registration_ID,
|
|
registrasi.tgl_masuk,
|
|
pasien.nama_pasien Patient_Name,
|
|
resources_patient.key_satu_sehat Patient_ID,
|
|
bagian.nama_bagian,
|
|
transaction_satu_sehat.key_satu_sehat Encounter_ID,
|
|
emr_detail.emr_detail_id,
|
|
emr_detail.objek_id,
|
|
emr_detail.input_time input_time_emr,
|
|
emr_detail.value,
|
|
icd.kode_diagnosa,
|
|
icd.nama_diagnosa
|
|
from
|
|
registrasi
|
|
inner join registrasi_detail on
|
|
registrasi.registrasi_id = registrasi_detail.registrasi_id
|
|
and registrasi_detail.status_batal is null
|
|
inner join bagian on
|
|
registrasi_detail.bagian_id = bagian.bagian_id
|
|
and bagian.referensi_bagian in (1, 313)
|
|
inner join pasien on
|
|
registrasi.pasien_id = pasien.pasien_id
|
|
inner join resources resources_patient on
|
|
pasien.pasien_id = resources_patient.key_simrs
|
|
and resources_patient.resources_type = 'Patient'
|
|
and resources_patient.key_satu_sehat <> '0'
|
|
inner join emr on
|
|
registrasi.registrasi_id = emr.registrasi_id
|
|
and emr.status_batal is null
|
|
and emr.form_id = 3
|
|
inner join emr_detail on
|
|
emr.emr_id = emr_detail.emr_id
|
|
and emr_detail.variabel = 'primary'
|
|
and emr_detail.objek_id in (42)
|
|
and emr_detail.status_batal is null
|
|
inner join transaction_satu_sehat on
|
|
registrasi.registrasi_id = transaction_satu_sehat.key_simrs
|
|
and transaction_satu_sehat.transaction_type = 'Encounter'
|
|
inner join icd on
|
|
emr_detail.value::int = icd.icd_id
|
|
left outer join transaction_satu_sehat transaction_satu_sehat_condition on
|
|
emr_detail.emr_detail_id = transaction_satu_sehat_condition.key_simrs
|
|
where
|
|
registrasi.status_batal is null
|
|
and registrasi.tgl_masuk::date = now()::date
|
|
and transaction_satu_sehat.key_satu_sehat is not null
|
|
and transaction_satu_sehat_condition.transaction_satu_sehat_id is null
|
|
limit ${parseInt(limit, 10)};
|
|
`;
|
|
return getDataPasien;
|
|
});
|
|
exports.getDataCondition = getDataCondition;
|
|
const updateInsertIdConditionRepo = (registrasi_id, payload, response, id, type, gagal = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const transaction_satu_sehatId = yield (0, database_handler_1.generateMaxDb1)("max_transaction_satu_sehat_idx", "transaction_satu_sehat_id");
|
|
let data = {
|
|
transaction_satu_sehat_id: transaction_satu_sehatId,
|
|
input_time: (0, time_1.dateNow)(),
|
|
input_user_id: 1,
|
|
payload: payload,
|
|
key_simrs: registrasi_id,
|
|
key_satu_sehat: id,
|
|
transaction_type: type,
|
|
response: response,
|
|
};
|
|
if (gagal === 1) {
|
|
data.status = 1;
|
|
}
|
|
const insertRujukan = yield db_1.prismaDb1.transaction_satu_sehat.create({
|
|
data,
|
|
});
|
|
});
|
|
exports.updateInsertIdConditionRepo = updateInsertIdConditionRepo;
|