Projet

Général

Profil

0001-toulouse-maelis-FSL-removed-from-Parsifal-project-71.patch

Nicolas Roche, 17 novembre 2022 08:47

Télécharger (27,8 ko)

Voir les différences:

Subject: [PATCH] toulouse-maelis: FSL removed from Parsifal project (#71387)

 passerelle/contrib/toulouse_maelis/models.py  |  46 --------
 passerelle/contrib/toulouse_maelis/schemas.py | 100 ------------------
 tests/data/toulouse_maelis/FamilyService.wsdl |   3 +-
 .../toulouse_maelis/Q_update_child_fsl.xml    |  38 -------
 tests/data/toulouse_maelis/R_read_family.xml  |  23 ----
 .../toulouse_maelis/R_read_family_relax.xml   |  23 ----
 .../R_read_family_reordered.xml               |  23 ----
 .../toulouse_maelis/R_update_child_fsl.xml    |   5 -
 tests/test_toulouse_maelis.py                 |  97 +----------------
 9 files changed, 2 insertions(+), 356 deletions(-)
 delete mode 100644 tests/data/toulouse_maelis/Q_update_child_fsl.xml
 delete mode 100644 tests/data/toulouse_maelis/R_update_child_fsl.xml
passerelle/contrib/toulouse_maelis/models.py
175 175
        return data
176 176

  
177 177
    def add_text_value_to_child(self, data):
178 178
        self.add_text_value('Sex', data, ['sexe'])
179 179
        self.add_text_value('DietCode', data, ['dietcode'])
180 180
        self.add_text_value('PAI', data, ['paiInfoBean', 'code'])
181 181
        for person in data['authorizedPersonList']:
182 182
            self.add_text_value_to_child_person(person)
183

  
184
        # convert O/N string into boolean
185
        if data.get('fsl'):
186
            for key in (
187
                'allergieAlimentaire',
188
                'allergieRespiratoire',
189
                'allergieAutre',
190
                'allergieMedicament',
191
                'asthme',
192
                'flPAI',
193
                'flImage',
194
            ):
195
                data['fsl'][key] = bool(data['fsl'][key] == 'O')
196 183
        return data
197 184

  
198 185
    def add_text_value_to_person(self, data):
199 186
        self.add_text_value('Civility', data, ['civility'])
200 187
        self.add_text_value('Quality', data, ['quality'])
201 188
        self.add_text_value('Sex', data, ['sexe'])
202 189

  
203 190
    def add_text_value_to_rl(self, data):
......
1091 1078
        # use None to empty date passed as an empty string by date filter
1092 1079
        for key in 'dateDeb', 'dateFin':
1093 1080
            if post_data[key] == '':
1094 1081
                post_data[key] = None
1095 1082

  
1096 1083
        self.call('Family', 'updateChildPAI', personNumber=child_id, **post_data)
1097 1084
        return {'data': 'ok'}
1098 1085

  
1099
    @endpoint(
1100
        display_category='Famille',
1101
        description="Créer ou mettre à jour la fiche sanitaire d'un enfant",
1102
        name='update-child-fsl',
1103
        perm='can_access',
1104
        parameters={
1105
            'NameID': {'description': 'Publik NameID'},
1106
            'child_id': {'description': "Numéro de l'enfant"},
1107
        },
1108
        post={'request_body': {'schema': {'application/json': schemas.FSL_SCHEMA}}},
1109
    )
1110
    def update_child_fsl(self, request, NameID, child_id, post_data):
1111
        self.get_link(NameID)
1112

  
1113
        # maelis expect strings O/N
1114
        for key in (
1115
            'allergieAlimentaire',
1116
            'allergieRespiratoire',
1117
            'allergieAutre',
1118
            'allergieMedicament',
1119
            'asthme',
1120
            'flPAI',
1121
            'flImage',
1122
        ):
1123
            post_data[key] = 'O' if post_data.get(key) else 'N'
1124

  
1125
        # use None to empty optional date passed as an empty string by date filter
1126
        if post_data.get('dtcPrap1') == '':
1127
            post_data['dtcPrap1'] = None
1128

  
1129
        self.call('Family', 'createOrUpdateFSL', arg0=child_id, arg1=post_data)
1130
        return {'data': 'ok'}
1131

  
1132 1086
    @endpoint(
1133 1087
        display_category='Famille',
1134 1088
        description="Créer ou mettre à jour les données médicales d'un enfant",
1135 1089
        name='update-child-medical-record',
1136 1090
        perm='can_access',
1137 1091
        parameters={
1138 1092
            'NameID': {'description': 'Publik NameID'},
1139 1093
            'child_id': {'description': "Numéro de l'enfant"},
passerelle/contrib/toulouse_maelis/schemas.py
241 241
        },
242 242
        'place': {
243 243
            'description': 'Lieu de naissance',
244 244
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
245 245
        },
246 246
    },
247 247
}
248 248

  
249
FSL_SCHEMA = {
250
    '$schema': 'http://json-schema.org/draft-04/schema#',
251
    'title': 'FSL',
252
    'description': 'Informations sur la fiche sanitaire',
253
    'type': 'object',
254
    'properties': {
255
        'dateDeb': {
256
            'description': 'Date de début',
257
            'type': 'string',
258
            'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
259
        },
260
        'dateFin': {
261
            'description': 'Date de fin',
262
            'type': 'string',
263
            'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
264
        },
265
        'allergieAlimentaire': {
266
            'description': 'Allergie alimentaire',
267
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
268
        },
269
        'allergieRespiratoire': {
270
            'description': 'Allergie respiratoire',
271
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
272
        },
273
        'allergieAutre': {
274
            'description': 'Allergie autre',
275
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
276
        },
277
        'allergieMedicament': {
278
            'description': 'Allergie médicament',
279
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
280
        },
281
        'asthme': {
282
            'description': 'Asthmatique',
283
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
284
        },
285
        'flPAI': {
286
            'description': 'PAI',
287
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
288
        },
289
        'flImage': {
290
            'description': 'Autorisation photo',
291
            'oneOf': BOOLEAN_TYPES + [{'type': 'null'}],
292
        },
293
        'dtcPrap1': {
294
            'description': 'Date du dernier rappel DT Polio',
295
            'type': 'string',
296
            'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$',
297
        },
298
        'obsMed1': {
299
            'description': 'Observation médecin 1',
300
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
301
        },
302
        'obsMed2': {
303
            'description': 'Observation médecin 2',
304
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
305
        },
306
        'obsMed3': {
307
            'description': 'Observation médecin 3',
308
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
309
        },
310
        'obsDir1': {
311
            'description': 'Observation directeur 1',
312
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
313
        },
314
        'obsDir2': {
315
            'description': 'Observation directeur 2',
316
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
317
        },
318
        'obsDir3': {
319
            'description': 'Observation directeur 3',
320
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
321
        },
322
        'obsAssist1': {
323
            'description': 'Observation assistant sanitaire 1',
324
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
325
        },
326
        'obsAssist2': {
327
            'description': 'Observation assistant sanitaire 2',
328
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
329
        },
330
        'obsAssist3': {
331
            'description': 'Observation assistant sanitaire 3',
332
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
333
        },
334
        'cons1Med': {
335
            'description': 'Conseil médecin 1',
336
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
337
        },
338
        'cons2Med': {
339
            'description': 'Conseil médecin 2',
340
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
341
        },
342
    },
343
    'additionalProperties': False,
344
}
345

  
346 249
DOCTORADDRESS_SCHEMA = {
347 250
    '$schema': 'http://json-schema.org/draft-04/schema#',
348 251
    'title': 'Doctor address',
349 252
    'description': "Informations sur l'adresse du docteur",
350 253
    'type': 'object',
351 254
    'properties': {
352 255
        'street1': {
353 256
            'description': 'Libellé de la voie',
......
484 387
        'bPhoto': {
485 388
            'description': 'Autorisation photo',
486 389
            'oneOf': BOOLEAN_TYPES,
487 390
        },
488 391
        'bLeaveAlone': {
489 392
            'description': 'Autorisation à partir seul',
490 393
            'oneOf': BOOLEAN_TYPES,
491 394
        },
492
        'fsl': {'oneOf': [FSL_SCHEMA, {'type': 'null'}]},
493 395
        'medicalRecord': {'oneOf': [MEDICALRECORD_SCHEMA, {'type': 'null'}]},
494 396
        'paiInfoBean': {'oneOf': [PAIINFO_SCHEMA, {'type': 'null'}]},
495 397
    },
496 398
    'additionalProperties': False,
497 399
}
498 400
CHILD_SCHEMA['properties'].update(ID_PROPERTIES)
499 401

  
500 402
CONTACTLIGHT_SCHEMA = {
......
628 530
    },
629 531
    'unflatten': True,
630 532
    'additionalProperties': False,
631 533
}
632 534

  
633 535
CREATE_FAMILY_SCHEMA = copy.deepcopy(UPDATE_FAMILY_SCHEMA)
634 536
CREATE_FAMILY_SCHEMA['required'] = ['rl1', 'categorie', 'situation']
635 537
create_family_child_schema = CREATE_FAMILY_SCHEMA['properties']['childList']['oneOf'][0]['items']
636
del create_family_child_schema['properties']['fsl']
637 538
del create_family_child_schema['properties']['bPhoto']
638 539
del create_family_child_schema['properties']['bLeaveAlone']
639 540
del create_family_child_schema['properties']['paiInfoBean']
640 541

  
641 542
CREATE_RL1_SCHEMA = copy.deepcopy(CREATE_FAMILY_SCHEMA)
642 543
del CREATE_RL1_SCHEMA['properties']['rl2']
643 544
del CREATE_RL1_SCHEMA['properties']['authorizedPersonList']
644 545
del CREATE_RL1_SCHEMA['properties']['emergencyPersonList']
......
660 561
del CREATE_RL2_SCHEMA['properties']['profession']
661 562
del CREATE_RL2_SCHEMA['properties']['CAFInfo']
662 563

  
663 564
UPDATE_RL2_SCHEMA = copy.deepcopy(UPDATE_RL1_SCHEMA)
664 565

  
665 566
CREATE_CHILD_SCHEMA = copy.deepcopy(CHILD_SCHEMA)
666 567
CREATE_CHILD_SCHEMA['unflatten'] = True
667 568
del CREATE_CHILD_SCHEMA['properties']['dietcode']
668
del CREATE_CHILD_SCHEMA['properties']['fsl']
669 569
del CREATE_CHILD_SCHEMA['properties']['medicalRecord']
670 570
del CREATE_CHILD_SCHEMA['properties']['paiInfoBean']
671 571

  
672 572
UPDATE_CHILD_SCHEMA = copy.deepcopy(CREATE_CHILD_SCHEMA)
673 573

  
674 574
UPDATE_COORDINATE_SCHEMA = {
675 575
    '$schema': 'http://json-schema.org/draft-04/schema#',
676 576
    'title': 'Update coordinate',
tests/data/toulouse_maelis/FamilyService.wsdl
797 797
  <xs:complexType name="childInfoBean">
798 798
    <xs:sequence>
799 799
      <xs:element minOccurs="0" name="num" type="xs:string"/>
800 800
      <xs:element name="lastname" type="xs:string"/>
801 801
      <xs:element name="firstname" type="xs:string"/>
802 802
      <xs:element name="sexe" type="xs:string"/>
803 803
      <xs:element name="birth" type="tns:birthInfoBean"/>
804 804
      <xs:element minOccurs="0" name="dietcode" type="xs:string"/>
805
      <xs:element minOccurs="0" name="fsl" type="ns1:fslBean"/>
806 805
      <xs:element minOccurs="0" name="bPhoto" type="xs:boolean"/>
807 806
      <xs:element minOccurs="0" name="bLeaveAlone" type="xs:boolean"/>
808 807
      <xs:element maxOccurs="unbounded" minOccurs="0" name="authorizedPersonList" nillable="true" type="tns:relatedPersonBean"/>
809 808
      <xs:element maxOccurs="unbounded" minOccurs="0" name="indicatorList" nillable="true" type="tns:indicatorBean"/>
810 809
      <xs:element minOccurs="0" name="medicalRecord" type="tns:medicalRecordBean"/>
811 810
      <xs:element maxOccurs="unbounded" minOccurs="0" name="subscribeSchoolList" nillable="true" type="tns:subscribeSchoolBean"/>
812 811
      <xs:element minOccurs="0" name="mother" type="tns:personBean"/>
813 812
      <xs:element minOccurs="0" name="father" type="tns:personBean"/>
......
2719 2718
      </wsdl:fault>
2720 2719
    </wsdl:operation>
2721 2720
  </wsdl:binding>
2722 2721
  <wsdl:service name="FamilyService">
2723 2722
    <wsdl:port binding="tns:FamilyServiceSoapBinding" name="FamilyServiceImplPort">
2724 2723
      <soap:address location="https://demo-toulouse.sigec.fr/maelisws-toulouse/services/FamilyService"/>
2725 2724
    </wsdl:port>
2726 2725
  </wsdl:service>
2727
</wsdl:definitions>
2726
</wsdl:definitions>
tests/data/toulouse_maelis/Q_update_child_fsl.xml
1
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
2
  <soap-env:Header>
3
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
4
      <wsse:UsernameToken>
5
        <wsse:Username>maelis-webservice</wsse:Username>
6
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">maelis-password</wsse:Password>
7
      </wsse:UsernameToken>
8
    </wsse:Security>
9
  </soap-env:Header>
10
  <soap-env:Body>
11
    <ns0:createOrUpdateFSL xmlns:ns0="family.ws.maelis.sigec.com">
12
      <arg0>613878</arg0>
13
      <arg1>
14
        <dateDeb>2022-01-01</dateDeb>
15
        <dateFin>2022-12-31</dateFin>
16
        <allergieAlimentaire>O</allergieAlimentaire>
17
        <allergieRespiratoire>O</allergieRespiratoire>
18
        <allergieAutre>O</allergieAutre>
19
        <allergieMedicament>O</allergieMedicament>
20
        <asthme>N</asthme>
21
        <flPAI>N</flPAI>
22
        <flImage>N</flImage>
23
        <dtcPrap1>2022-02-22</dtcPrap1>
24
        <obsMed1>some obsMed1 text</obsMed1>
25
        <obsMed2>some obsMed2 text</obsMed2>
26
        <obsMed3>some obsMed3 text</obsMed3>
27
        <obsDir1>some obsDir1 text</obsDir1>
28
        <obsDir2>some obsDir2 text</obsDir2>
29
        <obsDir3>some obsDir3 text</obsDir3>
30
        <obsAssist1>some obsAssist1 text</obsAssist1>
31
        <obsAssist2>some obsAssist2 text</obsAssist2>
32
        <obsAssist3>some obsAssist3 text</obsAssist3>
33
        <cons1Med>some cons1Med text</cons1Med>
34
        <cons2Med>some cons2Med text</cons2Med>
35
      </arg1>
36
    </ns0:createOrUpdateFSL>
37
  </soap-env:Body>
38
</soap-env:Envelope>
tests/data/toulouse_maelis/R_read_family.xml
92 92
          <num>613880</num>
93 93
          <lastname>DOE</lastname>
94 94
          <firstname>JANNIS</firstname>
95 95
          <sexe>F</sexe>
96 96
          <birth>
97 97
            <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
98 98
          </birth>
99 99
          <dietcode>RSV</dietcode>
100
          <fsl>
101
            <dateDeb>2022-01-01T00:00:00+01:00</dateDeb>
102
            <dateFin>2022-12-31T00:00:00+01:00</dateFin>
103
            <allergieAlimentaire>O</allergieAlimentaire>
104
            <allergieRespiratoire>O</allergieRespiratoire>
105
            <allergieAutre>O</allergieAutre>
106
            <allergieMedicament>O</allergieMedicament>
107
            <asthme>N</asthme>
108
            <flPAI>N</flPAI>
109
            <flImage>N</flImage>
110
            <dtcPrap1>2022-02-22T00:00:00+01:00</dtcPrap1>
111
            <obsMed1>some obsMed1 text</obsMed1>
112
            <obsMed2>some obsMed2 text</obsMed2>
113
            <obsMed3>some obsMed3 text</obsMed3>
114
            <obsDir1>some obsDir1 text</obsDir1>
115
            <obsDir2>some obsDir2 text</obsDir2>
116
            <obsDir3>some obsDir3 text</obsDir3>
117
            <obsAssist1>some obsAssist1 text</obsAssist1>
118
            <obsAssist2>some obsAssist2 text</obsAssist2>
119
            <obsAssist3>some obsAssist3 text</obsAssist3>
120
            <cons1Med>some cons1Med text</cons1Med>
121
            <cons2Med>some cons2Med text</cons2Med>
122
          </fsl>
123 100
          <bPhoto>true</bPhoto>
124 101
          <bLeaveAlone>false</bLeaveAlone>
125 102
          <authorizedPersonList>
126 103
            <personInfo>
127 104
              <num>614719</num>
128 105
              <lastname>BENT</lastname>
129 106
              <firstname>AMEL</firstname>
130 107
              <dateBirth>1985-06-21T00:00:00+02:00</dateBirth>
tests/data/toulouse_maelis/R_read_family_relax.xml
91 91
          <num>613880</num>
92 92
          <lastname>DOE</lastname>
93 93
          <firstname>JANNIS</firstname>
94 94
          <sexe>F</sexe>
95 95
          <birth>
96 96
            <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
97 97
          </birth>
98 98
          <dietcode>RSV</dietcode>
99
          <fsl>
100
            <dateDeb>2022-01-01T00:00:00+01:00</dateDeb>
101
            <dateFin>2022-12-31T00:00:00+01:00</dateFin>
102
            <allergieAlimentaire>O</allergieAlimentaire>
103
            <allergieRespiratoire>O</allergieRespiratoire>
104
            <allergieAutre>O</allergieAutre>
105
            <allergieMedicament>O</allergieMedicament>
106
            <asthme>N</asthme>
107
            <flPAI>N</flPAI>
108
            <flImage>N</flImage>
109
            <dtcPrap1>2022-02-22T00:00:00+01:00</dtcPrap1>
110
            <obsMed1>some obsMed1 text</obsMed1>
111
            <obsMed2>some obsMed2 text</obsMed2>
112
            <obsMed3>some obsMed3 text</obsMed3>
113
            <obsDir1>some obsDir1 text</obsDir1>
114
            <obsDir2>some obsDir2 text</obsDir2>
115
            <obsDir3>some obsDir3 text</obsDir3>
116
            <obsAssist1>some obsAssist1 text</obsAssist1>
117
            <obsAssist2>some obsAssist2 text</obsAssist2>
118
            <obsAssist3>some obsAssist3 text</obsAssist3>
119
            <cons1Med>some cons1Med text</cons1Med>
120
            <cons2Med>some cons2Med text</cons2Med>
121
          </fsl>
122 99
          <bPhoto>true</bPhoto>
123 100
          <bLeaveAlone>false</bLeaveAlone>
124 101
          <authorizedPersonList>
125 102
            <personInfo>
126 103
              <num>614719</num>
127 104
              <lastname>BENT</lastname>
128 105
              <firstname>AMEL</firstname>
129 106
              <dateBirth>1985-06-21T00:00:00+02:00</dateBirth>
tests/data/toulouse_maelis/R_read_family_reordered.xml
92 92
          <num>613880</num>
93 93
          <lastname>DOE</lastname>
94 94
          <firstname>JANNIS</firstname>
95 95
          <sexe>F</sexe>
96 96
          <birth>
97 97
            <dateBirth>1943-01-19T00:00:00+01:00</dateBirth>
98 98
          </birth>
99 99
          <dietcode>RSV</dietcode>
100
          <fsl>
101
            <dateDeb>2022-01-01T00:00:00+01:00</dateDeb>
102
            <dateFin>2022-12-31T00:00:00+01:00</dateFin>
103
            <allergieAlimentaire>O</allergieAlimentaire>
104
            <allergieRespiratoire>O</allergieRespiratoire>
105
            <allergieAutre>O</allergieAutre>
106
            <allergieMedicament>O</allergieMedicament>
107
            <asthme>N</asthme>
108
            <flPAI>N</flPAI>
109
            <flImage>N</flImage>
110
            <dtcPrap1>2022-02-22T00:00:00+01:00</dtcPrap1>
111
            <obsMed1>some obsMed1 text</obsMed1>
112
            <obsMed2>some obsMed2 text</obsMed2>
113
            <obsMed3>some obsMed3 text</obsMed3>
114
            <obsDir1>some obsDir1 text</obsDir1>
115
            <obsDir2>some obsDir2 text</obsDir2>
116
            <obsDir3>some obsDir3 text</obsDir3>
117
            <obsAssist1>some obsAssist1 text</obsAssist1>
118
            <obsAssist2>some obsAssist2 text</obsAssist2>
119
            <obsAssist3>some obsAssist3 text</obsAssist3>
120
            <cons1Med>some cons1Med text</cons1Med>
121
            <cons2Med>some cons2Med text</cons2Med>
122
          </fsl>
123 100
          <bPhoto>true</bPhoto>
124 101
          <bLeaveAlone>false</bLeaveAlone>
125 102
          <authorizedPersonList>
126 103
            <personInfo>
127 104
              <num>614719</num>
128 105
              <lastname>BENT</lastname>
129 106
              <firstname>AMEL</firstname>
130 107
              <dateBirth>1985-06-21T00:00:00+02:00</dateBirth>
tests/data/toulouse_maelis/R_update_child_fsl.xml
1
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
  <soap:Body>
3
    <ns2:createOrUpdateFSLResponse xmlns:ns2="family.ws.maelis.sigec.com"/>
4
  </soap:Body>
5
</soap:Envelope>
tests/test_toulouse_maelis.py
66 66
CREATE_CHILD = FakedResponse(content=get_xml_file('R_create_child.xml'), status_code=200)
67 67
CREATE_CHILD_ERR = FakedResponse(content=get_xml_file('R_create_child_error.xml'), status_code=200)
68 68
UPDATE_FAMILY = FakedResponse(content=get_xml_file('R_update_family.xml'), status_code=200)
69 69
UPDATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_update_family_error.xml'), status_code=200)
70 70
UPDATE_FAMILY_500 = FakedResponse(content=get_xml_file('R_update_family_soap_error.xml'), status_code=500)
71 71
UPDATE_DIETCODE = FakedResponse(content=get_xml_file('R_update_child_dietcode.xml'), status_code=200)
72 72
UPDATE_PAI = FakedResponse(content=get_xml_file('R_update_child_pai.xml'), status_code=200)
73 73
UPDATE_PAI_500 = FakedResponse(content=get_xml_file('R_update_child_pai_soap_error.xml'), status_code=500)
74
UPDATE_FSL = FakedResponse(content=get_xml_file('R_update_child_fsl.xml'), status_code=200)
75
UPDATE_FSL_500 = FakedResponse(content=get_xml_file('R_update_child_fsl_soap_error.xml'), status_code=500)
76
UPDATE_MEDICAL = FakedResponse(content=get_xml_file('R_update_child_fsl.xml'), status_code=200)
74
UPDATE_MEDICAL = FakedResponse(content=get_xml_file('R_update_child_medical_record.xml'), status_code=200)
77 75
UPDATE_MEDICAL_500 = FakedResponse(
78 76
    content=get_xml_file('R_update_child_medical_record_soap_error.xml'), status_code=500
79 77
)
80 78
UPDATE_CHILD_AUTO = FakedResponse(content=get_xml_file('R_update_child_authorization.xml'), status_code=200)
81 79

  
82 80

  
83 81
def assert_sent_payload(mocked_post, query_file):
84 82
    soap_sent = etree.tostring(etree.fromstring(mocked_post.call_args.kwargs['data']), pretty_print=True)
......
609 607
        },
610 608
        'CAFInfo': None,
611 609
        'civility_text': 'Monsieur',
612 610
        'quality_text': 'PERE',
613 611
        'quotientList': [],
614 612
        'subscribeActivityList': [],
615 613
    }
616 614
    data = resp.json['data']['childList'][0]
617
    del data['fsl']
618 615
    del data['medicalRecord']
619 616
    del data['authorizedPersonList']
620 617
    del data['paiInfoBean']
621 618
    assert data == {
622 619
        'num': '613880',
623 620
        'lastname': 'DOE',
624 621
        'firstname': 'JANNIS',
625 622
        'sexe': 'F',
......
646 643
        }
647 644
    else:
648 645
        assert resp.json['data']['childList'][0]['paiInfoBean'] == {
649 646
            'code': None,
650 647
            'dateDeb': '2022-01-01T00:00:00+01:00',
651 648
            'dateFin': '2022-12-31T00:00:00+01:00',
652 649
            'description': 'bla bla PAI',
653 650
        }
654
    assert resp.json['data']['childList'][0]['fsl'] == {
655
        'dateDeb': '2022-01-01T00:00:00+01:00',
656
        'dateFin': '2022-12-31T00:00:00+01:00',
657
        'allergieAlimentaire': True,
658
        'allergieRespiratoire': True,
659
        'allergieAutre': True,
660
        'allergieMedicament': True,
661
        'asthme': False,
662
        'flPAI': False,
663
        'flImage': False,
664
        'dtcPrap1': '2022-02-22T00:00:00+01:00',
665
        'obsMed1': 'some obsMed1 text',
666
        'obsMed2': 'some obsMed2 text',
667
        'obsMed3': 'some obsMed3 text',
668
        'obsDir1': 'some obsDir1 text',
669
        'obsDir2': 'some obsDir2 text',
670
        'obsDir3': 'some obsDir3 text',
671
        'obsAssist1': 'some obsAssist1 text',
672
        'obsAssist2': 'some obsAssist2 text',
673
        'obsAssist3': 'some obsAssist3 text',
674
        'cons1Med': 'some cons1Med text',
675
        'cons2Med': 'some cons2Med text',
676
    }
677 651
    assert resp.json['data']['childList'][0]['medicalRecord'] == {
678 652
        "familyDoctor": {
679 653
            "name": "DRE",
680 654
            "phone": "0612341234",
681 655
            "address": {"street1": "Alameda", "zipcode": "90220", "town": "Compton"},
682 656
        },
683 657
        "vaccinList": [
684 658
            {
......
2651 2625
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2652 2626
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2653 2627
    assert resp.json['err'] == 'Family-updateChildPAI-soap:Server'
2654 2628
    assert 'Une erreur est survenue' in resp.json['err_desc']
2655 2629
    assert 'valeur trop grande' in resp.json['err_desc']
2656 2630
    assert 'maximum : 500' in resp.json['err_desc']
2657 2631

  
2658 2632

  
2659
@mock.patch('passerelle.utils.Request.get')
2660
@mock.patch('passerelle.utils.Request.post')
2661
def test_update_child_fsl(mocked_post, mocked_get, con, app):
2662
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2663
    mocked_post.return_value = UPDATE_FSL
2664
    url = get_endpoint('update-child-fsl')
2665
    params = {
2666
        'dateDeb': '2022-01-01',
2667
        'dateFin': '2022-12-31',
2668
        'allergieAlimentaire': True,
2669
        'allergieRespiratoire': True,
2670
        'allergieAutre': True,
2671
        'allergieMedicament': True,
2672
        'asthme': False,
2673
        'flPAI': False,
2674
        'flImage': False,
2675
        'dtcPrap1': '2022-02-22',
2676
        'obsMed1': 'some obsMed1 text',
2677
        'obsMed2': 'some obsMed2 text',
2678
        'obsMed3': 'some obsMed3 text',
2679
        'obsDir1': 'some obsDir1 text',
2680
        'obsDir2': 'some obsDir2 text',
2681
        'obsDir3': 'some obsDir3 text',
2682
        'obsAssist1': 'some obsAssist1 text',
2683
        'obsAssist2': 'some obsAssist2 text',
2684
        'obsAssist3': 'some obsAssist3 text',
2685
        'cons1Med': 'some cons1Med text',
2686
        'cons2Med': 'some cons2Med text',
2687
    }
2688

  
2689
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2690
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2691
    assert_sent_payload(mocked_post, 'Q_update_child_fsl.xml')
2692
    assert resp.json['err'] == 0
2693
    assert resp.json['data'] == 'ok'
2694

  
2695

  
2696
def test_update_child_fsl_not_linked_error(con, app):
2697
    url = get_endpoint('update-child-fsl')
2698
    params = {
2699
        'dateDeb': '2022-01-01',
2700
        'dateFin': '2022-12-31',
2701
    }
2702

  
2703
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2704
    assert resp.json['err'] == 'not-linked'
2705
    assert resp.json['err_desc'] == 'User not linked to family'
2706

  
2707

  
2708
@mock.patch('passerelle.utils.Request.get')
2709
@mock.patch('passerelle.utils.Request.post')
2710
def test_update_child_fsl_soap_error(mocked_post, mocked_get, con, app):
2711
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2712
    mocked_post.return_value = UPDATE_FSL_500
2713
    url = get_endpoint('update-child-fsl')
2714
    params = {
2715
        'dateDeb': '2022-01-01',
2716
        'dateFin': '2022-12-31',
2717
        'obsMed1': 'a' * 71,
2718
    }
2719

  
2720
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2721
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2722
    assert resp.json['err'] == 'Family-createOrUpdateFSL-soap:Server'
2723
    assert 'Une erreur est survenue' in resp.json['err_desc']
2724
    assert 'valeur trop grande' in resp.json['err_desc']
2725
    assert 'maximum : 70' in resp.json['err_desc']
2726

  
2727

  
2728 2633
@mock.patch('passerelle.utils.Request.get')
2729 2634
@mock.patch('passerelle.utils.Request.post')
2730 2635
def test_update_child_medical_record(mocked_post, mocked_get, con, app):
2731 2636
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2732 2637
    mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL]
2733 2638
    url = get_endpoint('update-child-medical-record')
2734 2639
    params = {
2735 2640
        'familyDoctor/name': 'Dre',
2736
-