Skip to content

Commit

Permalink
Add endpoints for raw patient data retrieval (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
smailliwcs committed Mar 1, 2024
1 parent 3b0bd38 commit 18ac853
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.lantanagroup.link.db.SharedService;
import com.lantanagroup.link.db.TenantService;
import com.lantanagroup.link.db.model.AuditTypes;
import com.lantanagroup.link.db.model.PatientData;
import com.lantanagroup.link.model.TestResponse;
import com.lantanagroup.link.query.auth.HapiFhirAuthenticationInterceptor;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -146,4 +147,35 @@ public TestResponse test(@PathVariable String tenantId, @RequestParam(required =

return testResponse;
}

private Bundle getPatientDataBundle(List<PatientData> patientDataList) {
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.COLLECTION);
for (PatientData patientData : patientDataList) {
Bundle.BundleEntryComponent entry = bundle.addEntry();
entry.setResource((Resource) patientData.getResource());
}
return bundle;
}

@GetMapping("patient/{patientId}")
public Bundle getPatientData(@PathVariable String tenantId, @PathVariable String patientId) {
TenantService tenantService = TenantService.create(this.sharedService, tenantId);
if (tenantService == null) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Tenant not found");
}
return getPatientDataBundle(tenantService.findPatientData(patientId));
}

@GetMapping("patient/{patientId}/{reportId}")
public Bundle getReportPatientData(
@PathVariable String tenantId,
@PathVariable String patientId,
@PathVariable String reportId) {
TenantService tenantService = TenantService.create(this.sharedService, tenantId);
if (tenantService == null) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Tenant not found");
}
return getPatientDataBundle(tenantService.findPatientData(reportId, patientId));
}
}
55 changes: 55 additions & 0 deletions api/src/main/resources/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,61 @@ paths:
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
/api/{tenantId}/data/patient/{patientId}:
get:
tags:
- Data
summary: Returns a bundle of all data for the specified patient
parameters:
- name: tenantId
in: path
required: true
schema:
type: string
- name: patientId
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
/api/{tenantId}/data/patient/{patientId}/{reportId}:
get:
tags:
- Data
summary: Returns a bundle of all data for the specified patient and report
parameters:
- name: tenantId
in: path
required: true
schema:
type: string
- name: patientId
in: path
required: true
schema:
type: string
- name: reportId
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
/api/{tenantId}/bulk/$initiate-bulk-data:
post:
tags:
Expand Down

0 comments on commit 18ac853

Please sign in to comment.