onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
1 stars 1 forks source link

Change output to json #140

Closed Wambere closed 1 month ago

Wambere commented 4 months ago

Pass a flag to allow output to be in json format to allow easy consumption from the web

Example of current output

$ python3 main.py --csv_file csv/locations/locations_full.csv --resource_type locations --log_level info
INFO:root:Start time: 15:17:45
INFO:root:Starting csv import...
INFO:root:Reading csv file
INFO:root:Returning records from csv file
INFO:root:Processing locations
INFO:root:Building request payload
INFO:root:Posting request-----------------
INFO:root:Request type: GET
INFO:root:Url: https://fhir.labs.smartregister.org/fhir/Location/ba787982-b973-4bd5-854e-eacbe161e297
INFO:root:[200]: SUCCESS!
INFO:root:Posting request-----------------
INFO:root:Request type: GET
INFO:root:Url: https://fhir.labs.smartregister.org/fhir/Location/0a04f1c2-de2a-4869-bab2-763d017e5316
INFO:root:[200]: SUCCESS!
INFO:root:Posting request-----------------
INFO:root:Request type: POST
INFO:root:Url: https://fhir.labs.smartregister.org/fhir
INFO:root:Processing complete!
INFO:root:End time: 15:17:49
INFO:root:Total time: 4.256438 seconds
Wambere commented 4 months ago

@peterMuriuki are you able to provide an example of what the output above should look like?

peterMuriuki commented 4 months ago

yeah, will check and revert back.

peterMuriuki commented 4 months ago

My initial thoughts are

type Step = "ExtractTransform" | "Load"
type Status = "success" | "failure";

interface SuccessResponse {
  status: "success";
  step: Step;
  processed: Number;
  received: Number;
}

interface FailureResponse {
  status: "failure";
  step: Step;
  // https://www.hl7.org/fhir/R4/operationoutcome.html
  outcomes: OperationOutcome[]
}

We can jointly refine this, or completely change it.

Wambere commented 1 month ago

Closing this for now since we have the Print Final Response feature in place Once we have new specifications of what this output needs to look like we can create a new issue