tiss-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +1 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +5 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +8 -0
  10. data/Gemfile.lock +111 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +43 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/lib/tiss/constants.rb +73 -0
  17. data/lib/tiss/creator.rb +52 -0
  18. data/lib/tiss/generator/generator.rb +20 -0
  19. data/lib/tiss/generator/generators/base_generator.rb +54 -0
  20. data/lib/tiss/generator/generators/model_generator.rb +36 -0
  21. data/lib/tiss/generator/generators/templates/model_template.erb +22 -0
  22. data/lib/tiss/generator/generators/templates/validator_template.erb +60 -0
  23. data/lib/tiss/generator/generators/validator_generator.rb +44 -0
  24. data/lib/tiss/model.rb +66 -0
  25. data/lib/tiss/models/anexo_clinico.rb +18 -0
  26. data/lib/tiss/models/anexo_clinico_prorrogacao.rb +18 -0
  27. data/lib/tiss/models/anexos_clinicos.rb +22 -0
  28. data/lib/tiss/models/anexos_guias_tiss.rb +22 -0
  29. data/lib/tiss/models/beneficiario.rb +18 -0
  30. data/lib/tiss/models/cabecalho_demonstrativo_odonto.rb +26 -0
  31. data/lib/tiss/models/cabecalho_guia.rb +11 -0
  32. data/lib/tiss/models/cabecalho_transacao.rb +36 -0
  33. data/lib/tiss/models/cod_profissional.rb +14 -0
  34. data/lib/tiss/models/codigo_contratado.rb +14 -0
  35. data/lib/tiss/models/contratado_executante.rb +11 -0
  36. data/lib/tiss/models/cpf_cnpj_contratado.rb +14 -0
  37. data/lib/tiss/models/ct_anexo_cabecalho.rb +34 -0
  38. data/lib/tiss/models/ct_anexo_lote.rb +14 -0
  39. data/lib/tiss/models/ct_anexo_recebimento.rb +38 -0
  40. data/lib/tiss/models/ct_autorizacao_dados.rb +36 -0
  41. data/lib/tiss/models/ct_autorizacao_internacao.rb +32 -0
  42. data/lib/tiss/models/ct_autorizacao_sadt.rb +32 -0
  43. data/lib/tiss/models/ct_autorizacao_solicita_status.rb +18 -0
  44. data/lib/tiss/models/ct_beneficiario_dados.rb +36 -0
  45. data/lib/tiss/models/ct_conta_medica_resumo.rb +52 -0
  46. data/lib/tiss/models/ct_contratado_dados.rb +22 -0
  47. data/lib/tiss/models/ct_contratado_profissional_dados.rb +26 -0
  48. data/lib/tiss/models/ct_credito_odonto.rb +14 -0
  49. data/lib/tiss/models/ct_dados_complementares_beneficiario.rb +26 -0
  50. data/lib/tiss/models/ct_dados_complementares_beneficiario_radio.rb +14 -0
  51. data/lib/tiss/models/ct_dados_resumo_demonstrativo.rb +34 -0
  52. data/lib/tiss/models/ct_demonstrativo_cabecalho.rb +26 -0
  53. data/lib/tiss/models/ct_demonstrativo_retorno.rb +26 -0
  54. data/lib/tiss/models/ct_demonstrativo_solicitacao.rb +14 -0
  55. data/lib/tiss/models/ct_descontos.rb +22 -0
  56. data/lib/tiss/models/ct_diagnostico.rb +18 -0
  57. data/lib/tiss/models/ct_diagnostico_oncologico.rb +34 -0
  58. data/lib/tiss/models/ct_drogas_solicitadas.rb +31 -0
  59. data/lib/tiss/models/ct_elegibilidade_recibo.rb +58 -0
  60. data/lib/tiss/models/ct_elegibilidade_verifica.rb +50 -0
  61. data/lib/tiss/models/ct_fonte_pagadora.rb +14 -0
  62. data/lib/tiss/models/ct_glosa_recibo.rb +54 -0
  63. data/lib/tiss/models/ct_glosa_recibo_odonto.rb +54 -0
  64. data/lib/tiss/models/ct_guia_cabecalho.rb +14 -0
  65. data/lib/tiss/models/ct_guia_cancelamento.rb +22 -0
  66. data/lib/tiss/models/ct_guia_cancelamento_recibo.rb +18 -0
  67. data/lib/tiss/models/ct_guia_dados.rb +44 -0
  68. data/lib/tiss/models/ct_guia_dados_anexo.rb +34 -0
  69. data/lib/tiss/models/ct_guia_dados_odonto.rb +66 -0
  70. data/lib/tiss/models/ct_guia_recurso.rb +26 -0
  71. data/lib/tiss/models/ct_guia_recurso_lote.rb +14 -0
  72. data/lib/tiss/models/ct_guia_valor_total.rb +38 -0
  73. data/lib/tiss/models/ct_guia_valor_total_sadt.rb +34 -0
  74. data/lib/tiss/models/ct_hipotese_diagnostica.rb +14 -0
  75. data/lib/tiss/models/ct_ident_equipe.rb +34 -0
  76. data/lib/tiss/models/ct_ident_equipe_sadt.rb +34 -0
  77. data/lib/tiss/models/ct_intervalo_ciclos.rb +14 -0
  78. data/lib/tiss/models/ct_login_senha.rb +14 -0
  79. data/lib/tiss/models/ct_lote_anexo_status.rb +26 -0
  80. data/lib/tiss/models/ct_lote_status.rb +30 -0
  81. data/lib/tiss/models/ct_motivo_glosa.rb +14 -0
  82. data/lib/tiss/models/ct_opm_utilizada.rb +14 -0
  83. data/lib/tiss/models/ct_opme_dados.rb +14 -0
  84. data/lib/tiss/models/ct_outras_despesas.rb +10 -0
  85. data/lib/tiss/models/ct_pagamento_dados.rb +26 -0
  86. data/lib/tiss/models/ct_pagamento_resumo.rb +22 -0
  87. data/lib/tiss/models/ct_prestador_identificacao.rb +18 -0
  88. data/lib/tiss/models/ct_procedimento_autorizado.rb +51 -0
  89. data/lib/tiss/models/ct_procedimento_dados.rb +18 -0
  90. data/lib/tiss/models/ct_procedimento_executado.rb +59 -0
  91. data/lib/tiss/models/ct_procedimento_executado_honor_indiv.rb +55 -0
  92. data/lib/tiss/models/ct_procedimento_executado_int.rb +55 -0
  93. data/lib/tiss/models/ct_procedimento_executado_odonto.rb +47 -0
  94. data/lib/tiss/models/ct_procedimento_executado_outras.rb +62 -0
  95. data/lib/tiss/models/ct_procedimento_executado_sadt.rb +55 -0
  96. data/lib/tiss/models/ct_procedimento_solicitado.rb +18 -0
  97. data/lib/tiss/models/ct_procedimentos_complementares.rb +18 -0
  98. data/lib/tiss/models/ct_protocolo_anexo_status.rb +18 -0
  99. data/lib/tiss/models/ct_protocolo_detalhe.rb +22 -0
  100. data/lib/tiss/models/ct_protocolo_detalhe_anexo.rb +26 -0
  101. data/lib/tiss/models/ct_protocolo_recebimento.rb +26 -0
  102. data/lib/tiss/models/ct_protocolo_recebimento_anexo.rb +30 -0
  103. data/lib/tiss/models/ct_protocolo_recebimento_recurso.rb +30 -0
  104. data/lib/tiss/models/ct_protocolo_recurso.rb +18 -0
  105. data/lib/tiss/models/ct_protocolo_solicitacao_status.rb +14 -0
  106. data/lib/tiss/models/ct_protocolo_status.rb +18 -0
  107. data/lib/tiss/models/ct_recebimento_lote.rb +14 -0
  108. data/lib/tiss/models/ct_recebimento_recurso.rb +14 -0
  109. data/lib/tiss/models/ct_recibo_cancela_guia.rb +14 -0
  110. data/lib/tiss/models/ct_recibo_comunicacao.rb +14 -0
  111. data/lib/tiss/models/ct_recurso_glosa_recebimento.rb +54 -0
  112. data/lib/tiss/models/ct_resposta_elegibilidade.rb +14 -0
  113. data/lib/tiss/models/ct_resposta_glosa.rb +22 -0
  114. data/lib/tiss/models/ct_resposta_glosa_guia_medica.rb +35 -0
  115. data/lib/tiss/models/ct_resposta_glosa_item_medico.rb +55 -0
  116. data/lib/tiss/models/ct_resposta_recurso_guia_odonto.rb +34 -0
  117. data/lib/tiss/models/ct_resposta_recurso_item_odonto.rb +26 -0
  118. data/lib/tiss/models/ct_situacao_autorizacao.rb +26 -0
  119. data/lib/tiss/models/ct_situacao_clinica.rb +10 -0
  120. data/lib/tiss/models/ct_situacao_inicial.rb +22 -0
  121. data/lib/tiss/models/ct_situacao_protocolo.rb +18 -0
  122. data/lib/tiss/models/ct_valor_credito_desconto.rb +18 -0
  123. data/lib/tiss/models/ct_valor_total.rb +18 -0
  124. data/lib/tiss/models/ctm_anexo_solicitacao_opme.rb +34 -0
  125. data/lib/tiss/models/ctm_anexo_solicitacao_quimio.rb +55 -0
  126. data/lib/tiss/models/ctm_anexo_solicitacao_radio.rb +59 -0
  127. data/lib/tiss/models/ctm_anexo_solicitante.rb +18 -0
  128. data/lib/tiss/models/ctm_autorizacao_internacao.rb +22 -0
  129. data/lib/tiss/models/ctm_autorizacao_opme.rb +30 -0
  130. data/lib/tiss/models/ctm_autorizacao_prorrogacao.rb +22 -0
  131. data/lib/tiss/models/ctm_autorizacao_quimio.rb +67 -0
  132. data/lib/tiss/models/ctm_autorizacao_radio.rb +71 -0
  133. data/lib/tiss/models/ctm_autorizacao_servico.rb +47 -0
  134. data/lib/tiss/models/ctm_beneficiario_comunicacao.rb +22 -0
  135. data/lib/tiss/models/ctm_beneficiario_comunicacao_recibo.rb +18 -0
  136. data/lib/tiss/models/ctm_consulta_atendimento.rb +18 -0
  137. data/lib/tiss/models/ctm_consulta_guia.rb +52 -0
  138. data/lib/tiss/models/ctm_demonstrativo_analise_conta.rb +34 -0
  139. data/lib/tiss/models/ctm_demonstrativo_pagamento.rb +26 -0
  140. data/lib/tiss/models/ctm_guia_lote.rb +14 -0
  141. data/lib/tiss/models/ctm_honorario_individual_guia.rb +58 -0
  142. data/lib/tiss/models/ctm_internacao_dados.rb +42 -0
  143. data/lib/tiss/models/ctm_internacao_dados_saida.rb +18 -0
  144. data/lib/tiss/models/ctm_internacao_resumo_guia.rb +54 -0
  145. data/lib/tiss/models/ctm_internacao_solicitacao_guia.rb +65 -0
  146. data/lib/tiss/models/ctm_prorrogacao_solicitacao_guia.rb +50 -0
  147. data/lib/tiss/models/ctm_recurso_glosa.rb +50 -0
  148. data/lib/tiss/models/ctm_solicitacao_lote.rb +22 -0
  149. data/lib/tiss/models/ctm_sp_sadt_atendimento.rb +22 -0
  150. data/lib/tiss/models/ctm_sp_sadt_guia.rb +54 -0
  151. data/lib/tiss/models/ctm_sp_sadt_solicitacao_guia.rb +65 -0
  152. data/lib/tiss/models/cto_anexo_situacao_inicial.rb +34 -0
  153. data/lib/tiss/models/cto_anexo_situacao_inicialna_gto.rb +22 -0
  154. data/lib/tiss/models/cto_autorizacao_servico.rb +52 -0
  155. data/lib/tiss/models/cto_demonstrativo_odontologia.rb +42 -0
  156. data/lib/tiss/models/cto_guia_odontologia.rb +108 -0
  157. data/lib/tiss/models/cto_odonto_solicitacao_guia.rb +110 -0
  158. data/lib/tiss/models/cto_recurso_glosa_odonto.rb +50 -0
  159. data/lib/tiss/models/dados_beneficiario.rb +28 -0
  160. data/lib/tiss/models/dados_conta.rb +10 -0
  161. data/lib/tiss/models/dados_contratado.rb +22 -0
  162. data/lib/tiss/models/dados_contratado_executante.rb +18 -0
  163. data/lib/tiss/models/dados_executante.rb +22 -0
  164. data/lib/tiss/models/dados_guia.rb +18 -0
  165. data/lib/tiss/models/dados_guias_protocolo.rb +14 -0
  166. data/lib/tiss/models/dados_hospital_solicitado.rb +18 -0
  167. data/lib/tiss/models/dados_internacao.rb +54 -0
  168. data/lib/tiss/models/dados_pagamento.rb +71 -0
  169. data/lib/tiss/models/dados_pagamento_guia.rb +58 -0
  170. data/lib/tiss/models/dados_pagamento_por_data.rb +26 -0
  171. data/lib/tiss/models/dados_prestador.rb +26 -0
  172. data/lib/tiss/models/dados_profissionais_responsaveis.rb +58 -0
  173. data/lib/tiss/models/dados_resumo.rb +10 -0
  174. data/lib/tiss/models/dados_solicitacao.rb +18 -0
  175. data/lib/tiss/models/dados_solicitante.rb +14 -0
  176. data/lib/tiss/models/deb_cred_demonstrativo.rb +10 -0
  177. data/lib/tiss/models/deb_cred_por_data_pagamento.rb +10 -0
  178. data/lib/tiss/models/debitos_creditos_por_data.rb +10 -0
  179. data/lib/tiss/models/declaracoes.rb +22 -0
  180. data/lib/tiss/models/demonstrativo_analise.rb +18 -0
  181. data/lib/tiss/models/demonstrativo_pagamento.rb +22 -0
  182. data/lib/tiss/models/dente_regiao.rb +14 -0
  183. data/lib/tiss/models/dentes.rb +14 -0
  184. data/lib/tiss/models/despesa.rb +24 -0
  185. data/lib/tiss/models/destino.rb +14 -0
  186. data/lib/tiss/models/detalhes_guia.rb +43 -0
  187. data/lib/tiss/models/diagnostico_oncologico_quimioterapia.rb +33 -0
  188. data/lib/tiss/models/diagnostico_oncologico_radio.rb +14 -0
  189. data/lib/tiss/models/drogas_solicitadas.rb +10 -0
  190. data/lib/tiss/models/epilogo.rb +10 -0
  191. data/lib/tiss/models/glosa_anexo.rb +14 -0
  192. data/lib/tiss/models/glosa_guia.rb +10 -0
  193. data/lib/tiss/models/glosa_protocolo.rb +14 -0
  194. data/lib/tiss/models/glosas_procedimento.rb +14 -0
  195. data/lib/tiss/models/guias_canceladas.rb +10 -0
  196. data/lib/tiss/models/guias_cancelamento.rb +14 -0
  197. data/lib/tiss/models/guias_medicas.rb +10 -0
  198. data/lib/tiss/models/guias_odonto.rb +10 -0
  199. data/lib/tiss/models/guias_recurso.rb +22 -0
  200. data/lib/tiss/models/guias_tiss.rb +34 -0
  201. data/lib/tiss/models/hipoteses_diagnosticas.rb +14 -0
  202. data/lib/tiss/models/ident_equipe.rb +10 -0
  203. data/lib/tiss/models/identificacao_opm.rb +26 -0
  204. data/lib/tiss/models/identificacao_solicitante.rb +14 -0
  205. data/lib/tiss/models/identificacao_transacao.rb +22 -0
  206. data/lib/tiss/models/itens_guia.rb +47 -0
  207. data/lib/tiss/models/local_contratado.rb +18 -0
  208. data/lib/tiss/models/lote.rb +14 -0
  209. data/lib/tiss/models/lote_anexo.rb +14 -0
  210. data/lib/tiss/models/mensagem_tiss.rb +27 -0
  211. data/lib/tiss/models/motivos_glosa.rb +10 -0
  212. data/lib/tiss/models/motivos_negativa.rb +10 -0
  213. data/lib/tiss/models/opcao_recurso.rb +14 -0
  214. data/lib/tiss/models/opcao_recurso_guia.rb +18 -0
  215. data/lib/tiss/models/operadora_prestador.rb +50 -0
  216. data/lib/tiss/models/opm.rb +10 -0
  217. data/lib/tiss/models/opme_solicitada.rb +34 -0
  218. data/lib/tiss/models/opme_solicitadas.rb +10 -0
  219. data/lib/tiss/models/origem.rb +14 -0
  220. data/lib/tiss/models/pagamentos.rb +10 -0
  221. data/lib/tiss/models/pagamentos_por_data.rb +26 -0
  222. data/lib/tiss/models/periodo.rb +14 -0
  223. data/lib/tiss/models/periodo_proc.rb +14 -0
  224. data/lib/tiss/models/prestador_autorizado.rb +14 -0
  225. data/lib/tiss/models/prestador_operadora.rb +50 -0
  226. data/lib/tiss/models/procedimento.rb +18 -0
  227. data/lib/tiss/models/procedimento_realizado.rb +11 -0
  228. data/lib/tiss/models/procedimento_solicitado.rb +34 -0
  229. data/lib/tiss/models/procedimentos_adicionais.rb +14 -0
  230. data/lib/tiss/models/procedimentos_autorizados.rb +48 -0
  231. data/lib/tiss/models/procedimentos_complementares.rb +11 -0
  232. data/lib/tiss/models/procedimentos_executados.rb +51 -0
  233. data/lib/tiss/models/procedimentos_realizados.rb +10 -0
  234. data/lib/tiss/models/procedimentos_solicitados.rb +54 -0
  235. data/lib/tiss/models/profissionais.rb +34 -0
  236. data/lib/tiss/models/protocolos.rb +22 -0
  237. data/lib/tiss/models/recebimento_anexo.rb +14 -0
  238. data/lib/tiss/models/recibo_glosa_status.rb +42 -0
  239. data/lib/tiss/models/recurso_guia.rb +58 -0
  240. data/lib/tiss/models/recurso_guia_completa.rb +14 -0
  241. data/lib/tiss/models/recurso_procedimento.rb +55 -0
  242. data/lib/tiss/models/recurso_protocolo.rb +23 -0
  243. data/lib/tiss/models/relacao_glosa.rb +14 -0
  244. data/lib/tiss/models/relacao_guias.rb +70 -0
  245. data/lib/tiss/models/resposta_elegibilidade.rb +14 -0
  246. data/lib/tiss/models/servicos_autorizados.rb +10 -0
  247. data/lib/tiss/models/situacao_demonstrativo_retorno.rb +34 -0
  248. data/lib/tiss/models/totais_bruto_demonstrativo.rb +26 -0
  249. data/lib/tiss/models/totais_brutos_demonstrativo.rb +22 -0
  250. data/lib/tiss/models/totais_brutos_por_data.rb +22 -0
  251. data/lib/tiss/models/totais_demonstrativo.rb +18 -0
  252. data/lib/tiss/models/totais_liquidos_demonstrativo.rb +18 -0
  253. data/lib/tiss/models/totais_liquidos_por_data.rb +18 -0
  254. data/lib/tiss/models/totais_por_data.rb +26 -0
  255. data/lib/tiss/models/totais_por_protocolo.rb +26 -0
  256. data/lib/tiss/models/total_liquido_por_data.rb +18 -0
  257. data/lib/tiss/models/tratamentos_anteriores.rb +30 -0
  258. data/lib/tiss/tiss.rb +39 -0
  259. data/lib/tiss/version.rb +5 -0
  260. data/lib/tiss/xsd/class_maker.rb +242 -0
  261. data/lib/tiss/xsd/convert.rb +26 -0
  262. data/lib/tiss-ruby.rb +3 -0
  263. data/lib/xsd/class_maker.rb +219 -0
  264. data/lib/xsd/convert.rb +26 -0
  265. data/resources/TabelasDominio.doc +0 -0
  266. data/resources/tissAssinaturaDigital_v1.01.xsd +16 -0
  267. data/resources/tissComplexTypesV3_02_00.xsd +1370 -0
  268. data/resources/tissComplexTypesV3_02_01.xsd +1370 -0
  269. data/resources/tissComplexTypesV3_02_02.xsd +1370 -0
  270. data/resources/tissComplexTypesV3_03_01.xsd +1372 -0
  271. data/resources/tissComplexTypesV3_03_02.xsd +1372 -0
  272. data/resources/tissComplexTypesV3_03_03.xsd +1372 -0
  273. data/resources/tissComplexTypesV3_04_00.xsd +1406 -0
  274. data/resources/tissGuiasV3_02_00.xsd +1387 -0
  275. data/resources/tissGuiasV3_02_01.xsd +1388 -0
  276. data/resources/tissGuiasV3_02_02.xsd +1389 -0
  277. data/resources/tissGuiasV3_03_01.xsd +1402 -0
  278. data/resources/tissGuiasV3_03_02.xsd +1401 -0
  279. data/resources/tissGuiasV3_03_03.xsd +1401 -0
  280. data/resources/tissGuiasV3_04_00.xsd +1387 -0
  281. data/resources/tissSimpleTypesV3_02_00.xsd +3158 -0
  282. data/resources/tissSimpleTypesV3_02_01.xsd +3597 -0
  283. data/resources/tissSimpleTypesV3_02_02.xsd +3830 -0
  284. data/resources/tissSimpleTypesV3_03_01.xsd +4120 -0
  285. data/resources/tissSimpleTypesV3_03_02.xsd +4144 -0
  286. data/resources/tissSimpleTypesV3_03_03.xsd +4163 -0
  287. data/resources/tissSimpleTypesV3_04_00.xsd +4233 -0
  288. data/resources/tissV3_02_00.xsd +118 -0
  289. data/resources/tissV3_02_01.xsd +118 -0
  290. data/resources/tissV3_02_02.xsd +121 -0
  291. data/resources/tissV3_03_01.xsd +118 -0
  292. data/resources/tissV3_03_02.xsd +118 -0
  293. data/resources/tissV3_03_03.xsd +118 -0
  294. data/resources/tissV3_04_00.xsd +118 -0
  295. data/resources/xmldsig-core-schema.xsd +309 -0
  296. data/tiss-ruby.gemspec +55 -0
  297. metadata +569 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e1b738cabb9035fa8c20366d87d126355527ec32c20d90669290a3b02a05b237
4
+ data.tar.gz: fbfe55ad03bc48e8614998f9c788fa93bb6f6828d4f414e7855b60660ffd52da
5
+ SHA512:
6
+ metadata.gz: e624f6cce849f64e07f561405d755d511365c5a1dc956ede66be38e2008087e18f6c9105e902e336cf2d093b1379cd908f349bbc0cb8701dcd6e8ccd1e38b20e
7
+ data.tar.gz: 05ef013071a302f7b44b508297a6b05e544ed8d2aafde799592a32a76a41a1ec376d947bd303aa89cb11af66fd7e308bf2eca44ae4adbdcf2f42c88cb309fb25
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .idea
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ require: rubocop-rspec
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ tiss-ruby
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at marcos.junior@rhsoftware.com.br. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in tiss-ruby.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tiss-ruby (0.1.0)
5
+ activemodel
6
+ activesupport
7
+ dry-configurable
8
+ nokogiri
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (5.2.4.1)
14
+ activesupport (= 5.2.4.1)
15
+ activesupport (5.2.4.1)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ ast (2.4.0)
21
+ awesome_print (1.6.1)
22
+ binding_of_caller (0.8.0)
23
+ debug_inspector (>= 0.0.1)
24
+ coderay (1.1.2)
25
+ concurrent-ruby (1.1.5)
26
+ coolline (0.5.0)
27
+ unicode_utils (~> 1.4)
28
+ debug_inspector (0.0.3)
29
+ diff-lcs (1.3)
30
+ dry-configurable (0.8.3)
31
+ concurrent-ruby (~> 1.0)
32
+ dry-core (~> 0.4, >= 0.4.7)
33
+ dry-core (0.4.9)
34
+ concurrent-ruby (~> 1.0)
35
+ i18n (1.8.2)
36
+ concurrent-ruby (~> 1.0)
37
+ interception (0.5)
38
+ jaro_winkler (1.5.4)
39
+ method_source (0.9.2)
40
+ mini_portile2 (2.4.0)
41
+ minitest (5.14.0)
42
+ nokogiri (1.10.7)
43
+ mini_portile2 (~> 2.4.0)
44
+ parallel (1.19.1)
45
+ parser (2.7.0.2)
46
+ ast (~> 2.4.0)
47
+ pry (0.12.2)
48
+ coderay (~> 1.1.0)
49
+ method_source (~> 0.9.0)
50
+ pry-coolline (0.2.5)
51
+ coolline (~> 0.5)
52
+ pry-nav (0.3.0)
53
+ pry (>= 0.9.10, < 0.13.0)
54
+ pry-rescue (1.5.0)
55
+ interception (>= 0.5)
56
+ pry (>= 0.12.0)
57
+ pry-stack_explorer (0.4.9.3)
58
+ binding_of_caller (>= 0.7)
59
+ pry (>= 0.9.11)
60
+ rainbow (3.0.0)
61
+ rake (10.5.0)
62
+ rb-readline (0.5.5)
63
+ rspec (3.9.0)
64
+ rspec-core (~> 3.9.0)
65
+ rspec-expectations (~> 3.9.0)
66
+ rspec-mocks (~> 3.9.0)
67
+ rspec-core (3.9.1)
68
+ rspec-support (~> 3.9.1)
69
+ rspec-expectations (3.9.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.9.0)
72
+ rspec-mocks (3.9.1)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.9.0)
75
+ rspec-support (3.9.2)
76
+ rubocop (0.79.0)
77
+ jaro_winkler (~> 1.5.1)
78
+ parallel (~> 1.10)
79
+ parser (>= 2.7.0.1)
80
+ rainbow (>= 2.2.2, < 4.0)
81
+ ruby-progressbar (~> 1.7)
82
+ unicode-display_width (>= 1.4.0, < 1.7)
83
+ rubocop-rspec (1.37.1)
84
+ rubocop (>= 0.68.1)
85
+ ruby-progressbar (1.10.1)
86
+ thread_safe (0.3.6)
87
+ tzinfo (1.2.6)
88
+ thread_safe (~> 0.1)
89
+ unicode-display_width (1.6.1)
90
+ unicode_utils (1.4.0)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ awesome_print (~> 1.6.1, ~> 1.6)
97
+ bundler (~> 1.16)
98
+ pry
99
+ pry-coolline
100
+ pry-nav
101
+ pry-rescue
102
+ pry-stack_explorer
103
+ rake (~> 10.0)
104
+ rb-readline
105
+ rspec (~> 3.0)
106
+ rubocop (~> 0.79.0)
107
+ rubocop-rspec
108
+ tiss-ruby!
109
+
110
+ BUNDLED WITH
111
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Marcos Junior
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Tiss::Ruby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tiss/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tiss-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tiss-ruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tiss-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Tiss::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tiss-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'tiss-ruby'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tiss
4
+ class Constants
5
+ UF_MAP = {
6
+ 'RO' => '11',
7
+ 'AC' => '12',
8
+ 'AM' => '13',
9
+ 'RR' => '14',
10
+ 'PA' => '15',
11
+ 'AP' => '16',
12
+ 'TO' => '17',
13
+ 'MA' => '21',
14
+ 'PI' => '22',
15
+ 'CE' => '23',
16
+ 'RN' => '24',
17
+ 'PB' => '25',
18
+ 'PE' => '26',
19
+ 'AL' => '27',
20
+ 'SE' => '28',
21
+ 'BA' => '29',
22
+ 'MG' => '31',
23
+ 'ES' => '32',
24
+ 'RJ' => '33',
25
+ 'SP' => '35',
26
+ 'PR' => '41',
27
+ 'SC' => '42',
28
+ 'RS' => '43',
29
+ 'MS' => '50',
30
+ 'MT' => '51',
31
+ 'GO' => '52',
32
+ 'DF' => '53',
33
+ 'EX' => '98'
34
+ }.freeze
35
+
36
+ CR_TYPE_MAP_V2 = {
37
+ 'CRAS' => '1',
38
+ 'COREN' => '2',
39
+ 'CRF' => '3',
40
+ 'CRFA' => '4',
41
+ 'CREFITO' => '5',
42
+ 'CRM' => '6',
43
+ 'CRN' => '7',
44
+ 'CRO' => '8',
45
+ 'CRP' => '9',
46
+ 'OUT' => '10'
47
+ }.freeze
48
+
49
+ CR_TYPE_MAP_V3 = {
50
+ 'CRAS' => '01',
51
+ 'COREN' => '02',
52
+ 'CRF' => '03',
53
+ 'CRFA' => '04',
54
+ 'CREFITO' => '05',
55
+ 'CRM' => '06',
56
+ 'CRN' => '07',
57
+ 'CRO' => '08',
58
+ 'CRP' => '09',
59
+ 'OUT' => '10'
60
+ }.freeze
61
+
62
+ CR_TYPE_MAP = {
63
+ '3.02.00' => CR_TYPE_MAP_V2,
64
+ '3.02.01' => CR_TYPE_MAP_V2,
65
+ '3.02.02' => CR_TYPE_MAP_V2,
66
+ '3.03.01' => CR_TYPE_MAP_V3,
67
+ '3.03.02' => CR_TYPE_MAP_V3,
68
+ '3.03.03' => CR_TYPE_MAP_V3,
69
+ '3.04.00' => CR_TYPE_MAP_V3
70
+ }
71
+
72
+ end
73
+ end
@@ -0,0 +1,52 @@
1
+ module Tiss
2
+ class Creator
3
+ def self.[](version)
4
+ Creator.new(version)
5
+ end
6
+
7
+ attr_reader :version
8
+ attr_reader :hash
9
+
10
+ def initialize(version)
11
+ @version = version.gsub('.', '_')
12
+ @hash = ''
13
+ end
14
+
15
+ def build(object)
16
+ Nokogiri::XML::Builder.new(encoding: 'ISO-8859-1') do |xml|
17
+ xml['ans'].send(:mensagemTISS, 'xmlns:ans' => 'http://www.ans.gov.br/padroes/tiss/schemas') do
18
+ populate_object(xml, object, version)
19
+ end
20
+ end
21
+ end
22
+
23
+ def populate_object(xml, object, version)
24
+ attributes = object.attributes_by(version)
25
+ attributes.each_key do |attribute|
26
+ value = attributes[attribute]
27
+ next unless value.present?
28
+
29
+ if value.is_a? Tiss::Model::Base
30
+ xml.send(attribute) do
31
+ populate_object(xml, value, version)
32
+ end
33
+ elsif value.is_a?(Array)
34
+ # xml.send(attribute) do
35
+ value.each do |array_value|
36
+ xml.send(attribute) do
37
+ populate_object(xml, array_value, version)
38
+ end
39
+ end
40
+ # end
41
+ else
42
+
43
+ if attribute.to_s === 'hash'
44
+ attribute = 'hash_'.to_sym
45
+ end
46
+
47
+ xml.send(attribute, value)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'generators/base_generator'
4
+ require_relative 'generators/validator_generator'
5
+ require_relative 'generators/model_generator'
6
+ require 'nokogiri'
7
+
8
+ module Tiss::Generator
9
+ def models_from(xsd_definitions)
10
+ doc = Nokogiri::XML xsd_definitions
11
+
12
+ schema = doc.children.first
13
+
14
+ raise 'Invalid XMLSchema root' if schema.name != 'schema'
15
+ raise 'Missing XMLSchema namespace' if schema.namespace.nil?
16
+ raise 'Wrong XMLSchema namespace' unless is_xml_schema_node schema
17
+
18
+ schema.children.each { |node| make_definition node }
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+ require 'active_support'
5
+
6
+ module Tiss::Generator
7
+ class BaseGenerator
8
+ include ActiveSupport::Inflector
9
+
10
+ attr_reader :template_dir
11
+
12
+ class << self
13
+ def call(*args)
14
+ new.call(*args)
15
+ end
16
+ end
17
+
18
+ def initialize
19
+ @template_dir = File.join(File.dirname(File.absolute_path(__FILE__)), 'templates/')
20
+ end
21
+
22
+ def call(*_args)
23
+ puts 'Base Call'
24
+ end
25
+
26
+ def namespace_of(node)
27
+ node.namespace.href
28
+ end
29
+
30
+ def is_text(node)
31
+ node.name == 'text'
32
+ end
33
+
34
+ def is_xml_schema_node(node)
35
+ namespace_of(node) == XMLSchemaNS
36
+ end
37
+
38
+ def is_element(node)
39
+ is_xml_schema_node(node) && (node.name == 'element')
40
+ end
41
+
42
+ def is_simple(node)
43
+ is_xml_schema_node(node) && (node.name == 'simpleType')
44
+ end
45
+
46
+ def is_complex_root(node)
47
+ is_xml_schema_node(node) && (node.name == 'complexType')
48
+ end
49
+
50
+ def select_children(node, name)
51
+ node.children.select { |n| n.name == name }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tiss::Generator
4
+ class ModelGenerator < BaseGenerator
5
+ class << self
6
+ include ActiveSupport::Inflector
7
+ end
8
+
9
+ MODELS = {}
10
+
11
+ def self.append(version, name, attributes, extension)
12
+ model = ModelGenerator::MODELS[name.to_sym] || {}
13
+ model[:attributes] = [] unless model[:attributes].present?
14
+ model[:attributes] = model[:attributes] + attributes.compact.map { |item| item.merge(version: version) }
15
+ if extension.present?
16
+ model[:extension] = { class: extension, file: underscore(extension) }
17
+ end
18
+
19
+ ModelGenerator::MODELS[name.to_sym] = model
20
+ end
21
+
22
+ def call
23
+ template = File.read(File.join(template_dir, 'model_template.erb'))
24
+ models = ModelGenerator::MODELS
25
+ models.each_key do |model_name|
26
+ model_config = models[model_name]
27
+ attributes = model_config[:attributes].compact.uniq.group_by { |item| item[:name] }
28
+
29
+ file_content = ERB.new(template, nil, '-').result(binding)
30
+ File.open("lib/tiss/models/#{underscore(model_name.to_s)}.rb", 'w+') do |f|
31
+ f.write(file_content)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ <%- if model_config[:extension].present? -%>
2
+ require_relative '<%= model_config[:extension][:file] %>'
3
+ <%- end -%>
4
+
5
+ module Tiss::Model
6
+ class <%= model_name %> < <%= model_config[:extension].present? ? model_config[:extension][:class] : 'Base' %>
7
+ <%- attributes.each_key do |key| %>
8
+ # @type: <%= attributes[key].first[:type] %>
9
+ attr_accessor :<%= key.gsub('-', '_') %>
10
+ <% end -%>
11
+
12
+ <%- attributes.each_key do |key| -%>
13
+ <%- attr_versions = attributes[key].map{|attr| attr[:version]} -%>
14
+ <%- versions = Tiss.config.available_versions - attr_versions -%>
15
+ <%- if versions.any? && versions.count > 4 -%>
16
+ attribute_config :<%= key.gsub('-', '_') %>, only: %w[<%= attr_versions.join(' ') %>]
17
+ <%- elsif versions.any? && versions.count <= 4 -%>
18
+ attribute_config :<%= key.gsub('-', '_') %>, unless: %w[<%= versions.join(' ') %>]
19
+ <%- end %>
20
+ <%- end -%>
21
+ end
22
+ end
@@ -0,0 +1,60 @@
1
+ module Tiss::<%= version %>::Validator
2
+ class <%= name %>
3
+ TYPE = <%= type %>
4
+ <% unless ws_action.nil? %>
5
+ WS_ACTION = <%= ws_action %>
6
+ <% end %>
7
+ ENUM_VALUES = <%= enum_values %>
8
+ <% unless pattern.nil? %>
9
+ PATTERN = "<%= pattern %>"
10
+ REGEXP = Regexp.new("^<%= pattern %>$")
11
+ <% end %>
12
+
13
+ def validate_each(record, attribute, value)
14
+ validate_type record, attribute, value
15
+ handle_whitespaces record, attribute, value
16
+ unless self.class::ENUM_VALUES.empty?
17
+ validate_enumeration record, attribute, value
18
+ end
19
+ if self.class.const_defined? 'REGEXP'
20
+ validate_regexp record, attribute, value
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def validate_type(record, attribute, value)
27
+ unless value.is_a? self.class::TYPE
28
+ add_error record, attribute, "#{value}: not a #{self.class::TYPE}"
29
+ end
30
+ end
31
+
32
+ def handle_whitespaces(record, attribute, value)
33
+ if self.class.const_defined? 'WS_ACTION'
34
+ case self.class::WS_ACTION
35
+ when 'replace' then value.gsub! /[\n\t\r ]/, ' '
36
+ when 'collapse' then
37
+ value.gsub! /[\n\t\r]/, ' '
38
+ value = value.split.join ' '
39
+ end
40
+ record.send "#{attribute}=", value
41
+ end
42
+ end
43
+
44
+ def validate_enumeration(record, attribute, value)
45
+ unless self.class::ENUM_VALUES.include? value.to_s
46
+ add_error record, attribute, "#{value}: not in #{self.class::ENUM_VALUES}"
47
+ end
48
+ end
49
+
50
+ def validate_regexp(record, attribute, value)
51
+ unless value =~ self.class::REGEXP
52
+ add_error record, attribute, "#{value}: not matching #{self.class::PATTERN}"
53
+ end
54
+ end
55
+
56
+ def add_error(record, attribute, message = '')
57
+ record.errors[attribute] << (options[:message] || message)
58
+ end
59
+ end
60
+ end