513 lines
17 KiB
JavaScript
513 lines
17 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.router = void 0;
|
|
const express_1 = require("express");
|
|
const resources_service_1 = require("./resources.service");
|
|
const express_validator_1 = require("express-validator");
|
|
exports.router = (0, express_1.Router)();
|
|
exports.router.get("/create-job-pasien/:limit", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const limit = parseInt(req.params.limit, 10);
|
|
const statusAntrean = yield (0, resources_service_1.createJobPasien)(limit);
|
|
if (statusAntrean) {
|
|
res.send({
|
|
response: statusAntrean.data,
|
|
metadata: {
|
|
message: statusAntrean.message,
|
|
code: statusAntrean.code,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
response: "",
|
|
metadata: {
|
|
message: "Gagal",
|
|
code: 201,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/create-job-practitioner/:limit", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const limit = parseInt(req.params.limit, 10);
|
|
const statusAntrean = yield (0, resources_service_1.createJobPractitioner)(limit);
|
|
if (statusAntrean) {
|
|
res.send({
|
|
response: statusAntrean.data,
|
|
metadata: {
|
|
message: statusAntrean.message,
|
|
code: statusAntrean.code,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
response: "",
|
|
metadata: {
|
|
message: "Gagal",
|
|
code: 201,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/push-job/:nama_endpoint/:limit", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const limit = parseInt(req.params.limit, 10);
|
|
const nama_endpoint = req.params.nama_endpoint;
|
|
const pushJob = yield (0, resources_service_1.pushJobService)(nama_endpoint, limit);
|
|
if (pushJob) {
|
|
res.send({
|
|
response: pushJob.data,
|
|
metadata: {
|
|
message: pushJob.message,
|
|
code: pushJob.code,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
response: "",
|
|
metadata: {
|
|
message: "Gagal",
|
|
code: 201,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/patient/nik/:nik", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const nik = req.params.nik;
|
|
const patientByNik = yield (0, resources_service_1.getPatientNikService)(nik);
|
|
if (patientByNik.status === 200) {
|
|
if (patientByNik.data.total === 0) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: patientByNik.data,
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
patient_ihs_id: patientByNik.data.entry[0].resource.id,
|
|
resources_type: patientByNik.data.entry[0].resource
|
|
.resourceType,
|
|
raw_response: patientByNik.data,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: patientByNik.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/patient/send-all/limit/:limit", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const limit = req.params.limit;
|
|
const patientByNik = yield (0, resources_service_1.getPatientSendAllService)(limit);
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Pengerjaan Selesai!",
|
|
},
|
|
response: patientByNik,
|
|
});
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/get-practitioner-nik/:nik", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const nik = req.params.nik;
|
|
const practitionerByNik = yield (0, resources_service_1.getPractitionerNikService)(nik);
|
|
if (practitionerByNik.status === 200) {
|
|
if (practitionerByNik.data.total === 0) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: practitionerByNik.data,
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
practitioner_ihs_id: practitionerByNik.data.entry[0].resource.id,
|
|
resources_type: practitionerByNik.data.entry[0].resource
|
|
.resourceType,
|
|
raw_response: practitionerByNik.data,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: practitionerByNik.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/practitioner/nik/:nik", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const nik = req.params.nik;
|
|
const practitionerByNik = yield (0, resources_service_1.getPractitionerNikService)(nik);
|
|
if (practitionerByNik.status === 200) {
|
|
if (practitionerByNik.data.total === 0) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: practitionerByNik.data,
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
practitioner_ihs_id: practitionerByNik.data.entry[0].resource.id,
|
|
resources_type: practitionerByNik.data.entry[0].resource
|
|
.resourceType,
|
|
raw_response: practitionerByNik.data,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: practitionerByNik.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/practitioner/send-all/limit/:limit", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
const limit = req.params.limit;
|
|
const practitionerByNik = yield (0, resources_service_1.getPractitionerSendAllService)(limit);
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Pengerjaan Selesai!",
|
|
},
|
|
response: practitionerByNik,
|
|
});
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.post("/organization", (0, express_validator_1.body)(["nama_bagian", "bagian_id"]).notEmpty().isString(), (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const data = req.body;
|
|
const createOrganization = yield (0, resources_service_1.createOrganizationService)(data);
|
|
if (createOrganization.status === 201) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
practitioner_ihs_id: createOrganization.id,
|
|
resources_type: createOrganization.resourceType,
|
|
raw_response: createOrganization.data,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Operation failed!",
|
|
},
|
|
response: createOrganization.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/organization/id/:organization_id", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const { organization_id } = req.params;
|
|
const getOrganization = yield (0, resources_service_1.getOrganizationIdService)(organization_id);
|
|
if (getOrganization.status === 200) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
raw_response: getOrganization.data,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Operation failed!",
|
|
},
|
|
response: getOrganization.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/organization/partOf/:organization_id?", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const { organization_id } = req.params;
|
|
const getOrganization = yield (0, resources_service_1.getOrganizationPartofService)(organization_id);
|
|
if (getOrganization.status === 200) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
raw_response: getOrganization.data,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Operation failed!",
|
|
},
|
|
response: getOrganization.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.post("/location", (0, express_validator_1.body)(["nama_bagian", "bagian_id", "organization_id"]).notEmpty().isString(), (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const data = req.body;
|
|
const createLocation = yield (0, resources_service_1.createLocationService)(data);
|
|
if (createLocation.status === 201) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
practitioner_ihs_id: createLocation.id,
|
|
resources_type: createLocation.resourceType,
|
|
raw_response: createLocation.data,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Operation failed!",
|
|
},
|
|
response: createLocation.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/location/id/:location_id", (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const { location_id } = req.params;
|
|
const getLocation = yield (0, resources_service_1.getLocationIdService)(location_id);
|
|
if (getLocation.status === 200) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: {
|
|
raw_response: getLocation.data,
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Operation failed!",
|
|
},
|
|
response: getLocation.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|
|
exports.router.get("/kfa/kfa-name/:kfa_name", (0, express_validator_1.param)('kfa_name').notEmpty().isString().isLength({ min: 5 }), (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const errors = (0, express_validator_1.validationResult)(req);
|
|
if (!errors.isEmpty()) {
|
|
res.status(201).send({
|
|
response: errors.array(),
|
|
metadata: {
|
|
code: 400,
|
|
message: "Validation error",
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
try {
|
|
const kfa_name = req.params.kfa_name;
|
|
const resourcesKfa = yield (0, resources_service_1.getResourcesKfaService)(kfa_name);
|
|
if (resourcesKfa.status === 200) {
|
|
if (resourcesKfa.data.total === 0) {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: resourcesKfa.data,
|
|
});
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 200,
|
|
msg: "Operation completed successfully!",
|
|
},
|
|
response: resourcesKfa.data,
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
res.status(200).json({
|
|
metadata: {
|
|
code: 201,
|
|
msg: "Data tidak tersedia!",
|
|
},
|
|
response: resourcesKfa.data,
|
|
});
|
|
}
|
|
}
|
|
catch (err) {
|
|
next(err);
|
|
}
|
|
}));
|