Skip to content

Commit

Permalink
fix(application-system): Stop sending doctor visit dates when none ar…
Browse files Browse the repository at this point in the history
…e entered (#16957)

* fix(application-system): Stop sending doctor visit dates when none are entered

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 421f147 commit bd78723
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,29 @@ const createDateTime = (date?: string | null, time?: string | null): Date => {
return new Date(year, month - 1, day, hours, minutes)
}

const createNullableDateTime = (
date?: string | null,
time?: string | null,
): Date | null => {
if (!date) {
return null
}

const [year, month, day] = date.split('-').map(Number)
let hours = time ? parseInt(time.slice(0, 2), 10) : 0
let minutes = time ? parseInt(time.slice(2, 4), 10) : 0

if (hours > 23 || hours < 0) {
hours = 0
}

if (minutes > 59 || minutes < 0) {
minutes = 0
}

return new Date(year, month - 1, day, hours, minutes)
}

const getAccident = (
answers: AccidentNotificationAnswers,
): MinarsidurAPIModelsAccidentReportsAccidentDTO => {
Expand Down Expand Up @@ -294,7 +317,7 @@ const getAccident = (
location: accidentLocation,
locationDescription: locationDescription ?? '',
symptoms: accidentDetails?.accidentSymptoms ?? '',
dateTimeOfDoctorVisit: createDateTime(
dateTimeOfDoctorVisit: createNullableDateTime(
accidentDetails?.dateOfDoctorVisit,
accidentDetails?.timeOfDoctorVisit,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,46 @@
}
}
},
"/v1/aidsandnutrition/{iso}/renew": {
"get": {
"tags": ["aidsandnutrition"],
"operationId": "RenewAidOrNutrition",
"parameters": [
{
"name": "iso",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
},
"404": {
"description": "Not Found"
},
"401": {
"description": "Unauthorized"
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/v1/application": {
"post": {
"tags": ["application"],
Expand Down Expand Up @@ -2416,13 +2456,7 @@
"components": {
"schemas": {
"Minarsidur.API.Models.AccidentReports.AccidentDTO": {
"required": [
"datetime",
"dateTimeOfDoctorVisit",
"description",
"symptoms",
"type"
],
"required": ["datetime", "description", "type"],
"type": "object",
"properties": {
"type": {
Expand All @@ -2448,7 +2482,8 @@
},
"dateTimeOfDoctorVisit": {
"type": "string",
"format": "date-time"
"format": "date-time",
"nullable": true
},
"fatal": {
"type": "boolean",
Expand Down Expand Up @@ -2611,9 +2646,6 @@
"employer": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AccidentReports.EmployerDTO"
},
"club": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AccidentReports.ClubDTO"
},
"attachments": {
"type": "array",
"items": {
Expand All @@ -2624,25 +2656,6 @@
},
"additionalProperties": false
},
"Minarsidur.API.Models.AccidentReports.ClubDTO": {
"required": ["accidentType", "name", "nationalId"],
"type": "object",
"properties": {
"nationalId": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
},
"accidentType": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"Minarsidur.API.Models.AccidentReports.EmployerDTO": {
"required": [
"companyName",
Expand Down Expand Up @@ -2912,10 +2925,18 @@
"expiring": {
"type": "boolean",
"nullable": true
},
"renewalStatus": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionDTO_RenewalStatusEnum"
}
},
"additionalProperties": false
},
"Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionDTO_RenewalStatusEnum": {
"enum": [0, 1, 2, 3],
"type": "integer",
"format": "int32"
},
"Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionRefundDTO": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -4134,6 +4155,10 @@
"type": "string",
"nullable": true
},
"canRegister": {
"type": "boolean",
"nullable": true
},
"waitlistRegistration": {
"type": "boolean",
"nullable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export {
MinarsidurAPIModelsAccidentReportsInjuredDTO,
MinarsidurAPIModelsAccidentReportsAccidentDTO,
MinarsidurAPIModelsAccidentReportsEmployerDTO,
MinarsidurAPIModelsAccidentReportsClubDTO,
MinarsidurAPIModelsAccidentReportsAccidentReportAttachmentDTO,
MinarsidurAPIModelsAccidentReportsAccidentDTOAccidentLocationEnum,
MinarsidurAPIModelsAccidentReportsAccidentDTOAccidentAtSailorWorkDTOAccidentAtSailorWorkShipLocationEnum,
Expand Down

0 comments on commit bd78723

Please sign in to comment.