Resolve merge conflicts in PatVisitController and add CORS headers to AuthFilter; update ValueSet API documentation

This commit is contained in:
mahdahar 2026-02-13 06:35:05 +07:00
parent 305e605a60
commit 5085b8270f
3 changed files with 339 additions and 38 deletions

View File

@ -18,7 +18,6 @@ class PatVisitController extends BaseController {
public function index() {
try {
<<<<<<< HEAD
$InternalPID = $this->request->getVar('InternalPID');
$PVID = $this->request->getVar('PVID');
@ -41,17 +40,6 @@ class PatVisitController extends BaseController {
return $this->respond(['status' => 'success', 'message' => 'data found', 'data' => $rows], 200);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
=======
$page = $this->request->getVar('page') ?? 1;
$perPage = $this->request->getVar('per_page') ?? 50;
$rows = $this->model->paginate($perPage, 'default', $page);
$total = $this->model->countAllResults(false);
if($rows == []) { $message = "data not found"; }
else { $message = "data found"; }
return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $rows, 'total' => $total, 'page' => $page, 'per_page' => $perPage ], 200);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong '.$e->getMessage());
>>>>>>> c38f9d2f914aa58a65dd6faf90b98f448cf4347d
}
}

View File

@ -11,6 +11,25 @@ use Firebase\JWT\Key;
class AuthFilter implements FilterInterface
{
protected function addCorsHeaders($response)
{
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
$allowedOrigins = [
'http://localhost:5173',
'http://localhost',
'https://clqms01.services-summit.my.id',
];
if (in_array($origin, $allowedOrigins)) {
$response->setHeader('Access-Control-Allow-Origin', $origin);
$response->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS');
$response->setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, Accept, Origin, Cache-Control, Pragma');
$response->setHeader('Access-Control-Allow-Credentials', 'true');
}
return $response;
}
public function before(RequestInterface $request, $arguments = null)
{
$key = getenv('JWT_SECRET');

View File

@ -819,35 +819,83 @@ components:
format: date-time
# ValueSets
ValueSetLibItem:
type: object
description: Library/system value set item from JSON files
properties:
value:
type: string
description: The value/key code
label:
type: string
description: The display label
ValueSetDef:
type: object
description: User-defined value set definition (from database)
properties:
id:
VSetID:
type: integer
VSetCode:
description: Primary key
SiteID:
type: integer
description: Site reference
VSName:
type: string
VSetName:
description: Value set name
VSDesc:
type: string
Description:
description: Value set description
CreateDate:
type: string
Category:
format: date-time
description: Creation timestamp
EndDate:
type: string
format: date-time
nullable: true
description: Soft delete timestamp
ItemCount:
type: integer
description: Number of items in this value set
ValueSetItem:
type: object
description: User-defined value set item (from database)
properties:
id:
VID:
type: integer
description: Primary key
SiteID:
type: integer
description: Site reference
VSetID:
type: integer
description: Reference to value set definition
VOrder:
type: integer
description: Display order
VValue:
type: string
VLabel:
description: The value code
VDesc:
type: string
VSeq:
type: integer
IsActive:
type: boolean
description: The display description/label
VCategory:
type: string
description: Category code
CreateDate:
type: string
format: date-time
description: Creation timestamp
EndDate:
type: string
format: date-time
nullable: true
description: Soft delete timestamp
VSName:
type: string
description: Value set name (from joined definition)
# Master Data
Location:
@ -2874,7 +2922,7 @@ paths:
get:
tags: [ValueSets]
summary: List lib value sets
description: List all library/system value sets from JSON files
description: List all library/system value sets from JSON files with item counts. Returns an object where keys are value set names and values are item counts.
security:
- bearerAuth: []
parameters:
@ -2882,7 +2930,7 @@ paths:
in: query
schema:
type: string
description: Optional search term to filter value sets
description: Optional search term to filter value set names
responses:
'200':
description: List of lib value sets with item counts
@ -2893,17 +2941,72 @@ paths:
properties:
status:
type: string
example: success
data:
type: object
additionalProperties:
type: integer
description: Number of items in each value set
example:
sex: 3
marital_status: 6
order_status: 6
/api/valueset/{key}:
get:
tags: [ValueSets]
summary: Get lib value set by key
description: Get a specific library/system value set from JSON files
description: |
Get a specific library/system value set from JSON files.
**Available value set keys:**
- `activity_result` - Activity Result
- `additive` - Additive
- `adt_event` - ADT Event
- `area_class` - Area Class
- `body_site` - Body Site
- `collection_method` - Collection Method
- `container_cap_color` - Container Cap Color
- `container_class` - Container Class
- `container_size` - Container Size
- `country` - Country
- `death_indicator` - Death Indicator
- `did_type` - DID Type
- `enable_disable` - Enable/Disable
- `entity_type` - Entity Type
- `ethnic` - Ethnic
- `fasting_status` - Fasting Status
- `formula_language` - Formula Language
- `generate_by` - Generate By
- `identifier_type` - Identifier Type
- `location_type` - Location Type
- `marital_status` - Marital Status
- `math_sign` - Math Sign
- `numeric_ref_type` - Numeric Reference Type
- `operation` - Operation (CRUD)
- `order_priority` - Order Priority
- `order_status` - Order Status
- `race` - Race (Ethnicity)
- `range_type` - Range Type
- `reference_type` - Reference Type
- `religion` - Religion
- `requested_entity` - Requested Entity
- `result_type` - Result Type
- `result_unit` - Result Unit
- `sex` - Sex
- `site_class` - Site Class
- `site_type` - Site Type
- `specimen_activity` - Specimen Activity
- `specimen_condition` - Specimen Condition
- `specimen_role` - Specimen Role
- `specimen_status` - Specimen Status
- `specimen_type` - Specimen Type
- `test_activity` - Test Activity
- `test_type` - Test Type
- `text_ref_type` - Text Reference Type
- `unit` - Unit
- `v_category` - VCategory
- `ws_type` - Workstation Type
security:
- bearerAuth: []
parameters:
@ -2912,7 +3015,8 @@ paths:
required: true
schema:
type: string
description: Value set key (e.g., marital_status, sex)
enum: [activity_result, additive, adt_event, area_class, body_site, collection_method, container_cap_color, container_class, container_size, country, death_indicator, did_type, enable_disable, entity_type, ethnic, fasting_status, formula_language, generate_by, identifier_type, location_type, marital_status, math_sign, numeric_ref_type, operation, order_priority, order_status, race, range_type, reference_type, religion, requested_entity, result_type, result_unit, sex, site_class, site_type, specimen_activity, specimen_condition, specimen_role, specimen_status, specimen_type, test_activity, test_type, text_ref_type, unit, v_category, ws_type]
description: Value set key name
responses:
'200':
description: Lib value set details
@ -2926,23 +3030,29 @@ paths:
data:
type: array
items:
type: object
properties:
value:
type: string
label:
type: string
$ref: '#/components/schemas/ValueSetLibItem'
/api/valueset/refresh:
post:
tags: [ValueSets]
summary: Refresh lib ValueSet cache
description: Clear and reload the library/system ValueSet cache from JSON files
description: Clear and reload the library/system ValueSet cache from JSON files. Call this after modifying JSON files in app/Libraries/Data/.
security:
- bearerAuth: []
responses:
'200':
description: Lib ValueSet cache refreshed
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: success
message:
type: string
example: Cache cleared
/api/valueset/user/items:
get:
@ -2957,6 +3067,16 @@ paths:
schema:
type: integer
description: Filter by ValueSet ID
- name: search
in: query
schema:
type: string
description: Search term to filter by VValue, VDesc, or VSName
- name: param
in: query
schema:
type: string
description: Alternative search parameter (alias for search)
responses:
'200':
description: List of user value set items
@ -2965,6 +3085,8 @@ paths:
schema:
type: object
properties:
status:
type: string
data:
type: array
items:
@ -2981,10 +3103,39 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ValueSetItem'
type: object
required:
- VSetID
properties:
SiteID:
type: integer
description: Site reference (default 1)
VSetID:
type: integer
description: Reference to value set definition (required)
VOrder:
type: integer
description: Display order (default 0)
VValue:
type: string
description: The value code
VDesc:
type: string
description: The display description/label
responses:
'201':
description: User value set item created
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
data:
$ref: '#/components/schemas/ValueSetItem'
/api/valueset/user/items/{id}:
get:
@ -3002,6 +3153,15 @@ paths:
responses:
'200':
description: User value set item details
content:
application/json:
schema:
type: object
properties:
status:
type: string
data:
$ref: '#/components/schemas/ValueSetItem'
put:
tags: [ValueSets]
@ -3020,10 +3180,37 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ValueSetItem'
type: object
properties:
SiteID:
type: integer
description: Site reference
VSetID:
type: integer
description: Reference to value set definition
VOrder:
type: integer
description: Display order
VValue:
type: string
description: The value code
VDesc:
type: string
description: The display description/label
responses:
'200':
description: User value set item updated
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
data:
$ref: '#/components/schemas/ValueSetItem'
delete:
tags: [ValueSets]
@ -3040,6 +3227,15 @@ paths:
responses:
'200':
description: User value set item deleted
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
/api/valueset/user/def:
get:
@ -3048,9 +3244,47 @@ paths:
description: List value set definitions from database (user-defined)
security:
- bearerAuth: []
parameters:
- name: search
in: query
schema:
type: string
description: Optional search term to filter definitions
- name: page
in: query
schema:
type: integer
default: 1
description: Page number for pagination
- name: limit
in: query
schema:
type: integer
default: 100
description: Number of items per page
responses:
'200':
description: List of user value set definitions
content:
application/json:
schema:
type: object
properties:
status:
type: string
data:
type: array
items:
$ref: '#/components/schemas/ValueSetDef'
meta:
type: object
properties:
total:
type: integer
page:
type: integer
limit:
type: integer
post:
tags: [ValueSets]
@ -3063,10 +3297,31 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ValueSetDef'
type: object
properties:
SiteID:
type: integer
description: Site reference (default 1)
VSName:
type: string
description: Value set name
VSDesc:
type: string
description: Value set description
responses:
'201':
description: User value set definition created
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
data:
$ref: '#/components/schemas/ValueSetDef'
/api/valueset/user/def/{id}:
get:
@ -3084,6 +3339,15 @@ paths:
responses:
'200':
description: User value set definition details
content:
application/json:
schema:
type: object
properties:
status:
type: string
data:
$ref: '#/components/schemas/ValueSetDef'
put:
tags: [ValueSets]
@ -3102,10 +3366,31 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ValueSetDef'
type: object
properties:
SiteID:
type: integer
description: Site reference
VSName:
type: string
description: Value set name
VSDesc:
type: string
description: Value set description
responses:
'200':
description: User value set definition updated
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
data:
$ref: '#/components/schemas/ValueSetDef'
delete:
tags: [ValueSets]
@ -3122,6 +3407,15 @@ paths:
responses:
'200':
description: User value set definition deleted
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
# ========================================
# Master Data Routes