{
"statusCode": 200,
"results": {
"seq": "0002982975",
"hn": "031416",
"pid": "2341400019081",
"id_type": "1",
"title": "น.ส.",
"fname": "จรงค์ทรัพย์",
"lname": "พันธุ์วรรณ",
"marriage": "1",
"dob": "1993-07-20",
"sex": "2",
"nation": "099",
"hcode": "10953",
"hospital_name": "โรงพยาบาลม่วงสามสิบ",
"visit_date_time": "2023-10-08T20:25:39.000Z",
"vaccine": [
{
"code": "106",
"lot_number": "233L7002B",
"dose_quantity": "1",
"manufacturer": "",
"expiration_date": "2024-07-31",
"occurence_time": "2022-06-27 13:00",
"site_code": "",
"route_code": "IM",
"license_no": "ว.20812",
"name": "นพ.ประจักษ์ สีลาชาติ ",
"note": ""
}
]
},
"results_claim": {
"error": "unauthorized",
"message": "JWT Expire",
"message_th": "ยืนยันตัวตนไม่สำเร็จ",
"status": 401
}
}
##########################################################################
SELECT distinct
o.visit_id as seq
,o.hn
,p.cid as pid
,'1' as id_type
,CASE
WHEN p.PRENAME not in('') THEN TRIM(p.PRENAME)
WHEN TIMESTAMPDIFF(year,p.BIRTHDATE,NOW()) < '15' AND p.sex='1' THEN 'ด.ช.'
WHEN TIMESTAMPDIFF(year,p.BIRTHDATE,NOW()) >= '15' AND p.sex='1' THEN 'นาย'
WHEN TIMESTAMPDIFF(year,p.BIRTHDATE,NOW()) < '15' AND p.sex='2' THEN 'ด.ญ.'
WHEN TIMESTAMPDIFF(year,p.BIRTHDATE,NOW()) >= '15' AND p.sex='2' AND p.MARRIAGE ='1' THEN 'น.ส.'
ELSE 'นาง'
END as title
,trim(p.fname) as fname
,trim(p.lname) as lname
,oc.oc_name as nameoccptn
,CASE
WHEN p.marriage = '1' THEN '1'
WHEN p.marriage = '2' THEN '2'
WHEN p.marriage = '3' THEN '3'
WHEN p.marriage = '4' THEN '6'
ELSE '9'
END AS marriage
,p.birthdate as dob
,p.sex
,timestampdiff(year,p.birthdate,o.reg_datetime) as age
,concat('0',n.natn_id) as nation
,h.hospcode as hcode
,concat('โรงพยาบาล',h.hospname) as hospital_name
,DATE_FORMAT(o.reg_datetime,'%Y-%m-%dT%T.000Z') as visit_date_time
,'' as code_status
,d.drug_id
,d.drug_name
FROM address_hosp h, opd_visits o
INNER JOIN cid_hn c ON o.HN=c.HN AND o.IS_CANCEL=0
INNER JOIN population p ON p.CID=c.CID
LEFT JOIN opd_diagnosis dx on dx.visit_id= o.visit_id AND dx.is_cancel=0
LEFT JOIN icd10new i on i.icd10=dx.icd10
INNER JOIN prescriptions pr ON pr.visit_id = o.visit_id and pr.IS_CANCEL = 0
LEFT JOIN drugs d ON d.drug_id = pr.drug_id
LEFT JOIN occupation_new oc ON oc.oc_id = p.oc_id
LEFT JOIN nations n ON n.natn_id = p.natn_id
LEFT JOIN ipd_reg ipd ON ipd.visit_id = o.visit_id AND ipd.is_cancel = 0
where o.visit_id = ${info.vn}
#o.reg_datetime BETWEEN CURDATE()-2 AND NOW()
AND ipd.adm_id is null
AND TIMESTAMPDIFF(year,p.birthdate,o.reg_datetime) >= 25
AND d.drug_id = '1850'
ตามด้วย
SELECT DISTINCT
CASE
WHEN cv.dose_time = '1' THEN '106'
WHEN cv.dose_time = '2' THEN '107'
WHEN cv.dose_time = '3' THEN '108'
ELSE '109'
END as 'code'
,max(od.lot_no) as lot_number
,'1' as dose_quantity
,'' as manufacturer
,DATE_FORMAT(max(od.exp_date),'%Y-%m-%d') as expiration_date
,DATE_FORMAT(cv.vac_datetime,'%Y-%m-%d %H:%s') as occurence_time
,'' as site_code
,'IM' as route_code
,'ว.20812' as license_no
,'นพ.ประจักษ์ สีลาชาติ ' as 'name'
,'' as note
FROM opd_visits o
INNER JOIN cid_hn c ON o.HN=c.HN AND o.IS_CANCEL=0
INNER JOIN population p ON p.CID=c.CID
LEFT JOIN cid_vaccinate_v2 cv ON o.visit_id = o.visit_id
LEFT JOIN vaccinecovid vc ON vc.vaccine_id = cv.vaccine_id
LEFT JOIN order_details od ON od.ivt_id = vc.drug_id
#LEFT JOIN invoices v ON v.ivs_id = od.ivs_id
where o.visit_id = '0002982975'
#o.visit_id = ${info.vn}
AND vc.drug_id = '1850'
LIMIT 1
ไม่มีความคิดเห็น:
แสดงความคิดเห็น