medical card update
This commit is contained in:
@@ -18,8 +18,8 @@ class MedicalCardService(BaseService[MedicalCard, MedicalCardCreate, Any]):
|
||||
if searchstring is None or searchstring == '':
|
||||
raise HTTPException(status_code=404, detail='searchstring is required')
|
||||
|
||||
personal_information_host = os.getenv('ASTRA-PESONAL-INFORMATION')
|
||||
#personal_information_host = 'http://localhost:8001/persons'
|
||||
# personal_information_host = os.getenv('ASTRA-PESONAL-INFORMATION')
|
||||
personal_information_host = 'http://localhost:8001/persons'
|
||||
#TODO обобщение хоста personal_info
|
||||
#TODO обработка ошибок ответа сервиса personal_info
|
||||
|
||||
@@ -31,7 +31,6 @@ class MedicalCardService(BaseService[MedicalCard, MedicalCardCreate, Any]):
|
||||
if len(person_ids) < 1:
|
||||
return []
|
||||
|
||||
|
||||
objs = self.db_session.query(models.MedicalCard).filter(models.MedicalCard.person_id.in_(person_ids)).all()
|
||||
medical_cards = parse_obj_as(List[schemas.MedicalCard], objs)
|
||||
medical_cards = [medical_card.dict() for medical_card in medical_cards]
|
||||
@@ -51,8 +50,8 @@ class MedicalCardService(BaseService[MedicalCard, MedicalCardCreate, Any]):
|
||||
if obj is None:
|
||||
raise HTTPException(status_code=404, detail='NotFound')
|
||||
|
||||
personal_information_host = os.getenv('ASTRA-PESONAL-INFORMATION')
|
||||
# personal_information_host = 'http://localhost:8001/persons'
|
||||
# personal_information_host = os.getenv('ASTRA-PESONAL-INFORMATION')
|
||||
personal_information_host = 'http://localhost:8001/persons'
|
||||
|
||||
#TODO обработка ошибок ответа сервиса personal_info
|
||||
|
||||
@@ -60,4 +59,17 @@ class MedicalCardService(BaseService[MedicalCard, MedicalCardCreate, Any]):
|
||||
|
||||
medical_info = schemas.MedicalCardDetail.from_orm(obj).dict()
|
||||
medical_info['person'] = schemas.PersonDetail(**person_response.json()).dict()
|
||||
return medical_info
|
||||
return medical_info
|
||||
|
||||
def update(self, id: UUID4, mc_request: schemas.MedicalCardUpdateRq) -> Optional[MedicalCard]:
|
||||
mc_obj = self.db_session.get(self.model, id)
|
||||
if mc_obj is None:
|
||||
raise HTTPException(status_code=404, detail='NotFound')
|
||||
|
||||
for column, value in mc_request.dict(exclude_unset=True).items():
|
||||
setattr(mc_obj, column, value)
|
||||
|
||||
self.db_session.commit()
|
||||
|
||||
return mc_obj
|
||||
|
||||
Reference in New Issue
Block a user