datasus 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bpa.js +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datasus",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Library with helpers for datasus",
5
5
  "type": "module",
6
6
  "repository": "blikblum/datasus",
package/src/bpa.js CHANGED
@@ -21,7 +21,7 @@ const getHeader = (
21
21
  origin,
22
22
  destination,
23
23
  appInfo,
24
- { lineCount, sheetCount, controlAccumulator },
24
+ { lineCount, sheetCount, controlAccumulator }
25
25
  ) => {
26
26
  const controlCode = controlAccumulator % 1111
27
27
  const header = [
@@ -95,8 +95,8 @@ const getIndividualEntry = (procedure, competence, origin, index) => {
95
95
  padStartNumber(patient.race || 99, 2, '0').slice(0, 2),
96
96
  `${patient.ethnicity || ''}`.padEnd(4, ' ').slice(0, 4),
97
97
  padStartNumber(patient.nationality || 10, 3, '0').slice(0, 3),
98
- THREE_BLANKS, // service code
99
- THREE_BLANKS, // classification code
98
+ `${procedure.serviceCode || THREE_BLANKS}`.padStart(3, '0').slice(0, 3), // service code
99
+ `${procedure.classification || THREE_BLANKS}`.padStart(3, '0').slice(0, 3), // classification code
100
100
  EIGHT_BLANKS, // sequence code
101
101
  ' '.repeat(4), // area code
102
102
  ' '.repeat(14), // maintainer cnpj
@@ -109,9 +109,9 @@ const getIndividualEntry = (procedure, competence, origin, index) => {
109
109
  normalizeNumberText(patient.phone).padEnd(11, ' ').slice(0, 11),
110
110
  `${patient.email || ''}`.padEnd(40, ' ').slice(0, 40),
111
111
  padStartNumber(procedure.nationalId || TEN_BLANKS, 10, '0').slice(0, 10),
112
- procedure.cpf || ELEVEN_BLANKS,
112
+ patient.cpf || ELEVEN_BLANKS,
113
113
  ' ', // situação de rua
114
- procedure.cpf ? 'N' : 'S' // sem CPF
114
+ patient.cpf ? 'N' : 'S', // sem CPF
115
115
  ].join('')
116
116
 
117
117
  return entry
@@ -119,7 +119,7 @@ const getIndividualEntry = (procedure, competence, origin, index) => {
119
119
 
120
120
  export const generateBPA = (
121
121
  { procedures = [], origin = {}, destination = {}, competence = {}, appInfo = '' } = {},
122
- { consolidated = true, individual = true } = {},
122
+ { consolidated = true, individual = true } = {}
123
123
  ) => {
124
124
  const stats = { lineCount: 0, sheetCount: 0, controlAccumulator: 0 }
125
125