update
This commit is contained in:
@ -28,5 +28,8 @@
|
||||
"database": "saude_local",
|
||||
"synchronize": true,
|
||||
"logging": true
|
||||
},
|
||||
"service": {
|
||||
"file": "http://localhost:9080/service-file/api/"
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,5 +27,8 @@
|
||||
"password": "y0BZQ6of14OULYnb",
|
||||
"database": "saude_production",
|
||||
"logging": false
|
||||
},
|
||||
"service": {
|
||||
"file": "https://tcelanatl.shiblysolution.id/api/f/"
|
||||
}
|
||||
}
|
||||
|
||||
148
src/controllers/card_print_queue.ts
Normal file
148
src/controllers/card_print_queue.ts
Normal file
@ -0,0 +1,148 @@
|
||||
import { Response, NextFunction } from "express";
|
||||
import { Request } from "express-jwt";
|
||||
import { ReturnHelper } from "../helpers/express/return";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import Joi from "joi";
|
||||
import { ILogObj, Logger } from "tslog";
|
||||
import { Language } from "../langs/lang";
|
||||
import { Paging, CardPrintQueue, CardPrintQueueStatus, CardPrintQueueType } from "entity";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { CardPrintQueueModel } from "../model/card_print_queue";
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({ name: '[CardPrintQueueController]', type: 'pretty' });
|
||||
|
||||
export class CardPrintQueueController {
|
||||
static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||
/*
|
||||
#swagger.tags = ['CardPrintQueue']
|
||||
#swagger.security = [{ "bearerAuth": [] }]
|
||||
#swagger.parameters['filter'] = { description: '', in: 'query', type: 'string' }
|
||||
#swagger.parameters['limit'] = { in: 'query', required: true, type: 'number' }
|
||||
#swagger.parameters['page'] = { in: 'query', required: true, type: 'number' }
|
||||
#swagger.parameters['with_deleted'] = { in: 'query', required: true, type: 'boolean' }
|
||||
#swagger.parameters['order_field'] = { in: 'query', required: true, type: 'string' }
|
||||
#swagger.parameters['order_direction'] = { in: 'query', required: true, schema: { '@enum': ['ASC', 'DESC'] } }
|
||||
*/
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
filter: Joi.string().allow("").optional().label("Filter"),
|
||||
page: Joi.number().required().min(1).label("Page"),
|
||||
limit: Joi.number().required().min(1).label("Limit"),
|
||||
with_deleted: Joi.bool().required().label("With Deleted"),
|
||||
order_field: Joi.string().required().label("Order Field"),
|
||||
order_direction: Joi.string().allow("asc", "desc").required().label("Order Direction"),
|
||||
});
|
||||
|
||||
let param: Paging = await schema.validateAsync(req.query);
|
||||
|
||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||
let filterAny = filter.any && filter.any !== "" ? filter.any : "";
|
||||
|
||||
let filterObj = { ...filter } as any;
|
||||
delete filterObj.any;
|
||||
filterObj = { ...filterObj };
|
||||
|
||||
var query = await CardPrintQueueModel.list(filterObj, filterAny);
|
||||
|
||||
const offset = (param.page - 1) * param.limit;
|
||||
let limit = param.limit;
|
||||
|
||||
const res_count = query;
|
||||
const res_list = query
|
||||
.orderBy("card_print_queue." + param.order_field, param.order_direction)
|
||||
.offset(offset)
|
||||
.limit(limit);
|
||||
|
||||
if (param.with_deleted) {
|
||||
res_count.withDeleted();
|
||||
res_list.withDeleted();
|
||||
}
|
||||
|
||||
const current_page = param.page;
|
||||
const total_count_data = await res_count.getCount();
|
||||
const list_data = await res_list.getMany();
|
||||
const count_data = CommonHelper.countObject(list_data);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async create(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||
/*
|
||||
#swagger.tags = ['CardPrintQueue']
|
||||
#swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}]
|
||||
#swagger.requestBody = {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
$ref: "#/components/schemas/card_print_queue"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
mrn: Joi.string().max(256).allow("").optional().label("MRN"),
|
||||
municipiu_code: Joi.string().max(256).allow("").optional().label("Municipiu Code"),
|
||||
posto_adm_code: Joi.string().max(256).allow("").optional().label("Posto Adm Code"),
|
||||
name: Joi.string().max(256).allow("").optional().label("Name"),
|
||||
address: Joi.string().allow("").optional().label("Address"),
|
||||
municipiu: Joi.string().max(256).allow("").optional().label("Municipiu"),
|
||||
posto_adm: Joi.string().max(256).allow("").optional().label("Posto Adm"),
|
||||
suco: Joi.string().max(256).allow("").optional().label("Suco"),
|
||||
aldeia: Joi.string().max(256).allow("").optional().label("Aldeia"),
|
||||
sexo: Joi.string().max(64).allow("").optional().label("Sexo"),
|
||||
birthdate: Joi.string().max(64).allow("").optional().label("Birthdate"),
|
||||
patient_id: Joi.string().uuid().allow("").optional().label("Patient ID"),
|
||||
facility_code: Joi.string().max(256).allow("").optional().label("Facility Code"),
|
||||
status: Joi.string().valid("pending", "in_progress", "completed", "failed", "blocked").optional().label("Status"),
|
||||
});
|
||||
|
||||
const param: any = await schema.validateAsync(req.body);
|
||||
|
||||
const data = new CardPrintQueue();
|
||||
data.mrn = param.mrn || null;
|
||||
data.municipiu_code = param.municipiu_code || null;
|
||||
data.posto_adm_code = param.posto_adm_code || null;
|
||||
data.name = param.name || null;
|
||||
data.address = param.address || null;
|
||||
data.municipiu = param.municipiu || null;
|
||||
data.posto_adm = param.posto_adm || null;
|
||||
data.suco = param.suco || null;
|
||||
data.aldeia = param.aldeia || null;
|
||||
data.sexo = param.sexo || null;
|
||||
data.birthdate = param.birthdate || null;
|
||||
data.patient_id = param.patient_id || null;
|
||||
data.facility_code = param.facility_code || null;
|
||||
data.status = param.status || CardPrintQueueStatus.PENDING;
|
||||
data.type = CardPrintQueueType.PROVISION; //test
|
||||
|
||||
const authHeader = req.headers.authorization;
|
||||
let rawToken = "";
|
||||
if (authHeader) {
|
||||
const parts = authHeader.split(" ");
|
||||
rawToken = parts.length > 1 ? parts[1] : parts[0];
|
||||
}
|
||||
data.token = rawToken ? Buffer.from(rawToken).toString("base64") : null;
|
||||
|
||||
data.created_by = req.auth?.data?.name || null;
|
||||
data.updated_by = req.auth?.data?.name || null;
|
||||
|
||||
await OrmHelper.DB.manager.save(data);
|
||||
|
||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_insert, data);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
return ReturnHelper.errorResponse(res, 500, 401, Language.lang.failed_insert, err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,6 +93,7 @@ import {
|
||||
RoomNumber,
|
||||
MainDisease,
|
||||
CardKeySet,
|
||||
CardPrintQueue,
|
||||
EmrRegistrationTreatment,
|
||||
TreatmentPlanSession,
|
||||
TreatmentPlan
|
||||
@ -211,6 +212,7 @@ export class OrmHelper {
|
||||
RoomNumber,
|
||||
MainDisease,
|
||||
CardKeySet,
|
||||
CardPrintQueue,
|
||||
EmrRegistrationTreatment,
|
||||
TreatmentPlanSession,
|
||||
TreatmentPlan
|
||||
|
||||
37
src/model/card_print_queue.ts
Normal file
37
src/model/card_print_queue.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import { CardPrintQueue } from "entity";
|
||||
|
||||
export class CardPrintQueueModel {
|
||||
static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
|
||||
const repo = OrmHelper.DB.getRepository(CardPrintQueue);
|
||||
let whereAttr = [];
|
||||
let whereVal: any = {};
|
||||
if (filterObj) {
|
||||
const filterResult = CommonHelper.handleQueryFilter(filterObj);
|
||||
whereAttr = [...whereAttr, ...filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
|
||||
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
|
||||
const filterResult = CommonHelper.handleFilter({
|
||||
filter: JSON.stringify({ any: filterAny }),
|
||||
col_any_eq: [],
|
||||
col_any_like: ["name", "mrn"],
|
||||
});
|
||||
|
||||
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
|
||||
whereAttr = [...whereAttr, filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
}
|
||||
|
||||
var query = repo.createQueryBuilder("card_print_queue");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@ -62,6 +62,7 @@ import { PlanningVerificatorController } from "../controllers/pharmacy/planning_
|
||||
import { ScheduleController } from "../controllers/schedule";
|
||||
import { FareTypeController } from "../controllers/faretype";
|
||||
import { CardTypeController } from "../controllers/card_type";
|
||||
import { CardPrintQueueController } from "../controllers/card_print_queue";
|
||||
import { PaymentMethodController } from "../controllers/payment-method";
|
||||
import { RegistrationFeeController } from "../controllers/registrationfee";
|
||||
import { RegionController } from "../controllers/region";
|
||||
@ -540,6 +541,9 @@ export class RoutePrivate {
|
||||
app.delete("/api/card-type/delete/:id/:hard", CardTypeController.delete);
|
||||
app.put("/api/card-type/restore/:id", CardTypeController.restore);
|
||||
|
||||
app.get("/api/card-print-queue/list", CardPrintQueueController.list);
|
||||
app.post("/api/card-print-queue/create", CardPrintQueueController.create);
|
||||
|
||||
app.get("/api/payment-method/list", PaymentMethodController.list);
|
||||
app.post("/api/payment-method/create", PaymentMethodController.create);
|
||||
app.get("/api/payment-method/detail/:id", PaymentMethodController.detail);
|
||||
|
||||
@ -510,6 +510,22 @@ const doc = {
|
||||
card_type: {
|
||||
$name: "Name (string)",
|
||||
},
|
||||
card_print_queue: {
|
||||
mrn: "123456",
|
||||
municipiu_code: "code",
|
||||
posto_adm_code: "code",
|
||||
name: "Patient Name",
|
||||
address: "Address text",
|
||||
municipiu: "Municipiu name",
|
||||
posto_adm: "Posto adm name",
|
||||
suco: "Suco name",
|
||||
aldeia: "Aldeia name",
|
||||
sexo: "M",
|
||||
birthdate: "2026-06-10",
|
||||
patient_id: "patient-uuid",
|
||||
facility_code: "0001",
|
||||
status: { "@enum": ["pending", "in_progress", "completed", "failed", "blocked"] },
|
||||
},
|
||||
card_key_set: {
|
||||
$key_set_id: "Key Set ID (string)",
|
||||
app_master_key: "App Master Key (string, optional)",
|
||||
|
||||
Reference in New Issue
Block a user